diff options
author | Casey Rodarmor <casey@rodarmor.com> | 2015-08-05 17:47:34 -0400 |
---|---|---|
committer | Casey Rodarmor <casey@rodarmor.com> | 2015-08-21 15:31:37 -0400 |
commit | 0ce73985a80c3bb0c9a2024f8df6ce68c648dbb8 (patch) | |
tree | b78eda0e18074aa748107c6296abacb034b299bf /qa/rpc-tests/test_framework/blocktools.py | |
parent | 49793fbb097e9f00149a054adeddad07f0444c12 (diff) |
Add p2p-fullblocktest.py
Diffstat (limited to 'qa/rpc-tests/test_framework/blocktools.py')
-rw-r--r-- | qa/rpc-tests/test_framework/blocktools.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/qa/rpc-tests/test_framework/blocktools.py b/qa/rpc-tests/test_framework/blocktools.py index f397fe7cd6..59aa8c15cc 100644 --- a/qa/rpc-tests/test_framework/blocktools.py +++ b/qa/rpc-tests/test_framework/blocktools.py @@ -5,7 +5,7 @@ # from mininode import * -from script import CScript, CScriptOp +from script import CScript, CScriptOp, OP_TRUE, OP_CHECKSIG # Create a block (with regtest difficulty) def create_block(hashprev, coinbase, nTime=None): @@ -37,19 +37,21 @@ def serialize_script_num(value): r[-1] |= 0x80 return r -counter=1 -# Create an anyone-can-spend coinbase transaction, assuming no miner fees -def create_coinbase(heightAdjust = 0): - global counter +# Create a coinbase transaction, assuming no miner fees. +# If pubkey is passed in, the coinbase output will be a P2PK output; +# otherwise an anyone-can-spend output. +def create_coinbase(height, pubkey = None): coinbase = CTransaction() coinbase.vin.append(CTxIn(COutPoint(0, 0xffffffff), - ser_string(serialize_script_num(counter+heightAdjust)), 0xffffffff)) - counter += 1 + ser_string(serialize_script_num(height)), 0xffffffff)) coinbaseoutput = CTxOut() coinbaseoutput.nValue = 50*100000000 - halvings = int((counter+heightAdjust)/150) # regtest + halvings = int(height/150) # regtest coinbaseoutput.nValue >>= halvings - coinbaseoutput.scriptPubKey = "" + if (pubkey != None): + coinbaseoutput.scriptPubKey = CScript([pubkey, OP_CHECKSIG]) + else: + coinbaseoutput.scriptPubKey = CScript([OP_TRUE]) coinbase.vout = [ coinbaseoutput ] coinbase.calc_sha256() return coinbase |