Bitcoin Forum
April 26, 2024, 09:27:28 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin [ sendtoaddress ] command?  (Read 175 times)
wsxdrfv (OP)
Jr. Member
*
Offline Offline

Activity: 405
Merit: 5


View Profile WWW
May 01, 2018, 10:51:20 AM
 #1

As far as I know,

If some send bitcoin by this command, [ sendtoaddress ],

then wallet decide where to pull bitcoin remaining balance from any inside accounts?



1714123648
Hero Member
*
Offline Offline

Posts: 1714123648

View Profile Personal Message (Offline)

Ignore
1714123648
Reply with quote  #2

1714123648
Report to moderator
1714123648
Hero Member
*
Offline Offline

Posts: 1714123648

View Profile Personal Message (Offline)

Ignore
1714123648
Reply with quote  #2

1714123648
Report to moderator
There are several different types of Bitcoin clients. The most secure are full nodes like Bitcoin Core, but full nodes are more resource-heavy, and they must do a lengthy initial syncing process. As a result, lightweight clients with somewhat less security are commonly used.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714123648
Hero Member
*
Offline Offline

Posts: 1714123648

View Profile Personal Message (Offline)

Ignore
1714123648
Reply with quote  #2

1714123648
Report to moderator
AdolfinWolf
Legendary
*
Offline Offline

Activity: 1946
Merit: 1427


View Profile
May 01, 2018, 11:17:26 AM
 #2

As far as I know,

If some send bitcoin by this command, [ sendtoaddress ],

then wallet decide where to pull bitcoin remaining balance from any inside accounts?





I'm not quite sure what you mean.

Do you mean

 A. What inputs are chosen by the wallet to be spent?

It uses a multi-pass approach, first trying to use only coins with at least six confirmations. In the next two passes it relaxes these requirements. Within each pass, it tries to minimize the number of transaction outputs claimed and then the amount of change returned.

Note that all coins in your wallet are considered. In the accounting model that the Bitcoin client uses, specific coins do not belong to specific accounts.
https://bitcoin.stackexchange.com/questions/1077/what-is-the-coin-selection-algorithm

Or

B. Where the so called "change" goes in case your inputs hold more bitcoin than you want to spend?

I believe the change simply gets send to the first adress in your keypool that doesn't hold any balance.

If you want to specify where the change goes i think you could use something like

Code:
changeaddress=yournewchangeaddress
https://bitcoin.stackexchange.com/a/32713


Xynerise
Sr. Member
****
Offline Offline

Activity: 322
Merit: 363

39twH4PSYgDSzU7sLnRoDfthR6gWYrrPoD


View Profile
May 01, 2018, 11:53:54 AM
 #3

By "account" do you mean accounts with different HD seed & different addresses, or do you mean other addresses in the wallet.
If it's the former then
Code:
sendtoaddress
doesn't support accounts and will send from the default account ""

If it's the latter it just select UTXOs and spends according to the amount being sent.
wsxdrfv (OP)
Jr. Member
*
Offline Offline

Activity: 405
Merit: 5


View Profile WWW
May 02, 2018, 12:16:02 AM
 #4

By "account" do you mean accounts with different HD seed & different addresses, or do you mean other addresses in the wallet.
If it's the former then
Code:
sendtoaddress
doesn't support accounts and will send from the default account ""

If it's the latter it just select UTXOs and spends according to the amount being sent.

So I want to know both cases (HD wallet and old wallet).

And account does not need maybe? When exchange's wallet, when issue address to user, attach that user's ID to address.

Xynerise
Sr. Member
****
Offline Offline

Activity: 322
Merit: 363

39twH4PSYgDSzU7sLnRoDfthR6gWYrrPoD


View Profile
May 02, 2018, 02:00:05 AM
 #5

want to know both cases (HD wallet and old wallet).
If you have 2 accounts in bitcoin core, the default account and a new account named "A", and you have 2 BTC in default account but 5BTC in account B.
If you use the sendtoaddress command to send any amount of bitcoin, it will always debit the default account whether it has a balance or not.
For example if you send 3 BTC using the sendtoaddress command and the default account has 2 BTC balance, the transaction will succeed because Core will choose coins from the other account that has funds but still debit the default account so the new balance for the default account will be -1 BTC.

If instead you wish to send 3 BTC from the new wallet B instead then you'd use the
Code:
sendfrom 
command instead.
For example
Code:
sendfrom "B" 1BitcoinAddress 3
This time it will debit account B instead and the account balances will be: default address: 2BTC and account B: 2BTC

If you wish to adjust the balances of different accounts then use the
Code:
move
command. This is a cosmetic change  within the wallet and so there's no need for a bitcoin transaction.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3374
Merit: 4606



View Profile
May 02, 2018, 02:52:29 PM
 #6

If you have 2 accounts in bitcoin core, the default account and a new account named "A", and you have 2 BTC in default account but 5BTC in account B.
If you use the sendtoaddress command to send any amount of bitcoin, it will always debit the default account whether it has a balance or not.
For example if you send 3 BTC using the sendtoaddress command and the default account has 2 BTC balance, the transaction will succeed because Core will choose coins from the other account that has funds

No!

This is the type of confusion that happens when people try to use the accounting system in Bitcoin Core instead of implementing their own accounting system.

Bitcoin Core will just as likely choose to use bitcoins that were previously received at an account that currently has a 0 (or even negative) balance.

Think about this like a bank.

Imagine you deposit $200 into YOUR ACCOUNT at the bank, and I deposit $500 into MY ACCOUNT at the same bank.  Now imagine that I return the next day and withdraw $200 from MY ACCOUNT.  Am I going to get those exact same bills from the bank that I gave them?  No.  The bank mixes the bills all up internally and stores them all together in a vault without any indication as to which bills were deposited into which account.  The account is just a number that is updated when the deposit is made.  After that, the actual money has NO CONNECTION to the account at all.  When I withdraw $200, I might get some of my original bills, I might get some of your original bills. It doesn't matter.  Regardless of which bills I get, MY ACCOUNT will be reduced by the amount that I withdraw.

Bitcoin Core accounts work the same way.  When you "receive at an account" the account value is increased, but the bitcoins are not in any way tied to that account.  When you "send from account", the account value is decreased, but the bitcoins themselves just come from the total bitcoins under the control of the wallet.  Some of the bitcoins sent MIGHT be the same bitcoins that were received at that account, some of the bitcoins sent MIGHT have been received at other accounts. It doesn't matter.  Regardless of which actual bitcoins are sent, the account that is being "sent from" will be reduced by the amount sent.

but still debit the default account so the new balance for the default account will be -1 BTC.

Non-default accounts are also allowed to have a negative balance.
wsxdrfv (OP)
Jr. Member
*
Offline Offline

Activity: 405
Merit: 5


View Profile WWW
May 03, 2018, 07:36:25 AM
 #7


No!

This is the type of confusion that happens when people try to use the accounting system in Bitcoin Core instead of implementing their own accounting system.

Bitcoin Core will just as likely choose to use bitcoins that were previously received at an account that currently has a 0 (or even negative) balance.

Think about this like a bank.

Imagine you deposit $200 into YOUR ACCOUNT at the bank, and I deposit $500 into MY ACCOUNT at the same bank.  Now imagine that I return the next day and withdraw $200 from MY ACCOUNT.  Am I going to get those exact same bills from the bank that I gave them?  No.  The bank mixes the bills all up internally and stores them all together in a vault without any indication as to which bills were deposited into which account.  The account is just a number that is updated when the deposit is made.  After that, the actual money has NO CONNECTION to the account at all.  When I withdraw $200, I might get some of my original bills, I might get some of your original bills. It doesn't matter.  Regardless of which bills I get, MY ACCOUNT will be reduced by the amount that I withdraw.

Bitcoin Core accounts work the same way.  When you "receive at an account" the account value is increased, but the bitcoins are not in any way tied to that account.  When you "send from account", the account value is decreased, but the bitcoins themselves just come from the total bitcoins under the control of the wallet.  Some of the bitcoins sent MIGHT be the same bitcoins that were received at that account, some of the bitcoins sent MIGHT have been received at other accounts. It doesn't matter.  Regardless of which actual bitcoins are sent, the account that is being "sent from" will be reduced by the amount sent.
 
Thanks for clarification.
cashberycoin.com
Newbie
*
Offline Offline

Activity: 80
Merit: 0


View Profile
May 03, 2018, 07:54:40 AM
 #8

As far as I know,

If some send bitcoin by this command, [ sendtoaddress ],

then wallet decide where to pull bitcoin remaining balance from any inside accounts?


What is your wallet now?
wsxdrfv (OP)
Jr. Member
*
Offline Offline

Activity: 405
Merit: 5


View Profile WWW
May 06, 2018, 11:45:59 PM
 #9

As far as I know,

If some send bitcoin by this command, [ sendtoaddress ],

then wallet decide where to pull bitcoin remaining balance from any inside accounts?


What is your wallet now?
I use new&old wallet. I manage many altcoins.
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!