Author

Topic: Input output explanations (Read 377 times)

legendary
Activity: 3472
Merit: 4801
September 07, 2017, 11:20:09 AM
#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.
member
Activity: 162
Merit: 24
September 07, 2017, 10:54:13 AM
#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?
legendary
Activity: 3472
Merit: 4801
September 07, 2017, 10:47:20 AM
#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.


member
Activity: 162
Merit: 24
September 07, 2017, 07:39:12 AM
#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?
Jump to: