mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-13 08:44:41 +02:00
test: Avoid CScript() as default function argument
This does not cause any issues, because CScript in the tests are const. However, this change allows to enable the "function-call-in-default-argument (B008)" lint rule.
This commit is contained in:
@ -154,16 +154,18 @@ def create_coinbase(height, pubkey=None, *, script_pubkey=None, extra_output_scr
|
||||
coinbase.calc_sha256()
|
||||
return coinbase
|
||||
|
||||
def create_tx_with_script(prevtx, n, script_sig=b"", *, amount, script_pub_key=CScript()):
|
||||
def create_tx_with_script(prevtx, n, script_sig=b"", *, amount, output_script=None):
|
||||
"""Return one-input, one-output transaction object
|
||||
spending the prevtx's n-th output with the given amount.
|
||||
|
||||
Can optionally pass scriptPubKey and scriptSig, default is anyone-can-spend output.
|
||||
"""
|
||||
if output_script is None:
|
||||
output_script = CScript()
|
||||
tx = CTransaction()
|
||||
assert n < len(prevtx.vout)
|
||||
tx.vin.append(CTxIn(COutPoint(prevtx.sha256, n), script_sig, SEQUENCE_FINAL))
|
||||
tx.vout.append(CTxOut(amount, script_pub_key))
|
||||
tx.vout.append(CTxOut(amount, output_script))
|
||||
tx.calc_sha256()
|
||||
return tx
|
||||
|
||||
|
Reference in New Issue
Block a user