<p>Bitcoin uses a thing called the Unspent Transaction Output Set (UTXO set), not accounts or balances. A transaction will consume UTXOs as inputs and create UTXOs as outputs. When a node receives a block (either during initial sync or normal relay), it will update its own internal database which contains the UTXO set. In this update, it removes the UTXOs that have been spent and adds the UTXOs that were created. Because it does this for every block, if a node is fully synced, it should know what all of the UTXOs are and have them stored in the database.</p>

<p>When a node receives your transaction, it will look up the UTXOs that your transaction spends in its database. If they don't exist, then it discards your transaction as invalid. It does not need to traverse the blockchain; the data it needs have been pulled out and put into another place where it can be easily looked up.</p>

CC BY-SA 3.0
2017-11-07T05:17:59.347Z
2017-11-07T05:17:59.347Z
Ava Chow
<p>Once you understand how databases work, it's easier to believe. Besides, it's only the UTXO's (ie Unspent Transaction Outputs) that are needed to calculate your balance.</p>

<p>Bitcoin clients load the blockchain data into an indexed database to allow very quick checks of the data.</p>

<p>More details here: <a href="https://en.bitcoin.it/wiki/Bitcoin_Core_0.11_(ch_2):_Data_Storage" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Bitcoin_Core_0.11_(ch_2):_Data_Storage</a></p>

CC BY-SA 3.0
2017-11-07T16:26:43.140Z
I do understand how databases work, cause I am an software engineer. I am beginning to read about bitcoin and blockchain, so I have several question the documentation could not answered yet. For me this also means that new miners do have to upload the huge blockchain into a database, which will take a few moments.
LikeTomAndJerry
CC BY-SA 3.0
2018-01-06T07:56:57.323Z
Yes, validating the existing chain (which as a side effect builds up the database needed for validation of future blocks) tends to take several hours or more (based on disk, CPU and network speed). Validation of a new block afterwards only takes milliseconds, though.
Pieter Wuille
CC BY-SA 3.0
2017-11-06T04:09:36.367Z
2017-11-06T22:55:24.180Z
2017-11-06T22:55:24.180Z
Highly Irregular
<p>How do the miners check that I have enough Bitcoins. I cannot believe that they will walk through the huge and always growing blockchain established from 2009 to check each Transaction I made to calculate my balance ?</p>

CC BY-SA 3.0
2017-11-07T10:30:09.760Z
for better searching by other users in future, I think this question should be split into two. One focussed on blockchain validation, the other transaction validation.
rny
<blockchain><validation>
Blockchain and Transaction Validation
LikeTomAndJerry
# Blockchain and Transaction Validation

(Asked by: username_0 on 2017-11-05)

How do the miners check that I have enough Bitcoins. I cannot believe that they will walk through the huge and always growing blockchain established from 2009 to check each Transaction I made to calculate my balance ?

**Tags:** blockchain, validation

> **Comments:**
> **username_1**: for better searching by other users in future, I think this question should be split into two. One focussed on blockchain validation, the other transaction validation.  

---

## 2 answers

### Answer by username_2 on 2017-11-07. Score: 1

Bitcoin uses a thing called the Unspent Transaction Output Set (UTXO set), not accounts or balances. A transaction will consume UTXOs as inputs and create UTXOs as outputs. When a node receives a block (either during initial sync or normal relay), it will update its own internal database which contains the UTXO set. In this update, it removes the UTXOs that have been spent and adds the UTXOs that were created. Because it does this for every block, if a node is fully synced, it should know what all of the UTXOs are and have them stored in the database.

When a node receives your transaction, it will look up the UTXOs that your transaction spends in its database. If they don't exist, then it discards your transaction as invalid. It does not need to traverse the blockchain; the data it needs have been pulled out and put into another place where it can be easily looked up.


---

### Answer by username_3 on 2017-11-06. Score: 0

Once you understand how databases work, it's easier to believe. Besides, it's only the UTXO's (ie Unspent Transaction Outputs) that are needed to calculate your balance.

Bitcoin clients load the blockchain data into an indexed database to allow very quick checks of the data.

More details here: <https://en.bitcoin.it/wiki/Bitcoin_Core_0.11_(ch_2):_Data_Storage>

> **Comments:**
> **username_0**: I do understand how databases work, cause I am an software engineer. I am beginning to read about bitcoin and blockchain, so I have several question the documentation could not answered yet. For me this also means that new miners do have to upload the huge blockchain into a database, which will take a few moments.  
> **username_4**: Yes, validating the existing chain (which as a side effect builds up the database needed for validation of future blocks) tends to take several hours or more (based on disk, CPU and network speed). Validation of a new block afterwards only takes milliseconds, though.  

---

