aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2022-07-16 02:48:04 +0200
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2022-07-19 15:40:51 +0200
commitfdc1ca389646a55c4d9cb2a79feaa69f90b18c67 (patch)
treeb1cf799613c9286f9fe3375d268400335b6f1e87 /contrib
parent1b035c03f9fbbdf7a13663a35d75fb2428f44743 (diff)
downloadbitcoin-fdc1ca389646a55c4d9cb2a79feaa69f90b18c67.tar.xz
test: add constants for PSBT key types (BIP 174)
Also take use of the constants in the signet miner to get rid of magic numbers and increase readability and maintainability.
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/signet/miner12
1 files changed, 6 insertions, 6 deletions
diff --git a/contrib/signet/miner b/contrib/signet/miner
index 75f97e7c47..fdcd20ae3b 100755
--- a/contrib/signet/miner
+++ b/contrib/signet/miner
@@ -20,7 +20,7 @@ sys.path.insert(0, PATH_BASE_TEST_FUNCTIONAL)
from test_framework.blocktools import get_witness_script, script_BIP34_coinbase_height # noqa: E402
from test_framework.messages import CBlock, CBlockHeader, COutPoint, CTransaction, CTxIn, CTxInWitness, CTxOut, from_binary, from_hex, ser_string, ser_uint256, tx_from_hex # noqa: E402
-from test_framework.psbt import PSBT, PSBTMap # noqa: E402
+from test_framework.psbt import PSBT, PSBTMap, PSBT_GLOBAL_UNSIGNED_TX, PSBT_IN_FINAL_SCRIPTSIG, PSBT_IN_FINAL_SCRIPTWITNESS, PSBT_IN_NON_WITNESS_UTXO, PSBT_IN_SIGHASH_TYPE # noqa: E402
from test_framework.script import CScriptOp # noqa: E402
logging.basicConfig(
@@ -74,11 +74,11 @@ def signet_txs(block, challenge):
def do_createpsbt(block, signme, spendme):
psbt = PSBT()
- psbt.g = PSBTMap( {0: signme.serialize(),
+ psbt.g = PSBTMap( {PSBT_GLOBAL_UNSIGNED_TX: signme.serialize(),
PSBT_SIGNET_BLOCK: block.serialize()
} )
- psbt.i = [ PSBTMap( {0: spendme.serialize(),
- 3: bytes([1,0,0,0])})
+ psbt.i = [ PSBTMap( {PSBT_IN_NON_WITNESS_UTXO: spendme.serialize(),
+ PSBT_IN_SIGHASH_TYPE: bytes([1,0,0,0])})
]
psbt.o = [ PSBTMap() ]
return psbt.to_base64()
@@ -90,8 +90,8 @@ def do_decode_psbt(b64psbt):
assert len(psbt.tx.vout) == 1
assert PSBT_SIGNET_BLOCK in psbt.g.map
- scriptSig = psbt.i[0].map.get(7, b"")
- scriptWitness = psbt.i[0].map.get(8, b"\x00")
+ scriptSig = psbt.i[0].map.get(PSBT_IN_FINAL_SCRIPTSIG, b"")
+ scriptWitness = psbt.i[0].map.get(PSBT_IN_FINAL_SCRIPTWITNESS, b"\x00")
return from_binary(CBlock, psbt.g.map[PSBT_SIGNET_BLOCK]), ser_string(scriptSig) + scriptWitness