mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-13 11:09:23 +01:00
chainfee: special case a zero fee estimation.
Bitcoind will not report any fee estimation in case it has not enough data available. We used to just set the min mempool fee in such cases but this might not represent the current fee situation of the bitcoin network. We return an error now so that we will use the fallback fee instead.
This commit is contained in:
parent
b1d3b9f678
commit
45c6ee69d2
1 changed files with 12 additions and 3 deletions
|
@ -311,6 +311,8 @@ type BitcoindEstimator struct {
|
||||||
// to "CONSERVATIVE".
|
// to "CONSERVATIVE".
|
||||||
feeMode string
|
feeMode string
|
||||||
|
|
||||||
|
// TODO(ziggie): introduce an interface for the client to enhance
|
||||||
|
// testability of the estimator.
|
||||||
bitcoindConn *rpcclient.Client
|
bitcoindConn *rpcclient.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,6 +474,13 @@ func (b *BitcoindEstimator) fetchEstimate(confTarget uint32) (SatPerKWeight, err
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bitcoind will not report any fee estimation if it has not enough
|
||||||
|
// data available hence the fee will remain zero. We return an error
|
||||||
|
// here to make sure that we do not use the min relay fee instead.
|
||||||
|
if satPerKB == 0 {
|
||||||
|
return 0, fmt.Errorf("fee estimation data not available yet")
|
||||||
|
}
|
||||||
|
|
||||||
// Since we use fee rates in sat/kw internally, we'll convert the
|
// Since we use fee rates in sat/kw internally, we'll convert the
|
||||||
// estimated fee rate from its sat/kb representation to sat/kw.
|
// estimated fee rate from its sat/kb representation to sat/kw.
|
||||||
satPerKw := SatPerKVByte(satPerKB).FeePerKWeight()
|
satPerKw := SatPerKVByte(satPerKB).FeePerKWeight()
|
||||||
|
@ -479,14 +488,14 @@ func (b *BitcoindEstimator) fetchEstimate(confTarget uint32) (SatPerKWeight, err
|
||||||
// Finally, we'll enforce our fee floor.
|
// Finally, we'll enforce our fee floor.
|
||||||
minRelayFee := b.minFeeManager.fetchMinFee()
|
minRelayFee := b.minFeeManager.fetchMinFee()
|
||||||
if satPerKw < minRelayFee {
|
if satPerKw < minRelayFee {
|
||||||
log.Debugf("Estimated fee rate of %v sat/kw is too low, "+
|
log.Debugf("Estimated fee rate of %v is too low, "+
|
||||||
"using fee floor of %v sat/kw instead", satPerKw,
|
"using fee floor of %v instead", satPerKw,
|
||||||
minRelayFee)
|
minRelayFee)
|
||||||
|
|
||||||
satPerKw = minRelayFee
|
satPerKw = minRelayFee
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("Returning %v sat/kw for conf target of %v",
|
log.Debugf("Returning %v for conf target of %v",
|
||||||
int64(satPerKw), confTarget)
|
int64(satPerKw), confTarget)
|
||||||
|
|
||||||
return satPerKw, nil
|
return satPerKw, nil
|
||||||
|
|
Loading…
Add table
Reference in a new issue