Crypto Flexs
  • DIRECTORY
  • CRYPTO
    • ETHEREUM
    • BITCOIN
    • ALTCOIN
  • BLOCKCHAIN
  • EXCHANGE
  • ADOPTION
  • TRADING
  • HACKING
  • SLOT
Crypto Flexs
  • DIRECTORY
  • CRYPTO
    • ETHEREUM
    • BITCOIN
    • ALTCOIN
  • BLOCKCHAIN
  • EXCHANGE
  • ADOPTION
  • TRADING
  • HACKING
  • SLOT
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

Apple, X, Airbnb Eye Stablecoin Integration

June 7, 2025

Does Ethereum start their business? MorningStar Candlestick Pattern tells the story

June 6, 2025

Bitcoin Is An Unreplicable Lifeline In Authoritarian Regimes

June 6, 2025
Add A Comment

Comments are closed.

Recent Posts

Solana Whale will not announce $ 17 million in four years. Should I worry?

June 7, 2025

HOLONYM’s Human Network: Convert on boarding on boarding on human -friendly keys

June 7, 2025

The SEC gets $ 1.1m case when Crypto Schemer crosses the court.

June 7, 2025

NFT artists reproduce ‘password tax nightmares’ with new songs.

June 7, 2025

NVIDIA’s GB200 NVL72 and Dynamo improve MoE model performance

June 7, 2025

Despite market volatility

June 7, 2025

TEZOS promotes scaling efforts by activating data soluble layers.

June 7, 2025

It shows a graphite network. Tesla is nothing without trust because Tesla’s Tesla spent $ 150 billion after Musk and Trump’s fallout.

June 7, 2025

The merchant warns that Bitcoin is in ‘cancer price behavior’.

June 7, 2025

Is Bitcoin Price Rally $ 150K by the end of the year?

June 7, 2025

How does it affect Bitcoin?

June 7, 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

Solana Whale will not announce $ 17 million in four years. Should I worry?

June 7, 2025

HOLONYM’s Human Network: Convert on boarding on boarding on human -friendly keys

June 7, 2025

The SEC gets $ 1.1m case when Crypto Schemer crosses the court.

June 7, 2025
Most Popular

HKMA and HKAB establish joint task force to strengthen SME lending

August 23, 2024

Ethereum price forms a bullish pattern and why ETH could extend its bounce

November 24, 2023

Binance Announces Maintenance Schedule for Telegram Open Network (TON) Wallet

August 25, 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.