pay: fix re-adding payment amount back to estimated capacity #7188
+78
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #7177
Below lines of code failed to actually re-add the amount back to the channel hint's estimated capacity.
lightning/plugins/libplugin-pay.c
Lines 586 to 589 in 4b8d261
I'm not sure why tbh, it seems like a reasonable piece of code. However, it made the corresponding test (added in this PR) fail, because the channel hint's estimated capacity of the sender's own channel was below the amount he was trying to send. I tested this by logging the
channel_hints
before and after the operation in those lines. When substracting the amount (remove == false
) the estimated capacity of the sender's channel after the operation was smaller than before the operation. When adding the amount back (remove == true
) the estimated capacity of the sender's channel after the operation was equal to what it was before the operation.The consequence of this was that the estimated channel capacity in the sender's own channel was ever decreasing during the
pay
lifecycle.