|
6 | 6 |
|
7 | 7 | "github.com/btcsuite/btcutil" |
8 | 8 | "github.com/lightninglabs/loop" |
| 9 | + "github.com/lightninglabs/loop/labels" |
9 | 10 | "github.com/lightninglabs/loop/looprpc" |
10 | 11 | "github.com/lightningnetwork/lnd/routing/route" |
11 | 12 | "github.com/urfave/cli" |
|
24 | 25 | "confirm within", |
25 | 26 | } |
26 | 27 |
|
| 28 | + labelFlag = cli.StringFlag{ |
| 29 | + Name: "label", |
| 30 | + Usage: fmt.Sprintf("an optional label for this swap,"+ |
| 31 | + "limited to %v characters. The label may not start "+ |
| 32 | + "with our reserved prefix: %v.", |
| 33 | + labels.MaxLength, labels.Reserved), |
| 34 | + } |
| 35 | + |
27 | 36 | loopInCommand = cli.Command{ |
28 | 37 | Name: "in", |
29 | 38 | Usage: "perform an on-chain to off-chain swap (loop in)", |
|
51 | 60 | }, |
52 | 61 | confTargetFlag, |
53 | 62 | lastHopFlag, |
| 63 | + labelFlag, |
54 | 64 | }, |
55 | 65 | Action: loopIn, |
56 | 66 | } |
@@ -93,6 +103,12 @@ func loopIn(ctx *cli.Context) error { |
93 | 103 | return fmt.Errorf("external and conf_target both set") |
94 | 104 | } |
95 | 105 |
|
| 106 | + // Validate our label early so that we can fail before getting a quote. |
| 107 | + label := ctx.String(labelFlag.Name) |
| 108 | + if err := labels.Validate(label); err != nil { |
| 109 | + return err |
| 110 | + } |
| 111 | + |
96 | 112 | quote, err := client.GetLoopInQuote( |
97 | 113 | context.Background(), |
98 | 114 | &looprpc.QuoteRequest{ |
@@ -133,6 +149,7 @@ func loopIn(ctx *cli.Context) error { |
133 | 149 | MaxSwapFee: int64(limits.maxSwapFee), |
134 | 150 | ExternalHtlc: external, |
135 | 151 | HtlcConfTarget: htlcConfTarget, |
| 152 | + Label: label, |
136 | 153 | } |
137 | 154 |
|
138 | 155 | if ctx.IsSet(lastHopFlag.Name) { |
|
0 commit comments