4

Is a simple question, but I want to understand this at the low level.

Since the UTXO is a database with the yet-to-be-spent coins, how can I say that a given coin was already full spent? What would be a "half"-spent coin (if this is even possible)?

2
  • Bitcoin really doesn't have a notion of "coins" as individual objects. There are only transactions which can be of arbitrary amounts. Jan 28, 2016 at 17:33
  • Yeah, I "kind of" understand this, but how can the UXTO be built anyway? Jan 28, 2016 at 17:39

3 Answers 3

6

An output ("coin") is by definition either fully unspent or completely spent. There is nothing in between. A transaction has one or more inputs (which refer to the unspent outputs of earlier transaction) and it fully consumes them.

A transaction can also have 1 or more outputs. For each output a value is specified (number of Satoshis), so by being a little creative you can easily split or merge "coins".

This way Bitcoin "simply" needs to remember only the last outputs of a chain of transactions, there is no point in remembering (indexing) anything older. That's what the UTXO set is: Unspent Transaction Outputs database.

4
  • So, in addition to the Blockchain, there is a transaction chain? Hmmm, that's new to me :). Could you please elaborate this part? How can I track what is in the "head" of the transaction chain? Jan 28, 2016 at 17:59
  • 2
    @HenriqueBarcelos Transaction Chain: What he means is that whenever the money gets sent somewhere else only the latest transaction's output is relevant. Much like a one dollar bill might have switched owners a hundred times in the last month, but it's only relevant that it's now in your wallet. There is no dedicated data structure that collects this information in that form, but it just exists implicitly as the history of a transaction output in form of the related transactions spread out in the blocks of the blockchain.
    – Murch
    Jan 28, 2016 at 18:49
  • @HenriqueBarcelos Like Murch explains. I don't think transaction chain is an official word here, I just made it up. But thinking about it: when you look at the latest transaction you can jump back to the previous and the previous etc. Bit like a linked list (or chain) although in fact it's a graph since transactions generally have multiple input and outputs. Transaction graph is the term I have seen mentioned. I'll change the answer to use "a chain of transactions" to make it a bit more clear.
    – Jannes
    Jan 29, 2016 at 9:26
  • Fair enough, thank your for your clarifications (: Jan 29, 2016 at 12:42
1

UTXO can only be spent completely.

This happens by claiming them in the Transaction Input Script and requires a valid signature corresponding to the address the UTXO is associated with.

The transaction inputs' value is then reassigned by the transaction to create new unspent transaction outputs. Usually, there are at least two outputs, one going to the recipient of the payment, and a change output going back to the wallet of the sender. The sum of the assigned outputs must be smaller than or equal to the sum of consumed inputs.

Any amount that doesn't get assigned to new outputs can be claimed by the successful miner as transaction fee in the Coinbase transaction of the block the transaction gets included in.

When a block gets found, all nodes in the network enact all the transactions on their UTXO set, marking the inputs as spent and replacing them with the newly minted unspent transaction outputs.

1

Besides the whole blockchain database there is actually another database continuosly updated in each full node: The UTXO pool memory. When a transaction with a determined input sucesfully spend some transaction output, this outpus is removed from the UTXO pool memory. Otherwise the handle of the databases to find if a given UTXO hasn't been called by any input of any transaction included in the blockchain would be strenuous. Remember that an UTXO can only be spent once and you have to enable the verify engine to quickly check whether an UTXO is still available for spending by any future input.

4
  • Your answer seems correct, but the last sentence is phrased a bit confusingly. I think you mean to say that a UTXO can only be spent once and you have to be able to quickly check whether a UTXO is still available for spending. The way your answer puts it, it sounds as if one could spend parts of a UTXO which is not correct though.
    – Murch
    Mar 1, 2017 at 14:42
  • You put it in a much more clearer way. Thank you! Mar 4, 2017 at 5:06
  • The way it works here is that you just edit your post to improve it. That way we'll always have as good as possible answers to all questions. :)
    – Murch
    Mar 4, 2017 at 5:09
  • Thanks for the edit! :) Have you seen our tour?
    – Murch
    Mar 4, 2017 at 15:00

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.