Bitcoin Forum
May 03, 2024, 08:39:51 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: MultiBit HD - from which wallet address(es) is spent?  (Read 890 times)
Thura (OP)
Jr. Member
*
Offline Offline

Activity: 60
Merit: 5


View Profile
June 25, 2015, 05:16:30 AM
 #1

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?

1714768791
Hero Member
*
Offline Offline

Posts: 1714768791

View Profile Personal Message (Offline)

Ignore
1714768791
Reply with quote  #2

1714768791
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714768791
Hero Member
*
Offline Offline

Posts: 1714768791

View Profile Personal Message (Offline)

Ignore
1714768791
Reply with quote  #2

1714768791
Report to moderator
1714768791
Hero Member
*
Offline Offline

Posts: 1714768791

View Profile Personal Message (Offline)

Ignore
1714768791
Reply with quote  #2

1714768791
Report to moderator
1714768791
Hero Member
*
Offline Offline

Posts: 1714768791

View Profile Personal Message (Offline)

Ignore
1714768791
Reply with quote  #2

1714768791
Report to moderator
Muhammed Zakir
Hero Member
*****
Offline Offline

Activity: 560
Merit: 506


I prefer Zakir over Muhammed when mentioning me!


View Profile WWW
June 25, 2015, 09:59:24 AM
Last edit: June 25, 2015, 10:38:30 AM by Muhammed Zakir
 #2

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.

jim618
Legendary
*
Offline Offline

Activity: 1708
Merit: 1066



View Profile WWW
June 25, 2015, 10:16:12 AM
 #3

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.

MultiBit HD   Lightweight desktop client.                    Bitcoin Solutions Ltd   Bespoke software. Consultancy.
Thura (OP)
Jr. Member
*
Offline Offline

Activity: 60
Merit: 5


View Profile
June 25, 2015, 12:12:51 PM
 #4

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

Activity: 1708
Merit: 1066



View Profile WWW
June 25, 2015, 02:36:09 PM
 #5

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

:-)



MultiBit HD   Lightweight desktop client.                    Bitcoin Solutions Ltd   Bespoke software. Consultancy.
Thura (OP)
Jr. Member
*
Offline Offline

Activity: 60
Merit: 5


View Profile
June 25, 2015, 08:16:20 PM
 #6

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
shorena
Copper Member
Legendary
*
Offline Offline

Activity: 1498
Merit: 1499


No I dont escrow anymore.


View Profile WWW
June 26, 2015, 08:15:53 PM
 #7

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.

Im not really here, its just your imagination.
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!