rpc+cli: add general ListAliases function to dump all aliases

This commit is contained in:
eugene
2022-07-14 13:51:48 -04:00
parent 48f270fe20
commit aa576adecc
11 changed files with 1574 additions and 1084 deletions

View File

@@ -410,6 +410,11 @@ type LightningClient interface {
//SubscribeCustomMessages subscribes to a stream of incoming custom peer
//messages.
SubscribeCustomMessages(ctx context.Context, in *SubscribeCustomMessagesRequest, opts ...grpc.CallOption) (Lightning_SubscribeCustomMessagesClient, error)
// lncli: `listaliases`
//ListAliases returns the set of all aliases that have ever existed with
//their confirmed SCID (if it exists) and/or the base SCID (in the case of
//zero conf).
ListAliases(ctx context.Context, in *ListAliasesRequest, opts ...grpc.CallOption) (*ListAliasesResponse, error)
}
type lightningClient struct {
@@ -1302,6 +1307,15 @@ func (x *lightningSubscribeCustomMessagesClient) Recv() (*CustomMessage, error)
return m, nil
}
func (c *lightningClient) ListAliases(ctx context.Context, in *ListAliasesRequest, opts ...grpc.CallOption) (*ListAliasesResponse, error) {
out := new(ListAliasesResponse)
err := c.cc.Invoke(ctx, "/lnrpc.Lightning/ListAliases", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// LightningServer is the server API for Lightning service.
// All implementations must embed UnimplementedLightningServer
// for forward compatibility
@@ -1698,6 +1712,11 @@ type LightningServer interface {
//SubscribeCustomMessages subscribes to a stream of incoming custom peer
//messages.
SubscribeCustomMessages(*SubscribeCustomMessagesRequest, Lightning_SubscribeCustomMessagesServer) error
// lncli: `listaliases`
//ListAliases returns the set of all aliases that have ever existed with
//their confirmed SCID (if it exists) and/or the base SCID (in the case of
//zero conf).
ListAliases(context.Context, *ListAliasesRequest) (*ListAliasesResponse, error)
mustEmbedUnimplementedLightningServer()
}
@@ -1900,6 +1919,9 @@ func (UnimplementedLightningServer) SendCustomMessage(context.Context, *SendCust
func (UnimplementedLightningServer) SubscribeCustomMessages(*SubscribeCustomMessagesRequest, Lightning_SubscribeCustomMessagesServer) error {
return status.Errorf(codes.Unimplemented, "method SubscribeCustomMessages not implemented")
}
func (UnimplementedLightningServer) ListAliases(context.Context, *ListAliasesRequest) (*ListAliasesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListAliases not implemented")
}
func (UnimplementedLightningServer) mustEmbedUnimplementedLightningServer() {}
// UnsafeLightningServer may be embedded to opt out of forward compatibility for this service.
@@ -3142,6 +3164,24 @@ func (x *lightningSubscribeCustomMessagesServer) Send(m *CustomMessage) error {
return x.ServerStream.SendMsg(m)
}
func _Lightning_ListAliases_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListAliasesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LightningServer).ListAliases(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/lnrpc.Lightning/ListAliases",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LightningServer).ListAliases(ctx, req.(*ListAliasesRequest))
}
return interceptor(ctx, in, info, handler)
}
// Lightning_ServiceDesc is the grpc.ServiceDesc for Lightning service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -3357,6 +3397,10 @@ var Lightning_ServiceDesc = grpc.ServiceDesc{
MethodName: "SendCustomMessage",
Handler: _Lightning_SendCustomMessage_Handler,
},
{
MethodName: "ListAliases",
Handler: _Lightning_ListAliases_Handler,
},
},
Streams: []grpc.StreamDesc{
{