fix the lsps2 cltv delta check

It was wrongly assumed that the lsp had to enforce a cltv delta +2. It is
actually the recipient creating invoices with a cltv delta +2, but the LSP does
not have anything to do with that.
This commit is contained in:
Jesse de Wit
2024-01-19 16:19:04 +01:00
parent fc6c5982b3
commit 833c79e27f
5 changed files with 6 additions and 78 deletions

View File

@@ -210,11 +210,6 @@ var allTestCases = []*testCase{
test: testLsps2HappyFlow,
isLsps2: true,
},
{
name: "testLsps2Cltv",
test: testLsps2Cltv,
isLsps2: true,
},
{
name: "testLsps2NoBalance",
test: testLsps2NoBalance,

View File

@@ -1,66 +0,0 @@
package itest
import (
"log"
"time"
"github.com/breez/lntest"
"github.com/breez/lspd/lsps2"
"github.com/stretchr/testify/assert"
)
func testLsps2Cltv(p *testParams) {
alice := lntest.NewClnNode(p.h, p.m, "Alice")
alice.Start()
alice.Fund(10000000)
p.lsp.LightningNode().Fund(10000000)
log.Print("Opening channel between Alice and the lsp")
channel := alice.OpenChannel(p.lsp.LightningNode(), &lntest.OpenChannelOptions{
AmountSat: publicChanAmount,
})
aliceLspScid := alice.WaitForChannelReady(channel)
log.Print("Connecting bob to lspd")
p.BreezClient().Node().ConnectPeer(p.lsp.LightningNode())
// Make sure everything is activated.
<-time.After(htlcInterceptorDelay)
log.Printf("Calling lsps2.get_info")
info := Lsps2GetInfo(p.BreezClient(), p.Lsp(), lsps2.GetInfoRequest{
Token: &WorkingToken,
})
outerAmountMsat := uint64(2100000)
innerAmountMsat := lsps2CalculateInnerAmountMsat(p.lsp, outerAmountMsat, info.OpeningFeeParamsMenu[0])
p.BreezClient().SetHtlcAcceptor(innerAmountMsat)
log.Printf("Calling lsps2.buy")
buyResp := Lsps2Buy(p.BreezClient(), p.Lsp(), lsps2.BuyRequest{
OpeningFeeParams: *info.OpeningFeeParamsMenu[0],
PaymentSizeMsat: &outerAmountMsat,
})
log.Printf("Adding bob's invoices")
description := "Please pay me"
_, outerInvoice := GenerateLsps2Invoices(p.BreezClient(),
generateInvoicesRequest{
innerAmountMsat: innerAmountMsat,
outerAmountMsat: outerAmountMsat,
description: description,
lsp: p.lsp,
},
buyResp.JitChannelScid)
// TODO: Fix race waiting for htlc interceptor.
log.Printf("Waiting %v to allow htlc interceptor to activate.", htlcInterceptorDelay)
<-time.After(htlcInterceptorDelay)
log.Printf("Alice paying")
route := constructRoute(p.Lsp().LightningNode(), p.BreezClient().Node(), aliceLspScid, lntest.NewShortChanIDFromString(buyResp.JitChannelScid), outerAmountMsat)
// Increment the delay by one (should be incremented by 2), so the cltv delta is too little.
route.Hops[0].Delay++
_, err := alice.PayViaRoute(outerAmountMsat, outerInvoice.paymentHash, outerInvoice.paymentSecret, route)
assert.Contains(p.t, err.Error(), "WIRE_INCORRECT_CLTV_EXPIRY")
}