Based on what I read, there is this script to build the Merkle root

import hashlib     
def dblsha(data):      
    return hashlib.sha256(hashlib.sha256(data).digest()).digest()     
txnlist = [coinbase] + [binascii.a2b_hex(a['data']) for a in template['transactions']]     
merklehashes = [dblsha(t) for t in txnlist]     
while len(merklehashes) > 1:     
     if len(merklehashes) % 2:     
    merklehashes = [dblsha(merklehashes[i] + merklehashes[i + 1]) for i in range(0, len(merklehashes), 2)]      
merkleroot = merklehashes[0]        

I wanted to mine an empty block (a block with only a coinbase transaction in it) , can I modify the script so that txnlist only includes coinbase and ignore the other transactions? or it is considered a hard fork?

txnlist = [coinbase]       

Or this isn't the correct way to mine empty block?

I currently only have a shallow understanding of Bitcoin, that's why I ask.

1 Answer 1



A block is valid even with no transactions other than the coinbase transaction. There have been many such blocks. This is especially true for early blocks of the blockchain.

Average number of BTC transactions per block (source: Cointelegraph)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.