[bugfix] Process fee updates as any other update message #2397
Instead of special casing the UpdateFee messages, we instead add them to
This fixes a bug where we would reset the pendingFeeUpdate variable
A test to exercise the previous failure case is added.
The text was updated successfully, but these errors were encountered:
This commit adds a new updateType that can be used for PaymentDescriptors: FeeUpdate. We repurpose the fields of the existing PaymentDescriptor struct such that we can easily re-use the commit/ack logic used for other update types also for fee updates.
This commit adds conversion between the lnwire.UpdateFee message and the new FeeUpdate PaymentDescriptor. We re-purpose the existing Amount field in the PaymentDescriptor stuct to hold the feerate.
When compacting the update logs we remove any fee updates when they remove height is passed. We do this since we'll assume fee updates are added and removed at the same commit height, as they will apply for all commitments following the fee update.
This commit makes the evaluateHTLCView method process any found FeeUpdates in the logs, by returning the last set feerate.
Instead of special casing the UpdateFee messages, we instead add them to the update logs like any other HTLC update message. This lets us avoid having to keep an extra set of variables to keep track of the fee updates, and instead reuse the commit/ack logic used for other updates. This fixes a bug where we would reset the pendingFeeUpdate variable after signing our next commitment, which would make us calculate the new fee incorrectly if the remote sent a commitment concurrently. When restoring state logs, we also make sure to re-add any fee updates.
This tests make sure we don't reset our expected fee upate after signing our next commitment. This test would fail without the previous set of commits.
Since the feerate is part of the computed view now, we don't have to pass the found feerate as a distinct parameter.