mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-29 23:21:12 +02:00
channeldb: validate feature dependencies when adding invoice
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/lightningnetwork/lnd/channeldb/kvdb"
|
||||
"github.com/lightningnetwork/lnd/feature"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch/hop"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
@@ -674,6 +675,11 @@ func validateInvoice(i *Invoice, paymentHash lntypes.Hash) error {
|
||||
return errors.New("invoice must have a feature vector")
|
||||
}
|
||||
|
||||
err := feature.ValidateDeps(i.Terms.Features)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if i.Terms.PaymentPreimage == nil && !i.HodlInvoice {
|
||||
return errors.New("non-hodl invoices must have a preimage")
|
||||
}
|
||||
|
Reference in New Issue
Block a user