37
37
# Helper function to modify a transaction by
38
38
# 1) prepending a given script to the scriptSig of vin 0 and
39
39
# 2) (optionally) modify the nSequence of vin 0 and the tx's nLockTime
40
- def cltv_modify_tx (node , tx , prepend_scriptsig , nsequence = None , nlocktime = None ):
40
+ def cltv_modify_tx (tx , prepend_scriptsig , nsequence = None , nlocktime = None ):
41
41
assert_equal (len (tx .vin ), 1 )
42
42
if nsequence is not None :
43
43
tx .vin [0 ].nSequence = nsequence
@@ -48,7 +48,7 @@ def cltv_modify_tx(node, tx, prepend_scriptsig, nsequence=None, nlocktime=None):
48
48
return tx
49
49
50
50
51
- def cltv_invalidate (node , tx , failure_reason ):
51
+ def cltv_invalidate (tx , failure_reason ):
52
52
# Modify the signature in vin 0 and nSequence/nLockTime of the tx to fail CLTV
53
53
#
54
54
# According to BIP65, OP_CHECKLOCKTIMEVERIFY can fail due the following reasons:
@@ -69,14 +69,14 @@ def cltv_invalidate(node, tx, failure_reason):
69
69
[[CScriptNum (500 ), OP_CHECKLOCKTIMEVERIFY , OP_DROP ], 0xffffffff , 500 ],
70
70
][failure_reason ]
71
71
72
- return cltv_modify_tx (node , tx , prepend_scriptsig = scheme [0 ], nsequence = scheme [1 ], nlocktime = scheme [2 ])
72
+ return cltv_modify_tx (tx , prepend_scriptsig = scheme [0 ], nsequence = scheme [1 ], nlocktime = scheme [2 ])
73
73
74
74
75
- def cltv_validate (node , tx , height ):
75
+ def cltv_validate (tx , height ):
76
76
# Modify the signature in vin 0 and nSequence/nLockTime of the tx to pass CLTV
77
77
scheme = [[CScriptNum (height ), OP_CHECKLOCKTIMEVERIFY , OP_DROP ], 0 , height ]
78
78
79
- return cltv_modify_tx (node , tx , prepend_scriptsig = scheme [0 ], nsequence = scheme [1 ], nlocktime = scheme [2 ])
79
+ return cltv_modify_tx (tx , prepend_scriptsig = scheme [0 ], nsequence = scheme [1 ], nlocktime = scheme [2 ])
80
80
81
81
82
82
class BIP65Test (BitcoinTestFramework ):
@@ -114,7 +114,7 @@ def run_test(self):
114
114
invalid_cltv_txs = []
115
115
for i in range (5 ):
116
116
spendtx = wallet .create_self_transfer (from_node = self .nodes [0 ])['tx' ]
117
- spendtx = cltv_invalidate (self . nodes [ 0 ], spendtx , i )
117
+ spendtx = cltv_invalidate (spendtx , i )
118
118
invalid_cltv_txs .append (spendtx )
119
119
120
120
tip = self .nodes [0 ].getbestblockhash ()
@@ -149,7 +149,7 @@ def run_test(self):
149
149
# create and test one invalid tx per CLTV failure reason (5 in total)
150
150
for i in range (5 ):
151
151
spendtx = wallet .create_self_transfer (from_node = self .nodes [0 ])['tx' ]
152
- spendtx = cltv_invalidate (self . nodes [ 0 ], spendtx , i )
152
+ spendtx = cltv_invalidate (spendtx , i )
153
153
154
154
expected_cltv_reject_reason = [
155
155
"non-mandatory-script-verify-flag (Operation not valid with the current stack size)" ,
@@ -182,7 +182,7 @@ def run_test(self):
182
182
peer .sync_with_ping ()
183
183
184
184
self .log .info ("Test that a version 4 block with a valid-according-to-CLTV transaction is accepted" )
185
- spendtx = cltv_validate (self . nodes [ 0 ], spendtx , CLTV_HEIGHT - 1 )
185
+ spendtx = cltv_validate (spendtx , CLTV_HEIGHT - 1 )
186
186
187
187
block .vtx .pop (1 )
188
188
block .vtx .append (spendtx )
0 commit comments