0

Based on my knowledge I know (maybe wrong) when a miner is doing hash, he is inputting any arbitrary values, in order to get a value that can be hashed into something with certain preceding zeros. When he got that value, he put that value into the blockchain and generate a new block.

Then how is this contributing, or say, relating to the confirmations? Since the miners are just guessing arbitrary values to get the 0000000 preceded hash.

I think I must have some misunderstanding. I want to know how the hash-guessing is related to confirming the transactions.

2

2 Answers 2

1

he is inputting any arbitrary values, in order to get a value that can be hashed into something with certain preceding zeros. When he got that value, he put that value into the blockchain and generate a new block.

It happens in reverse.
First the miner builds the new block itself. Then builds its header, then hashes that header. Also what the miner looks for is not preceding zeros, but instead is a number (hash result interpreted as integer) that is smaller than the target.

The steps are something like this:

  1. Take 0 to max (to fill the block) number of transaction from mempool
  2. Build the mandatory coinbase transaction
  3. Build the hashMerkleRoot based on 1&2
  4. Fill the block header fields: Version, hashPrevBlock and Bits are unchanging; hashMerkleRoot, Time and Nonce can change
  5. Start a loop and change the variables on its iterations and hash the header.
  6. Convert the result of the hash to an integer and compare it with the target.
  7. Break out of the look and publish the result if hash <= target or if someone else were luckier and found and published the same block.

You can find more information in these links:
https://en.bitcoin.it/wiki/Block_hashing_algorithm
https://en.bitcoin.it/wiki/Proof_of_work

Then how is this contributing, or say, relating to the confirmations?

Confirmation is when a transaction is included in a block that was found. 1 confirmation means the transaction is inside the last found block, any subsequent number shows the depth of the transaction compared to the block height of that time and is an indication of how hard it would be to perform a double spend. https://en.bitcoin.it/wiki/Confirmation

1

When miners build valid blocks with transactions, they put in significant amount of compute work to generate a hash of the block header that meets the difficulty requirement. Blockchain is a chain of blocks where each block header references the hash of the header of the previous block. The hash of the block header is calculated using all the elements of the block, which includes the transactions it contains. If a component of the block is changed in any way, it will generate a completely different hash.

Confirmation is a direct reference to the difficulty of removing a transaction from the blockchain. If a transaction is included in a block that has 5 blocks mined after it, then an attacker who wants to exclude that particular transaction would have to perform "work" (compute hashes that match the difficulty requirement) to mine the block containing the transaction and all subsequent blocks after it. This is a total of 6 blocks and hence that particular transaction is said to have 6 confirmations.

If the transaction is mined in a block with sufficient confirmations, than the cost of excluding that transaction is very high as the attacker would have to perform the compute work. Thus, in the mining process the miners through their heavy compute work add finality to the transactions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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