Skip to content

Commit 1fb3be9

Browse files
committed
invoices: cancel htlc on HtlcModify signal
1 parent 417805a commit 1fb3be9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

invoices/invoiceregistry.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,8 @@ func (i *InvoiceRegistry) notifyExitHopHtlcLocked(
10491049
return nil, nil, err
10501050
}
10511051

1052+
var cancelSet bool
1053+
10521054
// Provide the invoice to the settlement interceptor to allow
10531055
// the interceptor's client an opportunity to manipulate the
10541056
// settlement process.
@@ -1066,6 +1068,8 @@ func (i *InvoiceRegistry) notifyExitHopHtlcLocked(
10661068
if resp.AmountPaid != 0 {
10671069
ctx.amtPaid = resp.AmountPaid
10681070
}
1071+
1072+
cancelSet = resp.CancelSet
10691073
})
10701074
if err != nil {
10711075
err := fmt.Errorf("error during invoice HTLC interception: %w",
@@ -1092,7 +1096,18 @@ func (i *InvoiceRegistry) notifyExitHopHtlcLocked(
10921096
updateDesc.State != nil
10931097

10941098
// Assign resolution to outer scope variable.
1095-
resolution = res
1099+
if cancelSet {
1100+
// If a cancel signal was set for the htlc set, we set
1101+
// the resolution as a failure with an underpayment
1102+
// indication. Something was wrong with this htlc, so
1103+
// we probably can't settle the invoice at all.
1104+
resolution = NewFailResolution(
1105+
ctx.circuitKey, ctx.currentHeight,
1106+
ResultAmountTooLow,
1107+
)
1108+
} else {
1109+
resolution = res
1110+
}
10961111

10971112
return updateDesc, nil
10981113
}

0 commit comments

Comments
 (0)