LSPS2: check and return if fee has been skimmed #134
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.
Based on #137 and #135
Using skimmed_fee_msat in the payment forwarded event we should actually check to make sure the we have skimmed the correct amount of fees.
I subtract the skimmed fee from the expected fee to get a remaining fee. If remaining fee is 0 then the logic continues as before.
If the remaining fee is > 0 then it basically performs the htlc_handling_failed logic but uses the remaining fee as the expected fee. This is likely outside of the spec and should in theory never happen since we check to make sure we can skim the entire fee before attempting the forward in the first place.
I also updated the payment_forwarded function to return a boolean for whether or not the channel has been sufficiently paid for so the LSP can use the response to determine if it should release a held funding tx when using client trusts lsp.