What is an "unspent output"?

30

13

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

ripper234

Posted 2012-07-29T13:24:38.293

Reputation: 25 192

Answers

42

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

Chris Moore

Posted 2012-07-29T13:24:38.293

Reputation: 13 952

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?John Little 2018-02-05T13:25:55.743

In the second row, surely A's output WERE spent by making them inputs of B and C, so why are they still unspent?John Little 2018-02-05T13:26:02.263

@JohnLittle A is the miner, he got another 50 for the second block he mined.xczzhh 2018-02-26T09:34:41.917

Can we assume that: Total balance = Sum of unspent transactionsDeveScie 2018-05-23T03:44:50.753

@Umarov I think the Total balance = Sum of unspent transactions - Sum of spent transactions.zhaozhiming 2018-06-07T07:12:12.317

@zhaozhiming No I don't think so. Read here and here

DeveScie 2018-06-08T00:16:56.820

@Umarov Yes, you're right. I misunderstood it. Thanks.zhaozhiming 2018-06-10T10:03:00.990

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.

ripper234

Posted 2012-07-29T13:24:38.293

Reputation: 25 192

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 2013-08-16T05:22:37.037

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 2013-08-18T18:06:03.443

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 2014-05-22T21:19:36.700

Yes, to total value of unspent transaction output are the total bitcoin in circulation.Haddar Macdasi 2015-03-11T15:53:08.167