Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If one output has amount below dust, throw exception instead of removing it #1182

Merged
merged 1 commit into from
Sep 1, 2023

Conversation

NicolasDorier
Copy link
Collaborator

@NicolasDorier NicolasDorier commented Aug 31, 2023

While it shouldn't really matter economically speaking to remove output with a value that is too small, it is surprising behavior for users, and give rise to several edge case.

Assuming 540 of dust, here is a summary of the changes of behavior:

Case Before Now
you send bob 600 satoshi, but substract 400 sats, the output left is 200 sats. Silently remove output Throw exception
you send bob 200 satoshi (without substract fee) Silently remove output Throw exception
you sent bob 600 satoshi, substracted 700 sats of fee Throw exception Throw exception

Before, we would silently remove such outputs in the built transaction. Now the builder will always throw an exception.

@NicolasDorier NicolasDorier merged commit e2d3362 into master Sep 1, 2023
10 of 12 checks passed
@NicolasDorier NicolasDorier deleted the feoqitnt branch September 1, 2023 01:52
if (txout.Value < minimumTxOutValue)
{
// If the txout is below dust, they throw an exception
throw new OutputTooSmallException("Can't substract fee from this output because the amount is too small",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this error is out of if (SubstractFee block. But it says Can't substract fee

This error will be thrown even user tries to send w/o SubstractFee, if the amount is less than dust. Kinda mis-leading.

@farukterzioglu
Copy link
Collaborator

How can we differentiate the cases;

  • User tries to send lower than dust (w/ or w/o fee subtract)
  • User tries to send bigger than dust, but the amount after fee subtraction is less than dust

If we can differentiate the second case, user can try to send it again after fees dropped.
When the fees are lower, subtracted amount will be less and remaining amount could be bigger than dust.

But the first case will be always fail.

Right now both of them throws OutputTooSmallException exception, so no way to handle them differently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants