Skip to content

Commit c4bc9fd

Browse files
tomt1664Tom Trevethan
andauthored
Fix position of version argument in walletcreatefundedpsbt (#1474)
* fix position of version argument and add test * add test for version number --------- Co-authored-by: Tom Trevethan <[email protected]>
1 parent 2f6f7ce commit c4bc9fd

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/wallet/rpc/spend.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,6 @@ RPCHelpMan walletcreatefundedpsbt()
15401540
UniValue::VNUM,
15411541
UniValue::VOBJ,
15421542
UniValue::VBOOL,
1543-
UniValue::VOBJ,
15441543
UniValue::VNUM,
15451544
}, true
15461545
);
@@ -1564,7 +1563,7 @@ RPCHelpMan walletcreatefundedpsbt()
15641563
// Make a blank psbt
15651564
uint32_t psbt_version = 2;
15661565
if (!request.params[5].isNull()) {
1567-
psbt_version = request.params[6].get_int();
1566+
psbt_version = request.params[5].get_int();
15681567
}
15691568
if (psbt_version != 2) {
15701569
throw JSONRPCError(RPC_INVALID_PARAMETER, "The PSBT version can only be 2");

test/functional/rpc_psbt.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,8 @@ def test_psbt_input_keys(psbt_input, keys):
11491149
# An external input without solving data should result in an error
11501150
assert_raises_rpc_error(-4, "Insufficient funds", wallet.walletcreatefundedpsbt, [ext_utxo], [{self.nodes[0].getnewaddress(): 15}])
11511151

1152+
# ELEMENTS: check psbt version is 2
1153+
assert_raises_rpc_error(-8, "The PSBT version can only be 2", wallet.walletcreatefundedpsbt, [ext_utxo], [{self.nodes[0].getnewaddress(): 15}], 0, {"add_inputs": True, "solving_data": {"pubkeys": [addr_info['pubkey']], "scripts": [addr_info["embedded"]["scriptPubKey"]]}},True,1)
11521154
# But funding should work when the solving data is provided
11531155
psbt = wallet.walletcreatefundedpsbt([ext_utxo], [{self.nodes[0].getnewaddress(): 15}], 0, {"add_inputs": True, "solving_data": {"pubkeys": [addr_info['pubkey']], "scripts": [addr_info["embedded"]["scriptPubKey"]]}})
11541156
signed = wallet.walletprocesspsbt(psbt['psbt'])

0 commit comments

Comments
 (0)