def build_block_on_tip(self, node, segwit=False):
    height = node.getblockcount()
    tip = node.getbestblockhash()
    mtp = node.getblockheader(tip)['mediantime']
    block = create_block(int(tip, 16), create_coinbase((height + 1)), (mtp + 1))
    block.nVersion = 4
    if segwit:
        add_witness_commitment(block)
    block.solve()
    return block
def build_block_on_tip(self, node, segwit=False):
    height = node.getblockcount()
    tip = node.getbestblockhash()
    mtp = node.getblockheader(tip)['mediantime']
    block = create_block(int(tip, 16), create_coinbase((height + 1)), (mtp + 1))
    block.nVersion = 4
    if segwit:
        add_witness_commitment(block)
    block.solve()
    return block