2

I know that the way miners claim their fees are by factoring them in the BTC amount specified in the coinbase, which the protocol forces the max selectable value to be the current block reward + the total fees included from TXs in the block.

But how do people themselves specify what amount of the BTC should be spent on fees in their transactions? Is there a special output area that says to pay it to the miner, or how is it structured?

My question is, in literal concept, how are the fees chosen in a TX when constructing a tx manually.

1 Answer 1

2

The miners fee is sum of inputs minus sum of outputs.

When you construct a transaction you make sure there is a difference between those two sums


Here's a made up example, I want to buy a cup of coffee and I only have the Bitcoin equivalent of a million dollar bill (banknote) in my trouser pocket.

Transaction:

Inputs Outputs
60.00000 (to coffee shop) 0.00018
  (change returned to me) 59.99981

Sums:

Inputs Outputs Difference
60.00000 59.99999 (fee for miner to collect) 0.00001
4
  • >”The miners fee is sum of inputs minus sum of outputs. When you construct a transaction you make sure there is a difference between those two sums“ ⇒ So what happens if the sender only has really large inputs? Is the miner to assume they are allowed to take a large fee from their transactions if they make small transactions with big inputs? How is something like fee-per-byte determined if you might not have the right input to limit your input-output difference? Is there a limit on how big of a fee can be taken?
    – Poseidon
    Dec 29, 2022 at 5:46
  • 1
    You would create a change output back to your wallet - just like in real life. This is very common and done automatically by your wallet software. You might want to take a closer look at the bitcoin transaction model and the concept of UTXO (unspent transaction outputs).
    – sutterseba
    Dec 29, 2022 at 15:39
  • 1
    @Poseidon: Check out bitcoin.stackexchange.com/q/736/5406
    – Murch
    Dec 29, 2022 at 16:07
  • I added an example to clarify Dec 29, 2022 at 16:59

Your Answer

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

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