0

My goal is to understand bitcoin.

I have read what happens during a transaction and have a question about it:

When a transaction happen, the miners compute a value called "prof of work". This value is calculated in order to get a 0 value (or something very closed to 0) for the hash of the value + the transaction + the last pow.

So the miner work is to calculate a prof of work. But i have read the miner discover new bitcoins too. Is it another form of mining ? I do not see the link between the POW calculation and the new bitcoins)

Thanks

  • Your question is a collection of many questions, and they have been answered before. Check out the search function on this site, and then report back with any other questions you may have :) – chytrik Aug 24 at 5:18
  • I have read a lot of things, including on stackexchange but this questions are very confusing for me. This is why i have compiled them... Thanks – Bob5421 Aug 24 at 5:31
  • Please split up your question in individual questions per topic. This is a Q&A site, not a forum, and the goal is making good questions with good answers searchable. – Pieter Wuille Aug 24 at 7:08
  • thanks for your answer, i have edit the first question – Bob5421 Aug 24 at 7:11
2

When a transaction happen, the miners compute a value called "prof of work". This value is calculated in order to get a 0 value (or something very closed to 0) for the hash of the value + the transaction + the last pow.

The miner does not perform the PoW on each transaction individually, but on a set of transactions, whose combined size is less than approximately 1MB when serialized (There is a 1MB limit for non-SegWit parts and 4MB limit for the entire structure including SegWit parts).

The set of transactions is placed into a structure called a block. The block has a header which contains, among other things, a timestamp, the target, a nonce, the hash of the previous block's header, and the merkle root of the set of transactions in this block. The actual representation of the transactions in the block structure is a simple serialized list.

Miners can choose which transactions they wish to include in a block and in what order. However, the usual method is to sort transactions by highest paying fee and select the first bunch of transactions which fit within the block size limit.

The merkle root is calculated by placing the transaction ids (the hash of the serialized transaction) into a binary tree where each parent's value is the hash of the concatenation of its two children's values. The value of the root of this tree is then placed into the block header, along with the other necessary information.

Proof-of-Work is then performed by taking a hash of this block header, and the proof of work is successful if the resulting hash is less than the value specified by the target, which determines the difficulty. The target indicates how many leading zeroes the hash must have - the more leading zeroes, the smaller the possible range of hashes becomes, making it more difficult to produce a matching hash. This difficulty is adjusted according to a consensus algorithm which attempts to make blocks created on average every 10 minutes - using historical data from the past 2016 blocks and their timestamps.

The Proof-of-Work is essentially brute-forcing the double-SHA256 of the block header by using different value for the nonce in the header until the resulting hash of the header is a value which is less than the target. The nonce can be randomly selected, but it is more sensible to simply cycle through all possible 32-bit integer values in order.

But i have read the miner discover new bitcoins too. Is it another form of mining ? I do not see the link between the POW calculation and the new bitcoins)

Each block must contain at least one transaction in its set, which must appear first in the list. This is known as the coinbase transaction. Unlike other transactions, it has no UTXOs as inputs - but its virtual input is newly generated coins plus the aggregate of fees paid in all transactions in this block. Newly generated coins must be strictly less than or equal to 50 >> floor(block_height / 210000) bitcoin, which determines that the number of new bitcoins which may be generated is halved approximately every 4 years (210000 blocks).

The coinbase can also be used to include an extra nonce value because the nonce in the regular block header is too small (32-bits), and its entire range can be exhausted by modern miners more quickly than new transactions are added to the block. Mining pools also usually insert their name into the coinbase transaction so it can be public knowledge.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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