Bitcoin Forum
February 07, 2023, 10:14:05 PM *
News: Latest Bitcoin Core release: 24.0.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to get current balance of address with bitcoind or maybe not bitcoind?  (Read 2182 times)
shark255 (OP)
Full Member
***
Offline Offline

Activity: 224
Merit: 100



View Profile
September 09, 2014, 08:57:14 PM
 #1

Question:

There is getreceivedbyaddress, but there is no command to get current balance of address.

Is there any workarounds ?


The grue lurks in the darkest places of the earth. Its favorite diet is adventurers, but its insatiable appetite is tempered by its fear of light. No grue has ever been seen by the light of day, and few have survived its fearsome jaws to tell the tale.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1675808045
Hero Member
*
Offline Offline

Posts: 1675808045

View Profile Personal Message (Offline)

Ignore
1675808045
Reply with quote  #2

1675808045
Report to moderator
1675808045
Hero Member
*
Offline Offline

Posts: 1675808045

View Profile Personal Message (Offline)

Ignore
1675808045
Reply with quote  #2

1675808045
Report to moderator
AltcoinInvestor
Sr. Member
****
Offline Offline

Activity: 294
Merit: 250



View Profile
September 09, 2014, 10:39:22 PM
 #2

did you named btc address?
if you request "getbalance name" it returns.

also this returns satoshi: https://blockchain.info/q/addressbalance/13qVUetqX6ZWLyEaYAwd8its5m64Bm1SaP
shark255 (OP)
Full Member
***
Offline Offline

Activity: 224
Merit: 100



View Profile
September 09, 2014, 10:41:37 PM
 #3

I mean using local server bitcoind, sure blockchain.info has more possibilities.
shorena
Copper Member
Legendary
*
Offline Offline

Activity: 1498
Merit: 1453


No I dont escrow anymore.


View Profile WWW
September 10, 2014, 07:42:25 AM
 #4

I mean using local server bitcoind, sure blockchain.info has more possibilities.


you could use listunspend and filter by address.

Im not really here, its just your imagination.
deepceleron
Legendary
*
Offline Offline

Activity: 1512
Merit: 1011



View Profile WWW
September 10, 2014, 10:41:19 AM
Last edit: December 04, 2017, 10:33:56 PM by deepceleron
 #5

The problem with such a command is it wouldn't work the way you would expect:

1. someone sends my 1DCeLERon address 5 BTC
2. i send 1 BTC to my friend
3. the balance of my 1DCeLERon address is 0 BTC

This is because if the 5 BTC is the only money in my wallet, the remainder 4 BTC is sent back to a different address in my wallet as change. If I get paid another 5 BTC to the same address again, I have 5 BTC in that address and 4 BTC in the other.

This is why Bitcoin gives you a wallet balance, not an address balance. It is also why looking up an address on a blockchain explorer site will confuse noobs. These sites can't tell if the 4 BTC or the 1 BTC is change back to you, or even if they are both payments to other parties.

I mean using local server bitcoind, sure blockchain.info has more possibilities.


you could use listunspend and filter by address.
The RPC command is "listunspent". I have 24 addresses with a balance in my current wallet just used for personal testing, and that is even after sending some money back to myself to consolidate it. What one entry from this command looks like, btw:

shark255 (OP)
Full Member
***
Offline Offline

Activity: 224
Merit: 100



View Profile
September 10, 2014, 11:32:54 AM
 #6

Thanks!
Got it and tested it. One thing, that I must walk through all elements of listunspent result to get balance for particular address.

shark255 (OP)
Full Member
***
Offline Offline

Activity: 224
Merit: 100



View Profile
September 10, 2014, 07:07:15 PM
 #7

And I think it would be better if listunspent could return in associative array a time of transaction.
Because again, I need to loop through another array and call gettransaction for each txid.
Miitch
Full Member
***
Offline Offline

Activity: 126
Merit: 100


View Profile
September 11, 2014, 08:07:05 PM
 #8

I found these problems too when working with bitcoind - it's really a bit of a pain to work with. I appreciate that Bitcoin works the way that bitcoin works. But it makes developing Bitcoin applications much slower than it could be for people new to working with it.

▇ ▇ ▇ ▇ ▇ ▇ ▇ ▇ ▇   COIN-SWEEPER
▇ ▇ ▇ ▇ ▇ ▇ ▇ ▇    Avoid Bombs Win BIG
▇ ▇ ▇ ▇ ▇ ▇ ▇ ▇   1% House Edge   ▇ ▇ ▇ ▇ ▇ ▇ ▇
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!