mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
wallet rpc: return final tx hex from walletprocesspsbt if complete
This commit is contained in:
@@ -217,12 +217,21 @@ class PSBTTest(BitcoinTestFramework):
|
||||
|
||||
self.nodes[0].walletpassphrase(passphrase="password", timeout=1000000)
|
||||
|
||||
# Sign the transaction and send
|
||||
signed_tx = self.nodes[0].walletprocesspsbt(psbt=psbtx, finalize=False)['psbt']
|
||||
finalized_tx = self.nodes[0].walletprocesspsbt(psbt=psbtx, finalize=True)['psbt']
|
||||
assert signed_tx != finalized_tx
|
||||
final_tx = self.nodes[0].finalizepsbt(signed_tx)['hex']
|
||||
self.nodes[0].sendrawtransaction(final_tx)
|
||||
# Sign the transaction but don't finalize
|
||||
processed_psbt = self.nodes[0].walletprocesspsbt(psbt=psbtx, finalize=False)
|
||||
assert "hex" not in processed_psbt
|
||||
signed_psbt = processed_psbt['psbt']
|
||||
|
||||
# Finalize and send
|
||||
finalized_hex = self.nodes[0].finalizepsbt(signed_psbt)['hex']
|
||||
self.nodes[0].sendrawtransaction(finalized_hex)
|
||||
|
||||
# Alternative method: sign AND finalize in one command
|
||||
processed_finalized_psbt = self.nodes[0].walletprocesspsbt(psbt=psbtx, finalize=True)
|
||||
finalized_psbt = processed_finalized_psbt['psbt']
|
||||
finalized_psbt_hex = processed_finalized_psbt['hex']
|
||||
assert signed_psbt != finalized_psbt
|
||||
assert finalized_psbt_hex == finalized_hex
|
||||
|
||||
# Manually selected inputs can be locked:
|
||||
assert_equal(len(self.nodes[0].listlockunspent()), 0)
|
||||
|
||||
Reference in New Issue
Block a user