Merge pull request #6734 from Crypt-iQ/alias_listchannels
rpc: add alias info to some rpcs
This commit is contained in:
12 files changed
+3986
-3328
No files matched your search
@@ -399,6 +399,23 @@ func (m *Manager) RequestAlias() (lnwire.ShortChannelID, error) {
|
||||
return nextAlias, nil
|
||||
}
|
||||
|
||||
// ListAliases returns a carbon copy of baseToSet. This is used by the rpc
|
||||
// layer.
|
||||
func (m *Manager) ListAliases() map[lnwire.ShortChannelID][]lnwire.ShortChannelID {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
|
||||
baseCopy := make(map[lnwire.ShortChannelID][]lnwire.ShortChannelID)
|
||||
|
||||
for k, v := range m.baseToSet {
|
||||
setCopy := make([]lnwire.ShortChannelID, len(v))
|
||||
copy(setCopy, v)
|
||||
baseCopy[k] = setCopy
|
||||
}
|
||||
|
||||
return baseCopy
|
||||
}
|
||||
|
||||
// getNextScid is a utility function that returns the next SCID for a given
|
||||
// alias SCID. The BlockHeight ranges from [16000000, 16250000], the TxIndex
|
||||
// ranges from [1, 16777215], and the TxPosition ranges from [1, 65535].
|
||||
|
||||
@@ -1419,6 +1419,31 @@ var listChannelsCommand = cli.Command{
|
||||
Action: actionDecorator(listChannels),
|
||||
}
|
||||
|
||||
var listAliasesCommand = cli.Command{
|
||||
Name: "listaliases",
|
||||
Category: "Channels",
|
||||
Usage: "List all aliases.",
|
||||
Flags: []cli.Flag{},
|
||||
Action: actionDecorator(listaliases),
|
||||
}
|
||||
|
||||
func listaliases(ctx *cli.Context) error {
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
req := &lnrpc.ListAliasesRequest{}
|
||||
|
||||
resp, err := client.ListAliases(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printRespJSON(resp)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func listChannels(ctx *cli.Context) error {
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
|
||||
@@ -414,6 +414,7 @@ func main() {
|
||||
sendCustomCommand,
|
||||
subscribeCustomCommand,
|
||||
fishCompletionCommand,
|
||||
listAliasesCommand,
|
||||
}
|
||||
|
||||
// Add any extra commands determined by build flags.
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
### Zero-Conf Channel Opens
|
||||
* [Introduces support for zero-conf channel opens and non-zero-conf option_scid_alias channels.](https://github.com/lightningnetwork/lnd/pull/5955)
|
||||
|
||||
* [The `listchannels` and `closedchannels` APIs have been updated to return alias and zero-conf
|
||||
information. A new `listaliases` API has also been added that returns a data dump of all
|
||||
existing alias info.](https://github.com/lightningnetwork/lnd/pull/6734)
|
||||
|
||||
## Build system
|
||||
|
||||
* [Add the release build directory to the `.gitignore` file to avoid the release
|
||||
|
||||
+3590
-3327
File diff suppressed because it is too large.
Load diff
@@ -2354,6 +2354,24 @@ func request_Lightning_SubscribeCustomMessages_0(ctx context.Context, marshaler
|
||||
|
||||
}
|
||||
|
||||
func request_Lightning_ListAliases_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq ListAliasesRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := client.ListAliases(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Lightning_ListAliases_0(ctx context.Context, marshaler runtime.Marshaler, server LightningServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq ListAliasesRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := server.ListAliases(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterLightningHandlerServer registers the http handlers for service Lightning to "mux".
|
||||
// UnaryRPC :call LightningServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
@@ -3640,6 +3658,29 @@ func RegisterLightningHandlerServer(ctx context.Context, mux *runtime.ServeMux,
|
||||
return
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Lightning_ListAliases_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/lnrpc.Lightning/ListAliases", runtime.WithHTTPPathPattern("/v1/aliases/list"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Lightning_ListAliases_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Lightning_ListAliases_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -4961,6 +5002,26 @@ func RegisterLightningHandlerClient(ctx context.Context, mux *runtime.ServeMux,
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Lightning_ListAliases_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/lnrpc.Lightning/ListAliases", runtime.WithHTTPPathPattern("/v1/aliases/list"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Lightning_ListAliases_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Lightning_ListAliases_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -5092,6 +5153,8 @@ var (
|
||||
pattern_Lightning_SendCustomMessage_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "custommessage"}, ""))
|
||||
|
||||
pattern_Lightning_SubscribeCustomMessages_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "custommessage", "subscribe"}, ""))
|
||||
|
||||
pattern_Lightning_ListAliases_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "aliases", "list"}, ""))
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -5222,4 +5285,6 @@ var (
|
||||
forward_Lightning_SendCustomMessage_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Lightning_SubscribeCustomMessages_0 = runtime.ForwardResponseStream
|
||||
|
||||
forward_Lightning_ListAliases_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
@@ -1700,4 +1700,29 @@ func RegisterLightningJSONCallbacks(registry map[string]func(ctx context.Context
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
registry["lnrpc.Lightning.ListAliases"] = func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
||||
|
||||
req := &ListAliasesRequest{}
|
||||
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
client := NewLightningClient(conn)
|
||||
resp, err := client.ListAliases(ctx, req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
respBytes, err := marshaler.Marshal(resp)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
callback(string(respBytes), nil)
|
||||
}
|
||||
}
|
||||
@@ -570,6 +570,13 @@ service Lightning {
|
||||
*/
|
||||
rpc SubscribeCustomMessages (SubscribeCustomMessagesRequest)
|
||||
returns (stream CustomMessage);
|
||||
|
||||
/* 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).
|
||||
*/
|
||||
rpc ListAliases (ListAliasesRequest) returns (ListAliasesResponse);
|
||||
}
|
||||
|
||||
message SubscribeCustomMessagesRequest {
|
||||
@@ -1482,6 +1489,18 @@ message Channel {
|
||||
|
||||
// List constraints for the remote node.
|
||||
ChannelConstraints remote_constraints = 30;
|
||||
|
||||
/*
|
||||
This lists out the set of alias short channel ids that exist for a channel.
|
||||
This may be empty.
|
||||
*/
|
||||
repeated uint64 alias_scids = 31;
|
||||
|
||||
// Whether or not this is a zero-conf channel.
|
||||
bool zero_conf = 32;
|
||||
|
||||
// This is the confirmed / on-chain zero-conf SCID.
|
||||
uint64 zero_conf_confirmed_scid = 33;
|
||||
}
|
||||
|
||||
message ListChannelsRequest {
|
||||
@@ -1501,6 +1520,22 @@ message ListChannelsResponse {
|
||||
repeated Channel channels = 11;
|
||||
}
|
||||
|
||||
message AliasMap {
|
||||
/*
|
||||
For non-zero-conf channels, this is the confirmed SCID. Otherwise, this is
|
||||
the first assigned "base" alias.
|
||||
*/
|
||||
uint64 base_scid = 1;
|
||||
|
||||
// The set of all aliases stored for the base SCID.
|
||||
repeated uint64 aliases = 2;
|
||||
}
|
||||
message ListAliasesRequest {
|
||||
}
|
||||
message ListAliasesResponse {
|
||||
repeated AliasMap alias_maps = 1;
|
||||
}
|
||||
|
||||
enum Initiator {
|
||||
INITIATOR_UNKNOWN = 0;
|
||||
INITIATOR_LOCAL = 1;
|
||||
@@ -1565,6 +1600,15 @@ message ChannelCloseSummary {
|
||||
Initiator close_initiator = 12;
|
||||
|
||||
repeated Resolution resolutions = 13;
|
||||
|
||||
/*
|
||||
This lists out the set of alias short channel ids that existed for the
|
||||
closed channel. This may be empty.
|
||||
*/
|
||||
repeated uint64 alias_scids = 14;
|
||||
|
||||
// The confirmed SCID for a zero-conf channel.
|
||||
uint64 zero_conf_confirmed_scid = 15 [jstype = JS_STRING];
|
||||
}
|
||||
|
||||
enum ResolutionType {
|
||||
|
||||
@@ -16,6 +16,29 @@
|
||||
"application/json"
|
||||
],
|
||||
"paths": {
|
||||
"/v1/aliases/list": {
|
||||
"get": {
|
||||
"summary": "lncli: `listaliases`\nListAliases returns the set of all aliases that have ever existed with\ntheir confirmed SCID (if it exists) and/or the base SCID (in the case of\nzero conf).",
|
||||
"operationId": "Lightning_ListAliases",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/lnrpcListAliasesResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/rpcStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"Lightning"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/v1/balance/blockchain": {
|
||||
"get": {
|
||||
"summary": "lncli: `walletbalance`\nWalletBalance returns total unspent outputs(confirmed and unconfirmed), all\nconfirmed unspent outputs and all unconfirmed unspent outputs under control\nof the wallet.",
|
||||
@@ -2951,6 +2974,24 @@
|
||||
"description": "- `p2wkh`: Pay to witness key hash (`WITNESS_PUBKEY_HASH` = 0)\n- `np2wkh`: Pay to nested witness key hash (`NESTED_PUBKEY_HASH` = 1)\n- `p2tr`: Pay to taproot pubkey (`TAPROOT_PUBKEY` = 4)",
|
||||
"title": "`AddressType` has to be one of:"
|
||||
},
|
||||
"lnrpcAliasMap": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"base_scid": {
|
||||
"type": "string",
|
||||
"format": "uint64",
|
||||
"description": "For non-zero-conf channels, this is the confirmed SCID. Otherwise, this is\nthe first assigned \"base\" alias."
|
||||
},
|
||||
"aliases": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"format": "uint64"
|
||||
},
|
||||
"description": "The set of all aliases stored for the base SCID."
|
||||
}
|
||||
}
|
||||
},
|
||||
"lnrpcAmount": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -3291,6 +3332,23 @@
|
||||
"remote_constraints": {
|
||||
"$ref": "#/definitions/lnrpcChannelConstraints",
|
||||
"description": "List constraints for the remote node."
|
||||
},
|
||||
"alias_scids": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"format": "uint64"
|
||||
},
|
||||
"description": "This lists out the set of alias short channel ids that exist for a channel.\nThis may be empty."
|
||||
},
|
||||
"zero_conf": {
|
||||
"type": "boolean",
|
||||
"description": "Whether or not this is a zero-conf channel."
|
||||
},
|
||||
"zero_conf_confirmed_scid": {
|
||||
"type": "string",
|
||||
"format": "uint64",
|
||||
"description": "This is the confirmed / on-chain zero-conf SCID."
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -3550,6 +3608,19 @@
|
||||
"items": {
|
||||
"$ref": "#/definitions/lnrpcResolution"
|
||||
}
|
||||
},
|
||||
"alias_scids": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"format": "uint64"
|
||||
},
|
||||
"description": "This lists out the set of alias short channel ids that existed for the\nclosed channel. This may be empty."
|
||||
},
|
||||
"zero_conf_confirmed_scid": {
|
||||
"type": "string",
|
||||
"format": "uint64",
|
||||
"description": "The confirmed SCID for a zero-conf channel."
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -4987,6 +5058,17 @@
|
||||
},
|
||||
"description": "An individual vertex/node within the channel graph. A node is\nconnected to other nodes by one or more channel edges emanating from it. As the\ngraph is directed, a node will also have an incoming edge attached to it for\neach outgoing edge."
|
||||
},
|
||||
"lnrpcListAliasesResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"alias_maps": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/lnrpcAliasMap"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"lnrpcListChannelsResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -160,3 +160,5 @@ http:
|
||||
body: "*"
|
||||
- selector: lnrpc.Lightning.SubscribeCustomMessages
|
||||
get: "/v1/custommessage/subscribe"
|
||||
- selector: lnrpc.Lightning.ListAliases
|
||||
get: "/v1/aliases/list"
|
||||
@@ -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{
|
||||
{
|
||||
|
||||
+87
-1
@@ -576,6 +576,10 @@ func MainRPCServerPermissions() map[string][]bakery.Op {
|
||||
Entity: "offchain",
|
||||
Action: "read",
|
||||
}},
|
||||
"/lnrpc.Lightning/ListAliases": {{
|
||||
Entity: "offchain",
|
||||
Action: "read",
|
||||
}},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4029,12 +4033,17 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
|
||||
// Extract the commitment type from the channel type flags.
|
||||
commitmentType := rpcCommitmentType(dbChannel.ChanType)
|
||||
|
||||
dbScid := dbChannel.ShortChannelID
|
||||
|
||||
// Fetch the set of aliases for the channel.
|
||||
channelAliases := r.server.aliasMgr.GetAliases(dbScid)
|
||||
|
||||
channel := &lnrpc.Channel{
|
||||
Active: isActive,
|
||||
Private: isPrivate(dbChannel),
|
||||
RemotePubkey: nodeID,
|
||||
ChannelPoint: chanPoint.String(),
|
||||
ChanId: dbChannel.ShortChannelID.ToUint64(),
|
||||
ChanId: dbScid.ToUint64(),
|
||||
Capacity: int64(dbChannel.Capacity),
|
||||
LocalBalance: int64(localBalance.ToSatoshis()),
|
||||
RemoteBalance: int64(remoteBalance.ToSatoshis()),
|
||||
@@ -4056,12 +4065,22 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
|
||||
RemoteConstraints: createChannelConstraint(
|
||||
&dbChannel.RemoteChanCfg,
|
||||
),
|
||||
AliasScids: make([]uint64, 0, len(channelAliases)),
|
||||
ZeroConf: dbChannel.IsZeroConf(),
|
||||
ZeroConfConfirmedScid: dbChannel.ZeroConfRealScid().ToUint64(),
|
||||
// TODO: remove the following deprecated fields
|
||||
CsvDelay: uint32(dbChannel.LocalChanCfg.CsvDelay),
|
||||
LocalChanReserveSat: int64(dbChannel.LocalChanCfg.ChanReserve),
|
||||
RemoteChanReserveSat: int64(dbChannel.RemoteChanCfg.ChanReserve),
|
||||
}
|
||||
|
||||
// Populate the set of aliases.
|
||||
for _, chanAlias := range channelAliases {
|
||||
channel.AliasScids = append(
|
||||
channel.AliasScids, chanAlias.ToUint64(),
|
||||
)
|
||||
}
|
||||
|
||||
for i, htlc := range localCommit.Htlcs {
|
||||
var rHash [32]byte
|
||||
copy(rHash[:], htlc.RHash[:])
|
||||
@@ -4227,6 +4246,11 @@ func (r *rpcServer) createRPCClosedChannel(
|
||||
closeType = lnrpc.ChannelCloseSummary_ABANDONED
|
||||
}
|
||||
|
||||
dbScid := dbChannel.ShortChanID
|
||||
|
||||
// Fetch the set of aliases for this channel.
|
||||
channelAliases := r.server.aliasMgr.GetAliases(dbScid)
|
||||
|
||||
channel := &lnrpc.ChannelCloseSummary{
|
||||
Capacity: int64(dbChannel.Capacity),
|
||||
RemotePubkey: nodeID,
|
||||
@@ -4240,6 +4264,37 @@ func (r *rpcServer) createRPCClosedChannel(
|
||||
ClosingTxHash: dbChannel.ClosingTXID.String(),
|
||||
OpenInitiator: openInit,
|
||||
CloseInitiator: closeInitiator,
|
||||
AliasScids: make([]uint64, 0, len(channelAliases)),
|
||||
}
|
||||
|
||||
// Populate the set of aliases.
|
||||
for _, chanAlias := range channelAliases {
|
||||
channel.AliasScids = append(
|
||||
channel.AliasScids, chanAlias.ToUint64(),
|
||||
)
|
||||
}
|
||||
|
||||
// Populate any historical data that the summary needs.
|
||||
histChan, err := r.server.chanStateDB.FetchHistoricalChannel(
|
||||
&dbChannel.ChanPoint,
|
||||
)
|
||||
switch err {
|
||||
// The channel was closed in a pre-historic version of lnd. Ignore the
|
||||
// error.
|
||||
case channeldb.ErrNoHistoricalBucket:
|
||||
case channeldb.ErrChannelNotFound:
|
||||
|
||||
case nil:
|
||||
if histChan.IsZeroConf() && histChan.ZeroConfConfirmed() {
|
||||
// If the channel was zero-conf, it may have confirmed.
|
||||
// Populate the confirmed SCID if so.
|
||||
confirmedScid := histChan.ZeroConfRealScid().ToUint64()
|
||||
channel.ZeroConfConfirmedScid = confirmedScid
|
||||
}
|
||||
|
||||
// Non-nil error not due to older versions of lnd.
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
|
||||
reports, err := r.server.miscDB.FetchChannelReports(
|
||||
@@ -7677,6 +7732,37 @@ func (r *rpcServer) SubscribeCustomMessages(req *lnrpc.SubscribeCustomMessagesRe
|
||||
}
|
||||
}
|
||||
|
||||
// ListAliases returns the set of all aliases we have ever allocated along with
|
||||
// their base SCID's and possibly a separate confirmed SCID in the case of
|
||||
// zero-conf.
|
||||
func (r *rpcServer) ListAliases(ctx context.Context,
|
||||
in *lnrpc.ListAliasesRequest) (*lnrpc.ListAliasesResponse, error) {
|
||||
|
||||
// Fetch the map of all aliases.
|
||||
mapAliases := r.server.aliasMgr.ListAliases()
|
||||
|
||||
// Fill out the response. This does not include the zero-conf confirmed
|
||||
// SCID. Doing so would require more database lookups and it can be
|
||||
// cross-referenced with the output of listchannels/closedchannels.
|
||||
resp := &lnrpc.ListAliasesResponse{
|
||||
AliasMaps: make([]*lnrpc.AliasMap, 0),
|
||||
}
|
||||
|
||||
for base, set := range mapAliases {
|
||||
rpcMap := &lnrpc.AliasMap{
|
||||
BaseScid: base.ToUint64(),
|
||||
}
|
||||
for _, alias := range set {
|
||||
rpcMap.Aliases = append(
|
||||
rpcMap.Aliases, alias.ToUint64(),
|
||||
)
|
||||
}
|
||||
resp.AliasMaps = append(resp.AliasMaps, rpcMap)
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// rpcInitiator returns the correct lnrpc initiator for channels where we have
|
||||
// a record of the opening channel.
|
||||
func rpcInitiator(isInitiator bool) lnrpc.Initiator {
|
||||
|
||||
Reference in new issue
Block a user