<p>Recall that transactions have inputs and outputs: when an output is listed as the input of another transaction, that output is spent.</p>

<p>So you go through the block chain from the beginning and make an index of unspent outputs.  For each transaction output you see, you add it to the index; for each input you see, you delete the corresponding output from the index, because it has been spent.</p>

<p>When you have an index of all unspent outputs, you look for those whose recipient is the address X.  Adding up the amounts of all those outputs gives you the "balance" of Bitcoins available to address X.</p>

CC BY-SA 3.0
2015-02-13T18:12:23.733Z
2015-02-13T18:12:23.733Z
Nate Eldredge
<p>What is the procedure to calculate the bitcoins owned by any address X?</p>

<p>do we have to search for every transaction in every block in the block chain, with recipient as X? But this will not give correct result, as X might have spend some amount? How is this recorded>?</p>

<protocol>
Computing the bitcoins of any address
Curious
# Computing the bitcoins of any address

(Asked by: username_0 on 2015-02-13)

What is the procedure to calculate the bitcoins owned by any address X?

do we have to search for every transaction in every block in the block chain, with recipient as X? But this will not give correct result, as X might have spend some amount? How is this recorded>?

**Tags:** protocol


---

## 1 answers

### Answer by username_1 on 2015-02-13. Score: 2 | Accepted answer

Recall that transactions have inputs and outputs: when an output is listed as the input of another transaction, that output is spent.

So you go through the block chain from the beginning and make an index of unspent outputs. For each transaction output you see, you add it to the index; for each input you see, you delete the corresponding output from the index, because it has been spent.

When you have an index of all unspent outputs, you look for those whose recipient is the address X. Adding up the amounts of all those outputs gives you the "balance" of Bitcoins available to address X.


---

