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 committed 2021-09-27 22:26:03 +02:00
1 parent be2566cf26
commit e067dc73b7
1 file changed
+11 -11
+11 -11
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 {