Merge pull request #9990 from ziggie1984/follow-up-payment-addr-spec-update

itest coverage increase following the spec update regarding MPP payments
This commit is contained in:
Oliver Gugger
2025-06-30 15:45:14 +02:00
committed by GitHub
4 changed files with 75 additions and 1 deletions

View File

@@ -99,6 +99,10 @@ circuit. The indices are only available for forwarding events saved after v0.20.
## Code Health
- [Increase itest coverage](https://github.com/lightningnetwork/lnd/pull/9990)
for payments. Now the payment address is mandatory for the writer and
reader of a payment request.
## Breaking Changes
## Performance Improvements
@@ -159,3 +163,4 @@ circuit. The indices are only available for forwarding events saved after v0.20.
* Funyug
* Mohamed Awnallah
* Pins
* Ziggie

View File

@@ -1038,7 +1038,11 @@ func (i *InvoiceRegistry) notifyExitHopHtlcLocked(
)
switch {
case errors.Is(err, ErrInvoiceNotFound) ||
errors.Is(err, ErrNoInvoicesCreated):
errors.Is(err, ErrNoInvoicesCreated) ||
errors.Is(err, ErrInvRefEquivocation):
log.Debugf("Invoice not found with error: %v, failing htlc",
err)
// If the invoice was not found, return a failure resolution
// with an invoice not found result.

View File

@@ -683,6 +683,10 @@ var allTestCases = []*lntest.TestCase{
Name: "invoice migration",
TestFunc: testInvoiceMigration,
},
{
Name: "payment address mismatch",
TestFunc: testWrongPaymentAddr,
},
{
Name: "fee replacement",
TestFunc: testFeeReplacement,

View File

@@ -1396,3 +1396,64 @@ func testSendPaymentKeysendMPPFail(ht *lntest.HarnessTest) {
_, err = ht.ReceivePaymentUpdate(client)
require.Error(ht, err)
}
// testWrongPaymentAddr is a test that checks that a payment using a wrong
// payment address will fail.
func testWrongPaymentAddr(ht *lntest.HarnessTest) {
// Set the feerate to be 10 sat/vb.
ht.SetFeeEstimate(2500)
// Open a channel with 100k satoshis between Alice and Bob with Alice
// being the sole funder of the channel.
chanAmt := btcutil.Amount(100_000)
openChannelParams := lntest.OpenChannelParams{
Amt: chanAmt,
}
cfgs := [][]string{nil, nil}
invoiceAmt := int64(1000)
// Create a two hop network: Alice -> Bob.
_, nodes := ht.CreateSimpleNetwork(cfgs, openChannelParams)
alice, bob := nodes[0], nodes[1]
request1 := bob.RPC.AddInvoice(&lnrpc.Invoice{
ValueMsat: invoiceAmt,
CltvExpiry: finalCltvDelta,
})
request2 := bob.RPC.AddInvoice(&lnrpc.Invoice{
ValueMsat: invoiceAmt,
CltvExpiry: finalCltvDelta,
})
payReq2 := alice.RPC.DecodePayReq(request2.PaymentRequest)
ht.AssertNumInvoices(bob, 2)
// Now we don't want to use the payment request to send the payment
// because we want to use the payment_addr two for the payment of the
// invoice 1 to simulate the case where the payment address is wrong.
route := alice.RPC.BuildRoute(
&routerrpc.BuildRouteRequest{
PaymentAddr: payReq2.PaymentAddr,
AmtMsat: invoiceAmt,
FinalCltvDelta: finalCltvDelta,
HopPubkeys: [][]byte{bob.PubKey[:]},
},
)
// Send the payment and expect it to fail the payment.
htlcAttempt := alice.RPC.SendToRouteV2(
&routerrpc.SendToRouteRequest{
Route: route.Route,
PaymentHash: request1.RHash,
},
)
require.Equal(ht, lnrpc.HTLCAttempt_FAILED, htlcAttempt.Status)
// Make sure the payment is marked as failed also in the database.
ht.AssertPaymentStatus(
alice, lntypes.Hash(request1.RHash), lnrpc.Payment_FAILED,
)
}