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

It announces the provision of the largest regulatory futures in Europe to strengthen its leading market in the region.

May 20, 2025

Chart Decoder Series: RSI -The easiest way to discover superb and overlooking markets

May 20, 2025

Is the transaction fee the lowest?

May 19, 2025
Add A Comment

Comments are closed.

Recent Posts

XRP News: XRPTURBO will be live by 25% APY Liquid Staying, and $ XRT will launch governance DApps at 150%.

May 21, 2025

RayTurbo data improvement increases processing speed by 5 times

May 21, 2025

Despite the mini price rally, the reason why Ethena buyers should be careful is as follows.

May 21, 2025

Together, we launch code sandboxes and interpreters to develop AI with enhanced AI.

May 21, 2025

‘Hawk Tuah Girlie Welch said that the FBI surveyed her’ Memecoin Disaster ‘.

May 21, 2025

DOW drops 115 points after the six -day rally of the S & P 500.

May 21, 2025

AI innovates Peru’s education. The teacher accepts Microsoft Copilot

May 21, 2025

How to start a bitcoin mining machine with Dogecoin (DOGE)

May 21, 2025

Bitcoin is ready to ‘evaporate’ shorts when the price discovery of more than $ 110K begins

May 21, 2025

The SEC is charged with Unicoin and executives for $ 100 million fraud.

May 21, 2025

Trader says Bitcoin (BTC) warns a weak reversal signal, and there is a gold meeting steam for the next leg.

May 21, 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

XRP News: XRPTURBO will be live by 25% APY Liquid Staying, and $ XRT will launch governance DApps at 150%.

May 21, 2025

RayTurbo data improvement increases processing speed by 5 times

May 21, 2025

Despite the mini price rally, the reason why Ethena buyers should be careful is as follows.

May 21, 2025
Most Popular

BlockDAG beats Cardano & Pandoshi presales with 5000x profit potential.

February 20, 2024

Cardano (ADA) pressure mount -more disadvantages of horizontal lines?

April 16, 2025

Market Outlook #261 – Altcoin Trader’s Blog

March 28, 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.