Skip to content

Commit 4e616d2

Browse files
committed
test: check that combining PSBTs with different txs fails
1 parent 2a428c7 commit 4e616d2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/functional/rpc_psbt.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,16 @@ def test_psbt_input_keys(psbt_input, keys):
820820
assert hash.hex() in res_input[preimage_key]
821821
assert_equal(res_input[preimage_key][hash.hex()], preimage.hex())
822822

823+
self.log.info("Test that combining PSBTs with different transactions fails")
824+
tx = CTransaction()
825+
tx.vin = [CTxIn(outpoint=COutPoint(hash=int('aa' * 32, 16), n=0), scriptSig=b"")]
826+
tx.vout = [CTxOut(nValue=0, scriptPubKey=b"")]
827+
psbt1 = PSBT(g=PSBTMap({PSBT_GLOBAL_UNSIGNED_TX: tx.serialize()}), i=[PSBTMap()], o=[PSBTMap()]).to_base64()
828+
tx.vout[0].nValue += 1 # slightly modify tx
829+
psbt2 = PSBT(g=PSBTMap({PSBT_GLOBAL_UNSIGNED_TX: tx.serialize()}), i=[PSBTMap()], o=[PSBTMap()]).to_base64()
830+
assert_raises_rpc_error(-8, "PSBTs not compatible (different transactions)", self.nodes[0].combinepsbt, [psbt1, psbt2])
831+
assert_equal(self.nodes[0].combinepsbt([psbt1, psbt1]), psbt1)
832+
823833

824834
if __name__ == '__main__':
825835
PSBTTest().main()

0 commit comments

Comments
 (0)