mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-11 14:48:14 +01:00
routing: account for blinded routes in fee calculation
When we introduce blinded routes, some of our hops are expected to have zero amounts to forward in their hop payload. This commit updates our hop fee logic to attribute the full blinded route's fees to the introduction node. We can't actually know where/how these fees are distributed, so we collect them all at the introduction node.
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
940b491051
commit
11a007dc16
@@ -296,3 +296,42 @@ func testPayloadSize(t *testing.T, hops []*Hop) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestBlindedHopFee tests calculation of hop fees for blinded routes.
|
||||
func TestBlindedHopFee(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
route := &Route{
|
||||
TotalAmount: 1500,
|
||||
Hops: []*Hop{
|
||||
// Start with two un-blinded hops.
|
||||
{
|
||||
AmtToForward: 1450,
|
||||
},
|
||||
{
|
||||
AmtToForward: 1300,
|
||||
},
|
||||
{
|
||||
// Our introduction node will have a zero
|
||||
// forward amount.
|
||||
AmtToForward: 0,
|
||||
},
|
||||
{
|
||||
// An intermediate blinded hop will also have
|
||||
// a zero forward amount.
|
||||
AmtToForward: 0,
|
||||
},
|
||||
{
|
||||
// Our final blinded hop should have a forward
|
||||
// amount set.
|
||||
AmtToForward: 1000,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
require.Equal(t, lnwire.MilliSatoshi(50), route.HopFee(0))
|
||||
require.Equal(t, lnwire.MilliSatoshi(150), route.HopFee(1))
|
||||
require.Equal(t, lnwire.MilliSatoshi(300), route.HopFee(2))
|
||||
require.Equal(t, lnwire.MilliSatoshi(0), route.HopFee(3))
|
||||
require.Equal(t, lnwire.MilliSatoshi(0), route.HopFee(4))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user