6

I'm working on some quirks of a wallet I'm developing, and one of the issues is what to do with change amounts that are larger than dust ~600 satoshis, but less than a practical amount to be sent again with a fee. Should I return the near-dust amount as change, or just tack it on as additional mining fees?

For example, let's say a user spends an amount that after paying to an output and a sufficient fee leaves only 1,000 satoshis as change. Should I send those 1,000 satoshis as change even though 1,000 satoshis is too small to be spent again with a sufficient fee?

Even with fees as low as 10 satoshis per byte with one input and output (P2PKH) you'd need at least 2,000 satoshis for fees.

I'm thinking it might be better to just put the leftover towards additional mining fees if change amount is below a certain threshold, say 3,000 satoshis. An address with just 1,000 satoshis is mostly useless, and would just add to the growing UTXO set that would likely never be spent. Does this approach seem appropriate, or am I "robbing" users of their dust?

1 Answer 1

2

I've done some research on a related topic* and I'd say it depends on your assumptions what will happen with the value of Bitcoin, the fee rate, and the cost of creating transactions in the long run.

Under the assumption that the fee rate (in [sat/B]) will remain roughly the same level or increase, it saves the user money to add the change to the fee when the change is smaller than the cost of creating one output and spending one input:

change ≤ (bytesOutput + bytesInput) × feePerByte ⇒ add to fee

For P2PKH at 150 satoshis per byte this is for example

change ≤ 27,300 satoshis = (34 bytes + 148 bytes) × 150 satoshis per byte

You may also want to consider that adding the change to transaction fees causes transactions to confirm more quickly, take less blockspace, and reduce the UTXO set.

However, smaller amounts may become spendable in the future, if fee rates would drastically drop, or the cost of spending inputs would significantly decrease. The former could happen due to blocksize increases or introduction of a second layer payment system, while the latter could be brought about by new transaction formats, signature aggregation, or a lowering of the minRelayTxFee.

Alternatively, you can either try to directly match the amount you're trying to spend or just select a sufficiently large amount to create a useful change output. Thank you, Pieter, for the reminder.

* my Master thesis on Coin Selection [PDF with 943KB]

2
  • 1
    An alternative is just doing input selection for a larger amount, and then creating change with the result. Mar 19, 2017 at 21:25
  • Right assuming there are additional inputs available. There's the option of allowing users to set their own fees as well, but that seems to open up the chance for errors.
    – m1xolyd1an
    Mar 20, 2017 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.