Skip to content

Commit faa12d4

Browse files
author
MarcoFalke
committed
test: Refactor MiniWallet sign_tx
To make the code less verbose and easier to read.
1 parent fa2d821 commit faa12d4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/functional/test_framework/wallet.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,12 @@ def sign_tx(self, tx, fixed_length=True):
180180
tx.vin[0].scriptSig = CScript([der_sig + bytes(bytearray([SIGHASH_ALL]))])
181181
tx.rehash()
182182
elif self._mode == MiniWalletMode.RAW_OP_TRUE:
183-
for i in range(len(tx.vin)):
184-
tx.vin[i].scriptSig = CScript([OP_NOP] * 43) # pad to identical size
183+
for i in tx.vin:
184+
i.scriptSig = CScript([OP_NOP] * 43) # pad to identical size
185185
elif self._mode == MiniWalletMode.ADDRESS_OP_TRUE:
186186
tx.wit.vtxinwit = [CTxInWitness()] * len(tx.vin)
187-
for i in range(len(tx.vin)):
188-
tx.wit.vtxinwit[i].scriptWitness.stack = [CScript([OP_TRUE]), bytes([LEAF_VERSION_TAPSCRIPT]) + self._internal_key]
187+
for i in tx.wit.vtxinwit:
188+
i.scriptWitness.stack = [CScript([OP_TRUE]), bytes([LEAF_VERSION_TAPSCRIPT]) + self._internal_key]
189189
else:
190190
assert False
191191

@@ -301,7 +301,7 @@ def create_self_transfer_multi(
301301

302302
# create tx
303303
tx = CTransaction()
304-
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)]
304+
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)]
305305
tx.vout = [CTxOut(amount_per_output, bytearray(self._scriptPubKey)) for _ in range(num_outputs)]
306306
tx.nLockTime = locktime
307307

0 commit comments

Comments
 (0)