Author

Topic: change address is not associated with account - what a hell ? (Read 1228 times)

legendary
Activity: 3388
Merit: 4615
Change goes to noname account, I have tested several times.

This is correct.  This is exactly how it should work.

If you add the change back to the "sendfrom" account, then you would increase the balance of the account. That would be incorrect and bad.

Example:

Account 1 receives 0.5 BTC (unspent output 1 is added to the wallet), account 1 balance = 0.5 BTC.
Account 2 receives 0.5 BTC (unspent output 2 is added to the wallet), account 2 balance = 0.5 BTC.
Account 1 receives 0.5 BTC (unspent output 3 is added to the wallet), account 1 balance = 1.0 BTC.
Account 2 receives 1.5 BTC (unspent output 4 is added to the wallet), account 2 balance = 2.0 BTC.

You decide to send 0.9 BTC from account 1, account 1 balance is reduced by 0.9 BTC to 0.1 BTC.

Wallet chooses to spend unspent output 4 (valued at 1.5 BTC) creating 2 new unspent outputs.
The first unspent output is the 0.9 BTC assigned to the destination address.
The second unspent output needs to go back into the wallet as "change".  Therefore, 0.5999 BTC is sent to a wallet change address.

If you added this 0.5999 BTC back to account 1, then account 1 would have the wrong balance (0.6999 BTC instead of 0.1 BTC). Therefore, the correct thing to do is to send the change to an unnamed account that belongs to the wallet.

Think of it like a bank account.  When you deposit cash into a bank account your account balance is updated, but they don't keep track of exactly which dollar bills were yours.  They just mix them all up in the safe.  When you withdraw, you might get different bills than the ones you deposited.  If the teller only has $100 bills in their drawer, they'll need to make change at the safe, but the extra change isn't added to your account, it's just eventually sent back into the safe.

Your problem has nothing to do with "change".  You are expecting the exact outputs that were received for an "account" to remain associated with that "account".  This isn't true at all.  It is entirely possible that an output that is received at one account is spent when sending from another account (just like the bills in a bank account). That's why it is possible for an account in the Bitcoin Core wallet to have a negative balance.  You can spend more bitcoins than an account has as long as the wallet has enough bitcoins for the transaction.
full member
Activity: 224
Merit: 100
(problem with change, that goes to "noname" account).
It doesn't. Check the balance of your accounts, not your addresses. The change produced by a transaction from account A will be counted in account A, regardless of what addresses are involved.


Change goes to noname account, I have tested several times.
You can check it on your server by running sendfrom , and then check getaccount on change address.
legendary
Activity: 4326
Merit: 3041
Vile Vixen and Miss Bitcointalk 2021-2023
(problem with change, that goes to "noname" account).
It doesn't. Check the balance of your accounts, not your addresses. The change produced by a transaction from account A will be counted in account A, regardless of what addresses are involved.
full member
Activity: 224
Merit: 100
Everything is clear, except one thing - this approach (accounts) is not useful.
It is useful if you are managing bitcoins belonging to multiple people, and need to keep track of who has how much (though an external database works just as well). It is not designed for any other purpose. What are you trying to use it for?

My use case is simple - I have two projects on my web server related to Bitcoin payouts. Both projects generate new addresses (no problems) and both projects make payouts (problem with change, that goes to "noname" account).
legendary
Activity: 4326
Merit: 3041
Vile Vixen and Miss Bitcointalk 2021-2023
Everything is clear, except one thing - this approach (accounts) is not useful.
It is useful if you are managing bitcoins belonging to multiple people, and need to keep track of who has how much (though an external database works just as well). It is not designed for any other purpose. What are you trying to use it for?
full member
Activity: 224
Merit: 100
Not a bug. Account addresses are for receiving only. When sending, addresses are not associated with accounts at all, and this is by design. In your example above, if account B sends BTC0.1, it may, for reasons of transaction priority, or no reason at all, decide to take the coins from the address associated with account A. But account A still has BTC0.5 to spend, by using the coins from the address associated with account B plus its change. Anyone who doesn't understand how accounts work should not be using them.

Everything is clear, except one thing - this approach (accounts) is not useful.  It's better to remove account functionality completely in this case.
legendary
Activity: 4326
Merit: 3041
Vile Vixen and Miss Bitcointalk 2021-2023
Not a bug. Account addresses are for receiving only. When sending, addresses are not associated with accounts at all, and this is by design. In your example above, if account B sends BTC0.1, it may, for reasons of transaction priority, or no reason at all, decide to take the coins from the address associated with account A. But account A still has BTC0.5 to spend, by using the coins from the address associated with account B plus its change. Anyone who doesn't understand how accounts work should not be using them.
staff
Activity: 3374
Merit: 6530
Just writing some code
Probably a bug in the accounts system which is slated for removal anyways. It is deprecated and no longer supported.

hope it will be fixed soon. Bug is appear in current 0.12.1 version. But maybe it's not a bug, and feature which is worse.
It probably won't be fixed. The "fix" will be the complete removal of the account system, something that is planned to happen soon. Anyways, it is still probably a good idea to create an issue about this on github. Did you see this behavior in previous versions.
full member
Activity: 224
Merit: 100
Probably a bug in the accounts system which is slated for removal anyways. It is deprecated and no longer supported.

hope it will be fixed soon. Bug is appear in current 0.12.1 version. But maybe it's not a bug, and feature which is worse.
staff
Activity: 3374
Merit: 6530
Just writing some code
Probably a bug in the accounts system which is slated for removal anyways. It is deprecated and no longer supported.
full member
Activity: 224
Merit: 100
After a huge time of using bitcoind API I realized, that change addresses are not associated with accounts.

For example - I have accounts A and B with 0.5 and 0.1 bitcoins.

If I send from account A to some address 0.1 BTC, then change 0.3999 BTC goes to noname account
AND CAN BE USED by account B as an input for sending other transaction.

This fact brakes account meaning. Why change goes to noname account, what is the sense of it ?
Jump to: