invoicesrpc: create sub server

Sub server implementation is still empty. This is a preparatory
step for adding invoice functionality.
This commit is contained in:
Joost Jager committed 2019-02-01 09:42:35 +01:00
1 parent bacd92418a
commit 3545685177
11 files changed
+321 -3

No files matched your search

+15 -1
View File
@@ -5,8 +5,10 @@ import (
"reflect"
"github.com/lightningnetwork/lnd/autopilot"
"github.com/lightningnetwork/lnd/invoices"
"github.com/lightningnetwork/lnd/lnrpc/autopilotrpc"
"github.com/lightningnetwork/lnd/lnrpc/chainrpc"
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
"github.com/lightningnetwork/lnd/macaroons"
@@ -37,6 +39,10 @@ type subRPCServerConfigs struct {
// client to be notified of certain on-chain events (new blocks,
// confirmations, spends).
ChainRPC *chainrpc.Config `group:"chainrpc" namespace:"chainrpc"`
// InvoicesRPC is a sub-RPC server that exposes invoice related methods
// as a gRPC service.
InvoicesRPC *invoicesrpc.Config `group:"invoicesrpc" namespace:"invoicesrpc"`
}
// PopulateDependencies attempts to iterate through all the sub-server configs
@@ -47,7 +53,8 @@ type subRPCServerConfigs struct {
// FetchConfig method.
func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl,
networkDir string, macService *macaroons.Service,
atpl *autopilot.Manager) error {
atpl *autopilot.Manager,
invoiceRegistry *invoices.InvoiceRegistry) error {
// First, we'll use reflect to obtain a version of the config struct
// that allows us to programmatically inspect its fields.
@@ -125,6 +132,13 @@ func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl,
reflect.ValueOf(cc.chainNotifier),
)
case *invoicesrpc.Config:
subCfgValue := extractReflectValue(cfg)
subCfgValue.FieldByName("InvoiceRegistry").Set(
reflect.ValueOf(invoiceRegistry),
)
default:
return fmt.Errorf("unknown field: %v, %T", fieldName,
cfg)