From 42ff52bbfb8329ca40cdb3aa9b31b835697ebb8d Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Fri, 18 Aug 2023 18:37:04 +0800 Subject: [PATCH] sweep: cap to max fee rate instead of failing This commit caps the estimated fee rate at the configged max fee rate instead of returning an error. --- sweep/sweeper.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sweep/sweeper.go b/sweep/sweeper.go index cd31e8620..44e1656b4 100644 --- a/sweep/sweeper.go +++ b/sweep/sweeper.go @@ -478,9 +478,15 @@ func (s *UtxoSweeper) feeRateForPreference( return 0, fmt.Errorf("fee preference resulted in invalid fee "+ "rate %v, minimum is %v", feeRate, s.relayFeeRate) } + + // If the estimated fee rate is above the maximum allowed fee rate, + // default to the max fee rate. if feeRate > s.cfg.MaxFeeRate.FeePerKWeight() { - return 0, fmt.Errorf("fee preference resulted in invalid fee "+ - "rate %v, maximum is %v", feeRate, s.cfg.MaxFeeRate) + log.Warnf("Estimated fee rate %v exceeds max allowed fee "+ + "rate %v, using max fee rate instead", feeRate, + s.cfg.MaxFeeRate.FeePerKWeight()) + + return s.cfg.MaxFeeRate.FeePerKWeight(), nil } return feeRate, nil