Skip to content

Commit 7bfa616

Browse files
committed
lncli: cancelable flag for SendPaymentRequest
1 parent bba01cf commit 7bfa616

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

cmd/lncli/cmd_payments.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@ var (
139139
Usage: "(blinded paths) the total cltv delay for the " +
140140
"blinded portion of the route",
141141
}
142+
143+
cancelableFlag = cli.BoolFlag{
144+
Name: "cancelable",
145+
Usage: "if set to true, the payment loop can be interrupted " +
146+
"by manually canceling the payment context, even " +
147+
"before the payment timeout is reached. Note that " +
148+
"the payment may still succeed after cancellation, " +
149+
"as in-flight attempts can still settle afterwards. " +
150+
"Canceling will only prevent further attempts from " +
151+
"being sent",
152+
}
142153
)
143154

144155
// paymentFlags returns common flags for sendpayment and payinvoice.
@@ -166,6 +177,7 @@ func paymentFlags() []cli.Flag {
166177
"after the timeout has elapsed",
167178
Value: paymentTimeout,
168179
},
180+
cancelableFlag,
169181
cltvLimitFlag,
170182
lastHopFlag,
171183
cli.Int64SliceFlag{
@@ -329,6 +341,7 @@ func sendPayment(ctx *cli.Context) error {
329341
Amt: ctx.Int64("amt"),
330342
DestCustomRecords: make(map[uint64][]byte),
331343
Amp: ctx.Bool(ampFlag.Name),
344+
Cancelable: ctx.Bool(cancelableFlag.Name),
332345
}
333346

334347
// We'll attempt to parse a payment address as well, given that
@@ -387,6 +400,7 @@ func sendPayment(ctx *cli.Context) error {
387400
Amt: amount,
388401
DestCustomRecords: make(map[uint64][]byte),
389402
Amp: ctx.Bool(ampFlag.Name),
403+
Cancelable: ctx.Bool(cancelableFlag.Name),
390404
}
391405

392406
var rHash []byte
@@ -888,6 +902,7 @@ func payInvoice(ctx *cli.Context) error {
888902
Amt: ctx.Int64("amt"),
889903
DestCustomRecords: make(map[uint64][]byte),
890904
Amp: ctx.Bool(ampFlag.Name),
905+
Cancelable: ctx.Bool(cancelableFlag.Name),
891906
}
892907

893908
return sendPaymentRequest(ctx, req)

0 commit comments

Comments
 (0)