Author

Topic: How is an account/address balance calculated? (Read 1278 times)

hero member
Activity: 590
Merit: 500
OK, I think I got that too. So scanning the entire block chain is only necessary if, say, you want to know the balance for an address that is not your own? Even then, you probably can scan backwards from the current block and stop when you've found all generation transactions.

Florian

or if you think the client missed a transaction announcement (e.g. internet outage, power outage, or something else that removes you from the network for a considerable length of time) and somehow missed it when you came back up and pulled the intervening blocks.  that's what the -rescan flag is for.  it forces the client to scan through the whole blockchain looking for transactions involving an address/keypair that you have in your wallet file.
sr. member
Activity: 406
Merit: 256
It doesn't matter who owns the address- you only need to see what addresses have coins credited to them- miners take care of making sure double spends don't happen. Just look to the block that last credits addressses.
newbie
Activity: 5
Merit: 0
1. Yep, that's how it works, kind of...
OK, so I got that right :-)

2. The only thing you're missing is that you don't need to go back through the entire chain- just to the previous transaction where it came under that address' control. Since every time you send coins it verifies that there is a tx where the coins came under your control, the block chain forms a transaction chain that is self building.

basically, you only need to look at the tx that gave the coins to the address that is spending them, not all the way back to generation- the blockchain already does that.
OK, I think I got that too. So scanning the entire block chain is only necessary if, say, you want to know the balance for an address that is not your own? Even then, you probably can scan backwards from the current block and stop when you've found all generation transactions.

Florian
sr. member
Activity: 406
Merit: 256
Hello everyone, I've been reading a bit of the bitcoin wiki and I'm really impressed by the technical details.

However, I have one question: how is the balance of a single address or an account calculated?
AFAICT, this is the sum over all transactions in the longest chain involving that address, correct?

If yes, this leads to the next question: won't the amount of computation needed to scan through the
entire chain become prohibitive at some point? Especially if the number of transactions increases at
a similar rate as, e.g. the global hash rate?

Florian

1. Yep, that's how it works, kind of...

2. The only thing you're missing is that you don't need to go back through the entire chain- just to the previous transaction where it came under that address' control. Since every time you send coins it verifies that there is a tx where the coins came under your control, the block chain forms a transaction chain that is self building.

basically, you only need to look at the tx that gave the coins to the address that is spending them, not all the way back to generation- the blockchain already does that.
newbie
Activity: 5
Merit: 0
Hello everyone, I've been reading a bit of the bitcoin wiki and I'm really impressed by the technical details.

However, I have one question: how is the balance of a single address or an account calculated?
AFAICT, this is the sum over all transactions in the longest chain involving that address, correct?

If yes, this leads to the next question: won't the amount of computation needed to scan through the
entire chain become prohibitive at some point? Especially if the number of transactions increases at
a similar rate as, e.g. the global hash rate?

Florian
Jump to: