0

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>?

1 Answer 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.