rpcserver: fix nil issue with historical channels [skip ci]

Fixes #5796.
Some historical channels might not have the forwarding packages
recorded. And since the error might be silenced, the historical channel
might be nil.
This commit is contained in:
Oliver Gugger 2021-09-27 22:21:50 +02:00
parent be2566cf26
commit e067dc73b7
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

View File

@ -3233,23 +3233,23 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
historical.ChanType,
)
// Get the number of forwarding packages from the
// historical channel.
fwdPkgs, err := historical.LoadFwdPkgs()
if err != nil {
rpcsLog.Errorf("unable to load forwarding "+
"packages for channel:%s, %v",
historical.ShortChannelID, err)
return nil, err
}
channel.NumForwardingPackages = int64(len(fwdPkgs))
// If the error is non-nil, and not due to older versions of lnd
// not persisting historical channels, return it.
default:
return nil, err
}
// Get the number of forwarding packages from the historical
// channel.
fwdPkgs, err := historical.LoadFwdPkgs()
if err != nil {
rpcsLog.Errorf("unable to load forwarding packages "+
"for channel:%s, %v",
historical.ShortChannelID, err)
return nil, err
}
channel.NumForwardingPackages = int64(len(fwdPkgs))
closeTXID := pendingClose.ClosingTXID.String()
switch pendingClose.CloseType {