mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-21 14:10:35 +02:00
routing: add inbound fee support for BuildRoute
This commit is contained in:
@@ -3688,7 +3688,7 @@ func TestLightningNodeSigVerification(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestComputeFee tests fee calculation based on both in- and outgoing amt.
|
||||
// TestComputeFee tests fee calculation based on the outgoing amt.
|
||||
func TestComputeFee(t *testing.T) {
|
||||
var (
|
||||
policy = models.ChannelEdgePolicy{
|
||||
@@ -3703,11 +3703,6 @@ func TestComputeFee(t *testing.T) {
|
||||
if fee != expectedFee {
|
||||
t.Fatalf("expected fee %v, got %v", expectedFee, fee)
|
||||
}
|
||||
|
||||
fwdFee := policy.ComputeFeeFromIncoming(outgoingAmt + fee)
|
||||
if fwdFee != expectedFee {
|
||||
t.Fatalf("expected fee %v, but got %v", fee, fwdFee)
|
||||
}
|
||||
}
|
||||
|
||||
// TestBatchedAddChannelEdge asserts that BatchedAddChannelEdge properly
|
||||
|
@@ -71,17 +71,6 @@ func (c *CachedEdgePolicy) ComputeFee(
|
||||
return c.FeeBaseMSat + (amt*c.FeeProportionalMillionths)/feeRateParts
|
||||
}
|
||||
|
||||
// ComputeFeeFromIncoming computes the fee to forward an HTLC given the incoming
|
||||
// amount.
|
||||
func (c *CachedEdgePolicy) ComputeFeeFromIncoming(
|
||||
incomingAmt lnwire.MilliSatoshi) lnwire.MilliSatoshi {
|
||||
|
||||
return incomingAmt - divideCeil(
|
||||
feeRateParts*(incomingAmt-c.FeeBaseMSat),
|
||||
feeRateParts+c.FeeProportionalMillionths,
|
||||
)
|
||||
}
|
||||
|
||||
// NewCachedPolicy turns a full policy into a minimal one that can be cached.
|
||||
func NewCachedPolicy(policy *ChannelEdgePolicy) *CachedEdgePolicy {
|
||||
return &CachedEdgePolicy{
|
||||
|
@@ -113,19 +113,3 @@ func (c *ChannelEdgePolicy) ComputeFee(
|
||||
|
||||
return c.FeeBaseMSat + (amt*c.FeeProportionalMillionths)/feeRateParts
|
||||
}
|
||||
|
||||
// divideCeil divides dividend by factor and rounds the result up.
|
||||
func divideCeil(dividend, factor lnwire.MilliSatoshi) lnwire.MilliSatoshi {
|
||||
return (dividend + factor - 1) / factor
|
||||
}
|
||||
|
||||
// ComputeFeeFromIncoming computes the fee to forward an HTLC given the incoming
|
||||
// amount.
|
||||
func (c *ChannelEdgePolicy) ComputeFeeFromIncoming(
|
||||
incomingAmt lnwire.MilliSatoshi) lnwire.MilliSatoshi {
|
||||
|
||||
return incomingAmt - divideCeil(
|
||||
feeRateParts*(incomingAmt-c.FeeBaseMSat),
|
||||
feeRateParts+c.FeeProportionalMillionths,
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user