I've received lots of tiny transactions, in amounts sometimes as low as 0.000003BTC.
Even though I've also received (relatively) larger amounts, I'm worried that when I want to spend my bitcoins the transaction fees may be very high thanks to the large number of "input" transactions needed to make up the output transaction.

As I understand it, the network has an algorithm for determining minimum transaction fees, and the relationship between number of inputs and required transaction fee is non-linear. This means there is likely some optimum way to combine my inputs. This has already been discussed here and here, but neither question asks how it can be done, and how bad the consequences can be.

It might be best to somehow include as many tiny inputs with a larger input each time I spend a moderate amount, or perhaps it would be better to somehow combine all the tiny inputs in individual batches of some optimum size and send them to myself to prevent future problems.

If I were to combine the tiny amounts, I'd be happy to wait for the newly combined bitcoins to age, so additional fees which would be required by spending young bitcoins won't be a problem.

In most, but not all, cases, my tiny amounts have been received to a dedicated tony-amount address.

For the sake of the question, let's assume I've received 1000 tiny transactions of 0.001BTC each, and another 100 transactions of 0.1BTC each, all in the same wallet. This would give a total balance of 11BTC. Assume all amounts were received 6 months ago.

If I wanted to spend the entire 11BTC at once (with 1100 transaction inputs), how high might the fee be?

If I only spent 1BTC at a time, how high might the fee be?

How can I actually combine the tiny amounts without affecting the larger ones?

I'm running the standard (Satoshi) client, but other clients could be an option.

1 Answer
1

I have not actually done this, but here is how I understand it. With many tiny amounts, you probably want to consolidate them because the fees for transactions with lots of inputs will be high. Now you ask, by consolidating, won't I just be paying the fees in advance? The answer is that by planning ahead and consolidating them, you can use the low-fee mining pool Eligius to do it.

To estimate the cost of the transaction, I'm going to use only the transaction size (for large transactions, the fee is dominated by or entirely consists of the cost per KB). This is based on the number of inputs and outputs. If all your balances are the same (0.01 BTC), then it doesn't matter how much you spend at at a time, the fee grows linearly with the total BTC amount.

Assuming 180 bytes per input, 1000 inputs comes to 175KB, which I'm going to round up to 200KB for a safety margin. With the official client, at the default 0.01 BTC / KB fee [1], that would cost 2 BTC.

Eligius will mine transactions for a fee of 0.2 TBC (0.00008192 BTC) per KB [2]. So Eligius's fee would be 0.016384 BTC. Might as well round that up to 0.02 BTC or higher just to be sure.

If your coins are old enough (say, 3 months for 10 BTC and a 200KB transaction size) [3], then the official client might not enforce the minimum fee on your transaction. Otherwise you may need to use a modified client that doesn't enforce a minimum fee.

In any case you will need to point your client to Lightfoot Hosting's free transaction relay, which will relay any transaction to the network [2], so it can be picked up by Eligius.

It may take longer than usual, but Eligius should eventually mine it.

As for combining the "dust" while leaving larger balances alone -- you would have to find a client that allows you to choose the inputs to your transaction. I don't know which clients can do that.

[3] Wiki link [1] above says that transactions with priority over 57,600,000 aren't subject to the minimum fee calculation. If this is true, then 10 BTC with an average age of 3 months in a 200KB transaction would have a priority of (1000000000 * 144 * 90) / (200 * 1024) = 63,281,250

Thanks for your answer! Especially for the mention of the waiver for the min transaction fee; I didn't know that
–
Highly IrregularDec 5 '12 at 20:25

You may update your answer with the fact that a fork of the original client done by cozz (github.com/cozz/bitcoin) does allow to pick specific inputs.
–
lioriApr 8 '13 at 15:01

Not sure why this old question popped up on the rss stream but might as well add the tidbit that bitcoin-qt these days also allows you to pick inputs manually. It has for a while actually.
–
JannesApr 30 at 14:57