Bitcoin Forum
May 06, 2024, 08:36:48 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: change address is not associated with account - what a hell ?  (Read 1228 times)
shark255 (OP)
Full Member
***
Offline Offline

Activity: 224
Merit: 100



View Profile
May 07, 2016, 06:22:58 PM
 #1

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

Posts: 1715027808

View Profile Personal Message (Offline)

Ignore
1715027808
Reply with quote  #2

1715027808
Report to moderator
Be very wary of relying on JavaScript for security on crypto sites. The site can change the JavaScript at any time unless you take unusual precautions, and browsers are not generally known for their airtight security.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6587


Just writing some code


View Profile WWW
May 07, 2016, 06:55:55 PM
 #2

Probably a bug in the accounts system which is slated for removal anyways. It is deprecated and no longer supported.

shark255 (OP)
Full Member
***
Offline Offline

Activity: 224
Merit: 100



View Profile
May 07, 2016, 08:12:56 PM
 #3

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.
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6587


Just writing some code


View Profile WWW
May 07, 2016, 08:15:40 PM
 #4

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.

Foxpup
Legendary
*
Offline Offline

Activity: 4354
Merit: 3042


Vile Vixen and Miss Bitcointalk 2021-2023


View Profile
May 08, 2016, 12:47:11 AM
 #5

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.

Will pretend to do unspeakable things (while actually eating a taco) for bitcoins: 1K6d1EviQKX3SVKjPYmJGyWBb1avbmCFM4
I am not on the scammers' paradise known as Telegram! Do not believe anyone claiming to be me off-forum without a signed message from the above address! Accept no excuses and make no exceptions!
shark255 (OP)
Full Member
***
Offline Offline

Activity: 224
Merit: 100



View Profile
May 08, 2016, 06:30:20 AM
 #6

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.
Foxpup
Legendary
*
Offline Offline

Activity: 4354
Merit: 3042


Vile Vixen and Miss Bitcointalk 2021-2023


View Profile
May 09, 2016, 07:55:50 AM
 #7

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?

Will pretend to do unspeakable things (while actually eating a taco) for bitcoins: 1K6d1EviQKX3SVKjPYmJGyWBb1avbmCFM4
I am not on the scammers' paradise known as Telegram! Do not believe anyone claiming to be me off-forum without a signed message from the above address! Accept no excuses and make no exceptions!
shark255 (OP)
Full Member
***
Offline Offline

Activity: 224
Merit: 100



View Profile
May 09, 2016, 08:14:01 AM
 #8

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).
Foxpup
Legendary
*
Offline Offline

Activity: 4354
Merit: 3042


Vile Vixen and Miss Bitcointalk 2021-2023


View Profile
May 10, 2016, 04:47:12 AM
 #9

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

Will pretend to do unspeakable things (while actually eating a taco) for bitcoins: 1K6d1EviQKX3SVKjPYmJGyWBb1avbmCFM4
I am not on the scammers' paradise known as Telegram! Do not believe anyone claiming to be me off-forum without a signed message from the above address! Accept no excuses and make no exceptions!
shark255 (OP)
Full Member
***
Offline Offline

Activity: 224
Merit: 100



View Profile
May 10, 2016, 08:28:46 PM
 #10

(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 <account>, and then check getaccount <btcaddr> on change address.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4622



View Profile
May 10, 2016, 09:17:16 PM
 #11

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