From 29f1fda60d54f227bffdff6fde8e98256d0dea6d Mon Sep 17 00:00:00 2001 From: Vadym Popov Date: Sun, 1 Apr 2018 02:40:50 +0300 Subject: [PATCH] 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 --- rpcserver.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index cec89b6c..d6332e01 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -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