cmd: expose ChannelBalance for decoration

This commit is contained in:
Olaoluwa Osuntokun 2024-04-25 17:17:20 -07:00
parent 675931ac9a
commit 7a3246855f
2 changed files with 15 additions and 4 deletions

View File

@ -1463,15 +1463,19 @@ func walletBalance(ctx *cli.Context) error {
return nil
}
var channelBalanceCommand = cli.Command{
var ChannelBalanceCommand = cli.Command{
Name: "channelbalance",
Category: "Channels",
Usage: "Returns the sum of the total available channel balance across " +
"all open channels.",
Action: actionDecorator(channelBalance),
Action: actionDecorator(func(c *cli.Context) error {
return ChannelBalance(c, nil)
}),
}
func channelBalance(ctx *cli.Context) error {
func ChannelBalance(ctx *cli.Context,
respDecorator ResponseDecorator[*lnrpc.ChannelBalanceResponse]) error {
ctxc := getContext()
client, cleanUp := getClient(ctx)
defer cleanUp()
@ -1482,6 +1486,13 @@ func channelBalance(ctx *cli.Context) error {
return err
}
if respDecorator != nil {
err = respDecorator(ctx, resp)
if err != nil {
return err
}
}
printRespJSON(resp)
return nil
}

View File

@ -458,7 +458,7 @@ func Main() {
abandonChannelCommand,
listPeersCommand,
walletBalanceCommand,
channelBalanceCommand,
ChannelBalanceCommand,
getInfoCommand,
getDebugInfoCommand,
encryptDebugPackageCommand,