Skip to content

Commit b577ad4

Browse files
routerrpc: default timeout_seconds to 60 in SendPaymentV2
If timeout_seconds is not set or is 0, the default value of 60 seconds will be used. Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
1 parent 4b16c29 commit b577ad4

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

lnrpc/routerrpc/router.pb.go

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lnrpc/routerrpc/router.proto

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,11 @@ message SendPaymentRequest {
227227
string payment_request = 5;
228228

229229
/*
230-
An upper limit on the amount of time we should spend when attempting to
231-
fulfill the payment. This is expressed in seconds. If we cannot make a
232-
successful payment within this time frame, an error will be returned.
233-
This field must be non-zero.
230+
An optional limit, expressed in seconds, on the time to wait before
231+
attempting the first HTLC. Once HTLCs are in flight, the payment will
232+
not be aborted until the HTLCs are either settled or failed. If the field
233+
is not set or is explicitly set to zero, the default value of 60 seconds
234+
will be applied.
234235
*/
235236
int32 timeout_seconds = 6;
236237

lnrpc/routerrpc/router.swagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1894,7 +1894,7 @@
18941894
"timeout_seconds": {
18951895
"type": "integer",
18961896
"format": "int32",
1897-
"description": "An upper limit on the amount of time we should spend when attempting to\nfulfill the payment. This is expressed in seconds. If we cannot make a\nsuccessful payment within this time frame, an error will be returned.\nThis field must be non-zero."
1897+
"description": "An optional limit, expressed in seconds, on the time to wait before\nattempting the first HTLC. Once HTLCs are in flight, the payment will\nnot be aborted until the HTLCs are either settled or failed. If the field\nis not set or is explicitly set to zero, the default value of 60 seconds\nwill be applied."
18981898
},
18991899
"fee_limit_sat": {
19001900
"type": "string",

lnrpc/routerrpc/router_backend.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,11 +878,6 @@ func (r *RouterBackend) extractIntentFromSendRequest(
878878
return nil, err
879879
}
880880

881-
// Set payment attempt timeout.
882-
if rpcPayReq.TimeoutSeconds == 0 {
883-
return nil, errors.New("timeout_seconds must be specified")
884-
}
885-
886881
customRecords := record.CustomSet(rpcPayReq.DestCustomRecords)
887882
if err := customRecords.Validate(); err != nil {
888883
return nil, err

lnrpc/routerrpc/router_server.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ const (
4040
// routeFeeLimitSat is the maximum routing fee that we allow to occur
4141
// when estimating a routing fee.
4242
routeFeeLimitSat = 100_000_000
43+
44+
// DefaultPaymentTimeout is the default value of time we should spend
45+
// when attempting to fulfill the payment.
46+
DefaultPaymentTimeout int32 = 60
4347
)
4448

4549
var (
@@ -344,6 +348,11 @@ func (r *ServerShell) CreateSubServer(configRegistry lnrpc.SubServerConfigDispat
344348
func (s *Server) SendPaymentV2(req *SendPaymentRequest,
345349
stream Router_SendPaymentV2Server) error {
346350

351+
// Set payment request attempt timeout.
352+
if req.TimeoutSeconds == 0 {
353+
req.TimeoutSeconds = DefaultPaymentTimeout
354+
}
355+
347356
payment, err := s.cfg.RouterBackend.extractIntentFromSendRequest(req)
348357
if err != nil {
349358
return err

0 commit comments

Comments
 (0)