<p>Yes. It doesn't have to do all the work when it receives the transaction, of course. If it's in sync with the network, it's already scanned the whole blockchain.</p>

CC BY-SA 3.0
2016-12-04T22:19:04.793Z
What do you mean by "it's already scanned the whole blockchain" ? Does the node build some kind of index of the transactions in the blockchain so that he can look it up faster than linear scan of the blockchain ?
user368507
CC BY-SA 3.0
2016-12-05T00:11:38.477Z
@user368507 Yes. What do you think it's doing when it gets all the blocks? It's building the UTXO (unspent transaction output) database.
David Schwartz
CC BY-SA 3.0
2013-10-12T23:13:46.300Z
2013-10-12T23:13:46.300Z
David Schwartz
<p>Yes, the whole blockchain needs to be scanned. But as David already says, it does so when it syncs/imports the whole blockchain.</p>

<p>So you can see it like this. When a new node is set up, it gets all the blocks from other nodes in the network and analyses them one by one. Every transaction is read and from all the transactions it creates a list of accounts that are on the network and how much bitcoins they have. So every bitcoin node has a list which more or less looks like this:</p>

<pre><code>account number                               amount of bitcoins in account
-----------------------------------------------------------------------------
188CnLx8fqfS8jhFCqv7QF346L9V1136tp     |     0.329 BTC
1MmTK7DnVSeFQQJm6gd1txk8HEYZ2rQnLg     |     1.70908 BTC
15dEBJMy3GTJ8Fd2TMqaXcDB9qt9MPqNWc     |     1.299 BTC
1FtKHoadhEeD1eyh4jUXjfGNctCSQFxExb     |     0.93993 BTC
1KoE88YBCP6ZuPq39uCTJNiBGM6XKzQZQS     |     0.393 BTC
34gRACXhU1SBR42d7B6BoJJ1U5M9mn5vXA     |     1.39899 BTC
37MEbe4MwSesFo3A4uJXuUHZ1mn4Gp6Z56     |     22.41484615 BTC
etc.
</code></pre>

<p>When a node receives a new transaction it can easily verify it by looking up the account number and see if it has enough bitcoins to do the transaction it wants to do.</p>

<p>I hope that makes it a bit more clear.</p>

CC BY-SA 3.0
2017-07-07T10:35:12.423Z
Talking about addresses as "accounts" having "balances" is extremely misleading. The node tracks Unspent Transaction Outputs (UTXOs) not "balances".
meshcollider
CC BY-SA 3.0
2017-07-07T11:44:17.823Z
@MeshCollider - yes, but the idea is the same: it knows how much can be spent from each address. This is just a beginners explanation which gives an idea of how it works.
kramer65
CC BY-SA 3.0
2017-07-07T13:06:11.677Z
That idea leads to a lot of confusion later on, for example: https://bitcoin.stackexchange.com/questions/55043/why-do-some-transactions-have-more-than-one-input
meshcollider
CC BY-SA 3.0
2017-07-07T09:04:32.510Z
2017-07-07T09:04:32.510Z
kramer65
<p>Does a Bitcoin node need to scan through the whole blockchain in order to be 100% sure that a transaction sent to it is genuine (especially when some inputs are derived from coins generated in the very early days)?</p>

<blockchain><nodes>
Does a Bitcoin node need to scan through the whole blockchain in order to be 100% sure that a transaction sent to it is genuine?
Ning
# Does a Bitcoin node need to scan through the whole blockchain in order to be 100% sure that a transaction sent to it is genuine?

(Asked by: username_0 on 2013-10-12)

Does a Bitcoin node need to scan through the whole blockchain in order to be 100% sure that a transaction sent to it is genuine (especially when some inputs are derived from coins generated in the very early days)?

**Tags:** blockchain, nodes


---

## 2 answers

### Answer by username_1 on 2013-10-12. Score: 2

Yes. It doesn't have to do all the work when it receives the transaction, of course. If it's in sync with the network, it's already scanned the whole blockchain.

> **Comments:**
> **username_2**: What do you mean by "it's already scanned the whole blockchain" ? Does the node build some kind of index of the transactions in the blockchain so that he can look it up faster than linear scan of the blockchain ?  
> **username_1**: @username_2 Yes. What do you think it's doing when it gets all the blocks? It's building the UTXO (unspent transaction output) database.  

---

### Answer by username_3 on 2017-07-07. Score: 0

Yes, the whole blockchain needs to be scanned. But as David already says, it does so when it syncs/imports the whole blockchain.
So you can see it like this. When a new node is set up, it gets all the blocks from other nodes in the network and analyses them one by one. Every transaction is read and from all the transactions it creates a list of accounts that are on the network and how much bitcoins they have. So every bitcoin node has a list which more or less looks like this:
account number                               amount of bitcoins in account
-----------------------------------------------------------------------------
188CnLx8fqfS8jhFCqv7QF346L9V1136tp     |     0.329 BTC
1MmTK7DnVSeFQQJm6gd1txk8HEYZ2rQnLg     |     1.70908 BTC
15dEBJMy3GTJ8Fd2TMqaXcDB9qt9MPqNWc     |     1.299 BTC
1FtKHoadhEeD1eyh4jUXjfGNctCSQFxExb     |     0.93993 BTC
1KoE88YBCP6ZuPq39uCTJNiBGM6XKzQZQS     |     0.393 BTC
34gRACXhU1SBR42d7B6BoJJ1U5M9mn5vXA     |     1.39899 BTC
37MEbe4MwSesFo3A4uJXuUHZ1mn4Gp6Z56     |     22.41484615 BTC
etc.

When a node receives a new transaction it can easily verify it by looking up the account number and see if it has enough bitcoins to do the transaction it wants to do.
I hope that makes it a bit more clear.

> **Comments:**
> **username_4**: Talking about addresses as "accounts" having "balances" is extremely misleading. The node tracks Unspent Transaction Outputs (UTXOs) not "balances".  
> **username_3**: @MeshCollider - yes, but the idea is the same: it knows how much can be spent from each address. This is just a beginners explanation which gives an idea of how it works.  
> **username_4**: That idea leads to a lot of confusion later on, for example: https://bitcoin.stackexchange.com/questions/55043/why-do-some-transactions-have-more-than-one-input  

---

