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.
This commit is contained in:
Johan T. Halseth 2017-11-18 16:30:51 -08:00
parent ae7c6c7e8f
commit 6065c763e6
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

View File

@ -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,