Bitcoin Forum
November 01, 2024, 04:34:29 PM *
News: Bitcoin Pumpkin Carving Contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: getreceivedbyaddress exists, where is getaddressbalance  (Read 1661 times)
Andrew Vorobyov (OP)
Hero Member
*****
Offline Offline

Activity: 558
Merit: 500



View Profile
June 02, 2012, 08:59:49 AM
 #1

"getreceivedbyaddress" exists = shows total received...

Why there is no "getaddressbalance"?

How can I get balance of address?
Pieter Wuille
Legendary
*
Offline Offline

Activity: 1072
Merit: 1181


View Profile WWW
June 02, 2012, 09:58:34 AM
 #2

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)
Hero Member
*****
Offline Offline

Activity: 558
Merit: 500



View Profile
June 02, 2012, 10:00:31 AM
 #3

It means, I can not get balance of specific address using official Bitcoin client??? Come on!
Gavin Andresen
Legendary
*
Offline Offline

Activity: 1652
Merit: 2301


Chief Scientist


View Profile WWW
June 02, 2012, 02:16:48 PM
Last edit: June 02, 2012, 02:27:02 PM by Gavin Andresen
 #4

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 Offline

Activity: 448
Merit: 250


1ngldh


View Profile
June 02, 2012, 02:23:57 PM
 #5

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.

Mining Rig Extraordinaire - the Trenton BPX6806 18-slot PCIe backplane [PICS] Dead project is dead, all hail the coming of the mighty ASIC!
Gavin Andresen
Legendary
*
Offline Offline

Activity: 1652
Merit: 2301


Chief Scientist


View Profile WWW
June 02, 2012, 02:26:21 PM
 #6

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 Offline

Activity: 1072
Merit: 1181


View Profile WWW
June 02, 2012, 02:39:22 PM
 #7

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 Offline

Activity: 1896
Merit: 1353



View Profile WWW
June 02, 2012, 03:14:40 PM
 #8

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 Smiley

Electrum: the convenience of a web wallet, without the risks
Gabi
Legendary
*
Offline Offline

Activity: 1148
Merit: 1008


If you want to walk on water, get out of the boat


View Profile
June 02, 2012, 03:24:00 PM
 #9

Quote
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 Offline

Activity: 1072
Merit: 1181


View Profile WWW
June 02, 2012, 03:30:19 PM
 #10

Quote
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
Full Member
***
Offline Offline

Activity: 203
Merit: 100



View Profile
June 02, 2012, 05:05:28 PM
 #11

Quote
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.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!