rpc: Optionally print feerates in sat/vb

bitcoin/bitcoin: PR #33741

1 minor finding · 3 suggestions

Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.

Findings

Link

[minor] · sat_vb bucket conversion can cast out-of-range doubles to CAmount

With sat_vb=true, crafted or corrupted local estimator data can make estimaterawfee cast out-of-range doubles to CAmount; no normal producer of these boundaries was found, and production impact is unconfirmed.

Location: src/rpc/fees.cpp:252 (head).

Details and suggested fix

static_cast<double>(INT64_MAX) rounds up to 2^63, so the strict > check admits 2^63. There is also no check for finite values below -2^63. Both reach an undefined floating-to-integer conversion. CBlockPolicyEstimator::Read accepts bucket doubles without range validation when the rest of the file is structurally valid. With empty statistics, the last boundary becomes fail.end, which this RPC formats even when estimation fails. The base emitted these fields as doubles without the cast. Check >= 2^63 and < -2^63 before converting, and route both cases through the existing scaled-double fallback.


Optional improvements

Link

[suggestion] · OpenRPC labels the new sat/vB outputs as BTC amounts

sat_vb=true makes five fee-rate fields use sat/vB while OpenRPC still tags them as BTC amounts; no in-tree consumer of the tag was found outside the schema test, so client misinterpretation remains unconfirmed.

Location: src/rpc/mempool.cpp:1154 (head).

Details and suggested fix

getmempoolinfo keeps STR_AMOUNT for mempoolminfee, minrelaytxfee and incrementalrelayfee, as does getnetworkinfo for relayfee and incrementalfee. The generator maps that type to x-bitcoin-unit: amount, documented as BTC, regardless of the request option. The updated descriptions explain the units only in prose. Use RPCResult::Type::NUM with those conditional descriptions to avoid giving schema consumers a contradictory unit annotation. This preserves the numeric wire format but also removes the pre-existing amount tag in the default BTC/kvB mode.


Link

[suggestion] · Functional tests do not verify the selected fee-rate units

The new functional assertions compare equivalent call forms, not numeric results across unit modes, so handlers that ignore sat_vb would still satisfy them.

Location: test/functional/rpc_named_arguments.py:41 (head).

Details and suggested fix

Each loop compares calls at the same sat_vb value. Forcing the handlers to use BTC_KVB while retaining option parsing would leave these assertions satisfied; rpc_format_feerate_values tests the formatter directly, not handler wiring. The fee-RPC fixture reaches height 200, but the cache removes estimator files and the test adds no fee-paying transactions, so its block_policy loop does not exercise a successful feerate. Compare known rates such as minrelaytxfee and relayfee across modes using the factor 100000, and check raw-estimate bucket boundaries against their default values divided by 1000. Add successful smart/raw feerate conversion assertions to a fixture with fee data, such as feature_fee_estimation.py, requiring the field to be present.


Link

[suggestion] · estimaterawfee help obscures the different default units

The hidden estimaterawfee RPC removes feerate's unit and retains previously unitless bucket descriptions, obscuring that sat_vb converts estimates from BTC/kvB but boundaries from sat/kvB.

Location: src/rpc/fees.cpp:178 (head).

Details and suggested fix

FeeEstimateHorizonDoc now says only "estimate fee rate", while the option help describes a switch from BTC/kvB to sat/vB. That source unit does not apply to startrange and endrange, whose default values are rounded sat/kvB boundaries. Describe feerate as "in BTC/kvB, or sat/vB if sat_vb is true" and both bucket boundaries as "in sat/kvB, or sat/vB if sat_vb is true". This makes both modes interpretable without knowing the estimator's internal units.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.