Bitcoin Forum
November 09, 2024, 07:17:12 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Account-Address association and effect on account balance  (Read 555 times)
arosca (OP)
Newbie
*
Offline Offline

Activity: 38
Merit: 0


View Profile
April 23, 2014, 08:01:07 PM
 #1

I'm a little confused about how account balances work.

Assume the following sequence:
  • the default account ("") already exists and has a balance of 1 BTC
  • a new address A is created and associated with account "A"
  • 1 BTC are are sent to address A; the balance of account "A" goes from 0 to 1 BTC; the wallet balance is now 2 BTC
  • 1.5 BTC are spent from the wallet; the wallet balance is now 0.5 BTC

What is the balance of account A at this point?

My understanding is that any inputs in the wallet can selected at any time for spending, including those associated with address A (and thus indirectly with account A).

Will the balance of the account remain unchanged (1 BTC) in this situation?
grau
Hero Member
*****
Offline Offline

Activity: 836
Merit: 1030


bits of proof


View Profile WWW
April 23, 2014, 08:07:45 PM
 #2

Do we have an FAQ for this?

Short answer:
There are no balances in Bitcoin at the protocol level.
You spend outputs of previous transactions and not balances.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3486
Merit: 4831



View Profile
April 23, 2014, 08:21:17 PM
 #3

I'm a little confused about how account balances work.

Assume the following sequence:
  • the default account ("") already exists and has a balance of 1 BTC
  • a new address A is created and associated with account "A"
  • 1 BTC are are sent to address A; the balance of account "A" goes from 0 to 1 BTC; the wallet balance is now 2 BTC
  • 1.5 BTC are spent from the wallet; the wallet balance is now 0.5 BTC

What is the balance of account A at this point?

My understanding is that any inputs in the wallet can selected at any time for spending, including those associated with address A (and thus indirectly with account A).

Will the balance of the account remain unchanged (1 BTC) in this situation?

If you don't use "sendfrom" and indicate which account you are sending from, then I think it updates the default account.  I could be mistaken on this, so you should probably do some testing on testnet to be sure.

If I'm right, then the default account will have a balance of -0.5 BTC (since it had 1 BTC, and you sent 1.5 BTC), and account "A" will have a balance of 1 BTC.
grau
Hero Member
*****
Offline Offline

Activity: 836
Merit: 1030


bits of proof


View Profile WWW
April 23, 2014, 08:30:48 PM
 #4

Sorry I have mistaken your "accounts" for addresses.

I am not a user of the reference client, therefore did not realize the context.
arosca (OP)
Newbie
*
Offline Offline

Activity: 38
Merit: 0


View Profile
April 23, 2014, 09:44:55 PM
 #5

If you don't use "sendfrom" and indicate which account you are sending from, then I think it updates the default account.  I could be mistaken on this, so you should probably do some testing on testnet to be sure.

If I'm right, then the default account will have a balance of -0.5 BTC (since it had 1 BTC, and you sent 1.5 BTC), and account "A" will have a balance of 1 BTC.


OK, I'll try this on testnet and post the results here (my testnet blockchain is still building right now :-( )
arosca (OP)
Newbie
*
Offline Offline

Activity: 38
Merit: 0


View Profile
April 24, 2014, 01:31:38 PM
 #6

If you don't use "sendfrom" and indicate which account you are sending from, then I think it updates the default account.  I could be mistaken on this, so you should probably do some testing on testnet to be sure.

If I'm right, then the default account will have a balance of -0.5 BTC (since it had 1 BTC, and you sent 1.5 BTC), and account "A" will have a balance of 1 BTC.


I tested this and you are correct. Invoking sendtoaddress with a balance larger than the default account has available results in a negative balance in the default account.

It turns out this is in fact documented at https://en.bitcoin.it/wiki/Accounts_explained#Accounts_and_Receiving_Addresses

Quote
- 'sendtoaddress' always succeeds if there are sufficient funds in the
   server's wallet.  For example, if your wallet account balances were 100 BTC in account
   'foo' and 0 BTC in the default account, then the balances after sendtoaddress
   1PC9aZC4hNX2rmmrt7uHTfYAS3hRbph4UN 10.00 would be 100 in account 'foo' and -10.00 in
   the default account (and the overall server balance would go from 100 to 90 BTC).  On
   the other hand, using 'sendfrom' to send from the default account with a zero balance
   will fail with message "Account has insufficient funds".
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!