channeldb: add ComputeFee function

This commit is contained in:
Joost Jager committed 2019-09-17 11:10:58 +02:00
1 parent 95502da7e8
commit 8c44cf4a22
2 files changed
+14 -11

No files matched your search

+12
View File
@@ -155,6 +155,9 @@ const (
// would be possible for a node to create a ton of updates and slowly
// fill our disk, and also waste bandwidth due to relaying.
MaxAllowedExtraOpaqueBytes = 10000
// feeRateParts is the total number of parts used to express fee rates.
feeRateParts = 1e6
)
// ChannelGraph is a persistent, on-disk graph representation of the Lightning
@@ -2820,6 +2823,15 @@ func (c *ChannelEdgePolicy) IsDisabled() bool {
lnwire.ChanUpdateDisabled
}
// ComputeFee computes the fee to forward an HTLC of `amt` milli-satoshis over
// the passed active payment channel. This value is currently computed as
// specified in BOLT07, but will likely change in the near future.
func (c *ChannelEdgePolicy) ComputeFee(
amt lnwire.MilliSatoshi) lnwire.MilliSatoshi {
return c.FeeBaseMSat + (amt*c.FeeProportionalMillionths)/feeRateParts
}
// FetchChannelEdgesByOutpoint attempts to lookup the two directed edges for
// the channel identified by the funding outpoint. If the channel can't be
// found, then ErrEdgeNotFound is returned. A struct which houses the general