Skip to content

Commit 73760ba

Browse files
authored
Merge pull request #1471 from tomt1664/fix/duplicate_solve_data
Removed duplicate solving_data for transaction funding RPCs
2 parents aab28aa + a9da179 commit 73760ba

File tree

3 files changed

+9
-56
lines changed

3 files changed

+9
-56
lines changed

src/rpc/client.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,12 @@ static const CRPCConvertParam vRPCConvertParams[] =
113113
{ "combinerawtransaction", 0, "txs" },
114114
{ "fundrawtransaction", 1, "options" },
115115
{ "fundrawtransaction", 2, "iswitness" },
116-
{ "fundrawtransaction", 3, "solving_data" },
117116
{ "walletcreatefundedpsbt", 0, "inputs" },
118117
{ "walletcreatefundedpsbt", 1, "outputs" },
119118
{ "walletcreatefundedpsbt", 2, "locktime" },
120119
{ "walletcreatefundedpsbt", 3, "options" },
121120
{ "walletcreatefundedpsbt", 4, "bip32derivs" },
122-
{ "walletcreatefundedpsbt", 5, "solving_data" },
123-
{ "walletcreatefundedpsbt", 6, "psbt_version" },
121+
{ "walletcreatefundedpsbt", 5, "psbt_version" },
124122
{ "walletprocesspsbt", 1, "sign" },
125123
{ "walletprocesspsbt", 3, "bip32derivs" },
126124
{ "walletprocesspsbt", 4, "finalize" },

src/wallet/rpc/spend.cpp

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ static std::vector<RPCArg> FundTxDoc()
440440
};
441441
}
442442

443-
void FundTransaction(CWallet& wallet, CMutableTransaction& tx, CAmount& fee_out, int& change_position, const UniValue& options, CCoinControl& coinControl, const UniValue& solving_data, bool override_min_fee)
443+
void FundTransaction(CWallet& wallet, CMutableTransaction& tx, CAmount& fee_out, int& change_position, const UniValue& options, CCoinControl& coinControl, bool override_min_fee)
444444
{
445445
// Make sure the results are valid at least up to the most recent block
446446
// the user could have gotten from another RPC command prior to now
@@ -792,25 +792,6 @@ RPCHelpMan fundrawtransaction()
792792
"This boolean should reflect whether the transaction has inputs\n"
793793
"(e.g. fully valid, or on-chain transactions), if known by the caller."
794794
},
795-
{"solving_data", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED_NAMED_ARG, "Keys and scripts needed for producing a final transaction with a dummy signature. Used for fee estimation during coin selection.\n",
796-
{
797-
{"pubkeys", RPCArg::Type::ARR, RPCArg::DefaultHint{"empty array"}, "A json array of public keys.\n",
798-
{
799-
{"pubkey", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "A public key"},
800-
},
801-
},
802-
{"scripts", RPCArg::Type::ARR, RPCArg::DefaultHint{"empty array"}, "A json array of scripts.\n",
803-
{
804-
{"script", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "A script"},
805-
},
806-
},
807-
{"descriptors", RPCArg::Type::ARR, RPCArg::DefaultHint{"empty array"}, "A json array of descriptors.\n",
808-
{
809-
{"descriptor", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "A descriptor"},
810-
},
811-
}
812-
}
813-
},
814795
},
815796
RPCResult{
816797
RPCResult::Type::OBJ, "", "",
@@ -850,7 +831,7 @@ RPCHelpMan fundrawtransaction()
850831
CCoinControl coin_control;
851832
// Automatically select (additional) coins. Can be overridden by options.add_inputs.
852833
coin_control.m_add_inputs = true;
853-
FundTransaction(*pwallet, tx, fee, change_position, request.params[1], coin_control, request.params[3], /* override_min_fee */ true);
834+
FundTransaction(*pwallet, tx, fee, change_position, request.params[1], coin_control, /* override_min_fee */ true);
854835

855836
UniValue result(UniValue::VOBJ);
856837
result.pushKV("hex", EncodeHexTx(CTransaction(tx)));
@@ -1293,12 +1274,8 @@ RPCHelpMan send()
12931274
// Automatically select coins, unless at least one is manually selected. Can
12941275
// be overridden by options.add_inputs.
12951276
coin_control.m_add_inputs = rawTx.vin.size() == 0;
1296-
UniValue solving_data = NullUniValue;
1297-
if (options.exists("solving_data")) {
1298-
solving_data = options["solving_data"].get_obj();
1299-
}
13001277
SetOptionsInputWeights(options["inputs"], options);
1301-
FundTransaction(*pwallet, rawTx, fee, change_position, options, coin_control, /* solving_data */ solving_data, /* override_min_fee */ false);
1278+
FundTransaction(*pwallet, rawTx, fee, change_position, options, coin_control, /* override_min_fee */ false);
13021279

13031280
bool add_to_wallet = true;
13041281
if (options.exists("add_to_wallet")) {
@@ -1530,25 +1507,6 @@ RPCHelpMan walletcreatefundedpsbt()
15301507
FundTxDoc()),
15311508
"options"},
15321509
{"bip32derivs", RPCArg::Type::BOOL, RPCArg::Default{true}, "Include BIP 32 derivation paths for public keys if we know them"},
1533-
{"solving_data", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED_NAMED_ARG, "Keys and scripts needed for producing a final transaction with a dummy signature. Used for fee estimation during coin selection.\n",
1534-
{
1535-
{"pubkeys", RPCArg::Type::ARR, RPCArg::DefaultHint{"empty array"}, "A json array of public keys.\n",
1536-
{
1537-
{"pubkey", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "A public key"},
1538-
},
1539-
},
1540-
{"scripts", RPCArg::Type::ARR, RPCArg::DefaultHint{"empty array"}, "A json array of scripts.\n",
1541-
{
1542-
{"script", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "A script"},
1543-
},
1544-
},
1545-
{"descriptors", RPCArg::Type::ARR, RPCArg::DefaultHint{"empty array"}, "A json array of descriptors.\n",
1546-
{
1547-
{"descriptor", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "A descriptor"},
1548-
},
1549-
}
1550-
}
1551-
},
15521510
{"psbt_version", RPCArg::Type::NUM, RPCArg::Default{2}, "The PSBT version number to use."},
15531511
},
15541512
RPCResult{
@@ -1605,7 +1563,7 @@ RPCHelpMan walletcreatefundedpsbt()
16051563

16061564
// Make a blank psbt
16071565
uint32_t psbt_version = 2;
1608-
if (!request.params[6].isNull()) {
1566+
if (!request.params[5].isNull()) {
16091567
psbt_version = request.params[6].get_int();
16101568
}
16111569
if (psbt_version != 2) {
@@ -1655,7 +1613,7 @@ RPCHelpMan walletcreatefundedpsbt()
16551613
}
16561614
}
16571615
SetOptionsInputWeights(request.params[0], options);
1658-
FundTransaction(wallet, rawTx, fee, change_position, options, coin_control, /* solving_data */ request.params[5], /* override_min_fee */ true);
1616+
FundTransaction(wallet, rawTx, fee, change_position, options, coin_control, /* override_min_fee */ true);
16591617
// Find an input that is ours
16601618
unsigned int blinder_index = 0;
16611619
{

test/functional/rpc_fundrawtransaction.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ def run_test(self):
132132
self.test_all_watched_funds()
133133
self.test_option_feerate()
134134
self.test_address_reuse()
135-
# ELEMENTS: FIXME
136-
# self.test_option_subtract_fee_from_outputs()
135+
self.test_option_subtract_fee_from_outputs()
137136
self.test_subtract_fee_with_presets()
138137
self.test_transaction_too_large()
139138
self.test_include_unsafe()
@@ -1005,11 +1004,9 @@ def test_option_subtract_fee_from_outputs(self):
10051004

10061005
# An external input without solving data should result in an error
10071006
raw_tx = self.nodes[2].createrawtransaction([{"txid": txid, "vout": vout}], [{addr_info['unconfidential']: 20}])
1008-
# // ELEMENTS: FIXME or explain why this tx is created without exception
1009-
# assert_raises_rpc_error(-4, "Missing solving data for estimating transaction size", self.nodes[2].fundrawtransaction, raw_tx)
10101007

1011-
# But funding should work when the solving data is provided
1012-
funded_tx = self.nodes[2].fundrawtransaction(raw_tx, {}, False, {"pubkeys": [addr_info['pubkey']]})
1008+
# But funding should work when the solving data is provided (as part of options)
1009+
funded_tx = self.nodes[2].fundrawtransaction(raw_tx, {"solving_data": {"pubkeys": [addr_info['pubkey']]}}, False)
10131010
signed_tx = self.nodes[2].signrawtransactionwithwallet(funded_tx['hex'])
10141011
assert not signed_tx['complete']
10151012
signed_tx = self.nodes[0].signrawtransactionwithwallet(signed_tx['hex'])

0 commit comments

Comments
 (0)