Author

Topic: MultiBit HD - from which wallet address(es) is spent? (Read 909 times)

copper member
Activity: 1498
Merit: 1528
No I dont escrow anymore.
Ah, when I understand correctly, the * is meant as the arithmetic multiplication sign, did not recognize that at first. So if a) would have less than double the age of b), b) would be taken to spend the 0.15 BTC. The rest is a little bit out of scope for me... so let it be Wink

In your example the algorithm (judging by the comment, I did not read the source) would always pick B, because it is closest to the amount you want to spend (or a little bigger). If there is no single input that is big enough the algorithm must have a way to select several inputs, assuming by the way it is selecting single inputs oldest first.
jr. member
Activity: 60
Merit: 5
Ah, when I understand correctly, the * is meant as the arithmetic multiplication sign, did not recognize that at first. So if a) would have less than double the age of b), b) would be taken to spend the 0.15 BTC. The rest is a little bit out of scope for me... so let it be Wink
legendary
Activity: 1708
Merit: 1066
Hi Thura,

More or less.

It is actually transaction outputs that get consumed.
If someone sends you 0.1 BTC it is usually on a single transaction output worth 0.1 BTC but it could be 2 separate outputs that _total_ 0.1 BTC.  Then the algorithm would work out the age * size for each transaction output, sort them and pick them.

It's all one big daisy chain of transaction inputs going to transaction outputs which become transaction inputs and then go to transaction outputs that  . . .

:-)


jr. member
Activity: 60
Merit: 5
Code:
        // Sort the inputs by age*value so we get the highest "coindays" spent.
        // Now iterate over the sorted outputs until we have got as close to the target as possible or a little
        // bit over (excessive value will be change).

Thanks very much for Your answer, Jim.

So as I understand that would mean putting a) and b) together for paying and then receive the change amount (0.15 BTC) to a new generated change address which then becomes the youngest address in the wallet (age*value). (aside of transaction fees for simplicity reasons in this example)
legendary
Activity: 1708
Merit: 1066
When you create a transaction you need to gather up enough unspent transaction outputs to cover the amount you want to spend.

The class that does it in MultiBit HD is a bitcoinj class called DefaultCoinSelector. Here are the relevant comments as to which transaction outputs gets chosen:

Code:
        // Sort the inputs by age*value so we get the highest "coindays" spent.
        // Now iterate over the sorted outputs until we have got as close to the target as possible or a little
        // bit over (excessive value will be change).

Thus it is predictable, but not particularly obvious.
hero member
Activity: 560
Merit: 509
I prefer Zakir over Muhammed when mentioning me!
It is possible that 0.15BTC will be spend from addressb as that transaction will only need 1 input. At least, this is what I see in most known wallets.

* Corrected typos.
jr. member
Activity: 60
Merit: 5
A technical question, just to understand what happens- given a new wallet to which are payed four amounts of BTC- each payment to an own receiving address (a,b,c,d in chronological order):

a) 0.1 BTC
b) 0.2 BTC
c) 0.1 BTC
d) 0.1 BTC

Now 0.15 BTC should be spent from the wallet. Is it predictable, from which address(es) the amount is spent? What would the algorithm for the sending address(es) selection be?

Jump to: