Based on this StackOverflow post: [https://bitcoin.stackexchange.com/a/64483](https://bitcoin.stackexchange.com/a/64483)
Let’s say someone has 10 BTC from various transactions (Tx) which were 1 BTC, 2 BTC, 3 BTC, and 4 BTC respectively, and they want to send someone else 5.5 BTC.
It is my understanding that you cannot simply verify that 5.5 < 10 and thus verify the Tx to be pushed into a block which will be mined.
Rather, you must find all of the previous unspent TX amounts that they received as inputs (someone else sent or change for sending too much) and select a combination of these such that their sum is greater than or equal to what they would like to send. From my example, that would be 2 BTC + 4 BTC (or 1 + 2 + 3 or even 3 + 4) – I assume that the system in place chooses the last number of unspent amounts that are closest to this amount, or does the account owner choose this?
If the amount of these unspent TX amounts equals the sum you want to send – great you get no change in return. Otherwise, you get change as a new unspent TX output. So in my example using 2+4 would give you a change of 0.5BTC, so now you have 0.5 BTC, 1 BTC, 3 BTC as UTXOs. Trying to spend more than 4.5 BTC would now cause the transaction to not be verified as all other nodes would see that you only have 4.5 BTC from your UTXO history.
Is my thinking correct? If so, I have a few questions I would love to get a better understanding on since I am currently working on a cryptocurrency project:
1. Does this approach come from the fact that BTC does not have denominations
2. Why is a UTXO system used rather than a Account Balance one?
3. Does every wallet have a UTXO history? What stops a user from editing it? Or does each node navigate the blockchain history searching for public key matching the transaction to find this history.
4. Double spending is prevented since only one set of transactions is approved at a time. Thus, if a user sends 5.5 BTC twice, and the first transaction is verified and added to the blockchain, the second transaction will fail since they do not have sufficient UTXOs now (only 4.5BTC)? If they had 20 BTC to start, then both will pass?
5. Miner need to first verify all transactions by their corresponding public key and above method of checking UTXO history for each transaction in a block. Then they can use a “nonce” to find a hash for this block that starts with a few zeros using their computational power. Once they do these steps, assuming they are lucky enough to be first, they get a portion of the “change” and some newly generated fraction of a bitcoin and the block they mined gets pushed onto the longest chain?
I have the big picture but just need a push in the right direction as I cannot see how all of these variables get put together to make the overall system secure.
Thank you for your time and advice.