Skip to content

Commit

Permalink
itest: multi-hop payment test with negative inbound fee
Browse files Browse the repository at this point in the history
Ensure that negative fees are backwards compatible.
  • Loading branch information
joostjager committed Nov 14, 2023
1 parent 4c0a1b3 commit 31769d8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 11 deletions.
12 changes: 12 additions & 0 deletions docs/release-notes/release-notes-0.18.0.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Release Notes
- [Release Notes](#release-notes)
- [Bug Fixes](#bug-fixes)
- [New Features](#new-features)
- [Functional Enhancements](#functional-enhancements)
- [RPC Additions](#rpc-additions)
- [lncli Additions](#lncli-additions)
- [Improvements](#improvements)
- [Functional Updates](#functional-updates)
- [Tlv](#tlv)
- [RPC Updates](#rpc-updates)
- [lncli Updates](#lncli-updates)
- [Code Health](#code-health)
Expand Down Expand Up @@ -40,6 +42,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
Expand Down Expand Up @@ -123,6 +134,7 @@
* Andras Banki-Horvath
* Carla Kirk-Cohen
* Elle Mouton
* Joost Jager
* Keagan McClelland
* Matt Morehouse
* Slyghtning
Expand Down
42 changes: 31 additions & 11 deletions itest/lnd_multi-hop-payments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand All @@ -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
Expand Down Expand Up @@ -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{
Expand All @@ -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)
Expand Down

0 comments on commit 31769d8

Please sign in to comment.