Skip to content

Commit 5bad792

Browse files
committed
[test] PSBT RPC: check that bip32_derivs are present by default
1 parent 29a21c9 commit 5bad792

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

test/functional/rpc_psbt.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,20 @@ def run_test(self):
192192
psbt_orig = self.nodes[0].createpsbt([{"txid":txid1, "vout":vout1}, {"txid":txid2, "vout":vout2}], {self.nodes[0].getnewaddress():25.999})
193193

194194
# Update psbts, should only have data for one input and not the other
195-
psbt1 = self.nodes[1].walletprocesspsbt(psbt_orig)['psbt']
195+
psbt1 = self.nodes[1].walletprocesspsbt(psbt_orig, False, "ALL")['psbt']
196196
psbt1_decoded = self.nodes[0].decodepsbt(psbt1)
197197
assert psbt1_decoded['inputs'][0] and not psbt1_decoded['inputs'][1]
198-
psbt2 = self.nodes[2].walletprocesspsbt(psbt_orig)['psbt']
198+
# Check that BIP32 path was added
199+
assert "bip32_derivs" in psbt1_decoded['inputs'][0]
200+
psbt2 = self.nodes[2].walletprocesspsbt(psbt_orig, False, "ALL", False)['psbt']
199201
psbt2_decoded = self.nodes[0].decodepsbt(psbt2)
200202
assert not psbt2_decoded['inputs'][0] and psbt2_decoded['inputs'][1]
203+
# Check that BIP32 paths were not added
204+
assert "bip32_derivs" not in psbt2_decoded['inputs'][1]
205+
206+
# Sign PSBTs (workaround issue #18039)
207+
psbt1 = self.nodes[1].walletprocesspsbt(psbt_orig)['psbt']
208+
psbt2 = self.nodes[2].walletprocesspsbt(psbt_orig)['psbt']
201209

202210
# Combine, finalize, and send the psbts
203211
combined = self.nodes[0].combinepsbt([psbt1, psbt2])
@@ -230,16 +238,18 @@ def run_test(self):
230238
# Same construction without optional arguments
231239
psbtx_info = self.nodes[0].walletcreatefundedpsbt([{"txid":unspent["txid"], "vout":unspent["vout"]}], [{self.nodes[2].getnewaddress():unspent["amount"]+1}])
232240
decoded_psbt = self.nodes[0].decodepsbt(psbtx_info["psbt"])
233-
for tx_in in decoded_psbt["tx"]["vin"]:
241+
for tx_in, psbt_in in zip(decoded_psbt["tx"]["vin"], decoded_psbt["inputs"]):
234242
assert_equal(tx_in["sequence"], MAX_BIP125_RBF_SEQUENCE)
243+
assert "bip32_derivs" in psbt_in
235244
assert_equal(decoded_psbt["tx"]["locktime"], 0)
236245

237246
# Same construction without optional arguments, for a node with -walletrbf=0
238247
unspent1 = self.nodes[1].listunspent()[0]
239248
psbtx_info = self.nodes[1].walletcreatefundedpsbt([{"txid":unspent1["txid"], "vout":unspent1["vout"]}], [{self.nodes[2].getnewaddress():unspent1["amount"]+1}], block_height)
240249
decoded_psbt = self.nodes[1].decodepsbt(psbtx_info["psbt"])
241-
for tx_in in decoded_psbt["tx"]["vin"]:
250+
for tx_in, psbt_in in zip(decoded_psbt["tx"]["vin"], decoded_psbt["inputs"]):
242251
assert_greater_than(tx_in["sequence"], MAX_BIP125_RBF_SEQUENCE)
252+
assert "bip32_derivs" in psbt_in
243253

244254
# Make sure change address wallet does not have P2SH innerscript access to results in success
245255
# when attempting BnB coin selection

0 commit comments

Comments
 (0)