mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
rpcserver: prevent overflow in channel count
This commit is contained in:
parent
a6cf6f4237
commit
1664617874
13
rpcserver.go
13
rpcserver.go
@ -1779,16 +1779,21 @@ func (r *rpcServer) fetchActiveChannel(chanPoint wire.OutPoint) (
|
||||
func (r *rpcServer) GetInfo(ctx context.Context,
|
||||
in *lnrpc.GetInfoRequest) (*lnrpc.GetInfoResponse, error) {
|
||||
|
||||
var activeChannels uint32
|
||||
serverPeers := r.server.Peers()
|
||||
for _, serverPeer := range serverPeers {
|
||||
activeChannels += uint32(len(serverPeer.ChannelSnapshots()))
|
||||
}
|
||||
|
||||
openChannels, err := r.server.chanDB.FetchAllOpenChannels()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var activeChannels uint32
|
||||
for _, channel := range openChannels {
|
||||
chanID := lnwire.NewChanIDFromOutPoint(&channel.FundingOutpoint)
|
||||
if r.server.htlcSwitch.HasActiveLink(chanID) {
|
||||
activeChannels++
|
||||
}
|
||||
}
|
||||
|
||||
inactiveChannels := uint32(len(openChannels)) - activeChannels
|
||||
|
||||
pendingChannels, err := r.server.chanDB.FetchPendingChannels()
|
||||
|
Loading…
Reference in New Issue
Block a user