diff --git a/cmd/lncli/commands.go b/cmd/lncli/commands.go index 1f9b131d4..077d3332a 100644 --- a/cmd/lncli/commands.go +++ b/cmd/lncli/commands.go @@ -132,6 +132,11 @@ var newAddressCommand = cli.Command{ Usage: "(optional) the name of the account to " + "generate a new address for", }, + cli.BoolFlag{ + Name: "unused", + Usage: "(optional) return the last unused address " + + "instead of generating a new one", + }, }, Description: ` Generate a wallet new address. Address-types has to be one of: @@ -153,14 +158,25 @@ func newAddress(ctx *cli.Context) error { // 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() + unused := ctx.Bool("unused") + var addrType lnrpc.AddressType switch stringAddrType { // TODO(roasbeef): make them ints on the cli? case "p2wkh": addrType = lnrpc.AddressType_WITNESS_PUBKEY_HASH + if unused { + addrType = lnrpc.AddressType_UNUSED_WITNESS_PUBKEY_HASH + } case "np2wkh": addrType = lnrpc.AddressType_NESTED_PUBKEY_HASH + if unused { + addrType = lnrpc.AddressType_UNUSED_NESTED_PUBKEY_HASH + } case "p2tr": addrType = lnrpc.AddressType_TAPROOT_PUBKEY + if unused { + addrType = lnrpc.AddressType_UNUSED_TAPROOT_PUBKEY + } default: return fmt.Errorf("invalid address type %v, support address type "+ "are: p2wkh, np2wkh, and p2tr", stringAddrType) diff --git a/docs/release-notes/release-notes-0.17.0.md b/docs/release-notes/release-notes-0.17.0.md index c0376be7a..63af5901e 100644 --- a/docs/release-notes/release-notes-0.17.0.md +++ b/docs/release-notes/release-notes-0.17.0.md @@ -81,6 +81,9 @@ unlock or create. * [Restore support](https://github.com/lightningnetwork/lnd/pull/7678) for `PKCS8`-encoded cert private keys. +* Add [`--unused`](https://github.com/lightningnetwork/lnd/pull/6387) to + `lncli newaddr` command. + ## Code Health * Updated [our fork for serializing protobuf as JSON to be based on the @@ -121,6 +124,7 @@ unlock or create. * Elle Mouton * Erik Arvstedt * ErikEk +* gabbyprecious * Guillermo Caracuel * hieblmi * Jordi Montes