Bitcoin Forum
May 06, 2024, 04:21:17 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Input output explanations  (Read 360 times)
zoltanb (OP)
Member
**
Offline Offline

Activity: 162
Merit: 24


View Profile
September 07, 2017, 12:39:12 PM
Last edit: September 07, 2017, 03:48:53 PM by zoltanb
 #1

I am trying to figure out how bitcoin core (the bitcoin cli interface) select the inputs used to send out payments. For ease of calculation let's suppose I have 10 addresses like this:

A: 0.1 BTC
B: 0.2 BTC
C: 0.3 BTC
D: 0.4 BTC
E: 0.5 BTC
F: 0.6 BTC
G: 0.7 BTC
H: 0.8 BTC
I: 0.9 BTC
J: 1 BTC

Let's suppose I need to send out 3 payments of 0.25, 0.42 and 0.70.
And I want to use the sendmany parameter to send by one command.

How will bitcoin-cli decide which of the above 10 addresses will be used to send out these payments?
Is there a general rule / calculation formula that will optimize inputs?
1714969277
Hero Member
*
Offline Offline

Posts: 1714969277

View Profile Personal Message (Offline)

Ignore
1714969277
Reply with quote  #2

1714969277
Report to moderator
1714969277
Hero Member
*
Offline Offline

Posts: 1714969277

View Profile Personal Message (Offline)

Ignore
1714969277
Reply with quote  #2

1714969277
Report to moderator
The block chain is the main innovation of Bitcoin. It is the first distributed timestamping system.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714969277
Hero Member
*
Offline Offline

Posts: 1714969277

View Profile Personal Message (Offline)

Ignore
1714969277
Reply with quote  #2

1714969277
Report to moderator
1714969277
Hero Member
*
Offline Offline

Posts: 1714969277

View Profile Personal Message (Offline)

Ignore
1714969277
Reply with quote  #2

1714969277
Report to moderator
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4616



View Profile
September 07, 2017, 03:47:20 PM
 #2

let's suppose I have 10 wallets like this:

When sending bitcoins, Bitcoin-cli only uses a single wallet (whichever wallet.dat is currently loaded).  It does not search through other copies of wallet.dat that you have stored elsewhere.

Perhaps you meant "addresses" or "accounts" and NOT "wallets"?  It is important that you understand the differences between these words and use them correctly or you will become confused about any advice you receive.

How will bitcoin-cli decide which of the above 10 addresses will be used to send out these payments?

bitcoin-cli does not take addresses into consideration at all when spending outputs.  Transactions spend unspent outputs, they do not "send from" addresses.


zoltanb (OP)
Member
**
Offline Offline

Activity: 162
Merit: 24


View Profile
September 07, 2017, 03:54:13 PM
 #3

let's suppose I have 10 wallets like this:

When sending bitcoins, Bitcoin-cli only uses a single wallet (whichever wallet.dat is currently loaded).  It does not search through other copies of wallet.dat that you have stored elsewhere.

Perhaps you meant "addresses" or "accounts" and NOT "wallets"?  It is important that you understand the differences between these words and use them correctly or you will become confused about any advice you receive.

How will bitcoin-cli decide which of the above 10 addresses will be used to send out these payments?

bitcoin-cli does not take addresses into consideration at all when spending outputs.  Transactions spend unspent outputs, they do not "send from" addresses.




My mistake. I wanted to write addresses. Thanks for pointing this out, I edited my original post.
To reformulate my question: when I send out to other addresses what method is used by bitcoin-cli to decide which addresses are debited (to use a more banking word)? Because, at the end I will have a deducted balance on one or more of the above 10 addresses, as I "spend" some of my bitcoins, right?
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4616



View Profile
September 07, 2017, 04:20:09 PM
 #4

My mistake. I wanted to write addresses. Thanks for pointing this out, I edited my original post.
To reformulate my question: when I send out to other addresses what method is used by bitcoin-cli to decide which addresses are debited (to use a more banking word)? Because, at the end I will have a deducted balance on one or more of the above 10 addresses, as I "spend" some of my bitcoins, right?

There are no addresses in transactions or in the blockchain.

Addresses are used in the human interface of wallets.

The wallets use those addresses to build transactions.

What is actually stored are transactions (and transaction outputs).  NOT balances.

To show you a wallet "balance" the wallet adds up all the outputs that it has control over and displays that sum to you as a "balance", but the outputs aren't literally combined.

To show you an "address balance" on a block explorer website, the block explorer adds up all the outputs that were built from the same address information and displays that sum to you as a "balance", but the outputs aren't literally combined.

I suspect that what you want to know is:

"When choosing from the unspent outputs that the wallet has control over, what criteria does the wallet use to choose which outputs to spend?"

If you want to know about "accounts", that's a different subsystem in Bitcoin Core that is completely under the control of the user and has nothing to do with the actual transactions created.

As for the answer to the unspent outputs question...  I unfortunately don't recall the specifics of that.  With a bit of research I could get you the answer, but don't have time for that at the moment.  If you don't have an answer from someone else by the end of today, I'll take a look at the code and see what I can figure out for you.
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!