Merge pull request #1333 from Roasbeef/min-fee-rate
funding+htlcswitch: enforce min fee rate of 253 sat/kw on commitments
This commit is contained in:
commit
4bde4c1c26
@ -67,6 +67,11 @@ const (
|
|||||||
// currently accepted on the Litecoin chain within the Lightning
|
// currently accepted on the Litecoin chain within the Lightning
|
||||||
// Protocol.
|
// Protocol.
|
||||||
maxLtcFundingAmount = maxBtcFundingAmount * btcToLtcConversionRate
|
maxLtcFundingAmount = maxBtcFundingAmount * btcToLtcConversionRate
|
||||||
|
|
||||||
|
// minCommitFeePerKw is the smallest fee rate that we should propose
|
||||||
|
// for a new fee update. We'll use this as a fee floor when proposing
|
||||||
|
// and accepting updates.
|
||||||
|
minCommitFeePerKw = 253
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -2520,12 +2525,19 @@ func (f *fundingManager) handleInitFundingMsg(msg *initFundingMsg) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// The protocol currently operates on the basis of fee-per-kw, so we'll
|
// If the converted fee-per-kw is below the current widely used policy
|
||||||
// multiply the computed sat/weight by 1000 to arrive at fee-per-kw.
|
// floor, then we'll use the floor instead.
|
||||||
commitFeePerKw := feePerVSize.FeePerKWeight()
|
commitFeePerKw := feePerVSize.FeePerKWeight()
|
||||||
|
if commitFeePerKw < minCommitFeePerKw {
|
||||||
|
fndgLog.Infof("Proposed fee rate of %v sat/kw is below min "+
|
||||||
|
"of %v sat/kw, using fee floor", int64(commitFeePerKw),
|
||||||
|
int64(minCommitFeePerKw))
|
||||||
|
|
||||||
// We set the channel flags to indicate whether we want this channel
|
commitFeePerKw = minCommitFeePerKw
|
||||||
// to be announced to the network.
|
}
|
||||||
|
|
||||||
|
// We set the channel flags to indicate whether we want this channel to
|
||||||
|
// be announced to the network.
|
||||||
var channelFlags lnwire.FundingFlag
|
var channelFlags lnwire.FundingFlag
|
||||||
if !msg.openChanReq.private {
|
if !msg.openChanReq.private {
|
||||||
// This channel will be announced.
|
// This channel will be announced.
|
||||||
|
@ -30,6 +30,11 @@ const (
|
|||||||
//
|
//
|
||||||
// TODO(roasbeef): must be < default delta
|
// TODO(roasbeef): must be < default delta
|
||||||
expiryGraceDelta = 2
|
expiryGraceDelta = 2
|
||||||
|
|
||||||
|
// minCommitFeePerKw is the smallest fee rate that we should propose
|
||||||
|
// for a new fee update. We'll use this as a fee floor when proposing
|
||||||
|
// and accepting updates.
|
||||||
|
minCommitFeePerKw = 253
|
||||||
)
|
)
|
||||||
|
|
||||||
// ForwardingPolicy describes the set of constraints that a given ChannelLink
|
// ForwardingPolicy describes the set of constraints that a given ChannelLink
|
||||||
@ -476,6 +481,16 @@ func (l *channelLink) sampleNetworkFee() (lnwallet.SatPerKWeight, error) {
|
|||||||
// Once we have this fee rate, we'll convert to sat-per-kw.
|
// Once we have this fee rate, we'll convert to sat-per-kw.
|
||||||
feePerKw := feePerVSize.FeePerKWeight()
|
feePerKw := feePerVSize.FeePerKWeight()
|
||||||
|
|
||||||
|
// If the returned feePerKw is less than the current widely used
|
||||||
|
// policy, then we'll use that instead as a floor.
|
||||||
|
if feePerKw < minCommitFeePerKw {
|
||||||
|
log.Debugf("Proposed fee rate of %v sat/kw is below min "+
|
||||||
|
"of %v sat/kw, using fee floor", int64(feePerKw),
|
||||||
|
int64(minCommitFeePerKw))
|
||||||
|
|
||||||
|
feePerKw = minCommitFeePerKw
|
||||||
|
}
|
||||||
|
|
||||||
log.Debugf("ChannelLink(%v): sampled fee rate for 3 block conf: %v "+
|
log.Debugf("ChannelLink(%v): sampled fee rate for 3 block conf: %v "+
|
||||||
"sat/kw", l, int64(feePerKw))
|
"sat/kw", l, int64(feePerKw))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user