rpc: extract fee estimate result helpers
What changed, and why it matters
This commit is a straightforward code cleanup in Bitcoin Core's RPC help documentation. It extracts repeated fee-estimation help text into reusable helper functions so the code is easier to maintain. It does not change what the software actually does, what data it returns, or how it handles user input.
No security action needed. Treat as a normal maintainability refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors src/rpc/fees.cpp by introducing FeeRateBucketDoc() and FeeEstimateHorizonDoc() helpers and using ElideGroup() to compress repeated documentation sections in the estimaterawfee RPC help output. The change is purely presentational: the same fields are documented in the same structure, just generated from shared helpers rather than inline literals. No runtime logic, serialization, validation, or consensus code is modified.
Changed components
src/rpc/fees.cppestimaterawfee RPC help documentationInspect captured patch +32 / −28
diff --git a/src/rpc/fees.cpp b/src/rpc/fees.cpp
index b1982669..450af530 100644
--- a/src/rpc/fees.cpp
+++ b/src/rpc/fees.cpp
@@ -94,6 +94,35 @@ static RPCMethod estimatesmartfee()
};
}
+static std::vector<RPCResult> FeeRateBucketDoc(bool elide = false)
+{
+ auto fields = std::vector<RPCResult>{
+ {RPCResult::Type::NUM, "startrange", "start of feerate range"},
+ {RPCResult::Type::NUM, "endrange", "end of feerate range"},
+ {RPCResult::Type::NUM, "withintarget", "number of txs over history horizon in the feerate range that were confirmed within target"},
+ {RPCResult::Type::NUM, "totalconfirmed", "number of txs over history horizon in the feerate range that were confirmed at any point"},
+ {RPCResult::Type::NUM, "inmempool", "current number of txs in mempool in the feerate range unconfirmed for at least target blocks"},
+ {RPCResult::Type::NUM, "leftmempool", "number of txs over history horizon in the feerate range that left mempool unconfirmed after target"},
+ };
+ return elide ? ElideGroup(std::move(fields)) : fields;
+}
+
+static std::vector<RPCResult> FeeEstimateHorizonDoc(bool elide = false)
+{
+ auto fields = std::vector<RPCResult>{
+ {RPCResult::Type::NUM, "feerate", /*optional=*/true, "estimate fee rate in " + CURRENCY_UNIT + "/kvB"},
+ {RPCResult::Type::NUM, "decay", "exponential decay (per block) for historical moving average of confirmation data"},
+ {RPCResult::Type::NUM, "scale", "The resolution of confirmation targets at this time horizon"},
+ {RPCResult::Type::OBJ, "pass", /*optional=*/true, "information about the lowest range of feerates to succeed in meeting the threshold", FeeRateBucketDoc()},
+ {RPCResult::Type::OBJ, "fail", /*optional=*/true, "information about the highest range of feerates to fail to meet the threshold", FeeRateBucketDoc(/*elide=*/true)},
+ {RPCResult::Type::ARR, "errors", /*optional=*/true, "Errors encountered during processing (if there are any)",
+ {
+ {RPCResult::Type::STR, "error", ""},
+ }},
+ };
+ return elide ? ElideGroup(std::move(fields)) : fields;
+}
+
static RPCMethod estimaterawfee()
{
return RPCMethod{
@@ -115,36 +144,11 @@ static RPCMethod estimaterawfee()
RPCResult::Type::OBJ, "", "Results are returned for any horizon which tracks blocks up to the confirmation target",
{
{RPCResult::Type::OBJ, "short", /*optional=*/true, "estimate for short time horizon",
- {
- {RPCResult::Type::NUM, "feerate", /*optional=*/true, "estimate fee rate in " + CURRENCY_UNIT + "/kvB"},
- {RPCResult::Type::NUM, "decay", "exponential decay (per block) for historical moving average of confirmation data"},
- {RPCResult::Type::NUM, "scale", "The resolution of confirmation targets at this time horizon"},
- {RPCResult::Type::OBJ, "pass", /*optional=*/true, "information about the lowest range of feerates to succeed in meeting the threshold",
- {
- {RPCResult::Type::NUM, "startrange", "start of feerate range"},
- {RPCResult::Type::NUM, "endrange", "end of feerate range"},
- {RPCResult::Type::NUM, "withintarget", "number of txs over history horizon in the feerate range that were confirmed within target"},
- {RPCResult::Type::NUM, "totalconfirmed", "number of txs over history horizon in the feerate range that were confirmed at any point"},
- {RPCResult::Type::NUM, "inmempool", "current number of txs in mempool in the feerate range unconfirmed for at least target blocks"},
- {RPCResult::Type::NUM, "leftmempool", "number of txs over history horizon in the feerate range that left mempool unconfirmed after target"},
- }},
- {RPCResult::Type::OBJ, "fail", /*optional=*/true, "information about the highest range of feerates to fail to meet the threshold",
- {
- {RPCResult::Type::ELISION, "", ""},
- }},
- {RPCResult::Type::ARR, "errors", /*optional=*/true, "Errors encountered during processing (if there are any)",
- {
- {RPCResult::Type::STR, "error", ""},
- }},
- }},
+ FeeEstimateHorizonDoc()},
{RPCResult::Type::OBJ, "medium", /*optional=*/true, "estimate for medium time horizon",
- {
- {RPCResult::Type::ELISION, "", ""},
- }},
+ FeeEstimateHorizonDoc(/*elide=*/true)},
{RPCResult::Type::OBJ, "long", /*optional=*/true, "estimate for long time horizon",
- {
- {RPCResult::Type::ELISION, "", ""},
- }},
+ FeeEstimateHorizonDoc(/*elide=*/true)},
}},
RPCExamples{
HelpExampleCli("estimaterawfee", "6 0.9")
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.