diff --git a/cmd/loop/loopin.go b/cmd/loop/loopin.go index d29f1345c..3d694dbf1 100644 --- a/cmd/loop/loopin.go +++ b/cmd/loop/loopin.go @@ -26,7 +26,7 @@ var ( labelFlag = &cli.StringFlag{ Name: "label", - Usage: fmt.Sprintf("an optional label for this swap,"+ + Usage: fmt.Sprintf("an optional label for this swap, "+ "limited to %v characters. The label may not start "+ "with our reserved prefix: %v.", labels.MaxLength, labels.Reserved), diff --git a/cmd/loop/staticaddr.go b/cmd/loop/staticaddr.go index 5b76551fa..ebca8521e 100644 --- a/cmd/loop/staticaddr.go +++ b/cmd/loop/staticaddr.go @@ -37,6 +37,7 @@ var staticAddressCommands = &cli.Command{ Commands: []*cli.Command{ newStaticAddressCommand, depositStaticAddressCommand, + updateStaticAddressLabelCommand, listUnspentCommand, listDepositsCommand, listWithdrawalsCommand, @@ -48,18 +49,27 @@ 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"}, Usage: "Create a new static loop in address.", Description: ` - Creates a new static loop in address. On a fresh installation, loopd creates - the static-address root lazily when the first address is requested; startup - alone does not create an address. Funds sent to the address will be locked by - a 2:2 multisig between us and the loop server, or a timeout path that we can - sweep once it opens up. The funds can either be cooperatively spent with a - signature from the server or looped in. + Creates a fresh static loop in address every time. --label sets local + address metadata, not the funding transaction label. On a fresh installation, + loopd creates the static-address root lazily when the first address is + requested; startup alone does not create an address. Funds sent to the address + will be locked by a 2:2 multisig between us and the loop server, or a timeout + path that we can sweep once it opens up. The funds can either be cooperatively + spent with a signature from the server or looped in. `, + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: labelFlag.Name, + Usage: "an optional local label for this static address", + }, + }, Action: newStaticAddress, } @@ -148,11 +158,18 @@ var ( } ) +// 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 @@ -165,7 +182,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: "