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 return nil
} }
var channelBalanceCommand = cli.Command{ var ChannelBalanceCommand = cli.Command{
Name: "channelbalance", Name: "channelbalance",
Category: "Channels", Category: "Channels",
Usage: "Returns the sum of the total available channel balance across " + Usage: "Returns the sum of the total available channel balance across " +
"all open channels.", "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() ctxc := getContext()
client, cleanUp := getClient(ctx) client, cleanUp := getClient(ctx)
defer cleanUp() defer cleanUp()
@ -1482,6 +1486,13 @@ func channelBalance(ctx *cli.Context) error {
return err return err
} }
if respDecorator != nil {
err = respDecorator(ctx, resp)
if err != nil {
return err
}
}
printRespJSON(resp) printRespJSON(resp)
return nil return nil
} }

View File

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