Crypto Flexs
  • DIRECTORY
  • CRYPTO
    • ETHEREUM
    • BITCOIN
    • ALTCOIN
  • BLOCKCHAIN
  • EXCHANGE
  • ADOPTION
  • TRADING
  • HACKING
  • SLOT
  • TRADE
Crypto Flexs
  • DIRECTORY
  • CRYPTO
    • ETHEREUM
    • BITCOIN
    • ALTCOIN
  • BLOCKCHAIN
  • EXCHANGE
  • ADOPTION
  • TRADING
  • HACKING
  • SLOT
  • TRADE
Crypto Flexs
Home»BITCOIN NEWS»Mining Theory – How to make a coinbase? How to use witnesses?
BITCOIN NEWS

Mining Theory – How to make a coinbase? How to use witnesses?

By Crypto FlexsDecember 13, 20232 Mins Read
Facebook Twitter Pinterest LinkedIn Tumblr Email
Mining Theory – How to make a coinbase?  How to use witnesses?
Share
Facebook Twitter LinkedIn Pinterest Email

BIP141 added a new rule called “witness appointments.” “Promises are written to the scriptPubKey of the Coinbase transaction,” the document states. I didn’t quite understand what it meant, so I directly placed ‘default_witness_commitment’ provided in the block template when creating Coinbase in the scriptPubKey location. Here is my code:

def makeCoinbase()->None:
    global coinbase,tmpl
    version=pack('<L',1)
    inputCount=unhexlify('01')
    txHash=unhexlify('0000000000000000000000000000000000000000000000000000000000000000')
    preSequence=unhexlify('ffffffff')
    eh=encodeHeight(tmpl('height'))  #Don't worry about this function, it handles height
    msg=eh+b'my message'
    msgSize=pack('B',len(msg))
    sequence=unhexlify('ffffffff')
    outCount=unhexlify('01')
    amount=pack('<Q',tmpl('coinbasevalue'))
    script=unhexlify(tmpl('default_witness_commitment'))
    scriptSize=pack('B',len(script))
    lockTime=unhexlify('00000000')
    coinbase=version+inputCount+txHash+preSequence+msgSize+msg+\
        sequence+outCount+amount+scriptSize+script+lockTime
    tmpl('transactions').insert(0,
        'data':coinbase.hex(),
        'txid':dblsha(coinbase)(::-1).hex()
    )

The tmpl variable is the template obtained using the “getblocktemplate” command. I am testing my code in regtest. When you submit a block, Bitcoin Core creates a new block. And my balance increased. However, when I checked Coinbase for the newly created block, the results were as follows.


    'txid': '9cb794f3292d1ece3af6c1d3055cf6fb26cf2126ff48b39b229bfec5ec651ec4', 
    'hash': 'de081b2a9552ac559d3501ed0669f675530fe9890e27d263c1aff65e678ddc4e', 
    'version': 1, 
    'size': 153, 
    'vsize': 126, 
    'weight': 504, 
    'locktime': 0, 
    'vin': (
        'coinbase': '016c54686520477265617420476f642050616e', 
        'txinwitness': ('0000000000000000000000000000000000000000000000000000000000000000'), 
        'sequence': 4294967295), 
    'vout': (
        'value': Decimal('50.00063100'), 
        'n': 0, 
        'scriptPubKey': 
            'asm': 'OP_RETURN aa21a9edb14717ddf39dacad0babfff4d8d951c076e95d11d2b1f328632c32f98c015d2c', 
            'desc': 'raw(6a24aa21a9edb14717ddf39dacad0babfff4d8d951c076e95d11d2b1f328632c32f98c015d2c)#psf60z3m', 
            'hex': '6a24aa21a9edb14717ddf39dacad0babfff4d8d951c076e95d11d2b1f328632c32f98c015d2c', 
            'type': 'nulldata'
        
    ), 
    'hex': '010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff13016c54686520477265617420476f642050616effffffff017ce8062a01000000266a24aa21a9edb14717ddf39dacad0babfff4d8d951c076e95d11d2b1f328632c32f98c015d2c0120000000000000000000000000000000000000000000000000000000000000000000000000'

As you can see, it only contains one vout. And that vout doesn’t contain any address. But if you look at Coinbase for a block on the main network, it always contains more than one vout, and the vout contains an address. My question is, am I building Coinbase the right way? If not, how do I fix it? Bitcoin Core did not report any errors, but I always suspected that I had lost the miner’s address.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email

Related Posts

Bitcoin is integrated into less than $ 108,000, but the eyes are set for $ 115,000.

June 29, 2025

Sequans starts $ 384M Bitcoin Treasury Initiative with Swan Bitcoin Partnership.

June 23, 2025

ECB Chairman Lagarde aims to seize the global order to strengthen the Euro’s global position.

June 17, 2025
Add A Comment

Comments are closed.

Recent Posts

Shheikh.io Launches SHHEIKH Token Presale For Blockchain-Backed Real‑World Asset Investments

June 30, 2025

What should I do with encryption?

June 30, 2025

AAS Miner Will Become The Top Free Cloud Mining Platform For Passive Income From Mining Cryptocurrencies Such As BTC And ETH In 2025

June 30, 2025

Bitcoin is integrated into less than $ 108,000, but the eyes are set for $ 115,000.

June 29, 2025

Etherrium price behavior is weakened-danger of short-term modifications

June 29, 2025

Last Opportunity-The bonus stage of the light chain AI begins after closing all 15 pre-sales stages.

June 29, 2025

Its Important To Know What’s Really Going On?

June 29, 2025

Elon Musk, SpaceX And Crypto Hype: What’s Really Going On?

June 28, 2025

Checkpoint #4: Berlinterop | Ether Leeum Foundation Blog

June 28, 2025

TRON Price Propects USDT supply exceeded $ 80 billion

June 28, 2025

Stablecoin startups surpass 2021 venture capital peaks as institutional money spills.

June 28, 2025

Crypto Flexs is a Professional Cryptocurrency News Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of Cryptocurrency. We hope you enjoy our Cryptocurrency News as much as we enjoy offering them to you.

Contact Us : Partner(@)Cryptoflexs.com

Top Insights

Shheikh.io Launches SHHEIKH Token Presale For Blockchain-Backed Real‑World Asset Investments

June 30, 2025

What should I do with encryption?

June 30, 2025

AAS Miner Will Become The Top Free Cloud Mining Platform For Passive Income From Mining Cryptocurrencies Such As BTC And ETH In 2025

June 30, 2025
Most Popular

Ethereum faces market volatility as Celsius offloads $1 billion from ETH

January 27, 2024

Ark Invest offloads an additional $33 million in Coinbase and $6 million in GBTC.

December 6, 2023

Bitcoin flash crashed to $90,200, causing liquidation of over $885 million.

December 6, 2024
  • Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions
© 2025 Crypto Flexs

Type above and press Enter to search. Press Esc to cancel.