<blockquote>
<p>How does a miner verify that the funds are available and not already spent without iterating through the entire Blockchain?</p>
</blockquote>
<p>Full nodes <strong>do</strong> iterate through the entire blockchain, but only once. As they work through the chain's history, they create and continuously update a 'UTXO set', which is just basically a list of all valid coins. With each new block, the full nodes on the network will verify the block's contents, and update their UTXO set as they do. This makes verifying new transactions easy: the node just checks their UTXO set to ensure the new transaction is spending valid inputs.</p>

CC BY-SA 4.0
2021-11-18T22:24:01.213Z
2021-11-18T22:24:01.213Z
chytrik
<p>Tl;dr: Bitcoin is cash, not a bank account.</p>
<p>Mints don't keep track of which people hold each of their coins or how much of their cash each person holds.</p>
<p>Mints provide users of their coins with some ways of distinguishing genuine coins from forged coins.</p>
<hr />
<blockquote>
<p><strong>How are funds verified?</strong></p>
</blockquote>
<p>They aren't. The Bitcoin network doesn't know about or care about funds. It mainly knows about transactions. From knowledge about transactions comes knowledge about &quot;coins&quot;.</p>
<blockquote>
<p><strong>I understand that transactions go into mempool</strong></p>
</blockquote>
<p>Yes, <em>unconfirmed</em> transactions go into the individual mempool of each node. As answers to other questions have stated, there is no coordination of mempool contents across nodes.</p>
<blockquote>
<p><strong>and a miner &quot;verifies&quot; the transactions</strong></p>
</blockquote>
<p>Well, <em>all</em> nodes verify transactions and not just miners. It isn't one miner. You may be conflating verification with confirmation. These are two very different things.</p>
<blockquote>
<p><strong>such as ensuring the user has the appropriate funds.</strong></p>
</blockquote>
<p>No nodes care about whether <em>users</em> have appropriate funds, the network doesn't really know anything about users.</p>
<blockquote>
<p><strong>and correct signature.</strong></p>
</blockquote>
<p>Yes, any signatures in the transaction are verified <em>by every node</em> separately. The system was designed so that no-one has to rely on some stranger doing verification for them. Signatures don't really identify actual people though.</p>
<blockquote>
<p><strong>Specifically, how are available funds verified?</strong></p>
</blockquote>
<p>Each node separately keeps track of its own list of all the unspent &quot;coins&quot; that exist globally. By &quot;coins&quot; we usually mean unspent transaction outputs (UTXOs).</p>
<blockquote>
<p><strong>It seems like you would have to iterate through every relevant transaction in every block to determine whether the funds have already been spent or not.</strong></p>
</blockquote>
<p>True.</p>
<blockquote>
<p><strong>This seems quite time consuming so surely there is a shortcut to verifying a user has available funds to spend.</strong></p>
</blockquote>
<p>No one care whether users have funds. We only care that coins are real (unspent). Its like cash. It <em>is</em> cash. When you buy something with cash, no one cares how much money you have, only that the cash you give them is not a forgery.</p>
<p>There is no real shortcut. Every nodes keeps track of a list of all genuine (unspent) coins.</p>
<p>lightweight nodes (SPV nodes) do rely on strangers to do some things for them - and consequently they are less secure.</p>
<blockquote>
<p><strong>How does a miner verify ...</strong></p>
</blockquote>
<p>The same way every other type of node verifies.</p>
<blockquote>
<p><strong>... that the funds are available and not already spent without iterating through the entire Blockchain?</strong></p>
</blockquote>
<p>By iterating through the entire blockchain <em>once</em> and creating useful, but much smaller, lists from it. Also by indexing those lists for faster retrieval. So this would include an indexed list of known good verified UTXOs that are acceptable to this node as inputs to future transactions it receives data about.</p>

CC BY-SA 4.0
2021-11-18T10:26:06.223Z
2021-11-18T10:46:36.763Z
2021-11-18T10:46:36.763Z
RedGrittyBrick
<blockquote>
<p>How does a miner verify that the funds are available and not already spent without iterating through the entire Blockchain?</p>
</blockquote>
<p>In order to know all the unspent transaction output you need the entire blockchain. This is what &quot;full nodes&quot; do. Full nodes look at the entire blockchain all the way back to the genesis block.</p>
<p>&quot;Simplified payment verification&quot; (SPV) nodes are lightweight nodes that don't download the entire block chain, but they need to rely on full node peers for verification.</p>

CC BY-SA 4.0
2021-11-18T09:04:42.647Z
2021-11-18T09:04:42.647Z
hft
<p>Spendable funds in Bitcoin are tracked in the form of <em><a href="https://bitcoin.stackexchange.com/q/4301/5406">Unspent Transaction Outputs (UTXOs)</a></em>. Each transaction consumes some existing UTXOs in the inputs, and creates new transaction outputs to assign recipients funds. Every full node keeps track of the entire set of spendable balances in a data structure we call the <em>UTXO set</em>. While you can think of the blockchain as Bitcoin's journal of transactions, the UTXO set is the ledger of balances.</p>
<p>Every full node recreates the UTXO set independently by starting with an empty UTXO set and applying every single transaction recorded in the blockchain up to the current block. Once they're caught up to the present, they have validated the entire transaction history of the Bitcoin network and end up with the complete set of all existing funds. The UTXO set suffices to verify whether a transaction is valid, because it explicitly contains the information which UTXOs are available for spending, they do not need to go back and &quot;iterate through every relevant transaction&quot; again.</p>

CC BY-SA 4.0
2021-11-19T17:03:03.240Z
2023-05-29T14:32:27.597Z
2023-05-29T14:32:27.597Z
Murch
<p>I understand that transactions go into mempool and a miner &quot;verifies&quot; the transactions such as ensuring the user has the appropriate funds and correct signature. Specifically, how are available funds verified? It seems like you would have to iterate through every relevant transaction in every block to determine whether the funds have already been spent or not. This seems quite time consuming so surely there is a shortcut to verifying a user has available funds to spend.</p>
<p>How does a miner verify that the funds are available and not already spent without iterating through the entire Blockchain?</p>

<transactions><blockchain><synchronization><utxo-set><funds>
How are funds verified?
koga73
# How are funds verified?

(Asked by: username_0 on 2021-11-18)

I understand that transactions go into mempool and a miner "verifies" the transactions such as ensuring the user has the appropriate funds and correct signature. Specifically, how are available funds verified? It seems like you would have to iterate through every relevant transaction in every block to determine whether the funds have already been spent or not. This seems quite time consuming so surely there is a shortcut to verifying a user has available funds to spend.

How does a miner verify that the funds are available and not already spent without iterating through the entire Blockchain?

**Tags:** transactions, blockchain, synchronization, utxo-set, funds


---

## 4 answers

### Answer by username_1 on 2021-11-18. Score: 7

> How does a miner verify that the funds are available and not already spent without iterating through the entire Blockchain?

Full nodes **do** iterate through the entire blockchain, but only once. As they work through the chain's history, they create and continuously update a 'UTXO set', which is just basically a list of all valid coins. With each new block, the full nodes on the network will verify the block's contents, and update their UTXO set as they do. This makes verifying new transactions easy: the node just checks their UTXO set to ensure the new transaction is spending valid inputs.


---

### Answer by username_2 on 2021-11-18. Score: 3

Tl;dr: Bitcoin is cash, not a bank account.

Mints don't keep track of which people hold each of their coins or how much of their cash each person holds.

Mints provide users of their coins with some ways of distinguishing genuine coins from forged coins.

---

> **How are funds verified?**

They aren't. The Bitcoin network doesn't know about or care about funds. It mainly knows about transactions. From knowledge about transactions comes knowledge about "coins".

> **I understand that transactions go into mempool**

Yes, *unconfirmed* transactions go into the individual mempool of each node. As answers to other questions have stated, there is no coordination of mempool contents across nodes.

> **and a miner "verifies" the transactions**

Well, *all* nodes verify transactions and not just miners. It isn't one miner. You may be conflating verification with confirmation. These are two very different things.

> **such as ensuring the user has the appropriate funds.**

No nodes care about whether *users* have appropriate funds, the network doesn't really know anything about users.

> **and correct signature.**

Yes, any signatures in the transaction are verified *by every node* separately. The system was designed so that no-one has to rely on some stranger doing verification for them. Signatures don't really identify actual people though.

> **Specifically, how are available funds verified?**

Each node separately keeps track of its own list of all the unspent "coins" that exist globally. By "coins" we usually mean unspent transaction outputs (UTXOs).

> **It seems like you would have to iterate through every relevant transaction in every block to determine whether the funds have already been spent or not.**

True.

> **This seems quite time consuming so surely there is a shortcut to verifying a user has available funds to spend.**

No one care whether users have funds. We only care that coins are real (unspent). Its like cash. It *is* cash. When you buy something with cash, no one cares how much money you have, only that the cash you give them is not a forgery.

There is no real shortcut. Every nodes keeps track of a list of all genuine (unspent) coins.

lightweight nodes (SPV nodes) do rely on strangers to do some things for them - and consequently they are less secure.

> **How does a miner verify ...**

The same way every other type of node verifies.

> **... that the funds are available and not already spent without iterating through the entire Blockchain?**

By iterating through the entire blockchain *once* and creating useful, but much smaller, lists from it. Also by indexing those lists for faster retrieval. So this would include an indexed list of known good verified UTXOs that are acceptable to this node as inputs to future transactions it receives data about.


---

### Answer by username_3 on 2021-11-18. Score: 3

> How does a miner verify that the funds are available and not already spent without iterating through the entire Blockchain?

In order to know all the unspent transaction output you need the entire blockchain. This is what "full nodes" do. Full nodes look at the entire blockchain all the way back to the genesis block.

"Simplified payment verification" (SPV) nodes are lightweight nodes that don't download the entire block chain, but they need to rely on full node peers for verification.


---

### Answer by username_4 on 2021-11-19. Score: 3

Spendable funds in Bitcoin are tracked in the form of *[Unspent Transaction Outputs (UTXOs)](https://bitcoin.stackexchange.com/q/4301/5406)*. Each transaction consumes some existing UTXOs in the inputs, and creates new transaction outputs to assign recipients funds. Every full node keeps track of the entire set of spendable balances in a data structure we call the *UTXO set*. While you can think of the blockchain as Bitcoin's journal of transactions, the UTXO set is the ledger of balances.

Every full node recreates the UTXO set independently by starting with an empty UTXO set and applying every single transaction recorded in the blockchain up to the current block. Once they're caught up to the present, they have validated the entire transaction history of the Bitcoin network and end up with the complete set of all existing funds. The UTXO set suffices to verify whether a transaction is valid, because it explicitly contains the information which UTXOs are available for spending, they do not need to go back and "iterate through every relevant transaction" again.


---

