[Test] MiniNode: Implement Zcash coinbase
This commit is contained in:
parent
7596a4922d
commit
c10c40779d
|
@ -5,7 +5,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
from mininode import CBlock, CTransaction, CTxIn, CTxOut, COutPoint
|
from mininode import CBlock, CTransaction, CTxIn, CTxOut, COutPoint
|
||||||
from script import CScript, OP_0
|
from script import CScript, OP_0, OP_EQUAL, OP_HASH160
|
||||||
|
|
||||||
# Create a block (with regtest difficulty)
|
# Create a block (with regtest difficulty)
|
||||||
def create_block(hashprev, coinbase, nTime=None, nBits=None):
|
def create_block(hashprev, coinbase, nTime=None, nBits=None):
|
||||||
|
@ -49,11 +49,21 @@ def create_coinbase(heightAdjust = 0):
|
||||||
CScript([counter+heightAdjust, OP_0]), 0xffffffff))
|
CScript([counter+heightAdjust, OP_0]), 0xffffffff))
|
||||||
counter += 1
|
counter += 1
|
||||||
coinbaseoutput = CTxOut()
|
coinbaseoutput = CTxOut()
|
||||||
coinbaseoutput.nValue = 50*100000000
|
coinbaseoutput.nValue = int(12.5*100000000)
|
||||||
halvings = int((counter+heightAdjust)/150) # regtest
|
halvings = int((counter+heightAdjust)/150) # regtest
|
||||||
coinbaseoutput.nValue >>= halvings
|
coinbaseoutput.nValue >>= halvings
|
||||||
coinbaseoutput.scriptPubKey = ""
|
coinbaseoutput.scriptPubKey = ""
|
||||||
coinbase.vout = [ coinbaseoutput ]
|
coinbase.vout = [ coinbaseoutput ]
|
||||||
|
if halvings == 0: # regtest
|
||||||
|
froutput = CTxOut()
|
||||||
|
froutput.nValue = coinbaseoutput.nValue / 5
|
||||||
|
# regtest
|
||||||
|
fraddr = bytearray([0x67, 0x08, 0xe6, 0x67, 0x0d, 0xb0, 0xb9, 0x50,
|
||||||
|
0xda, 0xc6, 0x80, 0x31, 0x02, 0x5c, 0xc5, 0xb6,
|
||||||
|
0x32, 0x13, 0xa4, 0x91])
|
||||||
|
froutput.scriptPubKey = CScript([OP_HASH160, fraddr, OP_EQUAL])
|
||||||
|
coinbaseoutput.nValue -= froutput.nValue
|
||||||
|
coinbase.vout = [ coinbaseoutput, froutput ]
|
||||||
coinbase.calc_sha256()
|
coinbase.calc_sha256()
|
||||||
return coinbase
|
return coinbase
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue