lnrpc: add the devrpc development only subserver + devrpc.ImportGraph

This commits adds the devrpc package which implements a subserver that
adds clean separation for RPC calls useful for development and
debugging. This subserver is only compiled in if the dev tag is set.
Furthermore the commit adds the devrpc.ImportGraph call which can
import a graph dump obtained from another node by calling DescribeGraph.
Since the graph dump does not include the auth proofs, the imported
channels will be considered private.
This commit is contained in:
Andras Banki-Horvath
2022-01-19 20:51:10 +01:00
parent 825422a82a
commit 1a8f094503
15 changed files with 1232 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import (
"github.com/lightningnetwork/lnd/lncfg"
"github.com/lightningnetwork/lnd/lnrpc/autopilotrpc"
"github.com/lightningnetwork/lnd/lnrpc/chainrpc"
"github.com/lightningnetwork/lnd/lnrpc/devrpc"
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
@ -74,6 +75,11 @@ type subRPCServerConfigs struct {
// instance within lnd in order to add, remove, list registered client
// towers, etc.
WatchtowerClientRPC *wtclientrpc.Config `group:"wtclientrpc" namespace:"wtclientrpc"`
// DevRPC is a sub-RPC server that exposes functionality that allows
// developers manipulate LND state that is normally not possible.
// Should only be used for development purposes.
DevRPC *devrpc.Config `group:"devrpc" namespace:"devrpc"`
}
// PopulateDependencies attempts to iterate through all the sub-server configs
@ -270,6 +276,17 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config,
reflect.ValueOf(rpcLogger),
)
case *devrpc.Config:
subCfgValue := extractReflectValue(subCfg)
subCfgValue.FieldByName("ActiveNetParams").Set(
reflect.ValueOf(activeNetParams),
)
subCfgValue.FieldByName("GraphDB").Set(
reflect.ValueOf(graphDB),
)
default:
return fmt.Errorf("unknown field: %v, %T", fieldName,
cfg)