mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-20 11:06:54 +01:00
lncli: add account flag to wallet related commands
This commit is contained in:
@@ -127,6 +127,13 @@ var newAddressCommand = cli.Command{
|
||||
Category: "Wallet",
|
||||
Usage: "Generates a new address.",
|
||||
ArgsUsage: "address-type",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "account",
|
||||
Usage: "(optional) the name of the account to " +
|
||||
"generate a new address for",
|
||||
},
|
||||
},
|
||||
Description: `
|
||||
Generate a wallet new address. Address-types has to be one of:
|
||||
- p2wkh: Pay to witness key hash
|
||||
@@ -136,13 +143,16 @@ var newAddressCommand = cli.Command{
|
||||
|
||||
func newAddress(ctx *cli.Context) error {
|
||||
ctxc := getContext()
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
stringAddrType := ctx.Args().First()
|
||||
// Display the command's help message if we do not have the expected
|
||||
// number of arguments/flags.
|
||||
if ctx.NArg() != 1 || ctx.NumFlags() > 1 {
|
||||
return cli.ShowCommandHelp(ctx, "newaddress")
|
||||
}
|
||||
|
||||
// Map the string encoded address type, to the concrete typed address
|
||||
// type enum. An unrecognized address type will result in an error.
|
||||
stringAddrType := ctx.Args().First()
|
||||
var addrType lnrpc.AddressType
|
||||
switch stringAddrType { // TODO(roasbeef): make them ints on the cli?
|
||||
case "p2wkh":
|
||||
@@ -154,8 +164,12 @@ func newAddress(ctx *cli.Context) error {
|
||||
"are: p2wkh and np2wkh", stringAddrType)
|
||||
}
|
||||
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
addr, err := client.NewAddress(ctxc, &lnrpc.NewAddressRequest{
|
||||
Type: addrType,
|
||||
Type: addrType,
|
||||
Account: ctx.String("account"),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user