Skip to content

Commit 922e59d

Browse files
multi: remove deprecated endpoints
In this commit, we remove deprecated endpoints `sendpayment`, `sendtoroute`, `sendtoroutesync`, and `sendpaymentsync`.
1 parent a388c1f commit 922e59d

13 files changed

+4130
-5999
lines changed

docs/release-notes/release-notes-0.19.0.md

+4
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@
160160
range TLVs provided with the existing set of records on the HTLC,
161161
overwriting any conflicting values with those supplied by the API.
162162

163+
* [Deprecated endpoints](https://github.com/lightningnetwork/lnd/pull/8348):
164+
`sendpayment`, `sendtoroute`, `sendtoroutesync`, and `sendpaymentsync` are
165+
replaced with `sendpaymentv2` and `sendtoroutev2`.
166+
163167
## lncli Updates
164168

165169
## Code Health

itest/lnd_channel_policy_test.go

+14-21
Original file line numberDiff line numberDiff line change
@@ -171,28 +171,23 @@ func testUpdateChannelPolicy(ht *lntest.HarnessTest) {
171171
routes.Routes[0].Hops[1].AmtToForward = amtSat
172172
routes.Routes[0].Hops[1].AmtToForwardMsat = amtMSat
173173

174-
// Send the payment with the modified value.
175-
alicePayStream := alice.RPC.SendToRoute()
176-
177-
sendReq := &lnrpc.SendToRouteRequest{
174+
// Send the payment with the modified value. The payment is expected to
175+
// fail, and the min_htlc value should be communicated back to us, as
176+
// the attempted HTLC value is too low.
177+
sendReq := &routerrpc.SendToRouteRequest{
178178
PaymentHash: resp.RHash,
179179
Route: routes.Routes[0],
180180
}
181-
err := alicePayStream.Send(sendReq)
182-
require.NoError(ht, err, "unable to send payment")
183-
184-
// We expect this payment to fail, and that the min_htlc value is
185-
// communicated back to us, since the attempted HTLC value was too low.
186-
sendResp, err := ht.ReceiveSendToRouteUpdate(alicePayStream)
187-
require.NoError(ht, err, "unable to receive payment stream")
181+
sendResp := alice.RPC.SendToRouteV2(sendReq)
182+
require.Equal(ht, sendResp.Status, lnrpc.HTLCAttempt_FAILED)
188183

189184
// Expected as part of the error message.
190185
substrs := []string{
191-
"AmountBelowMinimum",
192-
"HtlcMinimumMsat: (lnwire.MilliSatoshi) 5000 mSAT",
186+
"AMOUNT_BELOW_MINIMUM",
187+
"htlc_minimum_msat:5000",
193188
}
194189
for _, s := range substrs {
195-
require.Contains(ht, sendResp.PaymentError, s)
190+
require.Contains(ht, sendResp.Failure.String(), s)
196191
}
197192

198193
// Make sure sending using the original value succeeds.
@@ -214,17 +209,15 @@ func testUpdateChannelPolicy(ht *lntest.HarnessTest) {
214209
TotalAmtMsat: amtMSat,
215210
}
216211

217-
sendReq = &lnrpc.SendToRouteRequest{
212+
sendReq = &routerrpc.SendToRouteRequest{
218213
PaymentHash: resp.RHash,
219214
Route: route,
220215
}
221216

222-
err = alicePayStream.Send(sendReq)
223-
require.NoError(ht, err, "unable to send payment")
224-
225-
sendResp, err = ht.ReceiveSendToRouteUpdate(alicePayStream)
226-
require.NoError(ht, err, "unable to receive payment stream")
227-
require.Empty(ht, sendResp.PaymentError, "expected payment to succeed")
217+
sendResp = alice.RPC.SendToRouteV2(sendReq)
218+
require.Equal(ht, sendResp.Status, lnrpc.HTLCAttempt_SUCCEEDED)
219+
require.Nilf(ht, sendResp.Failure, "received payment error "+
220+
"from %s", alice.Name())
228221

229222
// With our little cluster set up, we'll update the outbound fees and
230223
// the max htlc size for the Bob side of the Alice->Bob channel, and

itest/lnd_routing_test.go

+15-83
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,10 @@ import (
2121
)
2222

2323
var sendToRouteTestCases = []*lntest.TestCase{
24-
{
25-
Name: "single hop with sync",
26-
TestFunc: func(ht *lntest.HarnessTest) {
27-
// useStream: false, routerrpc: false.
28-
testSingleHopSendToRouteCase(ht, false, false)
29-
},
30-
},
31-
{
32-
Name: "single hop with stream",
33-
TestFunc: func(ht *lntest.HarnessTest) {
34-
// useStream: true, routerrpc: false.
35-
testSingleHopSendToRouteCase(ht, true, false)
36-
},
37-
},
3824
{
3925
Name: "single hop with v2",
4026
TestFunc: func(ht *lntest.HarnessTest) {
41-
// useStream: false, routerrpc: true.
42-
testSingleHopSendToRouteCase(ht, false, true)
27+
testSingleHopSendToRouteCase(ht)
4328
},
4429
},
4530
}
@@ -50,12 +35,11 @@ var sendToRouteTestCases = []*lntest.TestCase{
5035
//
5136
// Carol --100k--> Dave
5237
//
53-
// We'll query the daemon for routes from Carol to Dave and then send payments
54-
// by feeding the route back into the various SendToRoute RPC methods. Here we
55-
// test all three SendToRoute endpoints, forcing each to perform both a regular
56-
// payment and an MPP payment.
57-
func testSingleHopSendToRouteCase(ht *lntest.HarnessTest,
58-
useStream, useRPC bool) {
38+
// We'll query the daemon for a route from Carol to Dave and then send payments
39+
// using SendToRouteV2. This test ensures that payments are properly processed
40+
// through the provided route with a single hop, and tests both regular payments
41+
// and Multi-Path Payments (MPP) via the same method.
42+
func testSingleHopSendToRouteCase(ht *lntest.HarnessTest) {
5943

6044
const chanAmt = btcutil.Amount(100000)
6145
const paymentAmtSat = 1000
@@ -119,44 +103,7 @@ func testSingleHopSendToRouteCase(ht *lntest.HarnessTest,
119103
}
120104
}
121105

122-
// Construct closures for each of the payment types covered:
123-
// - main rpc server sync
124-
// - main rpc server streaming
125-
// - routerrpc server sync
126-
sendToRouteSync := func() {
127-
for i, rHash := range rHashes {
128-
setMPPFields(i)
129-
130-
sendReq := &lnrpc.SendToRouteRequest{
131-
PaymentHash: rHash,
132-
Route: r,
133-
}
134-
resp := carol.RPC.SendToRouteSync(sendReq)
135-
require.Emptyf(ht, resp.PaymentError,
136-
"received payment error from %s: %v",
137-
carol.Name(), resp.PaymentError)
138-
}
139-
}
140-
sendToRouteStream := func() {
141-
alicePayStream := carol.RPC.SendToRoute()
142-
143-
for i, rHash := range rHashes {
144-
setMPPFields(i)
145-
146-
sendReq := &lnrpc.SendToRouteRequest{
147-
PaymentHash: rHash,
148-
Route: routes.Routes[0],
149-
}
150-
err := alicePayStream.Send(sendReq)
151-
require.NoError(ht, err, "unable to send payment")
152-
153-
resp, err := ht.ReceiveSendToRouteUpdate(alicePayStream)
154-
require.NoError(ht, err, "unable to receive stream")
155-
require.Emptyf(ht, resp.PaymentError,
156-
"received payment error from %s: %v",
157-
carol.Name(), resp.PaymentError)
158-
}
159-
}
106+
// Closure to send payments via the routerrpc server.
160107
sendToRouteRouterRPC := func() {
161108
for i, rHash := range rHashes {
162109
setMPPFields(i)
@@ -172,19 +119,8 @@ func testSingleHopSendToRouteCase(ht *lntest.HarnessTest,
172119
}
173120

174121
// Using Carol as the node as the source, send the payments
175-
// synchronously via the routerrpc's SendToRoute, or via the main RPC
176-
// server's SendToRoute streaming or sync calls.
177-
switch {
178-
case !useRPC && useStream:
179-
sendToRouteStream()
180-
case !useRPC && !useStream:
181-
sendToRouteSync()
182-
case useRPC && !useStream:
183-
sendToRouteRouterRPC()
184-
default:
185-
require.Fail(ht, "routerrpc does not support "+
186-
"streaming send_to_route")
187-
}
122+
// synchronously via the routerrpc's SendToRouteV2 method.
123+
sendToRouteRouterRPC()
188124

189125
// Verify that the payment's from Carol's PoV have the correct payment
190126
// hash and amount.
@@ -352,6 +288,7 @@ func runMultiHopSendToRoute(ht *lntest.HarnessTest, useGraphCache bool) {
352288
),
353289
}
354290

291+
// Using Alice as the source, pay to the invoice from Bob.
355292
sendReq := &routerrpc.SendToRouteRequest{
356293
PaymentHash: rHash,
357294
Route: route,
@@ -432,21 +369,16 @@ func testSendToRouteErrorPropagation(ht *lntest.HarnessTest) {
432369
rHash := resp.RHash
433370

434371
// Using Alice as the source, pay to the invoice from Bob.
435-
alicePayStream := alice.RPC.SendToRoute()
436-
437-
sendReq := &lnrpc.SendToRouteRequest{
372+
sendReq := &routerrpc.SendToRouteRequest{
438373
PaymentHash: rHash,
439374
Route: fakeRoute.Routes[0],
440375
}
441-
err := alicePayStream.Send(sendReq)
442-
require.NoError(ht, err, "unable to send payment")
376+
sendResp := alice.RPC.SendToRouteV2(sendReq)
377+
require.Equal(ht, sendResp.Status, lnrpc.HTLCAttempt_FAILED)
443378

444379
// At this place we should get an rpc error with notification
445-
// that edge is not found on hop(0)
446-
event, err := ht.ReceiveSendToRouteUpdate(alicePayStream)
447-
require.NoError(ht, err, "payment stream has been closed but fake "+
448-
"route has consumed")
449-
require.Contains(ht, event.PaymentError, "UnknownNextPeer")
380+
// that edge is not found on hop(0).
381+
require.Contains(ht, sendResp.Failure.String(), "UNKNOWN_NEXT_PEER")
450382
}
451383

452384
// testPrivateChannels tests that a private channel can be used for

0 commit comments

Comments
 (0)