channeldb/invoice: allow creating AMP invoices w/o preiamge

This commit is contained in:
Conner Fromknecht 2021-03-24 19:52:38 -07:00
parent ea934e1be9
commit cfa9e954c7
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

View File

@ -719,7 +719,12 @@ func validateInvoice(i *Invoice, paymentHash lntypes.Hash) error {
return err
}
if i.Terms.PaymentPreimage == nil && !i.HodlInvoice {
// AMP invoices and hodl invoices are allowed to have no preimage
// specified.
isAMP := i.Terms.Features.HasFeature(
lnwire.AMPOptional,
)
if i.Terms.PaymentPreimage == nil && !(i.HodlInvoice || isAMP) {
return errors.New("non-hodl invoices must have a preimage")
}