From 5f0561fdbc4ed89ca99a19194169945e2d56b081 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 6 May 2021 19:12:17 +0800 Subject: [PATCH] chainfee: replace conf target when it exceeds the maxBlockTarget In this commit, we add a check inside EstimateFeePerKW for bitcoind so that when the conf target exceeds the maxBlockTarget, we will use maxBlockTarget instead. --- lnwallet/chainfee/estimator.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lnwallet/chainfee/estimator.go b/lnwallet/chainfee/estimator.go index 77047567c..59d2b2f26 100644 --- a/lnwallet/chainfee/estimator.go +++ b/lnwallet/chainfee/estimator.go @@ -375,7 +375,16 @@ func (b *BitcoindEstimator) Stop() error { // confirmation and returns the estimated fee expressed in sat/kw. // // NOTE: This method is part of the Estimator interface. -func (b *BitcoindEstimator) EstimateFeePerKW(numBlocks uint32) (SatPerKWeight, error) { +func (b *BitcoindEstimator) EstimateFeePerKW( + numBlocks uint32) (SatPerKWeight, error) { + + if numBlocks > maxBlockTarget { + log.Debugf("conf target %d exceeds the max value, "+ + "use %d instead.", numBlocks, maxBlockTarget, + ) + numBlocks = maxBlockTarget + } + feeEstimate, err := b.fetchEstimate(numBlocks) switch { // If the estimator doesn't have enough data, or returns an error, then