def create_test_block(self, version=536870912):
    self.bump_mocktime(5)
    bt = self.nodes[0].getblocktemplate()
    tip = int(bt['previousblockhash'], 16)
    nextheight = bt['height']
    coinbase = create_coinbase(nextheight)
    coinbase.nVersion = 3
    coinbase.nType = 5
    coinbase.vout[0].nValue = bt['coinbasevalue']
    for mn in bt['masternode']:
        coinbase.vout.append(CTxOut(mn['amount'], CScript(hex_str_to_bytes(mn['script']))))
        coinbase.vout[0].nValue -= mn['amount']
    cbtx = FromHex(CCbTx(), bt['coinbase_payload'])
    coinbase.vExtraPayload = cbtx.serialize()
    coinbase.rehash()
    coinbase.calc_sha256()
    block = create_block(tip, coinbase, self.mocktime)
    block.nVersion = version
    for tx in bt['transactions']:
        tx2 = FromHex(CTransaction(), tx['data'])
        if (tx2.nType == 6):
            block.vtx.append(tx2)
    block.hashMerkleRoot = block.calc_merkle_root()
    block.rehash()
    block.solve()
    return block
def create_test_block(self, version=536870912):
    self.bump_mocktime(5)
    bt = self.nodes[0].getblocktemplate()
    tip = int(bt['previousblockhash'], 16)
    nextheight = bt['height']
    coinbase = create_coinbase(nextheight)
    coinbase.nVersion = 3
    coinbase.nType = 5
    coinbase.vout[0].nValue = bt['coinbasevalue']
    for mn in bt['masternode']:
        coinbase.vout.append(CTxOut(mn['amount'], CScript(hex_str_to_bytes(mn['script']))))
        coinbase.vout[0].nValue -= mn['amount']
    cbtx = FromHex(CCbTx(), bt['coinbase_payload'])
    coinbase.vExtraPayload = cbtx.serialize()
    coinbase.rehash()
    coinbase.calc_sha256()
    block = create_block(tip, coinbase, self.mocktime)
    block.nVersion = version
    for tx in bt['transactions']:
        tx2 = FromHex(CTransaction(), tx['data'])
        if (tx2.nType == 6):
            block.vtx.append(tx2)
    block.hashMerkleRoot = block.calc_merkle_root()
    block.rehash()
    block.solve()
    return block