mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
rpcserver: enrich ListChannels with peer alias
This commit is contained in:
parent
9d048ecd6a
commit
3e5943b7f9
19
rpcserver.go
19
rpcserver.go
@ -4017,7 +4017,9 @@ func (r *rpcServer) ListChannels(ctx context.Context,
|
||||
// Next, we'll determine whether we should add this channel to
|
||||
// our list depending on the type of channels requested to us.
|
||||
isActive := peerOnline && linkActive
|
||||
channel, err := createRPCOpenChannel(r, dbChannel, isActive)
|
||||
channel, err := createRPCOpenChannel(
|
||||
r, dbChannel, isActive, in.PeerAliasLookup,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -4066,7 +4068,6 @@ func rpcCommitmentType(chanType channeldb.ChannelType) lnrpc.CommitmentType {
|
||||
// *Channeldb.ChannelConfig.
|
||||
func createChannelConstraint(
|
||||
chanCfg *channeldb.ChannelConfig) *lnrpc.ChannelConstraints {
|
||||
|
||||
return &lnrpc.ChannelConstraints{
|
||||
CsvDelay: uint32(chanCfg.CsvDelay),
|
||||
ChanReserveSat: uint64(chanCfg.ChanReserve),
|
||||
@ -4088,7 +4089,7 @@ func isPrivate(dbChannel *channeldb.OpenChannel) bool {
|
||||
|
||||
// createRPCOpenChannel creates an *lnrpc.Channel from the *channeldb.Channel.
|
||||
func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
|
||||
isActive bool) (*lnrpc.Channel, error) {
|
||||
isActive, peerAliasLookup bool) (*lnrpc.Channel, error) {
|
||||
|
||||
nodePub := dbChannel.IdentityPub
|
||||
nodeID := hex.EncodeToString(nodePub.SerializeCompressed())
|
||||
@ -4164,6 +4165,16 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
|
||||
RemoteChanReserveSat: int64(dbChannel.RemoteChanCfg.ChanReserve),
|
||||
}
|
||||
|
||||
// Look up our channel peer's node alias if the caller requests it.
|
||||
if peerAliasLookup {
|
||||
peerAlias, err := r.server.graphDB.LookupAlias(nodePub)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to lookup peer "+
|
||||
"alias: %w", err)
|
||||
}
|
||||
channel.PeerAlias = peerAlias
|
||||
}
|
||||
|
||||
// Populate the set of aliases.
|
||||
for _, chanAlias := range channelAliases {
|
||||
channel.AliasScids = append(
|
||||
@ -4576,7 +4587,7 @@ func (r *rpcServer) SubscribeChannelEvents(req *lnrpc.ChannelEventSubscription,
|
||||
}
|
||||
case channelnotifier.OpenChannelEvent:
|
||||
channel, err := createRPCOpenChannel(
|
||||
r, event.Channel, true,
|
||||
r, event.Channel, true, false,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user