Add RPC to show current total available channel capacity #29 (#35)

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:
andrew.shvv
2016-09-15 22:59:51 +04:00
committed by Olaoluwa Osuntokun
parent 4c01e42670
commit 2788dbeaa8
9 changed files with 415 additions and 239 deletions

View File

@@ -420,6 +420,26 @@ func walletBalance(ctx *cli.Context) error {
return nil
}
var ChannelBalanceCommand = cli.Command{
Name: "channelbalance",
Description: "returns the sum of the total available channel balance across all open channels",
Action: channelBalance,
}
func channelBalance(ctx *cli.Context) error {
ctxb := context.Background()
client := getClient(ctx)
req := &lnrpc.ChannelBalanceRequest{}
resp, err := client.ChannelBalance(ctxb, req)
if err != nil {
return err
}
printRespJson(resp)
return nil
}
var GetInfoCommand = cli.Command{
Name: "getinfo",
Description: "returns basic information related to the active daemon",

View File

@@ -56,6 +56,7 @@ func main() {
CloseChannelCommand,
ListPeersCommand,
WalletBalanceCommand,
ChannelBalanceCommand,
ShellCommand,
GetInfoCommand,
PendingChannelsCommand,