mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loop: allow creation of loops with labels on cli
This commit is contained in:
parent
8da0ea6048
commit
f62d09528d
2 changed files with 26 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightninglabs/loop"
|
||||
"github.com/lightninglabs/loop/labels"
|
||||
"github.com/lightninglabs/loop/looprpc"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
"github.com/urfave/cli"
|
||||
|
|
@ -24,6 +25,14 @@ var (
|
|||
"confirm within",
|
||||
}
|
||||
|
||||
labelFlag = cli.StringFlag{
|
||||
Name: "label",
|
||||
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),
|
||||
}
|
||||
|
||||
loopInCommand = cli.Command{
|
||||
Name: "in",
|
||||
Usage: "perform an on-chain to off-chain swap (loop in)",
|
||||
|
|
@ -51,6 +60,7 @@ var (
|
|||
},
|
||||
confTargetFlag,
|
||||
lastHopFlag,
|
||||
labelFlag,
|
||||
},
|
||||
Action: loopIn,
|
||||
}
|
||||
|
|
@ -93,6 +103,12 @@ func loopIn(ctx *cli.Context) error {
|
|||
return fmt.Errorf("external and conf_target both set")
|
||||
}
|
||||
|
||||
// Validate our label early so that we can fail before getting a quote.
|
||||
label := ctx.String(labelFlag.Name)
|
||||
if err := labels.Validate(label); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
quote, err := client.GetLoopInQuote(
|
||||
context.Background(),
|
||||
&looprpc.QuoteRequest{
|
||||
|
|
@ -133,6 +149,7 @@ func loopIn(ctx *cli.Context) error {
|
|||
MaxSwapFee: int64(limits.maxSwapFee),
|
||||
ExternalHtlc: external,
|
||||
HtlcConfTarget: htlcConfTarget,
|
||||
Label: label,
|
||||
}
|
||||
|
||||
if ctx.IsSet(lastHopFlag.Name) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightninglabs/loop"
|
||||
"github.com/lightninglabs/loop/labels"
|
||||
"github.com/lightninglabs/loop/looprpc"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
|
@ -64,6 +65,7 @@ var loopOutCommand = cli.Command{
|
|||
"Not setting this flag therefore might " +
|
||||
"result in a lower swap fee.",
|
||||
},
|
||||
labelFlag,
|
||||
},
|
||||
Action: loopOut,
|
||||
}
|
||||
|
|
@ -104,6 +106,12 @@ func loopOut(ctx *cli.Context) error {
|
|||
}
|
||||
}
|
||||
|
||||
// Validate our label early so that we can fail before getting a quote.
|
||||
label := ctx.String(labelFlag.Name)
|
||||
if err := labels.Validate(label); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var destAddr string
|
||||
switch {
|
||||
case ctx.IsSet("addr"):
|
||||
|
|
@ -172,6 +180,7 @@ func loopOut(ctx *cli.Context) error {
|
|||
OutgoingChanSet: outgoingChanSet,
|
||||
SweepConfTarget: sweepConfTarget,
|
||||
SwapPublicationDeadline: uint64(swapDeadline.Unix()),
|
||||
Label: label,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue