mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-03 20:16:02 +02:00
This commit adds a new RPC command: `channelbalance` which returns the sum of all available channel capacity across all open channels. The total balance is currently returned in units of `satoshis`. Additionally the `networkHarness` has been modified slightly to allow specifying the additional "extra" command line parameters when creating the initial seed nodes. Minor refactoring within the integration tests has been undertaken in order to increase code re-use across tests. Closes #29.
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
4c01e42670
commit
2788dbeaa8
14
rpcserver.go
14
rpcserver.go
@ -385,6 +385,20 @@ func (r *rpcServer) WalletBalance(ctx context.Context,
|
||||
return &lnrpc.WalletBalanceResponse{balance.ToBTC()}, nil
|
||||
}
|
||||
|
||||
|
||||
func (r *rpcServer) ChannelBalance(ctx context.Context,
|
||||
in *lnrpc.ChannelBalanceRequest) (*lnrpc.ChannelBalanceResponse, error) {
|
||||
|
||||
var balance btcutil.Amount
|
||||
for _, peer := range r.server.Peers() {
|
||||
for _, snapshot := range peer.ChannelSnapshots() {
|
||||
balance += snapshot.LocalBalance
|
||||
}
|
||||
}
|
||||
|
||||
return &lnrpc.ChannelBalanceResponse{Balance: int64(balance)}, nil
|
||||
}
|
||||
|
||||
// PendingChannels returns a list of all the channels that are currently
|
||||
// considered "pending". A channel is pending if it has finished the funding
|
||||
// workflow and is waiting for confirmations for the funding txn, or is in the
|
||||
|
Reference in New Issue
Block a user