Author

Topic: bitcoind fee roulette (Read 1775 times)

legendary
Activity: 2940
Merit: 1333
February 25, 2012, 05:43:18 PM
#13
Selection runs again looking for 1.01

Good point.  I missed that.
staff
Activity: 4284
Merit: 8808
February 25, 2012, 05:04:36 PM
#12
Alternatively, if you feel comfortable building the client from source, you can modify it so that it prefers older coins.  Find the bit in wallet.cpp that says:

Er! Danger Will Robinson! Danger!

The selection function is fairly greedy but the objective is non-convex, this can lead to surprising results.  You can currently end up paying more fees than you need. Consider the following sequence:

Say you want to send 1.0 BTC.
Selection pass runs, finds 1.0 BTC using 100 .01 BTC inputs that all have more than six confirms.
Software then decides that a fee of .01 (random figure) is needed based on the size of the transaction.
Selection runs again looking for 1.01, but can't find that much using inputs with >=6 confirms, so it considers 1 confirm transactions.
Selects inputs of 1.0,0.01 from the set of transactions with at least one confirm, and pays fees that are not really required.

Adding more stages makes this worse.   I have a patch here that first only considers inputs from the set which are high enough priority that any transaction composed solely of them will be high priority, somewhat like your posed your proposed patch but it sets the threshold to be max(144/value,1) confirms.  In my testing I found that it pretty frequently caused stupid decisions at least for wallets with distributions like mine.

If you want to iterate it should be over the entire CreateTransaction, not just inside select coins (and, in fact, all the SelectCoins iteration should be removed). I'm hesitant to write code to do this because any change in this area desperately needs test cases. This code is far too risky to change lightly.


legendary
Activity: 2940
Merit: 1333
February 25, 2012, 03:05:52 PM
#11
If it is just random pick I'm thinking to have two wallets running. One to accept payment and leave there, another to send payments. Once in a while swap their functions.
it's not random. It's designed to maximize coin age and reduce inputs.

Where did this meme originate?  It's not true.  The official client will use coins with more than 6 confirmations if it can, but other than that makes no effort to use old coins.  It tries to find the set of coins which has the smallest value above the value you're trying to send, which usually results in a small 'change' output being left in your wallet, which can tend to increase future fees.

The idea of using two wallets is a reasonable one and should work.  Bear in mind that to avoid fees, each coin you spend should be at least one "bitcoin day" old.  i.e. multiply the coin's value in BTC by its age in days, and it that's more than about one then you can probably spend it for free.  That's just a rough rule of thumb, because the number of outputs also affects the transaction size, but only about 20% as much as the number of outputs does.  (Each input adds 179-181 bytes to the transaction size, while each input only adds 34 bytes).

Alternatively, if you feel comfortable building the client from source, you can modify it so that it prefers older coins.  Find the bit in wallet.cpp that says:
Code:
    return (SelectCoinsMinConf(nTargetValue, 1, 6, setCoinsRet, nValueRet) ||
            SelectCoinsMinConf(nTargetValue, 1, 1, setCoinsRet, nValueRet) ||
            SelectCoinsMinConf(nTargetValue, 0, 1, setCoinsRet, nValueRet));
and add a few more lines, so it tries the oldest coins first.  Something like this would work:
Code:
    return (SelectCoinsMinConf(nTargetValue, 1, 6*24*30, setCoinsRet, nValueRet) || // try just using 30 day old coins first
            SelectCoinsMinConf(nTargetValue, 1, 6*24*7, setCoinsRet, nValueRet) || // then 7 day old
            SelectCoinsMinConf(nTargetValue, 1, 6*24, setCoinsRet, nValueRet) || // then 1 day old
            SelectCoinsMinConf(nTargetValue, 1, 6, setCoinsRet, nValueRet) || // then 1 hour old
            SelectCoinsMinConf(nTargetValue, 1, 1, setCoinsRet, nValueRet) ||
            SelectCoinsMinConf(nTargetValue, 0, 1, setCoinsRet, nValueRet));

Depending how 'micro' your coins are, and how old your wallet is, you might want to go further still, but I'm sure you get the point.
administrator
Activity: 5222
Merit: 13032
February 25, 2012, 01:03:54 PM
#10
it's not random. It's designed to maximize coin age and reduce inputs.

Bitcoin actually chooses coins with the goal of reducing change. (This is not the best way to do it.)
Stn
full member
Activity: 227
Merit: 100
February 25, 2012, 12:17:55 PM
#9
I've installed latest version and fee reduced to 0.0005 BTC. Which is absolutely fine for me and makes useless any additional tricks.
legendary
Activity: 2058
Merit: 1452
February 25, 2012, 11:54:19 AM
#8
If it is just random pick I'm thinking to have two wallets running. One to accept payment and leave there, another to send payments. Once in a while swap their functions.
it's not random. It's designed to maximize coin age and reduce inputs.
Stn
full member
Activity: 227
Merit: 100
February 25, 2012, 01:11:13 AM
#7
It would be good if payments are to be sent in a time. But that is not an option to delay them in order collect a bunch.
full member
Activity: 154
Merit: 102
Bitcoin!
February 25, 2012, 12:01:42 AM
#6
It happens that I do send out many micro payments in automatic mode with bitcoind. In general I do not mind to pay some fees in order to support the network. But when it comes to the multiple small payments it damages my income.

I'm aware of that tiny or "young" transactions are need to backed up by fee. But I still can't understand the pattern of fee calculation.

Altogether around 50% transactions goes with 0.01 BTC fee and others are free. There is no correlations with the amount. Larger ones may be with fee and smaller may be free. The wallet consists of plenty BTC with the majority of funds being very mature. paytxfee parameter seems does not give any effect.

I'm trying to understand algorithm of fee calculation in order to minimize my losses.
Look into "sendmany".
Stn
full member
Activity: 227
Merit: 100
February 24, 2012, 11:37:34 PM
#5
If it is just random pick I'm thinking to have two wallets running. One to accept payment and leave there, another to send payments. Once in a while swap their functions.
Stn
full member
Activity: 227
Merit: 100
February 24, 2012, 11:33:14 PM
#4
Then if I have young and plenty mature money in the same wallet what bitcoind chooses to pay out?
donator
Activity: 1218
Merit: 1079
Gerald Davis
February 24, 2012, 11:25:00 PM
#3
The total amount of the transaction doesn't matter.

It is the amount and age of the inputs.

Thus 1 BTC paid by an 1 BTC input 144 blocks old = no fee, while 1 BTC paid by 1000 0.001 inputs which are 6 blocks old = relatively large fee.

legendary
Activity: 1512
Merit: 1036
February 24, 2012, 10:41:22 PM
#2
It happens that I do send out many micro payments in automatic mode with bitcoind. In general I do not mind to pay some fees in order to support the network. But when it comes to the multiple small payments it damages my income.

I'm aware of that tiny or "young" transactions are need to backed up by fee. But I still can't understand the pattern of fee calculation.

Altogether around 50% transactions goes with 0.01 BTC fee and others are free. There is no correlations with the amount. Larger ones may be with fee and smaller may be free. The wallet consists of plenty BTC with the majority of funds being very mature. paytxfee parameter seems does not give any effect.

I'm trying to understand algorithm of fee calculation in order to minimize my losses.
The minimum transaction fee is .0005 per KB of transaction message size, if your Bitcoin is suggesting more, it should be updated to something newer than <0.3.23. In addition, you can use sendmany to send payments to multiple recipients at once, which will be cheaper:
Code:
bitcoind sendmany "FromAccountName" "{\"1BiTCoinSNU2BMzf2cN2TK4yzPUA6CnTAd\":.001,\"1PHoenix9j9J3M6v3VQYWeXrHPPjf7y3rU\":.002}"


Stn
full member
Activity: 227
Merit: 100
February 24, 2012, 10:27:11 PM
#1
It happens that I do send out many micro payments in automatic mode with bitcoind. In general I do not mind to pay some fees in order to support the network. But when it comes to the multiple small payments it damages my income.

I'm aware of that tiny or "young" transactions are need to backed up by fee. But I still can't understand the pattern of fee calculation.

Altogether around 50% transactions goes with 0.01 BTC fee and others are free. There is no correlations with the amount. Larger ones may be with fee and smaller may be free. The wallet consists of plenty BTC with the majority of funds being very mature. paytxfee parameter seems does not give any effect.

I'm trying to understand algorithm of fee calculation in order to minimize my losses.
Jump to: