aboutsummaryrefslogtreecommitdiff
path: root/test/functional/rpc_psbt.py
diff options
context:
space:
mode:
authorGreg Sanders <gsanders87@gmail.com>2022-10-17 11:11:27 -0400
committerGreg Sanders <gsanders87@gmail.com>2022-10-17 11:13:30 -0400
commite133264c5b1f72e94dcb9cebd85cdb523fcf8070 (patch)
tree44cfe94e9d731c172848e32b3a91155f15c7479a /test/functional/rpc_psbt.py
parentd25699280af1ea45bebc884f63a10da7ea275ef9 (diff)
downloadbitcoin-e133264c5b1f72e94dcb9cebd85cdb523fcf8070.tar.xz
Add test for PSBT input verification
Diffstat (limited to 'test/functional/rpc_psbt.py')
-rwxr-xr-xtest/functional/rpc_psbt.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py
index 1fe3b21542..3b78a7d095 100755
--- a/test/functional/rpc_psbt.py
+++ b/test/functional/rpc_psbt.py
@@ -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()