lncli: adds list addresses cli command
This commit is contained in:
1 parent
dba77edf2a
commit
2f20012af6
1 file changed
+59
@@ -43,6 +43,16 @@ var (
|
|||||||
importPubKeyCommand,
|
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
|
// walletCommands will return the set of commands to enable for walletrpc
|
||||||
@@ -67,6 +77,7 @@ func walletCommands() []cli.Command {
|
|||||||
psbtCommand,
|
psbtCommand,
|
||||||
accountsCommand,
|
accountsCommand,
|
||||||
requiredReserveCommand,
|
requiredReserveCommand,
|
||||||
|
addressesCommand,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -1131,6 +1142,54 @@ func requiredReserve(ctx *cli.Context) error {
|
|||||||
return nil
|
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{
|
var importAccountCommand = cli.Command{
|
||||||
Name: "import",
|
Name: "import",
|
||||||
Usage: "Import an on-chain account into the wallet through its " +
|
Usage: "Import an on-chain account into the wallet through its " +
|
||||||
|
|||||||
Reference in new issue
Block a user