Skip to content

Commit 1f0c428

Browse files
committed
QA: add basic walletcreatefunded optional arg test
1 parent 1f18d7b commit 1f0c428

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/functional/rpc_psbt.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import json
1212
import os
1313

14+
MAX_BIP125_RBF_SEQUENCE = 0xfffffffd
15+
1416
# Create one-input, one-output, no-fee transaction:
1517
class PSBTTest(BitcoinTestFramework):
1618

@@ -135,6 +137,33 @@ def run_test(self):
135137
self.nodes[0].generate(6)
136138
self.sync_all()
137139

140+
# Test additional args in walletcreatepsbt
141+
# Make sure both pre-included and funded inputs
142+
# have the correct sequence numbers based on
143+
# replaceable arg
144+
block_height = self.nodes[0].getblockcount()
145+
unspent = self.nodes[0].listunspent()[0]
146+
psbtx_info = self.nodes[0].walletcreatefundedpsbt([{"txid":unspent["txid"], "vout":unspent["vout"]}], [{self.nodes[2].getnewaddress():unspent["amount"]+1}], block_height+2, {"replaceable":True})
147+
decoded_psbt = self.nodes[0].decodepsbt(psbtx_info["psbt"])
148+
for tx_in in decoded_psbt["tx"]["vin"]:
149+
assert_equal(tx_in["sequence"], MAX_BIP125_RBF_SEQUENCE)
150+
assert_equal(decoded_psbt["tx"]["locktime"], block_height+2)
151+
152+
# Same construction with only locktime set
153+
psbtx_info = self.nodes[0].walletcreatefundedpsbt([{"txid":unspent["txid"], "vout":unspent["vout"]}], [{self.nodes[2].getnewaddress():unspent["amount"]+1}], block_height)
154+
decoded_psbt = self.nodes[0].decodepsbt(psbtx_info["psbt"])
155+
for tx_in in decoded_psbt["tx"]["vin"]:
156+
assert tx_in["sequence"] > MAX_BIP125_RBF_SEQUENCE
157+
assert_equal(decoded_psbt["tx"]["locktime"], block_height)
158+
159+
# Same construction without optional arguments
160+
psbtx_info = self.nodes[0].walletcreatefundedpsbt([{"txid":unspent["txid"], "vout":unspent["vout"]}], [{self.nodes[2].getnewaddress():unspent["amount"]+1}])
161+
decoded_psbt = self.nodes[0].decodepsbt(psbtx_info["psbt"])
162+
for tx_in in decoded_psbt["tx"]["vin"]:
163+
assert tx_in["sequence"] > MAX_BIP125_RBF_SEQUENCE
164+
assert_equal(decoded_psbt["tx"]["locktime"], 0)
165+
166+
138167
# BIP 174 Test Vectors
139168

140169
# Check that unknown values are just passed through

0 commit comments

Comments
 (0)