invoices: fail HTLCs that target the wrong type of invoice
This commit is contained in:
parent
dba055de2d
commit
b0949054e5
@ -110,6 +110,10 @@ const (
|
|||||||
// payment.
|
// payment.
|
||||||
ResultMppInProgress
|
ResultMppInProgress
|
||||||
|
|
||||||
|
// ResultHtlcInvoiceTypeMismatch is returned when an AMP HTLC targets a
|
||||||
|
// non-AMP invoice and vice versa.
|
||||||
|
ResultHtlcInvoiceTypeMismatch
|
||||||
|
|
||||||
// ResultAmpError is returned when we receive invalid AMP parameters.
|
// ResultAmpError is returned when we receive invalid AMP parameters.
|
||||||
ResultAmpError
|
ResultAmpError
|
||||||
|
|
||||||
@ -176,6 +180,9 @@ func (f FailResolutionResult) FailureString() string {
|
|||||||
case ResultMppInProgress:
|
case ResultMppInProgress:
|
||||||
return "mpp reception in progress"
|
return "mpp reception in progress"
|
||||||
|
|
||||||
|
case ResultHtlcInvoiceTypeMismatch:
|
||||||
|
return "htlc invoice type mismatch"
|
||||||
|
|
||||||
case ResultAmpError:
|
case ResultAmpError:
|
||||||
return "invalid amp parameters"
|
return "invalid amp parameters"
|
||||||
|
|
||||||
|
@ -125,6 +125,21 @@ func updateMpp(ctx *invoiceUpdateCtx,
|
|||||||
inv *channeldb.Invoice) (*channeldb.InvoiceUpdateDesc,
|
inv *channeldb.Invoice) (*channeldb.InvoiceUpdateDesc,
|
||||||
HtlcResolution, error) {
|
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()
|
setID := ctx.setID()
|
||||||
|
|
||||||
// Start building the accept descriptor.
|
// Start building the accept descriptor.
|
||||||
|
Loading…
Reference in New Issue
Block a user