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.
This commit is contained in:
yyforyongyu 2023-08-18 18:37:04 +08:00 committed by Olaoluwa Osuntokun
parent 32fccc434b
commit 42ff52bbfb

View File

@ -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