-
Notifications
You must be signed in to change notification settings - Fork 405
Correct handling of added OP_RETURN
outputs
#3285
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
Correct handling of added OP_RETURN
outputs
#3285
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3285 +/- ##
========================================
Coverage 89.82% 89.82%
========================================
Files 126 126
Lines 103134 103449 +315
Branches 103134 103449 +315
========================================
+ Hits 92643 92926 +283
- Misses 7772 7800 +28
- Partials 2719 2723 +4 ☔ View full report in Codecov by Sentry. |
While these are consensus-valid, they have been nonstandard for quite some time and will not relay nor confirm.
299b9bd
to
4cd9a86
Compare
When we do coin selection for channel close anchor spends, we may do coin selection targeting exactly the input values we need. However, if coin selection does not include a change output, we may add an OP_RETURN output, which may cause us to end up with less fee than we wanted on the resulting package. Here we address this issue by running coin selection twice - first without seeking the extra weight of the OP_RETURN output, and again if we find that we under-selected.
We should always select at least as many coins as is required to meet the feerate target, but its perfectly fine if we overshoot. Specifically, we may overshoot deliberately if we choose to burn change to fee instead.
This adds a single test for coin selection which exercises the issues fixed in the past three commits.
4cd9a86
to
5a2372c
Compare
`ANCHOR_INPUT_WITNESS_WEIGHT` is too high by two weight units, likely it was calculated to include the SegWit marker bytes, but it is used to describe an `Input::satisfaction_weight`, which does not expect the marker bytes. This corrects that oversight, reducing the constant by two and adding the marker bytes back in our own internal weight calculations. It also fixes a second issue where the constant was too low by one when `grind_signatures` is not set, as that may result in a signature being one byte longer than we expect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT
Ugh, build failed with |
Note that I assume there is a similar bug in |
This fixes two bugs in handling of coin selections that don't contain change, both of them pretty minor (in part cause we'll always re-select soon anyway and that selection might well contain change) but also important.