Bitcoin Forum
May 09, 2024, 08:30:35 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [HELP!] Bitcoind balance address  (Read 1417 times)
ShopemNL (OP)
Legendary
*
Offline Offline

Activity: 1025
Merit: 1001



View Profile WWW
September 23, 2014, 02:44:00 PM
 #1

Hi there,

I have the bitcoin client installed on my vps and it works nice troughout JSON-RPC.

I was wondering how to calculatie the amount of bitcoins aviable on a address (not a wallet).

Like blockchain does :

https://blockchain.info/address/12sENwECeRSmTeDwyLNqwh47JistZqFmW8?format=json

"total_received":24119415125420, == JSON Aviable
"total_sent":23929615048320,
"final_balance":189800077100,

1715243435
Hero Member
*
Offline Offline

Posts: 1715243435

View Profile Personal Message (Offline)

Ignore
1715243435
Reply with quote  #2

1715243435
Report to moderator
It is a common myth that Bitcoin is ruled by a majority of miners. This is not true. Bitcoin miners "vote" on the ordering of transactions, but that's all they do. They can't vote to change the network rules.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715243435
Hero Member
*
Offline Offline

Posts: 1715243435

View Profile Personal Message (Offline)

Ignore
1715243435
Reply with quote  #2

1715243435
Report to moderator
1715243435
Hero Member
*
Offline Offline

Posts: 1715243435

View Profile Personal Message (Offline)

Ignore
1715243435
Reply with quote  #2

1715243435
Report to moderator
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
September 23, 2014, 03:13:52 PM
 #2

It is not possible troughout JSON-RPC
You should convert (and maintain) blockchain to another database
ShopemNL (OP)
Legendary
*
Offline Offline

Activity: 1025
Merit: 1001



View Profile WWW
September 23, 2014, 03:37:34 PM
 #3

It is not possible troughout JSON-RPC
You should convert (and maintain) blockchain to another database

Thought so, or make every adresss a separate account so you can use gebalance.

DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
September 23, 2014, 06:29:14 PM
 #4

Thought so, or make every adresss a separate account so you can use gebalance.

Unless you either never send any bitcoins from the wallet at all or create your own raw transactions, this won't work.

When you send from an "account", the Bitcoin Core wallet does not necessarily use the bitcoins that funded the "account" in the first place. It often may spend bitcoins that were received at some other address associated with a different "account" in the wallet.

You should not expect the "balance" associated with an address (or group of addresses) to be the same as the balance associated with any particular account in Bitcoin Core.
ShopemNL (OP)
Legendary
*
Offline Offline

Activity: 1025
Merit: 1001



View Profile WWW
September 23, 2014, 07:30:41 PM
 #5

Ah oke so what to do?

For a project we need to make user addresses, fund there balance and they need to be able to spend it trough any android/ios wallet with there private key.

If you make a transaction and give in a adress as the from with insufficient amount you will get an error right? Or does the system fills it with the balance from the rest of the wallet?

DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
September 23, 2014, 08:23:18 PM
 #6

Ah oke so what to do?

I'll need a lot more information about what you are trying to accomplish to give you a good answer.

Generally, you should not re-use bitcoin addresses.

Any time a user is going to send you bitcoins, you should generate a new bitcoin address for them.  When you receive the bitcoins in your wallet, you should have your own separate database that you use to track the balance for each user.  When you send bitcoins on behalf of a user from your wallet, you should update the balance in your database.

Most of the bitcoins you control should be in offline cold storage.  The bitcoins that you receive from users should probably be consolidated into larger outputs in your hot wallet on a regular basis to reduce transaction fees.

For a project we need to make user addresses, fund there balance and they need to be able to spend it trough any android/ios wallet with there private key.

I'm having a difficult time understanding what you are trying to accomplish, or why you are doing it that way.

If you make a transaction and give in a adress as the from with insufficient amount you will get an error right?

There is no such thing as sending "from an address" in bitcoin.  You can only send "to an address".  When you use the "sendfrom" command, you are not sending from an address, you are sending from an account.  The wallet will arbitrarily choose which outputs to spend, and they might not be outputs that were received at an address associated with that account.

Make sure you understand that "accounts" and "addresses" are not the same thing.  This causes many people a lot of confusion.

Or does the system fills it with the balance from the rest of the wallet?

Correct, if you use "Sendfrom", the wallet will fill the transaction with as many bitcoins as it needs regardless of which address received the bitcoins.
ShopemNL (OP)
Legendary
*
Offline Offline

Activity: 1025
Merit: 1001



View Profile WWW
September 23, 2014, 08:54:19 PM
Last edit: September 24, 2014, 05:00:02 AM by ShopemNL
 #7

Idea

DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
September 23, 2014, 09:47:56 PM
 #8

So the bitcoin deamon with wallet is useless?

Not useless.  Very useful.  Just not useful the way you are trying to use it.  You need to learn more about how accounts and addresses work in the daemon, and then do a lot of testing to make sure you didn't misunderstand something.

- So what you state if we use "move *order1* *order2* *fullamount* " option the bitcoindeamon wont necessarily move the balance on the account

I assume you are asking about the following command from the API?
Code:
move <fromaccount> <toaccount> <amount>

It will update the "account".  It will not update any "addresses".

that will be moved but can also use amount (balance) from other accounts in the deamon?

No.  It will only update the accounts that you you indicate in the "move" command, but it won't update ANY addresses at all.

- Or if we use "sendfrom *order1* *otheraddress* *amount* " it is possible it takes the balance from another account for this transaction? (If balance isnt enough on this account)

No. It will update the "account" that you indicate, but you won't have any control over which "addresses" the bitcoins that are spent were received at.

If i understand :
Bitcoin deamon is one wallet,

Yes.

one wallet can have multiple accounts,

Yes.

accounts can hold multiple addresses,

No. Accounts don't "hold" addresses. One or more addresses can be associated with accounts for receiving bitcoins.  If you associate an address with an account, then any bitcoins that are received at that address are credited to the associated account.  However, when you send bitcoins, you don't have any control over which addresses that sent bitcoins were previously received on unless you are creating raw transactions.

you can move funds between accounts but not between addresses.

Correct.  If you want to move funds between addresses, then you need to create a transaction, broadcast it to the bitcoin network, and wait for a miner to confirm it.

You can check balance of a account but not of a address.

You can check the balance of an address, but it is complex.  You need to run the command "listunspent" and then add up the values of all of the unspent outputs that were received at that address in the wallet.

You can sent from an account but not from an address.

Correct.  Addresses are used to control how bitcoins are received, not how they are sent.  Unspent outputs (identified by an transactionID and an index) are used to control how bitcoins are sent.

i understand the diff between accounts and addresses,

I'm still not sure that you do, but you are getting close.

one account can have many addresses.

No. Accounts don't "have" addresses. One or more addresses can be associated with accounts for receiving bitcoins.  If you associate an address with an account, then any bitcoins that are received at that address are credited to the associated account.  However, when you send bitcoins, you don't have any control over which addresses that sent bitcoins were previously received on unless you are creating raw transactions.

We are going to make a account for each order. So all accounts will only have one address. This makes it easyer to check balance of the address and to sent money from a particulair address

No it doesn't.

(you sendfrom an account, but if an account only has one address it will come from that address)

I don't think you can depend on this.
ShopemNL (OP)
Legendary
*
Offline Offline

Activity: 1025
Merit: 1001



View Profile WWW
September 23, 2014, 09:57:53 PM
Last edit: September 23, 2014, 10:08:58 PM by ShopemNL
 #9

Ah sweet now i understand! Thanks Smiley

Addresses within accounts are only used to credit accounts when payment received. So when a user gets the private key of an addresses and adds it to lets take blockchain app as example and then receive or sents payment on the address will the deamon still credits the account?

And if you use the api command sentfrom will it auto sents it to the blockchain and broadcast the transaction? (I quess because you receive txid)

jubalix
Legendary
*
Offline Offline

Activity: 2618
Merit: 1022


View Profile WWW
September 23, 2014, 11:09:11 PM
 #10

Hi there,

I have the bitcoin client installed on my vps and it works nice troughout JSON-RPC.

I was wondering how to calculatie the amount of bitcoins aviable on a address (not a wallet).

Like blockchain does :

https://blockchain.info/address/12sENwECeRSmTeDwyLNqwh47JistZqFmW8?format=json

"total_received":24119415125420, == JSON Aviable
"total_sent":23929615048320,
"final_balance":189800077100,

use my coinwatch program, see link in sig. its still beta though

Admitted Practicing Lawyer::BTC/Crypto Specialist. B.Engineering/B.Laws

https://www.binance.com/?ref=10062065
ShopemNL (OP)
Legendary
*
Offline Offline

Activity: 1025
Merit: 1001



View Profile WWW
September 24, 2014, 07:10:20 AM
 #11

Thanks! Ill check it out,

is there some php prog on the net where i can find how to check amount sent and received from an account to determine the spendable balance?

Or like this Smiley (hope it works)

getbalance = total going in and out
getreceivedbyaddress = received

getreceivedbyaddress (sum up all within the accounts) - getbalance = total spent.
getbalance - totalspent = aviable =]

// edit : nvm getreceivedbyaccount gives the same as getbalance.

ShopemNL (OP)
Legendary
*
Offline Offline

Activity: 1025
Merit: 1001



View Profile WWW
September 24, 2014, 06:06:04 PM
 #12

Can somebody explaine me how you can get the in and out transactions from an address or account? Google doesnt help, if posible with php or command example.

ShopemNL (OP)
Legendary
*
Offline Offline

Activity: 1025
Merit: 1001



View Profile WWW
September 25, 2014, 08:58:11 PM
 #13

Seems like listaddressgroupings (+listunspent where conf is 0) = totall

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!