Fee Calculation
Upcoming Topics:
- Transaction Fees
- Weight-vsize
- Fee Rate
- Fee Bumping (RBF, CPFP)
- Security Budget Problem.
Fees in Bitcoin are calculated as the difference between inputs and outputs amounts.
Fee = Sum of Inputs - Sum of OutputsLet's calculate the fee for the following transaction:
Fee = Input - (Output1 + Output2)
= 299.99430000 - (0.00140000 + 299.99240000)
= 0.00050000 BTC (50,000 sats)
Remember: Sum(Inputs) should always be greater than Sum(Outputs)
Why Do We Need Fees?
The purpose of fees is to incentivize miners to include transactions in the block.
Without fees, miners would have no reason to include transactions in their blocks.
Without fees, miners would have no reason to include transactions in their blocks.
- But how exactly do miners decide which transactions to include?
How Miners Select Transactions?
Miners receive two types of rewards for securing the network:
- Block Reward
- Transaction Fees
A miner who mines a block will have revenue as:
Revenue = Transaction Fees + Block SubsidyTo maximize their revenue, miners prioritize transactions that pay higher fees. The way they determine which transactions pay more will be covered in the next topic when we discuss fee rates.
For now, understand that:
- Transactions paying higher fees get priority for inclusion (fast confirmation)
- Transactions paying lower fees may wait longer in the mempool (or even fail)
Minimum Relay Fee
While miners can choose which transactions to include based on fees, there's actually a minimum threshold that transactions must meet just to be relayed through the network.
Continue reading https://bitcoindevs.xyz/decoding/fee-calculation
Tx 2in the mempool toTx 3in the block? And same for arrow going fromTx 3in mempool toTx 2in block.7000 satsfee tx getting prioritized over5000 satsand4000 satstransactions. Strictly speaking the miner would be looking at the fee rate and prioritizing accordingly (knapsack problem aside...)