rpcserver: include a pending_open_balance in channelbalance response

Changes in `ChannelBalance` rpcserver method implementation to
add `pending_open_balance` counted according state of opened channel
This commit is contained in:
Vadym Popov 2018-04-01 02:40:50 +03:00
parent 66224e6bf8
commit 29f1fda60d
No known key found for this signature in database
GPG Key ID: 80A808D6A76EE753

View File

@ -1330,14 +1330,19 @@ func (r *rpcServer) ChannelBalance(ctx context.Context,
return nil, err
}
var balance btcutil.Amount
var pendingOpenBalance, balance btcutil.Amount
for _, channel := range channels {
if !channel.IsPending {
if channel.IsPending {
pendingOpenBalance += channel.LocalCommitment.LocalBalance.ToSatoshis()
} else {
balance += channel.LocalCommitment.LocalBalance.ToSatoshis()
}
}
return &lnrpc.ChannelBalanceResponse{Balance: int64(balance)}, nil
return &lnrpc.ChannelBalanceResponse{
Balance: int64(balance),
PendingOpenBalance: int64(pendingOpenBalance),
}, nil
}
// PendingChannels returns a list of all the channels that are currently