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 committed 2022-01-24 17:42:59 +01:00
1 parent 825422a82a
commit 1a8f094503
15 files changed
+1232 -1

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
// Code generated by falafel 0.9.1. DO NOT EDIT.
// source: dev.proto
// +build js
package devrpc
import (
"context"
gateway "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/lightningnetwork/lnd/lnrpc"
"google.golang.org/grpc"
"google.golang.org/protobuf/encoding/protojson"
)
func RegisterDevJSONCallbacks(registry map[string]func(ctx context.Context,
conn *grpc.ClientConn, reqJSON string, callback func(string, error))) {
marshaler := &gateway.JSONPb{
MarshalOptions: protojson.MarshalOptions{
UseProtoNames: true,
EmitUnpopulated: true,
},
}
registry["devrpc.Dev.ImportGraph"] = func(ctx context.Context,
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
req := &lnrpc.ChannelGraph{}
err := marshaler.Unmarshal([]byte(reqJSON), req)
if err != nil {
callback("", err)
return
}
client := NewDevClient(conn)
resp, err := client.ImportGraph(ctx, req)
if err != nil {
callback("", err)
return
}
respBytes, err := marshaler.Marshal(resp)
if err != nil {
callback("", err)
return
}
callback(string(respBytes), nil)
}
}