From a9f1b2448d0c490c0fe4405f99e25a22e01fa8ae Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Tue, 11 Oct 2022 09:18:56 +0200 Subject: [PATCH] itest: multi-hop payment test with negative inbound fee Ensure that negative fees are backwards compatible. --- docs/release-notes/release-notes-0.18.0.md | 12 +++++++ itest/lnd_multi-hop-payments_test.go | 42 ++++++++++++++++------ 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/docs/release-notes/release-notes-0.18.0.md b/docs/release-notes/release-notes-0.18.0.md index 59ded97843..8acaf2d740 100644 --- a/docs/release-notes/release-notes-0.18.0.md +++ b/docs/release-notes/release-notes-0.18.0.md @@ -1,4 +1,5 @@ # Release Notes +- [Release Notes](#release-notes) - [Bug Fixes](#bug-fixes) - [New Features](#new-features) - [Functional Enhancements](#functional-enhancements) @@ -6,6 +7,7 @@ - [lncli Additions](#lncli-additions) - [Improvements](#improvements) - [Functional Updates](#functional-updates) + - [Tlv](#tlv) - [RPC Updates](#rpc-updates) - [lncli Updates](#lncli-updates) - [Code Health](#code-health) @@ -48,6 +50,15 @@ # New Features ## Functional Enhancements +* Experimental support for [inbound routing + fees](https://github.com/lightningnetwork/lnd/pull/6703) is added. This allows + node operators to require senders to pay an inbound fee for forwards and + payments. It is recommended to only use negative fees (an inbound "discount") + initially to keep the channels open for senders that do not recognize inbound + fees. In this release, no send support for pathfinding and route building is + added yet. We first want to learn more about the impact that inbound fees have + on the routing economy. + * A new config value, [sweeper.maxfeerate](https://github.com/lightningnetwork/lnd/pull/7823), is added so users can specify the max allowed fee rate when sweeping onchain @@ -175,6 +186,7 @@ * Andras Banki-Horvath * Carla Kirk-Cohen * Elle Mouton +* Joost Jager * Keagan McClelland * Marcos Fernandez Perez * Matt Morehouse diff --git a/itest/lnd_multi-hop-payments_test.go b/itest/lnd_multi-hop-payments_test.go index 30a4464710..55dddcb831 100644 --- a/itest/lnd_multi-hop-payments_test.go +++ b/itest/lnd_multi-hop-payments_test.go @@ -74,14 +74,29 @@ func testMultiHopPayments(ht *lntest.HarnessTest) { const aliceFeeRatePPM = 100000 updateChannelPolicy( ht, alice, chanPointAlice, aliceBaseFeeSat*1000, - aliceFeeRatePPM, chainreg.DefaultBitcoinTimeLockDelta, + aliceFeeRatePPM, 0, 0, chainreg.DefaultBitcoinTimeLockDelta, maxHtlc, carol, ) + // Define a negative inbound fee for Alice, to verify that this is + // backwards compatible with an older sender ignoring the discount. + const ( + aliceInboundBaseFeeMsat = -1 + aliceInboundFeeRate = -10000 + ) + + updateChannelPolicy( + ht, alice, chanPointDave, 0, 0, + aliceInboundBaseFeeMsat, aliceInboundFeeRate, + chainreg.DefaultBitcoinTimeLockDelta, maxHtlc, + dave, + ) + const daveBaseFeeSat = 5 const daveFeeRatePPM = 150000 updateChannelPolicy( ht, dave, chanPointDave, daveBaseFeeSat*1000, daveFeeRatePPM, + 0, 0, chainreg.DefaultBitcoinTimeLockDelta, maxHtlc, carol, ) @@ -104,8 +119,9 @@ func testMultiHopPayments(ht *lntest.HarnessTest) { ht.AssertAmountPaid("Alice(local) => Bob(remote)", alice, chanPointAlice, expectedAmountPaidAtoB, int64(0)) - // To forward a payment of 1000 sat, Alice is charging a fee of - // 1 sat + 10% = 101 sat. + // To forward a payment of 1000 sat, Alice is charging a fee of 1 sat + + // 10% = 101 sat. Note that this does not include the inbound fee + // (discount) because there is no sender support yet. const aliceFeePerPayment = aliceBaseFeeSat + (paymentAmt * aliceFeeRatePPM / 1_000_000) const expectedFeeAlice = numPayments * aliceFeePerPayment @@ -224,15 +240,17 @@ func testMultiHopPayments(ht *lntest.HarnessTest) { // NOTE: only used in current test. func updateChannelPolicy(ht *lntest.HarnessTest, hn *node.HarnessNode, chanPoint *lnrpc.ChannelPoint, baseFee int64, - feeRate int64, timeLockDelta uint32, - maxHtlc uint64, listenerNode *node.HarnessNode) { + feeRate int64, inboundBaseFee, inboundFeeRate int32, + timeLockDelta uint32, maxHtlc uint64, listenerNode *node.HarnessNode) { expectedPolicy := &lnrpc.RoutingPolicy{ - FeeBaseMsat: baseFee, - FeeRateMilliMsat: feeRate, - TimeLockDelta: timeLockDelta, - MinHtlc: 1000, // default value - MaxHtlcMsat: maxHtlc, + FeeBaseMsat: baseFee, + FeeRateMilliMsat: feeRate, + TimeLockDelta: timeLockDelta, + MinHtlc: 1000, // default value + MaxHtlcMsat: maxHtlc, + InboundFeeBaseMsat: inboundBaseFee, + InboundFeeRateMilliMsat: inboundFeeRate, } updateFeeReq := &lnrpc.PolicyUpdateRequest{ @@ -242,7 +260,9 @@ func updateChannelPolicy(ht *lntest.HarnessTest, hn *node.HarnessNode, Scope: &lnrpc.PolicyUpdateRequest_ChanPoint{ ChanPoint: chanPoint, }, - MaxHtlcMsat: maxHtlc, + MaxHtlcMsat: maxHtlc, + InboundBaseFeeMsat: inboundBaseFee, + InboundFeeRatePpm: inboundFeeRate, } hn.RPC.UpdateChannelPolicy(updateFeeReq)