Most of the confusion stems from the fact that people try to fit Bitcoin into the Addresses and Balances mental model, but it doesn't work like that. You must think in terms of Transactions, which are the atomical operation of Bitcoin and the actual pieces of data that are stored in the blockchain.
Transactions have Inputs and Outputs. Each input is a pointer to a single Output from a previous Transaction, and contains the unlocking script for that previous Output.
Each Output has some sat value assigned to it, plus a locking script. Outputs begin their lifecycle as UTXOs. The moment a new Transaction appears that points to and unlocks them successfully it ceases to be an UTXO and cannot be pointed at by any other Transaction (that'd be a double spend).
Finally, the Transaction fee is the difference between the total sat value assigned to the previous Outputs that are being spent minus the total sat value assigned to the Transaction's own Outputs. If that number is less than 0 the Transaction is invalid and rejected.
Tip: mempool.space is great to make sense of it all in a visual way.
Tip: mempool.space is great to make sense of it all in a visual way.
Yep, and they have very good documentation https://mempool.space/docs/faq
reply