|
11 | 11 | import json
|
12 | 12 | import os
|
13 | 13 |
|
| 14 | +MAX_BIP125_RBF_SEQUENCE = 0xfffffffd |
| 15 | + |
14 | 16 | # Create one-input, one-output, no-fee transaction:
|
15 | 17 | class PSBTTest(BitcoinTestFramework):
|
16 | 18 |
|
@@ -135,6 +137,33 @@ def run_test(self):
|
135 | 137 | self.nodes[0].generate(6)
|
136 | 138 | self.sync_all()
|
137 | 139 |
|
| 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 | + |
138 | 167 | # BIP 174 Test Vectors
|
139 | 168 |
|
140 | 169 | # Check that unknown values are just passed through
|
|
0 commit comments