lnrpc+rpcserver: thread GenAmpInvoiceFeatures to invoicesrpc

This commit is contained in:
Conner Fromknecht 2021-05-06 09:15:01 -07:00
parent e97da53676
commit 6a7d3c4b5e
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7
5 changed files with 29 additions and 9 deletions

@ -54,6 +54,10 @@ type AddInvoiceConfig struct {
// GenInvoiceFeatures returns a feature containing feature bits that // GenInvoiceFeatures returns a feature containing feature bits that
// should be advertised on freshly generated invoices. // should be advertised on freshly generated invoices.
GenInvoiceFeatures func() *lnwire.FeatureVector GenInvoiceFeatures func() *lnwire.FeatureVector
// GenAmpInvoiceFeatures returns a feature containing feature bits that
// should be advertised on freshly generated AMP invoices.
GenAmpInvoiceFeatures func() *lnwire.FeatureVector
} }
// AddInvoiceData contains the required data to create a new invoice. // AddInvoiceData contains the required data to create a new invoice.

@ -55,4 +55,8 @@ type Config struct {
// GenInvoiceFeatures returns a feature containing feature bits that // GenInvoiceFeatures returns a feature containing feature bits that
// should be advertised on freshly generated invoices. // should be advertised on freshly generated invoices.
GenInvoiceFeatures func() *lnwire.FeatureVector GenInvoiceFeatures func() *lnwire.FeatureVector
// GenAmpInvoiceFeatures returns a feature containing feature bits that
// should be advertised on freshly generated AMP invoices.
GenAmpInvoiceFeatures func() *lnwire.FeatureVector
} }

@ -316,6 +316,7 @@ func (s *Server) AddHoldInvoice(ctx context.Context,
ChanDB: s.cfg.RemoteChanDB, ChanDB: s.cfg.RemoteChanDB,
Graph: s.cfg.LocalChanDB.ChannelGraph(), Graph: s.cfg.LocalChanDB.ChannelGraph(),
GenInvoiceFeatures: s.cfg.GenInvoiceFeatures, GenInvoiceFeatures: s.cfg.GenInvoiceFeatures,
GenAmpInvoiceFeatures: s.cfg.GenAmpInvoiceFeatures,
} }
hash, err := lntypes.MakeHash(invoice.Hash) hash, err := lntypes.MakeHash(invoice.Hash)

@ -661,6 +661,9 @@ func (r *rpcServer) addDeps(s *server, macService *macaroons.Service,
genInvoiceFeatures := func() *lnwire.FeatureVector { genInvoiceFeatures := func() *lnwire.FeatureVector {
return s.featureMgr.Get(feature.SetInvoice) return s.featureMgr.Get(feature.SetInvoice)
} }
genAmpInvoiceFeatures := func() *lnwire.FeatureVector {
return s.featureMgr.Get(feature.SetInvoiceAmp)
}
var ( var (
subServers []lnrpc.SubServer subServers []lnrpc.SubServer
@ -677,7 +680,8 @@ func (r *rpcServer) addDeps(s *server, macService *macaroons.Service,
s.htlcSwitch, r.cfg.ActiveNetParams.Params, s.chanRouter, s.htlcSwitch, r.cfg.ActiveNetParams.Params, s.chanRouter,
routerBackend, s.nodeSigner, s.localChanDB, s.remoteChanDB, routerBackend, s.nodeSigner, s.localChanDB, s.remoteChanDB,
s.sweeper, tower, s.towerClient, s.anchorTowerClient, s.sweeper, tower, s.towerClient, s.anchorTowerClient,
r.cfg.net.ResolveTCPAddr, genInvoiceFeatures, rpcsLog, r.cfg.net.ResolveTCPAddr, genInvoiceFeatures,
genAmpInvoiceFeatures, rpcsLog,
) )
if err != nil { if err != nil {
return err return err
@ -4796,6 +4800,9 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
GenInvoiceFeatures: func() *lnwire.FeatureVector { GenInvoiceFeatures: func() *lnwire.FeatureVector {
return r.server.featureMgr.Get(feature.SetInvoice) return r.server.featureMgr.Get(feature.SetInvoice)
}, },
GenAmpInvoiceFeatures: func() *lnwire.FeatureVector {
return r.server.featureMgr.Get(feature.SetInvoiceAmp)
},
} }
value, err := lnrpc.UnmarshallAmt(invoice.Value, invoice.ValueMsat) value, err := lnrpc.UnmarshallAmt(invoice.Value, invoice.ValueMsat)

@ -100,6 +100,7 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config,
anchorTowerClient wtclient.Client, anchorTowerClient wtclient.Client,
tcpResolver lncfg.TCPResolver, tcpResolver lncfg.TCPResolver,
genInvoiceFeatures func() *lnwire.FeatureVector, genInvoiceFeatures func() *lnwire.FeatureVector,
genAmpInvoiceFeatures func() *lnwire.FeatureVector,
rpcLogger btclog.Logger) error { rpcLogger btclog.Logger) error {
// First, we'll use reflect to obtain a version of the config struct // First, we'll use reflect to obtain a version of the config struct
@ -230,6 +231,9 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config,
subCfgValue.FieldByName("GenInvoiceFeatures").Set( subCfgValue.FieldByName("GenInvoiceFeatures").Set(
reflect.ValueOf(genInvoiceFeatures), reflect.ValueOf(genInvoiceFeatures),
) )
subCfgValue.FieldByName("GenAmpInvoiceFeatures").Set(
reflect.ValueOf(genAmpInvoiceFeatures),
)
// RouterRPC isn't conditionally compiled and doesn't need to be // RouterRPC isn't conditionally compiled and doesn't need to be
// populated using reflection. // populated using reflection.