Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi: Deprecate endpoints sendpayment, sendtoroute, sendtoroutesync, and sendpaymentsync #8348

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/release-notes/release-notes-0.19.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@
range TLVs provided with the existing set of records on the HTLC,
overwriting any conflicting values with those supplied by the API.

* [Deprecate endpoints](https://github.com/lightningnetwork/lnd/pull/8348):
`sendpayment`, `sendtoroute`, `sendtoroutesync`, and `sendpaymentsync` are
replaced with `sendpaymentv2` and `sendtoroutev2`.

## lncli Updates

## Code Health
Expand Down
35 changes: 14 additions & 21 deletions itest/lnd_channel_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,28 +171,23 @@ func testUpdateChannelPolicy(ht *lntest.HarnessTest) {
routes.Routes[0].Hops[1].AmtToForward = amtSat
routes.Routes[0].Hops[1].AmtToForwardMsat = amtMSat

// Send the payment with the modified value.
alicePayStream := alice.RPC.SendToRoute()

sendReq := &lnrpc.SendToRouteRequest{
// Send the payment with the modified value. The payment is expected to
// fail, and the min_htlc value should be communicated back to us, as
// the attempted HTLC value is too low.
sendReq := &routerrpc.SendToRouteRequest{
PaymentHash: resp.RHash,
Route: routes.Routes[0],
}
err := alicePayStream.Send(sendReq)
require.NoError(ht, err, "unable to send payment")

// We expect this payment to fail, and that the min_htlc value is
// communicated back to us, since the attempted HTLC value was too low.
sendResp, err := ht.ReceiveSendToRouteUpdate(alicePayStream)
require.NoError(ht, err, "unable to receive payment stream")
sendResp := alice.RPC.SendToRouteV2(sendReq)
require.Equal(ht, sendResp.Status, lnrpc.HTLCAttempt_FAILED)

// Expected as part of the error message.
substrs := []string{
"AmountBelowMinimum",
"HtlcMinimumMsat: (lnwire.MilliSatoshi) 5000 mSAT",
"AMOUNT_BELOW_MINIMUM",
"htlc_minimum_msat:5000",
}
for _, s := range substrs {
require.Contains(ht, sendResp.PaymentError, s)
require.Contains(ht, sendResp.Failure.String(), s)
}

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

sendReq = &lnrpc.SendToRouteRequest{
sendReq = &routerrpc.SendToRouteRequest{
PaymentHash: resp.RHash,
Route: route,
}

err = alicePayStream.Send(sendReq)
require.NoError(ht, err, "unable to send payment")

sendResp, err = ht.ReceiveSendToRouteUpdate(alicePayStream)
require.NoError(ht, err, "unable to receive payment stream")
require.Empty(ht, sendResp.PaymentError, "expected payment to succeed")
sendResp = alice.RPC.SendToRouteV2(sendReq)
require.Equal(ht, sendResp.Status, lnrpc.HTLCAttempt_SUCCEEDED)
require.Nilf(ht, sendResp.Failure, "received payment error "+
"from %s", alice.Name())

// With our little cluster set up, we'll update the outbound fees and
// the max htlc size for the Bob side of the Alice->Bob channel, and
Expand Down
99 changes: 15 additions & 84 deletions itest/lnd_routing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,10 @@ import (
)

var sendToRouteTestCases = []*lntest.TestCase{
{
Name: "single hop with sync",
TestFunc: func(ht *lntest.HarnessTest) {
// useStream: false, routerrpc: false.
testSingleHopSendToRouteCase(ht, false, false)
},
},
{
Name: "single hop with stream",
TestFunc: func(ht *lntest.HarnessTest) {
// useStream: true, routerrpc: false.
testSingleHopSendToRouteCase(ht, true, false)
},
},
{
Name: "single hop with v2",
TestFunc: func(ht *lntest.HarnessTest) {
// useStream: false, routerrpc: true.
testSingleHopSendToRouteCase(ht, false, true)
testSingleHopSendToRouteCase(ht)
},
},
}
Expand All @@ -50,13 +35,11 @@ var sendToRouteTestCases = []*lntest.TestCase{
//
// Carol --100k--> Dave
//
// We'll query the daemon for routes from Carol to Dave and then send payments
// by feeding the route back into the various SendToRoute RPC methods. Here we
// test all three SendToRoute endpoints, forcing each to perform both a regular
// payment and an MPP payment.
func testSingleHopSendToRouteCase(ht *lntest.HarnessTest,
useStream, useRPC bool) {

// We'll query the daemon for a route from Carol to Dave and then send payments
// using SendToRouteV2. This test ensures that payments are properly processed
// through the provided route with a single hop, and tests both regular payments
// and Multi-Path Payments (MPP) via the same method.
func testSingleHopSendToRouteCase(ht *lntest.HarnessTest) {
const chanAmt = btcutil.Amount(100000)
const paymentAmtSat = 1000
const numPayments = 5
Expand Down Expand Up @@ -119,44 +102,7 @@ func testSingleHopSendToRouteCase(ht *lntest.HarnessTest,
}
}

// Construct closures for each of the payment types covered:
// - main rpc server sync
// - main rpc server streaming
// - routerrpc server sync
sendToRouteSync := func() {
for i, rHash := range rHashes {
setMPPFields(i)

sendReq := &lnrpc.SendToRouteRequest{
PaymentHash: rHash,
Route: r,
}
resp := carol.RPC.SendToRouteSync(sendReq)
require.Emptyf(ht, resp.PaymentError,
"received payment error from %s: %v",
carol.Name(), resp.PaymentError)
}
}
sendToRouteStream := func() {
alicePayStream := carol.RPC.SendToRoute()

for i, rHash := range rHashes {
setMPPFields(i)

sendReq := &lnrpc.SendToRouteRequest{
PaymentHash: rHash,
Route: routes.Routes[0],
}
err := alicePayStream.Send(sendReq)
require.NoError(ht, err, "unable to send payment")

resp, err := ht.ReceiveSendToRouteUpdate(alicePayStream)
require.NoError(ht, err, "unable to receive stream")
require.Emptyf(ht, resp.PaymentError,
"received payment error from %s: %v",
carol.Name(), resp.PaymentError)
}
}
// Closure to send payments via the routerrpc server.
sendToRouteRouterRPC := func() {
for i, rHash := range rHashes {
setMPPFields(i)
Expand All @@ -172,19 +118,8 @@ func testSingleHopSendToRouteCase(ht *lntest.HarnessTest,
}

// Using Carol as the node as the source, send the payments
// synchronously via the routerrpc's SendToRoute, or via the main RPC
// server's SendToRoute streaming or sync calls.
switch {
case !useRPC && useStream:
sendToRouteStream()
case !useRPC && !useStream:
sendToRouteSync()
case useRPC && !useStream:
sendToRouteRouterRPC()
default:
require.Fail(ht, "routerrpc does not support "+
"streaming send_to_route")
}
// synchronously via the routerrpc's SendToRouteV2 method.
sendToRouteRouterRPC()

// Verify that the payment's from Carol's PoV have the correct payment
// hash and amount.
Expand Down Expand Up @@ -352,6 +287,7 @@ func runMultiHopSendToRoute(ht *lntest.HarnessTest, useGraphCache bool) {
),
}

// Using Alice as the source, pay to the invoice from Bob.
sendReq := &routerrpc.SendToRouteRequest{
PaymentHash: rHash,
Route: route,
Expand Down Expand Up @@ -432,21 +368,16 @@ func testSendToRouteErrorPropagation(ht *lntest.HarnessTest) {
rHash := resp.RHash

// Using Alice as the source, pay to the invoice from Bob.
alicePayStream := alice.RPC.SendToRoute()

sendReq := &lnrpc.SendToRouteRequest{
sendReq := &routerrpc.SendToRouteRequest{
PaymentHash: rHash,
Route: fakeRoute.Routes[0],
}
err := alicePayStream.Send(sendReq)
require.NoError(ht, err, "unable to send payment")
sendResp := alice.RPC.SendToRouteV2(sendReq)
require.Equal(ht, sendResp.Status, lnrpc.HTLCAttempt_FAILED)

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

// testPrivateChannels tests that a private channel can be used for
Expand Down
Loading
Loading