From 6065c763e691af0b02b05cd89cf5c1882a0ccade Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Sat, 18 Nov 2017 16:30:51 -0800 Subject: [PATCH] rpcserver: only set channel Active=true if added to htlcswitch For a calls to ListChannels we now only set the ActiveChannel.Active=true if the link is found by the htlcswitch. This is done to be able to make it possible to tell if a newly opened channel has been added to the htlcswitch, such that we can synchronize on this during tests before we attempt to close the channel. --- rpcserver.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rpcserver.go b/rpcserver.go index 46e9869b..25f553e1 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1333,6 +1333,12 @@ func (r *rpcServer) ListChannels(ctx context.Context, peerOnline = true } + channelID := lnwire.NewChanIDFromOutPoint(&chanPoint) + var linkActive bool + if _, err := r.server.htlcSwitch.GetLink(channelID); err == nil { + linkActive = true + } + // As this is required for display purposes, we'll calculate // the weight of the commitment transaction. We also add on the // estimated weight of the witness to calculate the weight of @@ -1344,7 +1350,7 @@ func (r *rpcServer) ListChannels(ctx context.Context, commitWeight := commitBaseWeight + lnwallet.WitnessCommitmentTxWeight channel := &lnrpc.ActiveChannel{ - Active: peerOnline, + Active: peerOnline && linkActive, RemotePubkey: nodeID, ChannelPoint: chanPoint.String(), ChanId: chanID,