mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 20:32:35 -03:00
Merge bitcoin/bitcoin#25670: test: check that combining PSBTs with different txs fails
4e616d20c9
test: check that combining PSBTs with different txs fails (Sebastian Falbesoner)2a428c7989
test: support passing PSBTMaps directly to PSBT ctor (Sebastian Falbesoner) Pull request description: This PR adds missing test coverage for the `combinepsbt` RPC, in the case of combining two PSBTs with different transactions:b8067cd435/src/psbt.cpp (L24-L27)
The calling function `CombinePSBTs` checks for the false return value and then returns the transaction error string `PSBT_MISMATCH`:b8067cd435/src/psbt.cpp (L433-L435)
b8067cd435/src/util/error.cpp (L30-L31)
ACKs for top commit: instagibbs: reACK4e616d20c9
achow101: ACK4e616d20c9
Tree-SHA512: 45b2b224b13b44ad69ae62e4bc20f74cab32770cf8127b026ec47a7520f7253148fdbf1fad612afece59e45a6738bef9a351ae87ea98dc83d095cc78f6db0318
This commit is contained in:
commit
317ef0368b
2 changed files with 14 additions and 4 deletions
|
@ -820,6 +820,16 @@ class PSBTTest(BitcoinTestFramework):
|
|||
assert hash.hex() in res_input[preimage_key]
|
||||
assert_equal(res_input[preimage_key][hash.hex()], preimage.hex())
|
||||
|
||||
self.log.info("Test that combining PSBTs with different transactions fails")
|
||||
tx = CTransaction()
|
||||
tx.vin = [CTxIn(outpoint=COutPoint(hash=int('aa' * 32, 16), n=0), scriptSig=b"")]
|
||||
tx.vout = [CTxOut(nValue=0, scriptPubKey=b"")]
|
||||
psbt1 = PSBT(g=PSBTMap({PSBT_GLOBAL_UNSIGNED_TX: tx.serialize()}), i=[PSBTMap()], o=[PSBTMap()]).to_base64()
|
||||
tx.vout[0].nValue += 1 # slightly modify tx
|
||||
psbt2 = PSBT(g=PSBTMap({PSBT_GLOBAL_UNSIGNED_TX: tx.serialize()}), i=[PSBTMap()], o=[PSBTMap()]).to_base64()
|
||||
assert_raises_rpc_error(-8, "PSBTs not compatible (different transactions)", self.nodes[0].combinepsbt, [psbt1, psbt2])
|
||||
assert_equal(self.nodes[0].combinepsbt([psbt1, psbt1]), psbt1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
PSBTTest().main()
|
||||
|
|
|
@ -96,10 +96,10 @@ class PSBTMap:
|
|||
class PSBT:
|
||||
"""Class for serializing and deserializing PSBTs"""
|
||||
|
||||
def __init__(self):
|
||||
self.g = PSBTMap()
|
||||
self.i = []
|
||||
self.o = []
|
||||
def __init__(self, *, g=None, i=None, o=None):
|
||||
self.g = g if g is not None else PSBTMap()
|
||||
self.i = i if i is not None else []
|
||||
self.o = o if o is not None else []
|
||||
self.tx = None
|
||||
|
||||
def deserialize(self, f):
|
||||
|
|
Loading…
Reference in a new issue