Do I need to scan the whole blockchain to determine a balance?

1

1

My understanding of how the blockchain works is that to determine the balance of an address one must find all the transactions that have outputs to that address. So, the only way to be sure you are not missing a transaction is that you have to scan the whole blockchain to determine the balance of an address.

Is that correct?

Tyler Durden

Posted 2017-04-17T23:10:48.283

Reputation: 828

Answers

2

That is correct. This is what the optional -rescan flag does to the addresses in your wallet when launching bitcoind.

There is no balance property. Balances are just the total values added up on all unspent outputs for a given address, and the only way to determine the unspent outputs of an address is by scanning/tracing/following each output from address to address.

m1xolyd1an

Posted 2017-04-17T23:10:48.283

Reputation: 3 356

So, I assume when I make a transfer, it does not normally rescan the whole blockchain, but keeps a running balance for the addresses in the wallet, but if I add a new address to the wallet, then a rescan will be necessary. Is that right?Tyler Durden 2017-04-18T04:53:35.203

1Yes, but only when you add a new address which may have been used before. When the wallet itself creates a new address for you it knows it has never been used, so no need for a rescan.Pieter Wuille 2017-04-18T06:41:08.073