refactor: improve hold TLC settlement logic #1022
Open
+1,459
−148
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.
Refactor hold TLC settlement logic to improve payment handling:
RemoveTlcis called for invalid TLCsKey Changes
SettleTlcSetCommandmodule: Encapsulates TLC settlement logic with clear verification steps and settlement actionsSettleTlcSetinto two distinct commands:SettleTlcSet(payment_hash, tlc_ids)- Settle TLCs by given list of(channel_id, tlc_id)SettleHoldTlcSet(payment_hash)- Settle hold TLC set saved for a payment hashis_mppfield fromPendingNotifySettleTlcand simplified the settlement flowBehavior Notes
This refactoring ensures that, in the presence of multiple payments to the same invoice, at most one payment succeeds. However, due to the lack of database transaction support, there remains a small window where the total accepted amount may exceed the invoice amount.
Additionally, in the case of two concurrent MPP payments, it's possible to partially accept TLCs from both without either payment fully succeeding. This is an inherent limitation of MPP and cannot be avoided on the recipient side.
Related Issues
Closes #965