lncli: allow configurable timeout in send payment
This commit is contained in:
parent
f98c74319c
commit
0a76f87bd0
@ -26,9 +26,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// paymentTimeoutSeconds is the default timeout for the payment loop in
|
// paymentTimeout is the default timeout for the payment loop in lnd.
|
||||||
// lnd. No new attempts will be started after the timeout.
|
// No new attempts will be started after the timeout.
|
||||||
paymentTimeoutSeconds = 60
|
paymentTimeout = time.Second * 60
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -91,6 +91,13 @@ func paymentFlags() []cli.Flag {
|
|||||||
"the maximum fee allowed when sending the " +
|
"the maximum fee allowed when sending the " +
|
||||||
"payment",
|
"payment",
|
||||||
},
|
},
|
||||||
|
cli.DurationFlag{
|
||||||
|
Name: "timeout",
|
||||||
|
Usage: "the maximum amount of time we should spend " +
|
||||||
|
"trying to fulfill the payment, failing " +
|
||||||
|
"after the timeout has elapsed",
|
||||||
|
Value: paymentTimeout,
|
||||||
|
},
|
||||||
cltvLimitFlag,
|
cltvLimitFlag,
|
||||||
lastHopFlag,
|
lastHopFlag,
|
||||||
cli.Uint64Flag{
|
cli.Uint64Flag{
|
||||||
@ -336,7 +343,12 @@ func sendPaymentRequest(ctx *cli.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
req.CltvLimit = int32(ctx.Int(cltvLimitFlag.Name))
|
req.CltvLimit = int32(ctx.Int(cltvLimitFlag.Name))
|
||||||
req.TimeoutSeconds = paymentTimeoutSeconds
|
|
||||||
|
pmtTimeout := ctx.Duration("timeout")
|
||||||
|
if pmtTimeout <= 0 {
|
||||||
|
return errors.New("payment timeout must be greater than zero")
|
||||||
|
}
|
||||||
|
req.TimeoutSeconds = int32(pmtTimeout.Seconds())
|
||||||
|
|
||||||
req.AllowSelfPayment = ctx.Bool("allow_self_payment")
|
req.AllowSelfPayment = ctx.Bool("allow_self_payment")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user