Andrew Vorobyov (OP)
|
|
June 02, 2012, 08:59:49 AM |
|
"getreceivedbyaddress" exists = shows total received...
Why there is no "getaddressbalance"?
How can I get balance of address?
|
|
|
|
Pieter Wuille
Legendary
Offline
Activity: 1072
Merit: 1181
|
|
June 02, 2012, 09:58:34 AM |
|
That would require an index from each address to all blocks/transactions that spend to or from it. Since this is not required for normal operations, and quite expensive, it is not (yet?) implemented in the reference client.
|
I do Bitcoin stuff.
|
|
|
Andrew Vorobyov (OP)
|
|
June 02, 2012, 10:00:31 AM |
|
It means, I can not get balance of specific address using official Bitcoin client??? Come on!
|
|
|
|
Gavin Andresen
Legendary
Offline
Activity: 1652
Merit: 2301
Chief Scientist
|
|
June 02, 2012, 02:16:48 PM Last edit: June 02, 2012, 02:27:02 PM by Gavin Andresen |
|
How would you use a 'getaddressbalance'? What are you trying to do?
Start with an empty wallet. I send you 100 BTC to address 'foo'. Then you send somebody else 1 BTC.
Internally, a new change address with 49 (edit: 99) bitcoins is created, so getaddressbalance 'foo' would return zero. Would that ever be the right answer?
|
How often do you get the chance to work on a potentially world-changing project?
|
|
|
rjk
Sr. Member
Offline
Activity: 448
Merit: 250
1ngldh
|
|
June 02, 2012, 02:23:57 PM |
|
How would you use a 'getaddressbalance'? What are you trying to do?
Start with an empty wallet. I send you 100 BTC to address 'foo'. Then you send somebody else 1 BTC.
Internally, a new change address with 49 bitcoins is created, so getaddressbalance 'foo' would return zero. Would that ever be the right answer?
I think you mean 99 lol.
|
|
|
|
Gavin Andresen
Legendary
Offline
Activity: 1652
Merit: 2301
Chief Scientist
|
|
June 02, 2012, 02:26:21 PM |
|
I think you mean 99 lol.
I should lie and say I'm feeling extra generous to miners this morning and wanted to give them an imaginary 50 BTC fee...
|
How often do you get the chance to work on a potentially world-changing project?
|
|
|
Pieter Wuille
Legendary
Offline
Activity: 1072
Merit: 1181
|
|
June 02, 2012, 02:39:22 PM |
|
The core issue here is that the abstractions provided by the wallet and what you can see on blockchain explorers differs.
Wallets manage a set of keys, and a set of unspent coins available for those keys to spend. They can keep track of income per public address you create, but only the balance of the entire wallet that matters to you if you are looking at the wallet abstraction (i.e., the amount you're able to spend).
Internally, wallet create change addresses, and coins can be assigned to either public or change keys in the wallet. Blockchain explorer can however not see the entire wallet, they only see the individual addresses.
I think that when people want to know "the balance of an address", they really want the balance of a wallet, but have learnt to observe this through the only publically observable piece of information available: the individual addresses in it. The real solution is using watch-only deterministic wallets here, in my opinion (being worked on ...). That allows you to keep working in the wallet abstraction, without needing to be bothered with individual addresses and keys.
The alternative is using a lower-level wallet abstraction, where you micro-manage all keys and addresses yourself. There are certainly useful applications for this (for example satoshidice uses the specific input coins you sent them in your payouts, so they don't take a risk allowing low numbers of confirmations). This way of working is currently not supported in the reference client. There are plans to include this functionality, but it will only be the preferred solution for particular instances in my opinion. That said, it can be very educational.
|
I do Bitcoin stuff.
|
|
|
ThomasV
Legendary
Offline
Activity: 1896
Merit: 1353
|
|
June 02, 2012, 03:14:40 PM |
|
I think that when people want to know "the balance of an address", they really want the balance of a wallet
I think you are wrong. When people ask for something, chances are that they want that thing
|
Electrum: the convenience of a web wallet, without the risks
|
|
|
Gabi
Legendary
Offline
Activity: 1148
Merit: 1008
If you want to walk on water, get out of the boat
|
|
June 02, 2012, 03:24:00 PM |
|
They can keep track of income per public address you create, but only the balance of the entire wallet that matters to you if you are looking at the wallet abstraction (i.e., the amount you're able to spend). Maybe not. Maybe we have different addresses in a single wallet with btc coming from different sources and we want to keep them divided, and don't mix them.
|
|
|
|
Pieter Wuille
Legendary
Offline
Activity: 1072
Merit: 1181
|
|
June 02, 2012, 03:30:19 PM |
|
They can keep track of income per public address you create, but only the balance of the entire wallet that matters to you if you are looking at the wallet abstraction (i.e., the amount you're able to spend). Maybe not. Maybe we have different addresses in a single wallet with btc coming from different sources and we want to keep them divided, and don't mix them. That's certainly useful sometimes and very educational. It's also planned to be included in the client. But it doesn't fit in the wallet abstraction provided by the client. Breaking that abstraction would confuse people who only want to use it, and do not care about the internal functioning. It's something for an expert mode, and belongs in what I call micro-management. Certainly people will want this, but it doesn't fit in what the client currently provides (the abstraction that it represents a wallet with money in).
|
I do Bitcoin stuff.
|
|
|
Killdozer
|
|
June 02, 2012, 05:05:28 PM |
|
But it doesn't fit in the wallet abstraction provided by the client. Breaking that abstraction would confuse people who only want to use it, and do not care about the internal functioning. It's something for an expert mode, and belongs in what I call micro-management. Certainly people will want this, but it doesn't fit in what the client currently provides (the abstraction that it represents a wallet with money in). Using the rpc IS the expert mode. Do you think that people who easily get confused will use the rpc for something? Adding a command does not "break" anything, for the people who won't even know about it, nothing will change. For the people that do know about this, things will only get easier. It is just a command that should've been there from the beginning.
|
|
|
|
|