mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
Add test for PSBT input verification
This commit is contained in:
parent
d25699280a
commit
e133264c5b
1 changed files with 14 additions and 0 deletions
|
@ -27,8 +27,10 @@ from test_framework.psbt import (
|
|||
PSBT_IN_SHA256,
|
||||
PSBT_IN_HASH160,
|
||||
PSBT_IN_HASH256,
|
||||
PSBT_IN_WITNESS_UTXO,
|
||||
PSBT_OUT_TAP_TREE,
|
||||
)
|
||||
from test_framework.script import CScript, OP_TRUE
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_approx,
|
||||
|
@ -852,6 +854,18 @@ class PSBTTest(BitcoinTestFramework):
|
|||
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)
|
||||
|
||||
self.log.info("Test that PSBT inputs are being checked via script execution")
|
||||
acs_prevout = CTxOut(nValue=0, scriptPubKey=CScript([OP_TRUE]))
|
||||
tx = CTransaction()
|
||||
tx.vin = [CTxIn(outpoint=COutPoint(hash=int('dd' * 32, 16), n=0), scriptSig=b"")]
|
||||
tx.vout = [CTxOut(nValue=0, scriptPubKey=b"")]
|
||||
psbt = PSBT()
|
||||
psbt.g = PSBTMap({PSBT_GLOBAL_UNSIGNED_TX: tx.serialize()})
|
||||
psbt.i = [PSBTMap({bytes([PSBT_IN_WITNESS_UTXO]) : acs_prevout.serialize()})]
|
||||
psbt.o = [PSBTMap()]
|
||||
assert_equal(self.nodes[0].finalizepsbt(psbt.to_base64()),
|
||||
{'hex': '0200000001dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd0000000000000000000100000000000000000000000000', 'complete': True})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
PSBTTest().main()
|
||||
|
|
Loading…
Add table
Reference in a new issue