File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 8
8
from hashlib import sha256
9
9
from struct import pack
10
10
11
+ from test_framework .blocktools import create_coinbase
11
12
from test_framework .test_framework import BitcoinTestFramework
12
13
from test_framework .util import *
13
14
@@ -78,13 +79,13 @@ def run_test(self):
78
79
# Mine a block to leave initial block download
79
80
node .generate (1 )
80
81
tmpl = node .getblocktemplate ()
81
- if 'coinbasetxn' not in tmpl :
82
- rawcoinbase = encodeUNum ( tmpl [ 'height' ])
83
- rawcoinbase += b' \x01 -'
84
- hexcoinbase = b2x ( rawcoinbase )
85
- hexoutval = b2x ( pack ( '<Q' , tmpl [ 'coinbasevalue' ]))
86
- tmpl ['coinbasetxn' ] = {'data' : '01000000' + '01' + '0000000000000000000000000000000000000000000000000000000000000000ffffffff' + ( '%02x' % ( len ( rawcoinbase ),)) + hexcoinbase + 'fffffffe' + '01' + hexoutval + '00' + '00000000' }
87
- txlist = list ( bytearray (a2b_hex ( a [ 'data' ])) for a in ( tmpl [ 'coinbasetxn' ],) + tuple ( tmpl [ 'transactions' ]))
82
+ assert 'coinbasetxn' not in tmpl
83
+
84
+ coinbase_tx = create_coinbase ( height = int ( tmpl [ "height" ]) + 1 )
85
+ # sequence numbers must not be max for nLockTime to have effect
86
+ coinbase_tx . vin [ 0 ]. nSequence = 2 ** 32 - 2
87
+ tmpl ['coinbasetxn' ] = {'data' : coinbase_tx . serialize () }
88
+ txlist = [ bytearray (coinbase_tx . serialize ())]
88
89
89
90
self .log .info ("getblocktemplate: Test capability advertised" )
90
91
assert ('proposal' in tmpl ['capabilities' ])
You can’t perform that action at this time.
0 commit comments