in

Confused about UTXO and how it is used to determine if a user “mints bitcoin out of thin air”

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.



View Reddit by lbragile_devView Source

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

GIPHY App Key not set. Please check settings

3 Comments

  1. > Does every wallet have a UTXO history?

    Every full node does, to which a wallet has to connect to in order to establish balances, broadcast new transactions and so on.

    > What stops a user from editing it?

    If you tinker with the UTXO set on your node and try to “fake” coins that you don’t actually have, it will be recognized by other nodes on the network and your transaction won’t be rebroadcast (and your node might get banned by other peers).

    This is a decent read: https://hackernoon.com/bitcoin-miners-beware-invalid-blocks-need-not-apply-51c293ee278b

  2. You’ve got some important pieces wrong, but I don’t feel like explaining it all to you. I will tell you that each full node has a copy of the blockchain and the UTXO set. The wallets only store private keys, sign transactions/messages, and broadcast transactions. It takes awhile but just keep researching and you should eventually understand bitcoin.

Loading…

0

What do you think?

Barry Ritholz, asset wealth manager with 180k twitter followers, discusses the benefits of ticketing on blockchain and GET protocol

Cryptopolitan

Stellar Price Prediction 20% | Cryptopolitan