Difference between revisions of "Coinbase"

 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
'''Coinbase''' is the special name given to the first transaction in every block. These can also be called 'Generation Transactions'.  
 
'''Coinbase''' is the special name given to the first transaction in every block. These can also be called 'Generation Transactions'.  
  
The winning miner creates this special transaction as part of the block templating process.  
+
The winning Miner creates this special transaction as part of the block templating process.  
  
 
A coinbase transaction follows the same format as a normal transaction, except:
 
A coinbase transaction follows the same format as a normal transaction, except:
* It has exactly one txin
+
* It has exactly one txin.
 
* This txin's prevout hash is 0000...0000.
 
* This txin's prevout hash is 0000...0000.
* This txin's prevout index is 0xFFFFFFFF
+
* This txin's prevout [[index]] is 0xFFFFFFFF.
* The txin's prevout script is an arbitrary byte array which is used by miners to signal identity and pass messages from block winning nodes to the rest of the network
+
* The txin's prevout script is an arbitrary byte array which has historically been used by Miners to signal identity and pass messages from block winning nodes to the rest of the network.
* The sum of the txout's values cannot exceed the total of the current [[Miner subsidy]] plus the mining fees paid by all other transactions included in the block
+
* The sum of the values of all txout's cannot exceed the total of the [[Miner subsidy]] and the mining fees paid by all other transactions included in the block.
  
A part of the coinbase is also used as an 'extra nonce' during the block discovery process due to a single ASIC miner being able to test more combinations than allowed for in the 2^32 possible combinations that changing the nonce in the block header can create. The extra nonce field is incremented and the merkle root updated to generate a further 2^32 possible block hashes to try.
+
A part of the coinbase can also used as an 'extra nonce' during the block discovery process due to a single ASIC Miner being able to test more combinations than allowed for, in the 2^32 possible combinations that changing the nonce in the block header can create. The extra nonce field is incremented in the Coinbase transaction, which requires that a small number of hashes in the merkle tree are updated, changing the [[Merkle root]] in the [[block header]] allowing for a further 2^32 possible block hashes to be attempted.
  
The winning miner can pay the coinbase value to multiple outputs as needed, and is also free to include zero value OP_FALSE OP_RETURN outputs in the transaction.
+
A Coinbase transaction can have as many outputs attached as are needed by the miner. These can be used for second layer functions including:
 +
*[[Merchant API]], otherwise known as [[MAPI]], which allows the winning Miner to provide a dynamically accessible transaction pricing service enabling users to request pricing and transaction broadcast services from miners on the network.
 +
*[[MinerID]] also uses the Coinbase transaction to present information to the network such as node identity, MAPI access points and more. This data will use standard formats such that user wallets shall be able to read and parse the information, giving them up-to-date knowledge of which nodes are competing on the network and more.
  
[[https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki BIP 0034]] mandated that the block height value be specified in the first item of the coinbase transaction. This value requires 4 bytes to store.
+
Due to some early problems with blocks containing only a coinbase transaction with an identical coinbase text and outputs generating coinbase transactions with identical [[TXID|TXIDs]], miners agreed through consensus to begin enforcing [https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki BIP 0034] as a [[Protocol|protocol rule]]. This change mandated that the block height value be specified in the first item of the coinbase transaction. Prior to this, the coinbase script size was between 2 and 100 bytes. Currently the minimum length is 4 bytes which is needed to hold the blockheight in a [[VarInt]]. The maximum value storable in 3 bytes is 16,777,215 so with the generating blocks at a rate of approximately 59,000 per year so if this level of network activity is sustained then from approximately the year 2,300 the minimum length of a coinbase script size will need to increase to 5 bytes.
 
 
Prior to [[https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki BIP 0034]] the coinbase script size was between 2 and 100 bytes. Since the smallest number of bytes required to store the current Block Height is 1 byte for the length and 3 bytes for the value, a minimum of 4 bytes are required to store the block height. Therefore, post [[https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki BIP 0034]] the coinbase script size now is between 4 and 100 bytes in length.
 
 
 
''Note'': The maximum block height that can be represented in 3 bytes is (2 ^ (3 x 8 bits)) -1) == 16,777,215. At time of writing the block height is 614,372, therefore > 16 million more blocks can be represented with the current structure.
 
 
 
The block height of the [[Genesis_block]] is <u>zero</u>.
 
 
 
Upcoming innovations such as [[MinerID]] and the upcoming [[Merchant API]] will use the Coinbase transaction to present information to the network such as node identity, transaction pricing data and more. This data will use standard formats such that user wallets shall be able to read and parse the information, giving them up-to-date knowledge of which nodes are competitive on the network and more.
 

Latest revision as of 04:26, 25 April 2022

Coinbase is the special name given to the first transaction in every block. These can also be called 'Generation Transactions'.

The winning Miner creates this special transaction as part of the block templating process.

A coinbase transaction follows the same format as a normal transaction, except:

  • It has exactly one txin.
  • This txin's prevout hash is 0000...0000.
  • This txin's prevout index is 0xFFFFFFFF.
  • The txin's prevout script is an arbitrary byte array which has historically been used by Miners to signal identity and pass messages from block winning nodes to the rest of the network.
  • The sum of the values of all txout's cannot exceed the total of the Miner subsidy and the mining fees paid by all other transactions included in the block.

A part of the coinbase can also used as an 'extra nonce' during the block discovery process due to a single ASIC Miner being able to test more combinations than allowed for, in the 2^32 possible combinations that changing the nonce in the block header can create. The extra nonce field is incremented in the Coinbase transaction, which requires that a small number of hashes in the merkle tree are updated, changing the Merkle root in the block header allowing for a further 2^32 possible block hashes to be attempted.

A Coinbase transaction can have as many outputs attached as are needed by the miner. These can be used for second layer functions including:

  • Merchant API, otherwise known as MAPI, which allows the winning Miner to provide a dynamically accessible transaction pricing service enabling users to request pricing and transaction broadcast services from miners on the network.
  • MinerID also uses the Coinbase transaction to present information to the network such as node identity, MAPI access points and more. This data will use standard formats such that user wallets shall be able to read and parse the information, giving them up-to-date knowledge of which nodes are competing on the network and more.

Due to some early problems with blocks containing only a coinbase transaction with an identical coinbase text and outputs generating coinbase transactions with identical TXIDs, miners agreed through consensus to begin enforcing BIP 0034 as a protocol rule. This change mandated that the block height value be specified in the first item of the coinbase transaction. Prior to this, the coinbase script size was between 2 and 100 bytes. Currently the minimum length is 4 bytes which is needed to hold the blockheight in a VarInt. The maximum value storable in 3 bytes is 16,777,215 so with the generating blocks at a rate of approximately 59,000 per year so if this level of network activity is sustained then from approximately the year 2,300 the minimum length of a coinbase script size will need to increase to 5 bytes.