32

What is the meaning of the term "unspent output" in the Bitcoin protocol?

46

An unspent output is simply an output of a transaction which isn't yet an input of another transaction.

To take the example from ripper234's answer (in which generated coins are immediately spendable, and we don't have to wait 100 blocks for them to mature), where:

  • The first block contained 50 mined BTC in address A (A = 50)
  • The second block contained 50 mined BTC in address A, a transaction sending 20 BTC to address B, and putting the change in address C (A = 50, B = 20, C = 30)
  • The third block contained 50 mined BTC in address A, a transaction sending the 20 BTC from address B to address D (A = 50 + 50, C = 30, D = 20)

So, after three blocks, there are four unspent outputs:

  • A has two unspent outputs worth 50 BTC each
  • C has a single unspent output worth 30 BTC
  • D has a single unspent output worth 20 BTC

And there are two spent outputs:

  • the 50 BTC generated in the first block, spent in the 2nd block
  • the 20 BTC output created in the 2nd block and spent in the 3rd block

Note that unspent outputs don't merge together. The two unspent 50 BTC outputs at address A are separate, and will remain separate at least until they are spent in a transaction

7
  • I must be missing something, as I cant create any logic which can explain the above. A has 50 (I am assuming this is its balance, which we are saying is also called unspent outputs), and sends 20 to B and 30 to C. Now A has zero. Later A magically has 50 again, then 100. Does this mean A started off with more than 50? Feb 5 '18 at 13:25
  • In the second row, surely A's output WERE spent by making them inputs of B and C, so why are they still unspent? Feb 5 '18 at 13:26
  • @JohnLittle A is the miner, he got another 50 for the second block he mined.
    – xczzhh
    Feb 26 '18 at 9:34
  • Can we assume that: Total balance = Sum of unspent transactions
    – SpiralDev
    May 23 '18 at 3:44
  • @Umarov I think the Total balance = Sum of unspent transactions - Sum of spent transactions.
    – zzm
    Jun 7 '18 at 7:12
12

It means "Bitcoins that were not spent".

Imagine the early days, when the blockchain was of length 3 (imaginary chain of events):

  • The first block contained 50 mined BTC in address A
  • The second block contained 50 mined BTC in address A, a TX sending 20 BTC to address B, and putting the change in address C
  • The third block contained 50 mined BTC in address A, a tx sending the 20 BTC from address B to address D

So, after 3 blocks, this is the "sum total":

  • A has 100 BTC
  • C has 30 BTC
  • D has 20 BTC

Total 150 BTC in unspent outputs. These are the "unspent coins" - all the generated BTC, without counting transactions that moved BTC twice.

4
  • I don't quite understand what you mean by "bitcoins that were not spent". So what is a bitcoin that is spent? When a TX sends 20 BTC from A to B, aren't those coins considered spent? When will a coin be considered spent?
    – Pacerier
    Aug 16 '13 at 5:22
  • 1
    @Pacerier The coins in A are considered spent after this tx, but the coins now reside in B in an "unspent form". Note that it's not bitcoins that are actually spent or unspent, it's "outputs". Read Chris' answer for more details.
    – ripper234
    Aug 18 '13 at 18:06
  • Then the number of unspent coins will only increase and never decrease right? What's the point, I mean, Isn't the number of unspent BTCs forever equivalent to the number of BTCs?
    – Pacerier
    May 22 '14 at 21:19
  • Yes, to total value of unspent transaction output are the total bitcoin in circulation. Mar 11 '15 at 15:53
7

Bitcoin is a distributed system that enables users to receive, store, and send money. Value is transmitted by submitting a payment order to the network called a transaction. Transactions are cryptographically attested statements instructing each network participant to update their copy of the network's ledger of spendable balances which they independently maintain.

All funds in Bitcoin exist in the form of unspent transaction outputs (UTXOs): when users wish to spend bitcoins, their transaction explicitly states which UTXOs are being spent and define how their funds are to be assigned to new UTXOs. UTXOs cannot be partially spent, they are created once and then spent in full by another transaction. (You can think of bitcoins as a substance that is melted and recast every time it's spent.) Only while they are available to be spent, we refer to them as "unspent" transaction outputs, although the blockchain keeps the records of all past transaction outputs. UTXOs are denominated in satoshis, the native unit of the bitcoin protocol. 100,000,000 satoshis are one bitcoin.

Each UTXO is uniquely identified by its outpoint, the combination of the transaction that created it and its position in the transaction's list of outputs. Incidentally, "addresses" are proxies for the locking script the receiver must fulfill to spend the funds later and sending to the same address multiple times will create separate UTXOs.

Screenshot of transaction with two inputs and two outputs from Blockstream.info

For example the transaction f4272d...a70f2e depicted here, (1) spends the two UTXOs 5f9de0...be8c55:1 and 7be1b7...7c8378:0, and reassigns the funds to two new transaction outputs, (2) the zeroth output of the transaction f4272d...a70f2e:0, paying to the addresses 1GxJtQ7...mee8bg, and (3) the first outputs of the transaction f4272d...a70f2e:1, paying to the address bc1qy6...7pdwnc.

As you notice, these mechanics do not align with the common intuition that Bitcoin balances function like bank accounts. We refer to this model of tracking funds as the "UTXO model". You can read a bit more about the benefits of the UTXO model here: UTXO model vs. account/balance model

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