Is there some method how you can calculate the balance of an address without resorting to web-based API's? When I import a private key the rescanning of bitcoind takes hours. I know to get a balance you would need to iterate over all transactions in the whole chain, but maybe there is still some optimization possible.
-
possible duplicate of How to get an address's balance with the bitcoin client?– Steven RooseMay 14, 2013 at 13:43
-
@StevenRoose It's not a duplicate, I know how to do it via bitcoind, I'm looking for alternatives.– MaestroMay 14, 2013 at 20:20
-
I see, sadly I cannot revert my vote, but maybe no additional close votes are cast. (meta.stackexchange.com/questions/915/…)– Steven RooseMay 14, 2013 at 20:31
-
I would like to know how to this in bitcoind. The question Steven linked is also not properly answered. They all say "its not possible". What I'd like to know is how to traverse all unspent outputs, and find those corresponding to a given address, possibly not in the wallet.– Jus12Jul 2, 2013 at 20:46
-
see also How to know there is a new transaction?– Janus TroelsenMar 11, 2014 at 11:10
2 Answers
You would need to use a client node that has a different architecture, from the satoshi's client. Specifically, the client must be able to quickly browse through all the unspent outputs.
You may want to check this table for clients that support Multi-wallet. Among them, there is a new client Gocoin. It is currently in a testing phase, and you need to build it yourself from sources, but if you have a PC powerful enough to run it, it needs less than a second to give you an unspent balance of any standard bitcoin address.
This is probably not a full solution, but maybe a possible optimization. Since you send all BTC out of the address in every send transaction, you should only have to look at the transactions that happen after the last sending transaction to calculate the value at an address.