Skip to content

Commit

Permalink
lncli: cancelable flag for SendPaymentRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
hieblmi committed May 17, 2024
1 parent 6db427b commit 09592bf
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/lncli/cmd_payments.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ var (
Usage: "(blinded paths) the total cltv delay for the " +
"blinded portion of the route",
}

cancelableFlag = cli.BoolFlag{
Name: "cancelable",
Usage: "if set to true, the payment loop can be interrupted " +
"by manually canceling the payment context, even " +
"before the payment timeout is reached. Note that " +
"the payment may still succeed after cancellation, " +
"as in-flight attempts can still settle afterwards. " +
"Canceling will only prevent further attempts from " +
"being sent",
}
)

// paymentFlags returns common flags for sendpayment and payinvoice.
Expand Down Expand Up @@ -166,6 +177,7 @@ func paymentFlags() []cli.Flag {
"after the timeout has elapsed",
Value: paymentTimeout,
},
cancelableFlag,
cltvLimitFlag,
lastHopFlag,
cli.Int64SliceFlag{
Expand Down Expand Up @@ -328,6 +340,7 @@ func sendPayment(ctx *cli.Context) error {
PaymentRequest: stripPrefix(ctx.String("pay_req")),
Amt: ctx.Int64("amt"),
DestCustomRecords: make(map[uint64][]byte),
Cancelable: ctx.Bool(cancelableFlag.Name),
}

// We'll attempt to parse a payment address as well, given that
Expand Down Expand Up @@ -386,6 +399,7 @@ func sendPayment(ctx *cli.Context) error {
Amt: amount,
DestCustomRecords: make(map[uint64][]byte),
Amp: ctx.Bool(ampFlag.Name),
Cancelable: ctx.Bool(cancelableFlag.Name),
}

var rHash []byte
Expand Down Expand Up @@ -887,6 +901,7 @@ func payInvoice(ctx *cli.Context) error {
Amt: ctx.Int64("amt"),
DestCustomRecords: make(map[uint64][]byte),
Amp: ctx.Bool(ampFlag.Name),
Cancelable: ctx.Bool(cancelableFlag.Name),
}

return sendPaymentRequest(ctx, req)
Expand Down

0 comments on commit 09592bf

Please sign in to comment.