diff --git a/cmd/loop/staticaddr.go b/cmd/loop/staticaddr.go index c973a0028..c0e3b5a4f 100644 --- a/cmd/loop/staticaddr.go +++ b/cmd/loop/staticaddr.go @@ -29,6 +29,7 @@ var staticAddressCommands = &cli.Command{ Usage: "perform on-chain to off-chain swaps using static addresses.", Commands: []*cli.Command{ newStaticAddressCommand, + updateStaticAddressLabelCommand, listUnspentCommand, listDepositsCommand, listWithdrawalsCommand, @@ -40,6 +41,8 @@ var staticAddressCommands = &cli.Command{ }, } +// newStaticAddressCommand creates a static address and lets operators +// optionally set a local label at creation time. var newStaticAddressCommand = &cli.Command{ Name: "new", Aliases: []string{"n"}, @@ -51,14 +54,24 @@ var newStaticAddressCommand = &cli.Command{ funds can either be cooperatively spent with a signature from the server or looped in. `, + Flags: []cli.Flag{ + labelFlag, + }, Action: newStaticAddress, } +// newStaticAddress requests a new static address while keeping the label as +// local operator metadata. func newStaticAddress(ctx context.Context, cmd *cli.Command) error { if cmd.NArg() > 0 { return showCommandHelp(ctx, cmd) } + label := cmd.String(labelFlag.Name) + if err := labels.Validate(label); err != nil { + return err + } + err := displayNewAddressWarning() if err != nil { return err @@ -71,7 +84,78 @@ func newStaticAddress(ctx context.Context, cmd *cli.Command) error { defer cleanup() resp, err := client.NewStaticAddress( - ctx, &looprpc.NewStaticAddressRequest{}, + ctx, &looprpc.NewStaticAddressRequest{ + Label: label, + }, + ) + if err != nil { + return err + } + + printRespJSON(resp) + + return nil +} + +// updateStaticAddressLabelCommand updates local metadata for an existing static +// address so operators can relabel it without affecting the address script or +// Loop server protocol state. +var updateStaticAddressLabelCommand = &cli.Command{ + Name: "updatelabel", + Usage: "Update the label for a static address.", + ArgsUsage: "