mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-18 21:35:24 +01:00
lncli: adds list addresses cli command
This commit is contained in:
parent
dba77edf2a
commit
2f20012af6
@ -43,6 +43,16 @@ var (
|
||||
importPubKeyCommand,
|
||||
},
|
||||
}
|
||||
|
||||
// addressesCommand is a wallet subcommand that is responsible for
|
||||
// address management operations.
|
||||
addressesCommand = cli.Command{
|
||||
Name: "addresses",
|
||||
Usage: "Interact with wallet addresses.",
|
||||
Subcommands: []cli.Command{
|
||||
listAddressesCommand,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// walletCommands will return the set of commands to enable for walletrpc
|
||||
@ -67,6 +77,7 @@ func walletCommands() []cli.Command {
|
||||
psbtCommand,
|
||||
accountsCommand,
|
||||
requiredReserveCommand,
|
||||
addressesCommand,
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -1131,6 +1142,54 @@ func requiredReserve(ctx *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var listAddressesCommand = cli.Command{
|
||||
Name: "list",
|
||||
Usage: "Retrieve information of existing on-chain wallet addresses.",
|
||||
Description: `
|
||||
Retrieves information of existing on-chain wallet addresses along with
|
||||
their type, internal/external and balance.
|
||||
`,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "account_name",
|
||||
Usage: "(optional) only addreses matching this account " +
|
||||
"are returned",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "show_custom_accounts",
|
||||
Usage: "(optional) set this to true to show lnd's " +
|
||||
"custom accounts",
|
||||
},
|
||||
},
|
||||
Action: actionDecorator(listAddresses),
|
||||
}
|
||||
|
||||
func listAddresses(ctx *cli.Context) error {
|
||||
ctxc := getContext()
|
||||
|
||||
// Display the command's help message if we do not have the expected
|
||||
// number of arguments/flags.
|
||||
if ctx.NArg() > 0 || ctx.NumFlags() > 2 {
|
||||
return cli.ShowCommandHelp(ctx, "list")
|
||||
}
|
||||
|
||||
walletClient, cleanUp := getWalletClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
req := &walletrpc.ListAddressesRequest{
|
||||
AccountName: ctx.String("account_name"),
|
||||
ShowCustomAccounts: ctx.Bool("show_custom_accounts"),
|
||||
}
|
||||
resp, err := walletClient.ListAddresses(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printRespJSON(resp)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var importAccountCommand = cli.Command{
|
||||
Name: "import",
|
||||
Usage: "Import an on-chain account into the wallet through its " +
|
||||
|
Loading…
Reference in New Issue
Block a user