fees: split wallet and estimator fee reasons

The block policy estimator's FeeReason enum mixed two unrelated
concerns: the threshold that produced an estimateSmartFee result
(NONE, HALF_ESTIMATE, ...) and the reason the wallet selected a fee
rate (FALLBACK, MEMPOOL_MIN, REQUIRED).

Split them so each layer owns the reasons it reports:

- Add a wallet-facing FeeReason enum with the reasons the wallet can
  select a fee rate: FEE_RATE_ESTIMATOR, MEMPOOL_MIN, USER_SPECIFIED,
  FALLBACK, and REQUIRED.

- Rename the estimator enum to BlockPolicyEstimateReason and narrow it
  to estimator reasons: NONE, HALF_ESTIMATE, FULL_ESTIMATE,
  DOUBLE_ESTIMATE, and CONSERVATIVE.

- Return wallet fee selection metadata through MinimumFeeRateResult
  instead of exposing FeeCalculation to wallet callers. The returned
  target is now optional and is only set for fee rate estimator results.

Flatten GetMinimumFeeRate() with early returns while preserving the fee
selection order: user feerate still only applies the required-fee check,
while smart-fee results keep fallback, mempool-min, and required fallbacks.
The returned target is cleared for fallback, mempool-min, and required
results.

Replace the CreateTransactionInternal log with a simpler message that
does not depend on estimateSmartFee internals. Detailed estimator
logging will be added in a follow-up commit.
This commit is contained in:
ismaelsadeeq
2026-06-26 21:11:21 +01:00
parent f72537037d
commit 74245c20e0
19 changed files with 157 additions and 101 deletions

View File

@@ -8,12 +8,14 @@
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
#include <util/fees.h>
#include <cstdint>
#include <string>
#include <vector>
using common::StringForFeeReason;
using common::StringForBlockPolicyEstimateReason;
FUZZ_TARGET(fees)
{
@@ -26,6 +28,8 @@ FUZZ_TARGET(fees)
const CAmount rounded_fee = fee_filter_rounder.round(current_minimum_fee);
assert(MoneyRange(rounded_fee));
}
const FeeReason fee_reason = fuzzed_data_provider.PickValueInArray({FeeReason::NONE, FeeReason::HALF_ESTIMATE, FeeReason::FULL_ESTIMATE, FeeReason::DOUBLE_ESTIMATE, FeeReason::CONSERVATIVE, FeeReason::MEMPOOL_MIN, FeeReason::FALLBACK, FeeReason::REQUIRED});
const FeeReason fee_reason = fuzzed_data_provider.PickValueInArray({FeeReason::FEE_RATE_ESTIMATOR, FeeReason::MEMPOOL_MIN, FeeReason::USER_SPECIFIED, FeeReason::FALLBACK, FeeReason::REQUIRED});
(void)StringForFeeReason(fee_reason);
const BlockPolicyEstimateReason block_policy_fee_reason = fuzzed_data_provider.PickValueInArray({BlockPolicyEstimateReason::NONE, BlockPolicyEstimateReason::HALF_ESTIMATE, BlockPolicyEstimateReason::FULL_ESTIMATE, BlockPolicyEstimateReason::DOUBLE_ESTIMATE, BlockPolicyEstimateReason::CONSERVATIVE});
(void)StringForBlockPolicyEstimateReason(block_policy_fee_reason);
}