Part of #34075
Motivation
The wallet currently depends on CBlockPolicyEstimator internals through FeeCalculation and the old FeeReason enum returned by estimateSmartFee.
That enum mixed two different concepts:
- why the block policy estimator chose a specific estimate, such as the half-target, full-target, double-target, or conservative threshold;
- why the wallet selected the fee rate it will use, such as fallback fee, mempool minimum fee, user-specified fee, or minimum required fee.
This coupling makes wallet fee selection harder to reason about and exposes estimator-specific details through wallet code and wallet RPC output. This PR separates those concerns so the estimator owns its internal estimate reasons and the wallet reports only wallet-level fee selection reasons.
Key Changes
Split wallet and estimator fee reasons:
- Added a wallet-facing
FeeReasonenum insrc/util/fees.hwithFEE_RATE_ESTIMATOR,MEMPOOL_MIN,USER_SPECIFIED,FALLBACK, andREQUIRED. - Renamed the estimator reason enum to
BlockPolicyEstimateReasonand scoped it to estimator outputs:NONE,HALF_ESTIMATE,FULL_ESTIMATE,DOUBLE_ESTIMATE, andCONSERVATIVE.
- Added a wallet-facing
Stop passing estimator internals through wallet fee selection:
- Replaced the
FeeCalculation*output parameter inwallet::GetMinimumFeeRatewith aMinimumFeeRateResultstruct containing the selected fee rate, wallet fee reason, and returned target. - Updated wallet, Qt, RPC, interface, and test/fuzz callers to use the wallet fee reason instead of
FeeCalculation. - Updated
CreatedTransactionResultto store the walletFeeReasoninstead of a fullFeeCalculation.
- Replaced the
Keep wallet RPC
fee_reasonat wallet scope:- Verbose wallet RPC responses still use the existing
fee_reasonfield name for compatibility. - The field now reports the wallet fee selection reason, not the block policy estimator's detailed threshold reason.
- The help text for the affected wallet RPC responses was updated to describe this behavior.
- Verbose wallet RPC responses still use the existing
Move estimator reason stringification into the estimator:
- Moved
StringForBlockPolicyEstimateReasonout ofsrc/common/messages.cppand intosrc/policy/fees/block_policy_estimator.cpp. - Implemented it with a
switchwithout adefaultcase so missing enum cases can be caught by compiler warnings.
- Moved
Move detailed estimator logging into
estimateSmartFee:CBlockPolicyEstimator::estimateSmartFeenow always populates a localFeeCalculation, even when the caller does not pass one, so estimator debug logging remains available inside the estimator.- The detailed estimate debug log now lives in
estimateSmartFee, where the estimator data originates. - Wallet transaction creation now logs only the selected fee, transaction size, and wallet fee reason.