Merge pull request #5797 from guggero/fix-nil-channel

rpcserver: fix nil issue with historical channels
This commit is contained in:
Oliver Gugger 2021-09-28 11:02:12 +02:00 committed by GitHub
commit 410606b082
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3234,23 +3234,23 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
historical.ChanType, 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 // If the error is non-nil, and not due to older versions of lnd
// not persisting historical channels, return it. // not persisting historical channels, return it.
default: default:
return nil, err 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() closeTXID := pendingClose.ClosingTXID.String()
switch pendingClose.CloseType { switch pendingClose.CloseType {