Bitcoin Forum
May 17, 2024, 12:34:45 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: How do miners actually collect commission for creating a block?  (Read 187 times)
BoyFromDubai (OP)
Jr. Member
*
Offline Offline

Activity: 33
Merit: 22


View Profile
December 15, 2022, 04:49:36 PM
 #1

I've just looked through Blockchain.com and looked through transactions in a block. And neither a lot of outputs were in the coinbase transaction nor the last transaction was with lots of outputs. So how does miner actually collects commission?
Charles-Tim
Legendary
*
Offline Offline

Activity: 1554
Merit: 4904



View Profile
December 15, 2022, 05:14:03 PM
Merited by pooya87 (2), bitmover (2)
 #2

A miner mine a block and the miner is given the reward. The miner can do anything with the rewards.

This is an example: https://www.blockchain.com/explorer/blocks/btc/767547

Block 767547
The reward for block mined is 6.25 BTC
The reward for including transaction into the block mined is: 0.13448374 BTC
Reward in total which would be on the miners address(es) (block reward + transaction fees): 6.38448374 BTC

witcher_sense
Legendary
*
Offline Offline

Activity: 2352
Merit: 4336


🔐BitcoinMessage.Tools🔑


View Profile WWW
December 15, 2022, 05:20:08 PM
Merited by pooya87 (2), bitmover (1)
 #3

I've just looked through Blockchain.com and looked through transactions in a block. And neither a lot of outputs were in the coinbase transaction nor the last transaction was with lots of outputs. So how does miner actually collects commission?
Transaction fees aren't included in a transaction and rather calculated implicitly: essentially it is a surplus (or difference) of bitcoin between total sum of inputs and total sum of outputs. When miners calculates his reward, he adds up this surplus to block subsidy and collects block reward.

You can read more here: https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch10.asciidoc

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
bitmover
Legendary
*
Online Online

Activity: 2310
Merit: 5951


bitcoindata.science


View Profile WWW
December 15, 2022, 05:25:42 PM
 #4

I've just looked through Blockchain.com and looked through transactions in a block. And neither a lot of outputs were in the coinbase transaction nor the last transaction was with lots of outputs. So how does miner actually collects commission?

As Charles-Tim pointed out, it is part of the Coinbase transaction, the first transaction in a block.

Block Reward = subsidy + fees

You can also read it in the whitepaper:

Quote
By convention, the first transaction in a block is a special transaction that starts a new coin owned
by the creator of the block. This adds an incentive for nodes to support the network
, and provides
a way to initially distribute coins into circulation, since there is no central authority to issue them.
The steady addition of a constant of amount of new coins is analogous to gold miners expending
resources to add gold to circulation. In our case, it is CPU time and electricity that is expended.

The incentive can also be funded with transaction fees. If the output value of a transaction is
less than its input value, the difference is a transaction fee that is added to the incentive value of
the block containing the transaction. Once a predetermined number of coins have entered
circulation, the incentive can transition entirely to transaction fees and be completely inflation
free.
https://bitcoin.org/bitcoin.pdf

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
NotATether
Legendary
*
Online Online

Activity: 1610
Merit: 6746


bitcoincleanup.com / bitmixlist.org


View Profile WWW
December 15, 2022, 05:45:55 PM
 #5

The bitcoin network is hardwired to accept the first transaction placed inside a block that contains (BLOCK_SUBSIDY) amount more bitcoins in total outputs than inputs.

Miners can choose to not claim the reward, but they will never be able to take that coinbase reward again if they do.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
BoyFromDubai (OP)
Jr. Member
*
Offline Offline

Activity: 33
Merit: 22


View Profile
December 15, 2022, 06:25:51 PM
Last edit: December 16, 2022, 02:07:12 PM by mprep
 #6

I got
Thanks to all of you!!!



But I've got another question
For a miner coinbase transaction contains always the same information (If we don't consider the division by 2 the number of bitcoins for mining). But txid for this transaction always different. that's because of fees? This time I've got 1 bitcoin in fees, the next time I've got 1.1 bitcoins. And tx information for me is always the same, excluding the reward. If I've got correctly, txid always different because of fees, isn't it?

[moderator's note: consecutive posts merged]
NotATether
Legendary
*
Online Online

Activity: 1610
Merit: 6746


bitcoincleanup.com / bitmixlist.org


View Profile WWW
December 15, 2022, 06:55:38 PM
 #7

But I've got another question
For a miner coinbase transaction contains always the same information (If we don't consider the division by 2 the number of bitcoins for mining). But txid for this transaction always different. that's because of fees? This time I've got 1 bitcoin in fees, the next time I've got 1.1 bitcoins. And tx information for me is always the same, excluding the reward. If I've got correctly, txid always different because of fees, isn't it?

The Txid is just the hash of the raw transaction data that is encoded in binary.

You might see such transactions represented as hex or as rich-text fields, but it is not hashed like that. It has to be represented as the 8-bit binary that will usually contain unreadable/non-printable characters.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
BoyFromDubai (OP)
Jr. Member
*
Offline Offline

Activity: 33
Merit: 22


View Profile
December 15, 2022, 07:19:31 PM
 #8

Yeah, I know that. But I'm interested in why hash of tx data of one miner always different? All information in coinbase tx the same for one miner excluding the reward that consists of  block reward + number of fees he gets from the block?
garlonicon
Hero Member
*****
Offline Offline

Activity: 806
Merit: 1940


View Profile
December 15, 2022, 07:22:50 PM
Merited by pooya87 (1)
 #9

Quote
But txid for this transaction always different. that's because of fees?
No, it is because the block number is included. And each block has a different number. See: BIP-34

For example, before BIP-34, it was possible to create duplicated coinbase transactions. See also: BIP-30.
BoyFromDubai (OP)
Jr. Member
*
Offline Offline

Activity: 33
Merit: 22


View Profile
December 15, 2022, 07:47:49 PM
 #10

Hmm
Then, this article is a bit old and doesn't show the current way of creating transacctions?
https://learnmeabitcoin.com/technical/transaction-data
I mean, now the structure of transaction is different?
garlonicon
Hero Member
*****
Offline Offline

Activity: 806
Merit: 1940


View Profile
December 15, 2022, 08:56:01 PM
 #11

Quote
I mean, now the structure of transaction is different?
It is compatible, so those things are still valid. Because if some old standard timelocked transaction was created in the past, it has to be valid today.

Of course, we have Segwit on top of that. It means, the coinbase transaction is different, and you can read more in other BIPs, like BIP-141. In general, Segwit transaction has just the same structure as non-Segwit transaction, but it also has some witness data, that are not processed by older, non-upgraded nodes.
hosseinimr93
Legendary
*
Online Online

Activity: 2408
Merit: 5239



View Profile
December 15, 2022, 09:02:22 PM
 #12

The Txid is just the hash of the raw transaction data that is encoded in binary.
To be more accurate, the transaction hash is calculated by hashing the transaction data through SHA256 function twice.


Yeah, I know that. But I'm interested in why hash of tx data of one miner always different?
According to BIP34, the coinbase transaction must contain the block height.
Before implementation of BIP34, it was possible to duplicate a coinbase transaction.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
BoyFromDubai (OP)
Jr. Member
*
Offline Offline

Activity: 33
Merit: 22


View Profile
December 15, 2022, 10:13:38 PM
 #13

But what did happen before this BIP? Two coinbase transactions with the same txid, it's a collision. How to save two coinbase vouts into leveldb and how to spend one of them if they have the same txid?
 
hosseinimr93
Legendary
*
Online Online

Activity: 2408
Merit: 5239



View Profile
December 15, 2022, 10:37:58 PM
Last edit: December 15, 2022, 10:57:32 PM by hosseinimr93
Merited by ABCbits (1)
 #14

But what did happen before this BIP? Two coinbase transactions with the same txid, it's a collision. How to save two coinbase vouts into leveldb and how to spend one of them if they have the same txid?
With BIP34, it's very very unlikely that two coinbase transactions have the same ID, but in theory it's still possible that two transactions have the same transaction ID.
If a transaction has the same ID as an existing transaction, the second one would replace the first one and there wouldn't be any way to spend the fund received in the first one.
See blocks number 91,722 and 91,880. The coinbase transactions in these two blocks have the same ID. The person who received the block reward on block number 91,722 can't spend it.
The solution to this problem was BIP30. According to BIP30, a block can't include a transaction with the same ID as a not-fully-spent transaction.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
NotATether
Legendary
*
Online Online

Activity: 1610
Merit: 6746


bitcoincleanup.com / bitmixlist.org


View Profile WWW
December 16, 2022, 03:18:58 AM
 #15

But what did happen before this BIP? Two coinbase transactions with the same txid, it's a collision. How to save two coinbase vouts into leveldb and how to spend one of them if they have the same txid?

The thing is that the network will accept only the first coinbase transaction in the block (which HAS to be the first transaction). Everything else is invalid from a protocol standpoint, even if two coinbase transactions are included in a block.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
hosseinimr93
Legendary
*
Online Online

Activity: 2408
Merit: 5239



View Profile
December 16, 2022, 03:50:27 AM
 #16

The thing is that the network will accept only the first coinbase transaction in the block (which HAS to be the first transaction). Everything else is invalid from a protocol standpoint, even if two coinbase transactions are included in a block.
I think OP is talking about two coinbase transactions with the same ID in two different blocks, not in the single block.

In theory, it's possible that a block includes a transaction with the same ID as an existing transaction if the existing transaction has been fully spent. Whether it's a coinbase transaction or a normal transfer, there's nothing prevent network from accepeting such a transaction.
Before implementation of BIP30, a block could include a transaction with the same ID as an existing transaction, even if the existing transaction had been unspent.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
pooya87
Legendary
*
Offline Offline

Activity: 3458
Merit: 10564



View Profile
December 16, 2022, 04:19:47 AM
 #17

For a miner coinbase transaction contains always the same information
There are many variables in a transaction. The only thing that must always be the same is the outpoint of a coinbase transaction's only input. The other thing that must be different is the coinbase's signature script. The rest can be different (tx version, number of outputs, the outputs and the rest of the input's signature script).

If a transaction has the same ID as an existing transaction, the second one would replace the first one and there wouldn't be any way to spend the fund received in the first one.
It used to be like this, but today if this happens the transaction and the block containing it will be rejected as invalid. Note that this is a general rule not just for coinbase txs and BIP30 only prevented coinbase duplication.

even if two coinbase transactions are included in a block.
That has always been impossible because a coinbase tx spends a special input (null hash with -1 index) which is not possible to see in any other tx. So you can't have 2 coinbase transactions in a block regardless of what BIP30 did.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
hosseinimr93
Legendary
*
Online Online

Activity: 2408
Merit: 5239



View Profile
December 16, 2022, 05:03:01 AM
 #18

It used to be like this, but today if this happens the transaction and the block containing it will be rejected as invalid.
But we can still have a block including a transaction with the same ID as an existing transaction, if the existing transaction has been fully spent. Right?
I know the chance of that happening is almost zero.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
NotATether
Legendary
*
Online Online

Activity: 1610
Merit: 6746


bitcoincleanup.com / bitmixlist.org


View Profile WWW
December 16, 2022, 05:13:28 AM
 #19

The thing is that the network will accept only the first coinbase transaction in the block (which HAS to be the first transaction). Everything else is invalid from a protocol standpoint, even if two coinbase transactions are included in a block.
I think OP is talking about two coinbase transactions with the same ID in two different blocks, not in the single block.

Most full nodes should be able to detect this anomaly very quickly, since the UTXO sets will not be identical, and that will cause problems and validation errors when verifying child transactions.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
pooya87
Legendary
*
Offline Offline

Activity: 3458
Merit: 10564



View Profile
December 16, 2022, 05:30:19 AM
 #20

It used to be like this, but today if this happens the transaction and the block containing it will be rejected as invalid.
But we can still have a block including a transaction with the same ID as an existing transaction, if the existing transaction has been fully spent. Right?
I know the chance of that happening is almost zero.
Yes.
Your node only checks the UTXO database to see the transaction can be found among the unspent outputs not the whole blockchain. It would take a long time to search the entire blockchain that is not indexed anyways.
I believe this is the line where it rejects such transactions if they exist among "coins": https://github.com/bitcoin/bitcoin/blob/968f03e65c98a9a36aea6c57a29306839b0ada57/src/validation.cpp#L2151

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Pages: [1] 2 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!