diff options
Diffstat (limited to 'test/functional/rpc_psbt.py')
-rwxr-xr-x | test/functional/rpc_psbt.py | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index 9affca43e3..c01dc64df0 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -106,11 +106,11 @@ class PSBTTest(BitcoinTestFramework): assert "non_witness_utxo" in mining_node.decodepsbt(psbt_new.to_base64())["inputs"][0] # Have the offline node sign the PSBT (which will remove the non-witness UTXO) - signed_psbt = offline_node.walletprocesspsbt(psbt_new.to_base64())["psbt"] - assert not "non_witness_utxo" in mining_node.decodepsbt(signed_psbt)["inputs"][0] + signed_psbt = offline_node.walletprocesspsbt(psbt_new.to_base64()) + assert not "non_witness_utxo" in mining_node.decodepsbt(signed_psbt["psbt"])["inputs"][0] # Make sure we can mine the resulting transaction - txid = mining_node.sendrawtransaction(mining_node.finalizepsbt(signed_psbt)["hex"]) + txid = mining_node.sendrawtransaction(signed_psbt["hex"]) self.generate(mining_node, nblocks=1, sync_fun=lambda: self.sync_all([online_node, mining_node])) assert_equal(online_node.gettxout(txid,0)["confirmations"], 1) @@ -142,9 +142,8 @@ class PSBTTest(BitcoinTestFramework): utxo1 = tx1_inputs[0] assert_equal(unconfirmed_txid, utxo1['txid']) - signed_tx1 = wallet.walletprocesspsbt(psbtx1)['psbt'] - final_tx1 = wallet.finalizepsbt(signed_tx1)['hex'] - txid1 = self.nodes[0].sendrawtransaction(final_tx1) + signed_tx1 = wallet.walletprocesspsbt(psbtx1) + txid1 = self.nodes[0].sendrawtransaction(signed_tx1['hex']) mempool = self.nodes[0].getrawmempool() assert txid1 in mempool @@ -157,9 +156,8 @@ class PSBTTest(BitcoinTestFramework): self.log.info("Fail to broadcast a new PSBT with maxconf 0 due to BIP125 rules to verify it actually chose unconfirmed outputs") psbt_invalid = wallet.walletcreatefundedpsbt([{'txid': utxo1['txid'], 'vout': utxo1['vout']}], {target_address: 1}, 0, {'add_inputs': True, 'maxconf': 0, 'fee_rate': 10})['psbt'] - signed_invalid = wallet.walletprocesspsbt(psbt_invalid)['psbt'] - final_invalid = wallet.finalizepsbt(signed_invalid)['hex'] - assert_raises_rpc_error(-26, "bad-txns-spends-conflicting-tx", self.nodes[0].sendrawtransaction, final_invalid) + signed_invalid = wallet.walletprocesspsbt(psbt_invalid) + assert_raises_rpc_error(-26, "bad-txns-spends-conflicting-tx", self.nodes[0].sendrawtransaction, signed_invalid['hex']) self.log.info("Craft a replacement adding inputs with highest confs possible") psbtx2 = wallet.walletcreatefundedpsbt([{'txid': utxo1['txid'], 'vout': utxo1['vout']}], {target_address: 1}, 0, {'add_inputs': True, 'minconf': 2, 'fee_rate': 10})['psbt'] @@ -169,9 +167,8 @@ class PSBTTest(BitcoinTestFramework): if vin['txid'] != unconfirmed_txid: assert_greater_than_or_equal(self.nodes[0].gettxout(vin['txid'], vin['vout'])['confirmations'], 2) - signed_tx2 = wallet.walletprocesspsbt(psbtx2)['psbt'] - final_tx2 = wallet.finalizepsbt(signed_tx2)['hex'] - txid2 = self.nodes[0].sendrawtransaction(final_tx2) + signed_tx2 = wallet.walletprocesspsbt(psbtx2) + txid2 = self.nodes[0].sendrawtransaction(signed_tx2['hex']) mempool = self.nodes[0].getrawmempool() assert txid1 not in mempool @@ -305,7 +302,7 @@ class PSBTTest(BitcoinTestFramework): # Check decodepsbt fee calculation (input values shall only be counted once per UTXO) assert_equal(decoded['fee'], created_psbt['fee']) assert_equal(walletprocesspsbt_out['complete'], True) - self.nodes[1].sendrawtransaction(self.nodes[1].finalizepsbt(walletprocesspsbt_out['psbt'])['hex']) + self.nodes[1].sendrawtransaction(walletprocesspsbt_out['hex']) self.log.info("Test walletcreatefundedpsbt fee rate of 10000 sat/vB and 0.1 BTC/kvB produces a total fee at or slightly below -maxtxfee (~0.05290000)") res1 = self.nodes[1].walletcreatefundedpsbt(inputs, outputs, 0, {"fee_rate": 10000, "add_inputs": True}) @@ -396,7 +393,7 @@ class PSBTTest(BitcoinTestFramework): # partially sign with node 2. This should be complete and sendable walletprocesspsbt_out = self.nodes[2].walletprocesspsbt(psbtx) assert_equal(walletprocesspsbt_out['complete'], True) - self.nodes[2].sendrawtransaction(self.nodes[2].finalizepsbt(walletprocesspsbt_out['psbt'])['hex']) + self.nodes[2].sendrawtransaction(walletprocesspsbt_out['hex']) # check that walletprocesspsbt fails to decode a non-psbt rawtx = self.nodes[1].createrawtransaction([{"txid":txid,"vout":p2wpkh_pos}], {self.nodes[1].getnewaddress():9.99}) @@ -748,14 +745,13 @@ class PSBTTest(BitcoinTestFramework): assert not signed['complete'] signed = self.nodes[0].walletprocesspsbt(signed['psbt']) assert signed['complete'] - self.nodes[0].finalizepsbt(signed['psbt']) psbt = wallet.walletcreatefundedpsbt([ext_utxo], {self.nodes[0].getnewaddress(): 15}, 0, {"add_inputs": True, "solving_data":{"descriptors": [desc]}}) signed = wallet.walletprocesspsbt(psbt['psbt']) assert not signed['complete'] signed = self.nodes[0].walletprocesspsbt(signed['psbt']) assert signed['complete'] - final = self.nodes[0].finalizepsbt(signed['psbt'], False) + final = signed['hex'] dec = self.nodes[0].decodepsbt(signed["psbt"]) for i, txin in enumerate(dec["tx"]["vin"]): @@ -790,8 +786,8 @@ class PSBTTest(BitcoinTestFramework): ) signed = wallet.walletprocesspsbt(psbt["psbt"]) signed = self.nodes[0].walletprocesspsbt(signed["psbt"]) - final = self.nodes[0].finalizepsbt(signed["psbt"]) - assert self.nodes[0].testmempoolaccept([final["hex"]])[0]["allowed"] + final = signed["hex"] + assert self.nodes[0].testmempoolaccept([final])[0]["allowed"] # Reducing the weight should have a lower fee psbt2 = wallet.walletcreatefundedpsbt( inputs=[{"txid": ext_utxo["txid"], "vout": ext_utxo["vout"], "weight": low_input_weight}], @@ -846,8 +842,8 @@ class PSBTTest(BitcoinTestFramework): self.nodes[0].importprivkey(privkey) psbt = watchonly.sendall([wallet.getnewaddress()])["psbt"] - psbt = self.nodes[0].walletprocesspsbt(psbt)["psbt"] - self.nodes[0].sendrawtransaction(self.nodes[0].finalizepsbt(psbt)["hex"]) + signed_tx = self.nodes[0].walletprocesspsbt(psbt) + self.nodes[0].sendrawtransaction(signed_tx["hex"]) # Same test but for taproot if self.options.descriptors: @@ -862,8 +858,8 @@ class PSBTTest(BitcoinTestFramework): self.nodes[0].importdescriptors([{"desc": descsum_create("tr({})".format(privkey)), "timestamp":"now"}]) psbt = watchonly.sendall([wallet.getnewaddress(), addr])["psbt"] - psbt = self.nodes[0].walletprocesspsbt(psbt)["psbt"] - txid = self.nodes[0].sendrawtransaction(self.nodes[0].finalizepsbt(psbt)["hex"]) + processed_psbt = self.nodes[0].walletprocesspsbt(psbt) + txid = self.nodes[0].sendrawtransaction(processed_psbt["hex"]) vout = find_vout_for_address(self.nodes[0], txid, addr) # Make sure tap tree is in psbt @@ -880,7 +876,7 @@ class PSBTTest(BitcoinTestFramework): vout = find_vout_for_address(self.nodes[0], txid, addr) psbt = self.nodes[0].createpsbt([{"txid": txid, "vout": vout}], [{self.nodes[0].getnewaddress(): 0.9999}]) signed = self.nodes[0].walletprocesspsbt(psbt) - rawtx = self.nodes[0].finalizepsbt(signed["psbt"])["hex"] + rawtx = signed["hex"] self.nodes[0].sendrawtransaction(rawtx) self.generate(self.nodes[0], 1) |