Skip to content

Commit

Permalink
routerrpc: add a default value for timeout_seconds in SendPaymentV2
Browse files Browse the repository at this point in the history
Signed-off-by: Nishant Bansal <[email protected]>

routerrpc: update itests to validate default timeout_seconds

Signed-off-by: Nishant Bansal <[email protected]>
  • Loading branch information
NishantBansal2003 committed Dec 20, 2024
1 parent a388c1f commit 2c4b55c
Show file tree
Hide file tree
Showing 32 changed files with 720 additions and 739 deletions.
5 changes: 4 additions & 1 deletion cmd/commands/cmd_payments.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,10 @@ func SendPaymentRequest(ctx *cli.Context, req *routerrpc.SendPaymentRequest,
if pmtTimeout <= 0 {
return errors.New("payment timeout must be greater than zero")
}
req.TimeoutSeconds = int32(pmtTimeout.Seconds())
if req.TimeoutSeconds == nil {
req.TimeoutSeconds = new(int32)
}
*req.TimeoutSeconds = int32(pmtTimeout.Seconds())

req.AllowSelfPayment = ctx.Bool("allow_self_payment")

Expand Down
5 changes: 5 additions & 0 deletions docs/release-notes/release-notes-0.19.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
are now [sorted](https://github.com/lightningnetwork/lnd/pull/9337) based on
the `InvoiceHTLC.HtlcIndex`.

* [routerrpc.SendPaymentV2](https://github.com/lightningnetwork/lnd/pull/9359)
RPC method now applies a default timeout of 60 seconds when the
`timeout_seconds` field is not set. Explicitly setting `timeout_seconds` to 0
is no longer allowed.

## lncli Additions

* [A pre-generated macaroon root key can now be specified in `lncli create` and
Expand Down
2 changes: 0 additions & 2 deletions itest/lnd_amp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func testSendPaymentAMPInvoiceCase(ht *lntest.HarnessTest,
sendReq := &routerrpc.SendPaymentRequest{
PaymentRequest: addInvoiceResp.PaymentRequest,
PaymentAddr: externalPayAddr,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
Amp: true,
}
Expand Down Expand Up @@ -400,7 +399,6 @@ func testSendPaymentAMP(ht *lntest.HarnessTest) {
Dest: mts.bob.PubKey[:],
Amt: int64(paymentAmt),
FinalCltvDelta: chainreg.DefaultBitcoinTimeLockDelta,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
Amp: true,
}
Expand Down
1 change: 0 additions & 1 deletion itest/lnd_channel_balance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ func testChannelUnsettledBalance(ht *lntest.HarnessTest) {
Amt: int64(payAmt),
PaymentHash: ht.Random32Bytes(),
FinalCltvDelta: finalCltvDelta,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAssertInflight(alice, req)
Expand Down
2 changes: 0 additions & 2 deletions itest/lnd_channel_force_close_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ func runChannelForceClosureTest(ht *lntest.HarnessTest,
Amt: int64(paymentAmt),
PaymentHash: ht.Random32Bytes(),
FinalCltvDelta: finalCltvDelta,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAssertInflight(alice, req)
Expand Down Expand Up @@ -811,7 +810,6 @@ func testFailingChannel(ht *lntest.HarnessTest) {
// won't work as the channel cannot be found.
req := &routerrpc.SendPaymentRequest{
PaymentRequest: resp.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAndAssertStatus(alice, req, lnrpc.Payment_IN_FLIGHT)
Expand Down
1 change: 0 additions & 1 deletion itest/lnd_channel_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ func testUpdateChannelPolicy(ht *lntest.HarnessTest) {
// not be able to find a path during routing.
payReq := &routerrpc.SendPaymentRequest{
PaymentRequest: resp.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAssertFail(
Expand Down
2 changes: 0 additions & 2 deletions itest/lnd_coop_close_with_htlcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func coopCloseWithHTLCs(ht *lntest.HarnessTest) {
// HTLC for it.
req := &routerrpc.SendPaymentRequest{
PaymentRequest: resp.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitSat: 1000000,
}
ht.SendPaymentAndAssertStatus(bob, req, lnrpc.Payment_IN_FLIGHT)
Expand Down Expand Up @@ -166,7 +165,6 @@ func coopCloseWithHTLCsWithRestart(ht *lntest.HarnessTest) {
// for it.
req := &routerrpc.SendPaymentRequest{
PaymentRequest: resp.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitSat: 1000000,
}
ht.SendPaymentAndAssertStatus(bob, req, lnrpc.Payment_IN_FLIGHT)
Expand Down
3 changes: 2 additions & 1 deletion itest/lnd_experimental_endorsement.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ func testEndorsement(ht *lntest.HarnessTest, aliceEndorse bool) {
addResponse := eve.RPC.AddInvoice(req)
invoice := eve.RPC.LookupInvoice(addResponse.RHash)

timeoutDurationInSeconds := int32(wait.PaymentTimeout.Seconds())
sendReq := &routerrpc.SendPaymentRequest{
PaymentRequest: invoice.PaymentRequest,
TimeoutSeconds: int32(wait.PaymentTimeout.Seconds()),
TimeoutSeconds: &timeoutDurationInSeconds,
FeeLimitMsat: math.MaxInt64,
}

Expand Down
7 changes: 4 additions & 3 deletions itest/lnd_forward_interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,10 @@ func testForwardInterceptorWireRecords(ht *lntest.HarnessTest) {
customRecords := map[uint64][]byte{
65537: []byte("test"),
}
timeoutDurationInSeconds := int32(wait.PaymentTimeout.Seconds())
sendReq := &routerrpc.SendPaymentRequest{
PaymentRequest: invoice.PaymentRequest,
TimeoutSeconds: int32(wait.PaymentTimeout.Seconds()),
TimeoutSeconds: &timeoutDurationInSeconds,
FeeLimitMsat: noFeeLimitMsat,
FirstHopCustomRecords: customRecords,
}
Expand Down Expand Up @@ -594,10 +595,10 @@ func testForwardInterceptorRestart(ht *lntest.HarnessTest) {
customRecords := map[uint64][]byte{
65537: []byte("test"),
}

timeoutDurationInSeconds := int32(wait.PaymentTimeout.Seconds())
sendReq := &routerrpc.SendPaymentRequest{
PaymentRequest: invoice.PaymentRequest,
TimeoutSeconds: int32(wait.PaymentTimeout.Seconds()),
TimeoutSeconds: &timeoutDurationInSeconds,
FeeLimitMsat: noFeeLimitMsat,
FirstHopCustomRecords: customRecords,
}
Expand Down
1 change: 0 additions & 1 deletion itest/lnd_hold_invoice_force_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func testHoldInvoiceForceClose(ht *lntest.HarnessTest) {
// single htlc.
req := &routerrpc.SendPaymentRequest{
PaymentRequest: bobInvoice.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAssertInflight(alice, req)
Expand Down
1 change: 0 additions & 1 deletion itest/lnd_hold_persistence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ func testHoldInvoicePersistence(ht *lntest.HarnessTest) {
for _, payReq := range payReqs {
req := &routerrpc.SendPaymentRequest{
PaymentRequest: payReq,
TimeoutSeconds: 60,
FeeLimitSat: 1000000,
}

Expand Down
2 changes: 0 additions & 2 deletions itest/lnd_htlc_timeout_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ func testHtlcTimeoutResolverExtractPreimageRemote(ht *lntest.HarnessTest) {
// will not immediately settle the payment.
req := &routerrpc.SendPaymentRequest{
PaymentRequest: eveInvoice.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAssertInflight(alice, req)
Expand Down Expand Up @@ -267,7 +266,6 @@ func testHtlcTimeoutResolverExtractPreimageLocal(ht *lntest.HarnessTest) {
// will not immediately settle the payment.
req := &routerrpc.SendPaymentRequest{
PaymentRequest: carolInvoice.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAssertInflight(alice, req)
Expand Down
12 changes: 5 additions & 7 deletions itest/lnd_max_htlcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@ func testMaxHtlcPathfind(ht *lntest.HarnessTest) {
// We've hit our max remote htlcs, so we expect this payment to spin
// out dramatically with pathfinding.
sendReq := &routerrpc.SendPaymentRequest{
Amt: 1000,
Dest: alice.PubKey[:],
TimeoutSeconds: 60,
FeeLimitSat: 1000000,
MaxParts: 10,
Amp: true,
Amt: 1000,
Dest: alice.PubKey[:],
FeeLimitSat: 1000000,
MaxParts: 10,
Amp: true,
}
ht.SendPaymentAndAssertStatus(bob, sendReq, lnrpc.Payment_FAILED)

Expand Down Expand Up @@ -130,7 +129,6 @@ func acceptHoldInvoice(ht *lntest.HarnessTest, idx int, sender,

sendReq := &routerrpc.SendPaymentRequest{
PaymentRequest: invoice.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitSat: 1000000,
}
payStream := sender.RPC.SendPayment(sendReq)
Expand Down
2 changes: 0 additions & 2 deletions itest/lnd_misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ func testSphinxReplayPersistence(ht *lntest.HarnessTest) {
// to the above generated invoice.
req := &routerrpc.SendPaymentRequest{
PaymentRequest: invoiceResp.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
payStream := fred.RPC.SendPayment(req)
Expand Down Expand Up @@ -607,7 +606,6 @@ func testRejectHTLC(ht *lntest.HarnessTest) {
// lnd with --rejecthtlc.
paymentReq := &routerrpc.SendPaymentRequest{
PaymentRequest: resp.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAssertFail(
Expand Down
1 change: 0 additions & 1 deletion itest/lnd_mpp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func testSendMultiPathPayment(ht *lntest.HarnessTest) {
sendReq := &routerrpc.SendPaymentRequest{
PaymentRequest: payReq,
MaxParts: 10,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
payment := ht.SendPaymentAssertSettled(mts.alice, sendReq)
Expand Down
5 changes: 0 additions & 5 deletions itest/lnd_multi-hop-error-propagation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ func testHtlcErrorPropagation(ht *lntest.HarnessTest) {
Dest: carol.PubKey[:],
Amt: payAmt,
FinalCltvDelta: int32(carolPayReq.CltvExpiry),
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
MaxParts: 1,
}
Expand Down Expand Up @@ -203,7 +202,6 @@ func testHtlcErrorPropagation(ht *lntest.HarnessTest) {
// 10k satoshis are expected.
Amt: int64(htlcAmt.ToSatoshis()),
FinalCltvDelta: int32(carolPayReq.CltvExpiry),
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
MaxParts: 1,
}
Expand Down Expand Up @@ -251,7 +249,6 @@ func testHtlcErrorPropagation(ht *lntest.HarnessTest) {

req := &routerrpc.SendPaymentRequest{
PaymentRequest: carolInvoice2.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
MaxParts: 1,
}
Expand Down Expand Up @@ -287,7 +284,6 @@ func testHtlcErrorPropagation(ht *lntest.HarnessTest) {

sendReq = &routerrpc.SendPaymentRequest{
PaymentRequest: carolInvoice3.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
MaxParts: 1,
}
Expand Down Expand Up @@ -336,7 +332,6 @@ func testHtlcErrorPropagation(ht *lntest.HarnessTest) {

req = &routerrpc.SendPaymentRequest{
PaymentRequest: carolInvoice.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
MaxParts: 1,
}
Expand Down
11 changes: 0 additions & 11 deletions itest/lnd_multi-hop_force_close_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ func runLocalClaimOutgoingHTLC(ht *lntest.HarnessTest,
Amt: int64(dustHtlcAmt),
PaymentHash: dustPayHash,
FinalCltvDelta: finalCltvDelta,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
RouteHints: routeHints,
}
Expand All @@ -383,7 +382,6 @@ func runLocalClaimOutgoingHTLC(ht *lntest.HarnessTest,
Amt: int64(htlcAmt),
PaymentHash: payHash,
FinalCltvDelta: finalCltvDelta,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
RouteHints: routeHints,
}
Expand Down Expand Up @@ -726,7 +724,6 @@ func runMultiHopReceiverPreimageClaim(ht *lntest.HarnessTest,
// will not immediately settle the payment.
req := &routerrpc.SendPaymentRequest{
PaymentRequest: carolInvoice.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAssertInflight(alice, req)
Expand Down Expand Up @@ -1093,7 +1090,6 @@ func runLocalForceCloseBeforeHtlcTimeout(ht *lntest.HarnessTest,
Amt: int64(htlcAmt),
PaymentHash: payHash,
FinalCltvDelta: finalCltvDelta,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
RouteHints: routeHints,
}
Expand Down Expand Up @@ -1415,7 +1411,6 @@ func runRemoteForceCloseBeforeHtlcTimeout(ht *lntest.HarnessTest,

req := &routerrpc.SendPaymentRequest{
PaymentRequest: carolInvoice.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAssertInflight(alice, req)
Expand Down Expand Up @@ -1684,7 +1679,6 @@ func runLocalClaimIncomingHTLC(ht *lntest.HarnessTest,
// will not immediately settle the payment.
req := &routerrpc.SendPaymentRequest{
PaymentRequest: carolInvoice.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAssertInflight(alice, req)
Expand Down Expand Up @@ -1997,7 +1991,6 @@ func runLocalClaimIncomingHTLCLeased(ht *lntest.HarnessTest,
// will not immediately settle the payment.
req := &routerrpc.SendPaymentRequest{
PaymentRequest: carolInvoice.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAssertInflight(alice, req)
Expand Down Expand Up @@ -2348,7 +2341,6 @@ func runLocalPreimageClaim(ht *lntest.HarnessTest,
// will not immediately settle the payment.
req := &routerrpc.SendPaymentRequest{
PaymentRequest: carolInvoice.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAssertInflight(alice, req)
Expand Down Expand Up @@ -2654,7 +2646,6 @@ func runLocalPreimageClaimLeased(ht *lntest.HarnessTest,
// will not immediately settle the payment.
req := &routerrpc.SendPaymentRequest{
PaymentRequest: carolInvoice.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAssertInflight(alice, req)
Expand Down Expand Up @@ -3103,7 +3094,6 @@ func runHtlcAggregation(ht *lntest.HarnessTest,
for _, carolInvoice := range carolInvoices {
req := &routerrpc.SendPaymentRequest{
PaymentRequest: carolInvoice.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAssertInflight(alice, req)
Expand All @@ -3113,7 +3103,6 @@ func runHtlcAggregation(ht *lntest.HarnessTest,
for _, aliceInvoice := range aliceInvoices {
req := &routerrpc.SendPaymentRequest{
PaymentRequest: aliceInvoice.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAssertInflight(carol, req)
Expand Down
2 changes: 0 additions & 2 deletions itest/lnd_open_channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,6 @@ func testUpdateOnFunderPendingOpenChannels(ht *lntest.HarnessTest) {
// in-flight instead of being failed by Alice.
bobReq := &routerrpc.SendPaymentRequest{
PaymentRequest: invoice.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
bobStream := bob.RPC.SendPayment(bobReq)
Expand Down Expand Up @@ -750,7 +749,6 @@ func testUpdateOnFundeePendingOpenChannels(ht *lntest.HarnessTest) {
// in-flight instead of being failed by Bob.
aliceReq := &routerrpc.SendPaymentRequest{
PaymentRequest: bobInvoice.PaymentRequest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
aliceStream := alice.RPC.SendPayment(aliceReq)
Expand Down
Loading

0 comments on commit 2c4b55c

Please sign in to comment.