multi: set invoice feature bits using feature manager

This commit is contained in:
Conner Fromknecht committed 2019-12-10 13:09:52 -08:00
1 parent a168f37b9c
commit 1367187454
5 files changed
+33 -14

No files matched your search

+6 -5
View File
@@ -47,6 +47,10 @@ type AddInvoiceConfig struct {
// ChanDB is a global boltdb instance which is needed to access the
// channel graph.
ChanDB *channeldb.DB
// GenInvoiceFeatures returns a feature containing feature bits that
// should be advertised on freshly generated invoices.
GenInvoiceFeatures func() *lnwire.FeatureVector
}
// AddInvoiceData contains the required data to create a new invoice.
@@ -363,11 +367,8 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
}
// Set a blank feature vector, as our invoice generation forbids nil
// features.
invoiceFeatures := lnwire.NewFeatureVector(
lnwire.NewRawFeatureVector(), lnwire.Features,
)
// Set our desired invoice features and add them to our list of options.
invoiceFeatures := cfg.GenInvoiceFeatures()
options = append(options, zpay32.Features(invoiceFeatures))
// Generate and set a random payment address for this invoice. If the
+4
View File
@@ -50,4 +50,8 @@ type Config struct {
// ChanDB is a global boltdb instance which is needed to access the
// channel graph.
ChanDB *channeldb.DB
// GenInvoiceFeatures returns a feature containing feature bits that
// should be advertised on freshly generated invoices.
GenInvoiceFeatures func() *lnwire.FeatureVector
}
+8 -7
View File
@@ -246,13 +246,14 @@ func (s *Server) AddHoldInvoice(ctx context.Context,
invoice *AddHoldInvoiceRequest) (*AddHoldInvoiceResp, error) {
addInvoiceCfg := &AddInvoiceConfig{
AddInvoice: s.cfg.InvoiceRegistry.AddInvoice,
IsChannelActive: s.cfg.IsChannelActive,
ChainParams: s.cfg.ChainParams,
NodeSigner: s.cfg.NodeSigner,
MaxPaymentMSat: s.cfg.MaxPaymentMSat,
DefaultCLTVExpiry: s.cfg.DefaultCLTVExpiry,
ChanDB: s.cfg.ChanDB,
AddInvoice: s.cfg.InvoiceRegistry.AddInvoice,
IsChannelActive: s.cfg.IsChannelActive,
ChainParams: s.cfg.ChainParams,
NodeSigner: s.cfg.NodeSigner,
MaxPaymentMSat: s.cfg.MaxPaymentMSat,
DefaultCLTVExpiry: s.cfg.DefaultCLTVExpiry,
ChanDB: s.cfg.ChanDB,
GenInvoiceFeatures: s.cfg.GenInvoiceFeatures,
}
hash, err := lntypes.MakeHash(invoice.Hash)