-
Notifications
You must be signed in to change notification settings - Fork 122
staticaddr: fast-flag #1009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
staticaddr: fast-flag #1009
Changes from all commits
8464e4c
83c8666
92a8726
422bcd7
51258af
168420c
aaeeefe
2548522
f05b0e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -485,6 +485,12 @@ var staticAddressLoopInCommand = cli.Command{ | |
"is change it is sent back to the static " + | ||
"address.", | ||
}, | ||
cli.BoolFlag{ | ||
Name: "fast", | ||
Usage: "Usage: complete the swap faster by paying a " + | ||
"higher fee, so the change output is " + | ||
"available sooner", | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I propose to rephrase it to make the purpose clearer:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added this description |
||
lastHopFlag, | ||
labelFlag, | ||
routeHintsFlag, | ||
|
@@ -500,6 +506,23 @@ func staticAddressLoopIn(ctx *cli.Context) error { | |
return cli.ShowCommandHelp(ctx, "in") | ||
} | ||
|
||
var selectedAmount int64 | ||
bhandras marked this conversation as resolved.
Show resolved
Hide resolved
|
||
switch { | ||
case ctx.NArg() == 1: | ||
amt, err := parseAmt(ctx.Args().Get(0)) | ||
if err != nil { | ||
return err | ||
} | ||
selectedAmount = int64(amt) | ||
|
||
case ctx.NArg() > 1: | ||
return fmt.Errorf("only a single positional argument is " + | ||
"allowed") | ||
|
||
default: | ||
selectedAmount = ctx.Int64("amount") | ||
} | ||
|
||
client, cleanup, err := getClient(ctx) | ||
if err != nil { | ||
return err | ||
|
@@ -510,7 +533,6 @@ func staticAddressLoopIn(ctx *cli.Context) error { | |
ctxb = context.Background() | ||
isAllSelected = ctx.IsSet("all") | ||
isUtxoSelected = ctx.IsSet("utxo") | ||
selectedAmount = ctx.Int64("amount") | ||
autoSelectDepositsForQuote bool | ||
label = ctx.String("static-loop-in") | ||
hints []*swapserverrpc.RouteHint | ||
|
@@ -573,7 +595,8 @@ func staticAddressLoopIn(ctx *cli.Context) error { | |
depositOutpoints = ctx.StringSlice("utxo") | ||
|
||
case selectedAmount > 0: | ||
// If only an amount is selected we will trigger coin selection. | ||
// If only an amount is selected, we will trigger coin | ||
// selection. | ||
|
||
default: | ||
return fmt.Errorf("unknown quote request") | ||
|
@@ -594,6 +617,7 @@ func staticAddressLoopIn(ctx *cli.Context) error { | |
Private: ctx.Bool(privateFlag.Name), | ||
DepositOutpoints: depositOutpoints, | ||
AutoSelectDeposits: autoSelectDepositsForQuote, | ||
Fast: ctx.Bool("fast"), | ||
} | ||
quote, err := client.GetLoopInQuote(ctxb, quoteReq) | ||
if err != nil { | ||
|
@@ -623,6 +647,7 @@ func staticAddressLoopIn(ctx *cli.Context) error { | |
RouteHints: hints, | ||
Private: ctx.Bool("private"), | ||
PaymentTimeoutSeconds: paymentTimeoutSeconds, | ||
Fast: ctx.Bool("fast"), | ||
} | ||
|
||
resp, err := client.StaticAddressLoopIn(ctxb, req) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -908,6 +908,14 @@ func (s *swapClientServer) GetLoopInQuote(ctx context.Context, | |
return nil, err | ||
} | ||
|
||
// The fast flag is only available for static loop in quote requests. | ||
if req.Fast { | ||
if !autoSelectDeposits && len(req.DepositOutpoints) == 0 { | ||
return nil, fmt.Errorf("fast flag is only " + | ||
"available for static address requests") | ||
} | ||
} | ||
|
||
// If deposits should be automatically selected, we do so and count the | ||
// number of deposits to quote for. | ||
numDeposits := 0 | ||
|
@@ -1025,6 +1033,7 @@ func (s *swapClientServer) GetLoopInQuote(ctx context.Context, | |
Private: req.Private, | ||
Initiator: defaultLoopdInitiator, | ||
NumDeposits: uint32(numDeposits), | ||
Fast: req.Fast, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I propose to check here that if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a sanity check. |
||
}) | ||
if err != nil { | ||
return nil, err | ||
|
@@ -2052,6 +2061,7 @@ func (s *swapClientServer) StaticAddressLoopIn(ctx context.Context, | |
Private: in.Private, | ||
RouteHints: routeHints, | ||
PaymentTimeoutSeconds: in.PaymentTimeoutSeconds, | ||
Fast: in.Fast, | ||
} | ||
|
||
if in.LastHop != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- Drop 'fast' flag from static_address_swaps | ||
ALTER TABLE static_address_swaps DROP COLUMN fast; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- Add 'fast' flag to static_address_swaps, default false | ||
ALTER TABLE static_address_swaps ADD COLUMN fast BOOLEAN NOT NULL DEFAULT false; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep previous flag as well? So it is possible to set it via
--amount
. Some people may prefer this, e.g. in scripts where each argument is on a separate line. Positional argument is good for manual use.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, I re-added the flag.