peer: only return a channel snapshot if the channel can route

In this commit, we fix a slight miscalculation within the GetInfo call.
Before this commit, we would list any channel that the peer knew of as
active, instead of those which are, well, actually *active*. We fix
this by skipping any channels that we don’t have the remote revocation
for.
This commit is contained in:
Olaoluwa Osuntokun 2018-02-08 19:40:48 -08:00
parent 1b504b6041
commit 2e090ee2ab
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -1160,6 +1160,12 @@ func (p *peer) ChannelSnapshots() []*channeldb.ChannelSnapshot {
snapshots := make([]*channeldb.ChannelSnapshot, 0, len(p.activeChannels))
for _, activeChan := range p.activeChannels {
// We'll only return a snapshot for channels that are
// *immedately* available for routing payments over.
if activeChan.RemoteNextRevocation() == nil {
continue
}
snapshot := activeChan.StateSnapshot()
snapshots = append(snapshots, snapshot)
}