Skip to content

Commit 7314e6c

Browse files
lnd: remove deprecated endpoints sendpayment, sendtoroute, sendtoroutesync, and sendpaymentsync.
This pull request removes the deprecated endpoints `sendpayment`, `sendtoroute`, `sendtoroutesync`, and `sendpaymentsync` in `lightning.proto`, `rpcserver.go`, `lntest/rpc/lnd.go`, and its related test cases in `itest/lnd_routing_test.go` and `itest/lnd_channel_policy_test.go`. docs: Update release notes for 0.18.0 Added release note in version 0.18.0 to notify about the upcoming removal of deprecated endpoints (`sendpayment`, `sendtoroute`, `sendtoroutesync`, and `sendpaymentsync`). Referenced PR (#8348) for more details.
1 parent 2f04ce7 commit 7314e6c

File tree

6 files changed

+13
-288
lines changed

6 files changed

+13
-288
lines changed

docs/release-notes/release-notes-0.18.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@
207207
* [Remove database pointers](https://github.com/lightningnetwork/lnd/pull/8117)
208208
from channeldb schema structs.
209209

210+
* Deprecated Endpoints Removal Preparation: In preparation for the next release (0.19.0), deprecated endpoints (`sendpayment`, `sendtoroute`, `sendtoroutesync`, and `sendpaymentsync`) will be removed. Developers are encouraged to update their implementations accordingly (if any). See PR (https://github.com/lightningnetwork/lnd/pull/8348) for more details.
211+
210212
## Tooling and Documentation
211213

212214
# Contributors (Alphabetical Order)

itest/lnd_channel_policy_test.go

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -172,29 +172,12 @@ func testUpdateChannelPolicy(ht *lntest.HarnessTest) {
172172
routes.Routes[0].Hops[1].AmtToForward = amtSat
173173
routes.Routes[0].Hops[1].AmtToForwardMsat = amtMSat
174174

175-
// Send the payment with the modified value.
176-
alicePayStream := alice.RPC.SendToRoute()
177-
178-
sendReq := &lnrpc.SendToRouteRequest{
175+
sendReq := &routerrpc.SendToRouteRequest{
179176
PaymentHash: resp.RHash,
180177
Route: routes.Routes[0],
181178
}
182-
err := alicePayStream.Send(sendReq)
183-
require.NoError(ht, err, "unable to send payment")
184-
185-
// We expect this payment to fail, and that the min_htlc value is
186-
// communicated back to us, since the attempted HTLC value was too low.
187-
sendResp, err := ht.ReceiveSendToRouteUpdate(alicePayStream)
188-
require.NoError(ht, err, "unable to receive payment stream")
189-
190-
// Expected as part of the error message.
191-
substrs := []string{
192-
"AmountBelowMinimum",
193-
"HtlcMinimumMsat: (lnwire.MilliSatoshi) 5000 mSAT",
194-
}
195-
for _, s := range substrs {
196-
require.Contains(ht, sendResp.PaymentError, s)
197-
}
179+
aliceHTLCAttempt := alice.RPC.SendToRouteV2(sendReq)
180+
require.NotNil(ht, aliceHTLCAttempt.Failure)
198181

199182
// Make sure sending using the original value succeeds.
200183
payAmt = btcutil.Amount(5)
@@ -215,17 +198,12 @@ func testUpdateChannelPolicy(ht *lntest.HarnessTest) {
215198
TotalAmtMsat: amtMSat,
216199
}
217200

218-
sendReq = &lnrpc.SendToRouteRequest{
201+
sendReq = &routerrpc.SendToRouteRequest{
219202
PaymentHash: resp.RHash,
220203
Route: route,
221204
}
222-
223-
err = alicePayStream.Send(sendReq)
224-
require.NoError(ht, err, "unable to send payment")
225-
226-
sendResp, err = ht.ReceiveSendToRouteUpdate(alicePayStream)
227-
require.NoError(ht, err, "unable to receive payment stream")
228-
require.Empty(ht, sendResp.PaymentError, "expected payment to succeed")
205+
aliceHTLCAttempt = alice.RPC.SendToRouteV2(sendReq)
206+
require.Nil(ht, aliceHTLCAttempt.Failure, "received payment error")
229207

230208
// With our little cluster set up, we'll update the fees and the max
231209
// htlc size for the Bob side of the Alice->Bob channel, and make sure

itest/lnd_routing_test.go

Lines changed: 5 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,16 @@ import (
2222
type singleHopSendToRouteCase struct {
2323
name string
2424

25-
// streaming tests streaming SendToRoute if true, otherwise tests
26-
// synchronous SenToRoute.
27-
streaming bool
28-
2925
// routerrpc submits the request to the routerrpc subserver if true,
3026
// otherwise submits to the main rpc server.
3127
routerrpc bool
3228
}
3329

3430
var singleHopSendToRouteCases = []singleHopSendToRouteCase{
35-
{
36-
name: "regular main sync",
37-
},
38-
{
39-
name: "regular main stream",
40-
streaming: true,
41-
},
4231
{
4332
name: "regular routerrpc sync",
4433
routerrpc: true,
4534
},
46-
{
47-
name: "mpp main sync",
48-
},
49-
{
50-
name: "mpp main stream",
51-
streaming: true,
52-
},
5335
{
5436
name: "mpp routerrpc sync",
5537
routerrpc: true,
@@ -144,43 +126,7 @@ func testSingleHopSendToRouteCase(ht *lntest.HarnessTest,
144126
}
145127

146128
// Construct closures for each of the payment types covered:
147-
// - main rpc server sync
148-
// - main rpc server streaming
149129
// - routerrpc server sync
150-
sendToRouteSync := func() {
151-
for i, rHash := range rHashes {
152-
setMPPFields(i)
153-
154-
sendReq := &lnrpc.SendToRouteRequest{
155-
PaymentHash: rHash,
156-
Route: r,
157-
}
158-
resp := carol.RPC.SendToRouteSync(sendReq)
159-
require.Emptyf(ht, resp.PaymentError,
160-
"received payment error from %s: %v",
161-
carol.Name(), resp.PaymentError)
162-
}
163-
}
164-
sendToRouteStream := func() {
165-
alicePayStream := carol.RPC.SendToRoute()
166-
167-
for i, rHash := range rHashes {
168-
setMPPFields(i)
169-
170-
sendReq := &lnrpc.SendToRouteRequest{
171-
PaymentHash: rHash,
172-
Route: routes.Routes[0],
173-
}
174-
err := alicePayStream.Send(sendReq)
175-
require.NoError(ht, err, "unable to send payment")
176-
177-
resp, err := ht.ReceiveSendToRouteUpdate(alicePayStream)
178-
require.NoError(ht, err, "unable to receive stream")
179-
require.Emptyf(ht, resp.PaymentError,
180-
"received payment error from %s: %v",
181-
carol.Name(), resp.PaymentError)
182-
}
183-
}
184130
sendToRouteRouterRPC := func() {
185131
for i, rHash := range rHashes {
186132
setMPPFields(i)
@@ -196,18 +142,9 @@ func testSingleHopSendToRouteCase(ht *lntest.HarnessTest,
196142
}
197143

198144
// Using Carol as the node as the source, send the payments
199-
// synchronously via the routerrpc's SendToRoute, or via the main RPC
200-
// server's SendToRoute streaming or sync calls.
201-
switch {
202-
case !test.routerrpc && test.streaming:
203-
sendToRouteStream()
204-
case !test.routerrpc && !test.streaming:
205-
sendToRouteSync()
206-
case test.routerrpc && !test.streaming:
145+
// synchronously via the routerrpc's SendToRoute.
146+
if test.routerrpc {
207147
sendToRouteRouterRPC()
208-
default:
209-
require.Fail(ht, "routerrpc does not support "+
210-
"streaming send_to_route")
211148
}
212149

213150
// Verify that the payment's from Carol's PoV have the correct payment
@@ -457,22 +394,12 @@ func testSendToRouteErrorPropagation(ht *lntest.HarnessTest) {
457394
resp := bob.RPC.AddInvoice(invoice)
458395
rHash := resp.RHash
459396

460-
// Using Alice as the source, pay to the invoice from Bob.
461-
alicePayStream := alice.RPC.SendToRoute()
462-
463-
sendReq := &lnrpc.SendToRouteRequest{
397+
sendReq := &routerrpc.SendToRouteRequest{
464398
PaymentHash: rHash,
465399
Route: fakeRoute.Routes[0],
466400
}
467-
err := alicePayStream.Send(sendReq)
468-
require.NoError(ht, err, "unable to send payment")
469-
470-
// At this place we should get an rpc error with notification
471-
// that edge is not found on hop(0)
472-
event, err := ht.ReceiveSendToRouteUpdate(alicePayStream)
473-
require.NoError(ht, err, "payment stream has been closed but fake "+
474-
"route has consumed")
475-
require.Contains(ht, event.PaymentError, "UnknownNextPeer")
401+
aliceHTLCAttempt := alice.RPC.SendToRouteV2(sendReq)
402+
require.NotNil(ht, aliceHTLCAttempt.Failure)
476403

477404
ht.CloseChannel(alice, chanPointAlice)
478405
}

lnrpc/lightning.proto

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -255,42 +255,6 @@ service Lightning {
255255
*/
256256
rpc AbandonChannel (AbandonChannelRequest) returns (AbandonChannelResponse);
257257

258-
/* lncli: `sendpayment`
259-
Deprecated, use routerrpc.SendPaymentV2. SendPayment dispatches a
260-
bi-directional streaming RPC for sending payments through the Lightning
261-
Network. A single RPC invocation creates a persistent bi-directional
262-
stream allowing clients to rapidly send payments through the Lightning
263-
Network with a single persistent connection.
264-
*/
265-
rpc SendPayment (stream SendRequest) returns (stream SendResponse) {
266-
option deprecated = true;
267-
}
268-
269-
/*
270-
SendPaymentSync is the synchronous non-streaming version of SendPayment.
271-
This RPC is intended to be consumed by clients of the REST proxy.
272-
Additionally, this RPC expects the destination's public key and the payment
273-
hash (if any) to be encoded as hex strings.
274-
*/
275-
rpc SendPaymentSync (SendRequest) returns (SendResponse);
276-
277-
/* lncli: `sendtoroute`
278-
Deprecated, use routerrpc.SendToRouteV2. SendToRoute is a bi-directional
279-
streaming RPC for sending payment through the Lightning Network. This
280-
method differs from SendPayment in that it allows users to specify a full
281-
route manually. This can be used for things like rebalancing, and atomic
282-
swaps.
283-
*/
284-
rpc SendToRoute (stream SendToRouteRequest) returns (stream SendResponse) {
285-
option deprecated = true;
286-
}
287-
288-
/*
289-
SendToRouteSync is a synchronous version of SendToRoute. It Will block
290-
until the payment either fails or succeeds.
291-
*/
292-
rpc SendToRouteSync (SendToRouteRequest) returns (SendResponse);
293-
294258
/* lncli: `addinvoice`
295259
AddInvoice attempts to add a new invoice to the invoice database. Any
296260
duplicated invoices are rejected, therefore all invoices *must* have a

lntest/rpc/lnd.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -487,30 +487,6 @@ func (h *HarnessRPC) QueryRoutes(
487487

488488
type SendToRouteClient lnrpc.Lightning_SendToRouteClient
489489

490-
// SendToRoute makes a RPC call to SendToRoute and asserts.
491-
func (h *HarnessRPC) SendToRoute() SendToRouteClient {
492-
// SendToRoute needs to have the context alive for the entire test case
493-
// as the returned client will be used for send and receive payment
494-
// stream. Thus we use runCtx here instead of a timeout context.
495-
client, err := h.LN.SendToRoute(h.runCtx)
496-
h.NoError(err, "SendToRoute")
497-
498-
return client
499-
}
500-
501-
// SendToRouteSync makes a RPC call to SendToRouteSync and asserts.
502-
func (h *HarnessRPC) SendToRouteSync(
503-
req *lnrpc.SendToRouteRequest) *lnrpc.SendResponse {
504-
505-
ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
506-
defer cancel()
507-
508-
resp, err := h.LN.SendToRouteSync(ctxt, req)
509-
h.NoError(err, "SendToRouteSync")
510-
511-
return resp
512-
}
513-
514490
// UpdateChannelPolicy makes a RPC call to UpdateChannelPolicy and asserts.
515491
func (h *HarnessRPC) UpdateChannelPolicy(
516492
req *lnrpc.PolicyUpdateRequest) *lnrpc.PolicyUpdateResponse {

0 commit comments

Comments
 (0)