<p>Yes, you've basically got it.</p>

<p>Regarding multiple outputs, the solution is quite simple.  Your input, instead of just specifying a transaction to spend, instead specifies a particular output of a transaction.  So instead of your input saying "I am spending transaction <code>abc123</code>", it says "I am spending output #2 of transaction <code>abc123</code>".</p>

<p>Every full node on the Bitcoin network maintains a database of <em>unspent transaction outputs</em> or <em>UTXOs</em>.  It is indexed by transaction ID and output number.  So when a node sees your transaction, it will mark transaction <code>abc123</code> output #2 as spent.  Outputs #0 and #1 of that same transaction have their own independent entries in the database and so their states are unchanged; if they have not been spent previously, they can be spent by some later transaction.</p>

CC BY-SA 3.0
2017-10-21T14:59:05.797Z
1. Every full node maintains list of all processed transactions? 
2. This list is called blockchain?
And only part of this list is UTXO.
croraf
CC BY-SA 3.0
2017-10-21T15:08:33.693Z
@croraf: Yes, a full node maintains a complete list of all transactions.  That's what "full node" means. The blockchain consists of this list, plus block headers.  It would be inefficient to search the whole list every time a new transaction has to be verified, so as the node downloads each block for the first time, it builds the UTXO database, so that it can check UTXOs in constant time.
Nate Eldredge
CC BY-SA 3.0
2017-10-21T14:09:52.190Z
2017-10-21T14:09:52.190Z
Nate Eldredge
<p>I'm learning bitcoin protocol theory.</p>

<p>To pay to someone you use a transaction. In the transaction you specify some of old transactions that gave you money (so called <em>inputs</em>). These inputs should have not been already spent. </p>

<p>Therefore the bitcoin network must check these inputs are unspent. Bitcoin network holds the list of all unspent transactions. Transactions are in tree-like structures, and all unspent transactions are the roots of these trees. So bitcoin network checks that input transaction is in this list.</p>

<p>After current transaction is done, all used input transactions (<em>inputs</em>) are now spent, and output transaction and change are now put in the list of unspent transactions.</p>

<p>Is the above process and terminology correct?</p>

<p>EDIT: I found confusing now the thing that transaction can have multiple outputs. This means I cannot just state that transaction is my input, and that the it gets invalidated when used for new transaction, as this transaction has an output that is someone else input. How is this handled?</p>

<bitcoin-core><client><algorithms>
How bitcoin protocol checks transaction is valid (in particular that inputs are unspent)?
croraf
# How bitcoin protocol checks transaction is valid (in particular that inputs are unspent)?

(Asked by: username_0 on 2017-10-21)

I'm learning bitcoin protocol theory.

To pay to someone you use a transaction. In the transaction you specify some of old transactions that gave you money (so called *inputs*). These inputs should have not been already spent.

Therefore the bitcoin network must check these inputs are unspent. Bitcoin network holds the list of all unspent transactions. Transactions are in tree-like structures, and all unspent transactions are the roots of these trees. So bitcoin network checks that input transaction is in this list.

After current transaction is done, all used input transactions (*inputs*) are now spent, and output transaction and change are now put in the list of unspent transactions.

Is the above process and terminology correct?

EDIT: I found confusing now the thing that transaction can have multiple outputs. This means I cannot just state that transaction is my input, and that the it gets invalidated when used for new transaction, as this transaction has an output that is someone else input. How is this handled?

**Tags:** bitcoin-core, client, algorithms


---

## 1 answers

### Answer by username_1 on 2017-10-21. Score: 2 | Accepted answer

Yes, you've basically got it.

Regarding multiple outputs, the solution is quite simple. Your input, instead of just specifying a transaction to spend, instead specifies a particular output of a transaction. So instead of your input saying "I am spending transaction `abc123`", it says "I am spending output #2 of transaction `abc123`".

Every full node on the Bitcoin network maintains a database of *unspent transaction outputs* or *UTXOs*. It is indexed by transaction ID and output number. So when a node sees your transaction, it will mark transaction `abc123` output #2 as spent. Outputs #0 and #1 of that same transaction have their own independent entries in the database and so their states are unchanged; if they have not been spent previously, they can be spent by some later transaction.

> **Comments:**
> **username_0**: 1. Every full node maintains list of all processed transactions?  2. This list is called blockchain? And only part of this list is UTXO.  
> **username_1**: @username_0: Yes, a full node maintains a complete list of all transactions.  That's what "full node" means. The blockchain consists of this list, plus block headers.  It would be inefficient to search the whole list every time a new transaction has to be verified, so as the node downloads each block for the first time, it builds the UTXO database, so that it can check UTXOs in constant time.  

---

