mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-29 23:21:12 +02:00
routerrpc+zpay32: EstimateRouteFee overhaul
In this commit the mission control based fee estimation is supplemented with a payment probe estimation which can lead to more accurate estimation results. The probing utilizes a hop-hint heurisic to detect routes through LSPs in order to manually estimate fees to destinations behind an LSP that would otherwise block the payment probe.
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package zpay32
|
||||
|
||||
import "github.com/btcsuite/btcd/btcec/v2"
|
||||
import (
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultAssumedFinalCLTVDelta is the default value to be used as the
|
||||
@@ -10,6 +13,9 @@ const (
|
||||
// See also:
|
||||
// https://github.com/lightning/bolts/blob/master/02-peer-protocol.md
|
||||
DefaultAssumedFinalCLTVDelta = 18
|
||||
|
||||
// feeRateParts is the total number of parts used to express fee rates.
|
||||
feeRateParts = 1e6
|
||||
)
|
||||
|
||||
// HopHint is a routing hint that contains the minimum information of a channel
|
||||
@@ -45,3 +51,13 @@ func (h HopHint) Copy() HopHint {
|
||||
CLTVExpiryDelta: h.CLTVExpiryDelta,
|
||||
}
|
||||
}
|
||||
|
||||
// HopFee calculates the fee for a given amount that is forwarded over a hop.
|
||||
// The amount has to be denoted in milli satoshi. The returned fee is also
|
||||
// denoted in milli satoshi.
|
||||
func (h HopHint) HopFee(amt lnwire.MilliSatoshi) lnwire.MilliSatoshi {
|
||||
baseFee := lnwire.MilliSatoshi(h.FeeBaseMSat)
|
||||
feeRate := lnwire.MilliSatoshi(h.FeeProportionalMillionths)
|
||||
|
||||
return baseFee + (amt*feeRate)/feeRateParts
|
||||
}
|
||||
|
Reference in New Issue
Block a user