invoices: fail HTLCs that target the wrong type of invoice

This commit is contained in:
Conner Fromknecht committed 2021-05-10 22:02:14 -07:00
1 parent dba055de2d
commit b0949054e5
2 files changed
+22

No files matched your search

+15
View File
@@ -125,6 +125,21 @@ func updateMpp(ctx *invoiceUpdateCtx,
inv *channeldb.Invoice) (*channeldb.InvoiceUpdateDesc,
HtlcResolution, error) {
// Reject HTLCs to AMP invoices if they are missing an AMP payload, and
// HTLCs to MPP invoices if they have an AMP payload.
switch {
case inv.Terms.Features.RequiresFeature(lnwire.AMPRequired) &&
ctx.amp == nil:
return nil, ctx.failRes(ResultHtlcInvoiceTypeMismatch), nil
case !inv.Terms.Features.RequiresFeature(lnwire.AMPRequired) &&
ctx.amp != nil:
return nil, ctx.failRes(ResultHtlcInvoiceTypeMismatch), nil
}
setID := ctx.setID()
// Start building the accept descriptor.