lnwallet: detect and handle noop HTLCs

We update the lightning channel state machine in some key areas. If the
noop TLV is set in the update_add_htlc custom records then we change the
entry type to noop. When settling the HTLC if the type is noop we credit
the satoshi amount back to the sender.
This commit is contained in:
George Tsagkarelis committed 2025-08-08 20:03:30 +02:00
1 parent aacefb9055
commit a5a15f6401
3 files changed
+198 -19

No files matched your search

+13
View File
@@ -225,6 +225,14 @@ type paymentDescriptor struct {
// into the log to the HTLC being modified.
EntryType updateType
// noOpSettle is a flag indicating whether a chain of entries resulted
// in an effective no-op settle. That means that the amount was credited
// back to the sender. This is useful as we need a way to mark whether
// the noop add was effective, which can be useful at later stages,
// where we might not be able to re-run the criteria for the
// effectiveness of the noop-add.
noOpSettle bool
// isForwarded denotes if an incoming HTLC has been forwarded to any
// possible upstream peers in the route.
isForwarded bool
@@ -320,3 +328,8 @@ func (pd *paymentDescriptor) setCommitHeight(
)
}
}
// isAdd returns true if the paymentDescriptor is of type Add.
func (pd *paymentDescriptor) isAdd() bool {
return pd.EntryType == Add || pd.EntryType == NoOpAdd
}