Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)?

share|improve this question
    
Bitcoin really doesn't have a notion of "coins" as individual objects. There are only transactions which can be of arbitrary amounts. – Nate Eldredge Jan 28 at 17:33
    
Yeah, I "kind of" understand this, but how can the UXTO be built anyway? – Henrique Barcelos Jan 28 at 17:39
up vote 4 down vote accepted

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.

share|improve this answer
    
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? – Henrique Barcelos Jan 28 at 17:59
1  
@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 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 at 9:26
    
Fair enough, thank your for your clarifications (: – Henrique Barcelos Jan 29 at 12:42

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.