mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-08 13:49:35 +02:00
test: Refactor MiniWallet sign_tx
To make the code less verbose and easier to read.
This commit is contained in:
@@ -180,12 +180,12 @@ class MiniWallet:
|
|||||||
tx.vin[0].scriptSig = CScript([der_sig + bytes(bytearray([SIGHASH_ALL]))])
|
tx.vin[0].scriptSig = CScript([der_sig + bytes(bytearray([SIGHASH_ALL]))])
|
||||||
tx.rehash()
|
tx.rehash()
|
||||||
elif self._mode == MiniWalletMode.RAW_OP_TRUE:
|
elif self._mode == MiniWalletMode.RAW_OP_TRUE:
|
||||||
for i in range(len(tx.vin)):
|
for i in tx.vin:
|
||||||
tx.vin[i].scriptSig = CScript([OP_NOP] * 43) # pad to identical size
|
i.scriptSig = CScript([OP_NOP] * 43) # pad to identical size
|
||||||
elif self._mode == MiniWalletMode.ADDRESS_OP_TRUE:
|
elif self._mode == MiniWalletMode.ADDRESS_OP_TRUE:
|
||||||
tx.wit.vtxinwit = [CTxInWitness()] * len(tx.vin)
|
tx.wit.vtxinwit = [CTxInWitness()] * len(tx.vin)
|
||||||
for i in range(len(tx.vin)):
|
for i in tx.wit.vtxinwit:
|
||||||
tx.wit.vtxinwit[i].scriptWitness.stack = [CScript([OP_TRUE]), bytes([LEAF_VERSION_TAPSCRIPT]) + self._internal_key]
|
i.scriptWitness.stack = [CScript([OP_TRUE]), bytes([LEAF_VERSION_TAPSCRIPT]) + self._internal_key]
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
|
|
||||||
@@ -301,7 +301,7 @@ class MiniWallet:
|
|||||||
|
|
||||||
# create tx
|
# create tx
|
||||||
tx = CTransaction()
|
tx = CTransaction()
|
||||||
tx.vin = [CTxIn(COutPoint(int(utxo_to_spend['txid'], 16), utxo_to_spend['vout']), nSequence=seq) for utxo_to_spend,seq in zip(utxos_to_spend, sequence)]
|
tx.vin = [CTxIn(COutPoint(int(utxo_to_spend['txid'], 16), utxo_to_spend['vout']), nSequence=seq) for utxo_to_spend, seq in zip(utxos_to_spend, sequence)]
|
||||||
tx.vout = [CTxOut(amount_per_output, bytearray(self._scriptPubKey)) for _ in range(num_outputs)]
|
tx.vout = [CTxOut(amount_per_output, bytearray(self._scriptPubKey)) for _ in range(num_outputs)]
|
||||||
tx.nLockTime = locktime
|
tx.nLockTime = locktime
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user