Skip to content

Commit 01555f6

Browse files
Merge #7129: chore: sync formating of rpc (exclude wallet rpc) code with Bitcoin Core
1a49e0f refactor: change function order to unify with Bitcoin Core in rpc/node (Konstantin Akimov) 1bde72a fmt: unify formatting for RPC code with Bitcoin Core (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented Doing backports for any RPC-related is struggle, because at some points formatting of files got different; due to missing changes from bitcoin#14726, bitcoin#25029, bitcoin#17809 and multiple other occasions. ## What was done? Manually sync formatting with rpc/ code (exclude wallet) Bitcoin Core v25.99 (commit bbbf89a) See also: #7130 These changes are split to 2 PR to reduce amount of conflicts and rebases in case of any backport are done due to huge diff size. Hint: use 'ignore whitespace' feature to review this PR. ## How Has This Been Tested? On top of this PR finally succeed to backport bitcoin#24118 for which I had lots of troubles to resolve conflicts. ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone ACKs for top commit: UdjinM6: utACK 1a49e0f Tree-SHA512: c9848090c85f968453d667db60c910312dc76e2eba601551c60b388531de18a57ecbe30769c4fe1f218c36e83423a24ae1e219bc20f2ecb6f01b5f46e0d90ab9
2 parents f7b9d60 + 1a49e0f commit 01555f6

11 files changed

Lines changed: 1233 additions & 1236 deletions

src/rpc/blockchain.cpp

Lines changed: 325 additions & 326 deletions
Large diffs are not rendered by default.

src/rpc/fees.cpp

Lines changed: 96 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -63,40 +63,40 @@ static RPCHelpMan estimatesmartfee()
6363
HelpExampleRpc("estimatesmartfee", "6")
6464
},
6565
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
66-
{
67-
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VSTR});
68-
69-
CBlockPolicyEstimator& fee_estimator = EnsureAnyFeeEstimator(request.context);
70-
const NodeContext& node = EnsureAnyNodeContext(request.context);
71-
const CTxMemPool& mempool = EnsureMemPool(node);
72-
73-
unsigned int max_target = fee_estimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE);
74-
unsigned int conf_target = ParseConfirmTarget(request.params[0], max_target);
75-
bool conservative = true;
76-
if (!request.params[1].isNull()) {
77-
FeeEstimateMode fee_mode;
78-
if (!FeeModeFromString(request.params[1].get_str(), fee_mode)) {
79-
throw JSONRPCError(RPC_INVALID_PARAMETER, InvalidEstimateModeErrorMessage());
80-
}
81-
if (fee_mode == FeeEstimateMode::ECONOMICAL) conservative = false;
82-
}
83-
84-
UniValue result(UniValue::VOBJ);
85-
UniValue errors(UniValue::VARR);
86-
FeeCalculation feeCalc;
87-
CFeeRate feeRate{fee_estimator.estimateSmartFee(conf_target, &feeCalc, conservative)};
88-
if (feeRate != CFeeRate(0)) {
89-
CFeeRate min_mempool_feerate{mempool.GetMinFee(gArgs.GetIntArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000)};
90-
CFeeRate min_relay_feerate{::minRelayTxFee};
91-
feeRate = std::max({feeRate, min_mempool_feerate, min_relay_feerate});
92-
result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK()));
93-
} else {
94-
errors.push_back("Insufficient data or no feerate found");
95-
result.pushKV("errors", errors);
96-
}
97-
result.pushKV("blocks", feeCalc.returnedTarget);
98-
return result;
99-
},
66+
{
67+
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VSTR});
68+
69+
CBlockPolicyEstimator& fee_estimator = EnsureAnyFeeEstimator(request.context);
70+
const NodeContext& node = EnsureAnyNodeContext(request.context);
71+
const CTxMemPool& mempool = EnsureMemPool(node);
72+
73+
unsigned int max_target = fee_estimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE);
74+
unsigned int conf_target = ParseConfirmTarget(request.params[0], max_target);
75+
bool conservative = true;
76+
if (!request.params[1].isNull()) {
77+
FeeEstimateMode fee_mode;
78+
if (!FeeModeFromString(request.params[1].get_str(), fee_mode)) {
79+
throw JSONRPCError(RPC_INVALID_PARAMETER, InvalidEstimateModeErrorMessage());
80+
}
81+
if (fee_mode == FeeEstimateMode::ECONOMICAL) conservative = false;
82+
}
83+
84+
UniValue result(UniValue::VOBJ);
85+
UniValue errors(UniValue::VARR);
86+
FeeCalculation feeCalc;
87+
CFeeRate feeRate{fee_estimator.estimateSmartFee(conf_target, &feeCalc, conservative)};
88+
if (feeRate != CFeeRate(0)) {
89+
CFeeRate min_mempool_feerate{mempool.GetMinFee(gArgs.GetIntArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000)};
90+
CFeeRate min_relay_feerate{::minRelayTxFee};
91+
feeRate = std::max({feeRate, min_mempool_feerate, min_relay_feerate});
92+
result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK()));
93+
} else {
94+
errors.push_back("Insufficient data or no feerate found");
95+
result.pushKV("errors", errors);
96+
}
97+
result.pushKV("blocks", feeCalc.returnedTarget);
98+
return result;
99+
},
100100
};
101101
}
102102

@@ -154,68 +154,68 @@ static RPCHelpMan estimaterawfee()
154154
HelpExampleCli("estimaterawfee", "6 0.9")
155155
},
156156
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
157-
{
158-
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM}, true);
159-
160-
CBlockPolicyEstimator& fee_estimator = EnsureAnyFeeEstimator(request.context);
161-
162-
unsigned int max_target = fee_estimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE);
163-
unsigned int conf_target = ParseConfirmTarget(request.params[0], max_target);
164-
double threshold = 0.95;
165-
if (!request.params[1].isNull()) {
166-
threshold = request.params[1].get_real();
167-
}
168-
if (threshold < 0 || threshold > 1) {
169-
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid threshold");
170-
}
171-
172-
UniValue result(UniValue::VOBJ);
173-
174-
for (const FeeEstimateHorizon horizon : ALL_FEE_ESTIMATE_HORIZONS) {
175-
CFeeRate feeRate;
176-
EstimationResult buckets;
177-
178-
// Only output results for horizons which track the target
179-
if (conf_target > fee_estimator.HighestTargetTracked(horizon)) continue;
180-
181-
feeRate = fee_estimator.estimateRawFee(conf_target, threshold, horizon, &buckets);
182-
UniValue horizon_result(UniValue::VOBJ);
183-
UniValue errors(UniValue::VARR);
184-
UniValue passbucket(UniValue::VOBJ);
185-
passbucket.pushKV("startrange", round(buckets.pass.start));
186-
passbucket.pushKV("endrange", round(buckets.pass.end));
187-
passbucket.pushKV("withintarget", round(buckets.pass.withinTarget * 100.0) / 100.0);
188-
passbucket.pushKV("totalconfirmed", round(buckets.pass.totalConfirmed * 100.0) / 100.0);
189-
passbucket.pushKV("inmempool", round(buckets.pass.inMempool * 100.0) / 100.0);
190-
passbucket.pushKV("leftmempool", round(buckets.pass.leftMempool * 100.0) / 100.0);
191-
UniValue failbucket(UniValue::VOBJ);
192-
failbucket.pushKV("startrange", round(buckets.fail.start));
193-
failbucket.pushKV("endrange", round(buckets.fail.end));
194-
failbucket.pushKV("withintarget", round(buckets.fail.withinTarget * 100.0) / 100.0);
195-
failbucket.pushKV("totalconfirmed", round(buckets.fail.totalConfirmed * 100.0) / 100.0);
196-
failbucket.pushKV("inmempool", round(buckets.fail.inMempool * 100.0) / 100.0);
197-
failbucket.pushKV("leftmempool", round(buckets.fail.leftMempool * 100.0) / 100.0);
198-
199-
// CFeeRate(0) is used to indicate error as a return value from estimateRawFee
200-
if (feeRate != CFeeRate(0)) {
201-
horizon_result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK()));
202-
horizon_result.pushKV("decay", buckets.decay);
203-
horizon_result.pushKV("scale", (int)buckets.scale);
204-
horizon_result.pushKV("pass", passbucket);
205-
// buckets.fail.start == -1 indicates that all buckets passed, there is no fail bucket to output
206-
if (buckets.fail.start != -1) horizon_result.pushKV("fail", failbucket);
207-
} else {
208-
// Output only information that is still meaningful in the event of error
209-
horizon_result.pushKV("decay", buckets.decay);
210-
horizon_result.pushKV("scale", (int)buckets.scale);
211-
horizon_result.pushKV("fail", failbucket);
212-
errors.push_back("Insufficient data or no feerate found which meets threshold");
213-
horizon_result.pushKV("errors", errors);
214-
}
215-
result.pushKV(StringForFeeEstimateHorizon(horizon), horizon_result);
216-
}
217-
return result;
218-
},
157+
{
158+
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM}, true);
159+
160+
CBlockPolicyEstimator& fee_estimator = EnsureAnyFeeEstimator(request.context);
161+
162+
unsigned int max_target = fee_estimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE);
163+
unsigned int conf_target = ParseConfirmTarget(request.params[0], max_target);
164+
double threshold = 0.95;
165+
if (!request.params[1].isNull()) {
166+
threshold = request.params[1].get_real();
167+
}
168+
if (threshold < 0 || threshold > 1) {
169+
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid threshold");
170+
}
171+
172+
UniValue result(UniValue::VOBJ);
173+
174+
for (const FeeEstimateHorizon horizon : ALL_FEE_ESTIMATE_HORIZONS) {
175+
CFeeRate feeRate;
176+
EstimationResult buckets;
177+
178+
// Only output results for horizons which track the target
179+
if (conf_target > fee_estimator.HighestTargetTracked(horizon)) continue;
180+
181+
feeRate = fee_estimator.estimateRawFee(conf_target, threshold, horizon, &buckets);
182+
UniValue horizon_result(UniValue::VOBJ);
183+
UniValue errors(UniValue::VARR);
184+
UniValue passbucket(UniValue::VOBJ);
185+
passbucket.pushKV("startrange", round(buckets.pass.start));
186+
passbucket.pushKV("endrange", round(buckets.pass.end));
187+
passbucket.pushKV("withintarget", round(buckets.pass.withinTarget * 100.0) / 100.0);
188+
passbucket.pushKV("totalconfirmed", round(buckets.pass.totalConfirmed * 100.0) / 100.0);
189+
passbucket.pushKV("inmempool", round(buckets.pass.inMempool * 100.0) / 100.0);
190+
passbucket.pushKV("leftmempool", round(buckets.pass.leftMempool * 100.0) / 100.0);
191+
UniValue failbucket(UniValue::VOBJ);
192+
failbucket.pushKV("startrange", round(buckets.fail.start));
193+
failbucket.pushKV("endrange", round(buckets.fail.end));
194+
failbucket.pushKV("withintarget", round(buckets.fail.withinTarget * 100.0) / 100.0);
195+
failbucket.pushKV("totalconfirmed", round(buckets.fail.totalConfirmed * 100.0) / 100.0);
196+
failbucket.pushKV("inmempool", round(buckets.fail.inMempool * 100.0) / 100.0);
197+
failbucket.pushKV("leftmempool", round(buckets.fail.leftMempool * 100.0) / 100.0);
198+
199+
// CFeeRate(0) is used to indicate error as a return value from estimateRawFee
200+
if (feeRate != CFeeRate(0)) {
201+
horizon_result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK()));
202+
horizon_result.pushKV("decay", buckets.decay);
203+
horizon_result.pushKV("scale", (int)buckets.scale);
204+
horizon_result.pushKV("pass", passbucket);
205+
// buckets.fail.start == -1 indicates that all buckets passed, there is no fail bucket to output
206+
if (buckets.fail.start != -1) horizon_result.pushKV("fail", failbucket);
207+
} else {
208+
// Output only information that is still meaningful in the event of error
209+
horizon_result.pushKV("decay", buckets.decay);
210+
horizon_result.pushKV("scale", (int)buckets.scale);
211+
horizon_result.pushKV("fail", failbucket);
212+
errors.push_back("Insufficient data or no feerate found which meets threshold");
213+
horizon_result.pushKV("errors", errors);
214+
}
215+
result.pushKV(StringForFeeEstimateHorizon(horizon), horizon_result);
216+
}
217+
return result;
218+
},
219219
};
220220
}
221221

src/rpc/mempool.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -236,37 +236,37 @@ static RPCHelpMan testmempoolaccept()
236236
static std::vector<RPCResult> MempoolEntryDescription()
237237
{
238238
return {
239-
RPCResult{RPCResult::Type::NUM, "vsize", "virtual transaction size. This can be different from actual serialized size for high-sigop transactions."},
240-
RPCResult{RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true,
241-
"transaction fee, denominated in " + CURRENCY_UNIT + " (DEPRECATED, returned only if config option -deprecatedrpc=fees is passed)"},
242-
RPCResult{RPCResult::Type::STR_AMOUNT, "modifiedfee", /*optional=*/true,
243-
"transaction fee with fee deltas used for mining priority, denominated in " + CURRENCY_UNIT +
244-
" (DEPRECATED, returned only if config option -deprecatedrpc=fees is passed)"},
245-
RPCResult{RPCResult::Type::NUM_TIME, "time", "local time transaction entered pool in " + UNIX_EPOCH_TIME},
246-
RPCResult{RPCResult::Type::NUM, "height", "block height when transaction entered pool"},
247-
RPCResult{RPCResult::Type::NUM, "descendantcount", "number of in-mempool descendant transactions (including this one)"},
248-
RPCResult{RPCResult::Type::NUM, "descendantsize", "size of in-mempool descendants (including this one)"},
249-
RPCResult{RPCResult::Type::STR_AMOUNT, "descendantfees", /*optional=*/true,
250-
"transaction fees of in-mempool descendants (including this one) with fee deltas used for mining priority, denominated in " +
251-
CURRENCY_ATOM + "s (DEPRECATED, returned only if config option -deprecatedrpc=fees is passed)"},
252-
RPCResult{RPCResult::Type::NUM, "ancestorcount", "number of in-mempool ancestor transactions (including this one)"},
253-
RPCResult{RPCResult::Type::NUM, "ancestorsize", "size of in-mempool ancestors (including this one)"},
254-
RPCResult{RPCResult::Type::STR_AMOUNT, "ancestorfees", /*optional=*/true,
255-
"transaction fees of in-mempool ancestors (including this one) with fee deltas used for mining priority, denominated in " +
256-
CURRENCY_ATOM + "s (DEPRECATED, returned only if config option -deprecatedrpc=fees is passed)"},
257-
RPCResult{RPCResult::Type::OBJ, "fees", "",
258-
{
259-
RPCResult{RPCResult::Type::STR_AMOUNT, "base", "transaction fee, denominated in " + CURRENCY_UNIT},
260-
RPCResult{RPCResult::Type::STR_AMOUNT, "modified", "transaction fee with fee deltas used for mining priority, denominated in " + CURRENCY_UNIT},
261-
RPCResult{RPCResult::Type::STR_AMOUNT, "ancestor", "transaction fees of in-mempool ancestors (including this one) with fee deltas used for mining priority, denominated in " + CURRENCY_UNIT},
262-
RPCResult{RPCResult::Type::STR_AMOUNT, "descendant", "transaction fees of in-mempool descendants (including this one) with fee deltas used for mining priority, denominated in " + CURRENCY_UNIT},
263-
}},
264-
RPCResult{RPCResult::Type::ARR, "depends", "unconfirmed transactions used as inputs for this transaction",
265-
{RPCResult{RPCResult::Type::STR_HEX, "transactionid", "parent transaction id"}}},
266-
RPCResult{RPCResult::Type::ARR, "spentby", "unconfirmed transactions spending outputs from this transaction",
267-
{RPCResult{RPCResult::Type::STR_HEX, "transactionid", "child transaction id"}}},
268-
RPCResult{RPCResult::Type::BOOL, "instantsend", "True if this transaction was locked via InstantSend"},
269-
RPCResult{RPCResult::Type::BOOL, "unbroadcast", "Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)"}
239+
RPCResult{RPCResult::Type::NUM, "vsize", "virtual transaction size. This can be different from actual serialized size for high-sigop transactions."},
240+
RPCResult{RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true,
241+
"transaction fee, denominated in " + CURRENCY_UNIT + " (DEPRECATED, returned only if config option -deprecatedrpc=fees is passed)"},
242+
RPCResult{RPCResult::Type::STR_AMOUNT, "modifiedfee", /*optional=*/true,
243+
"transaction fee with fee deltas used for mining priority, denominated in " + CURRENCY_UNIT +
244+
" (DEPRECATED, returned only if config option -deprecatedrpc=fees is passed)"},
245+
RPCResult{RPCResult::Type::NUM_TIME, "time", "local time transaction entered pool in " + UNIX_EPOCH_TIME},
246+
RPCResult{RPCResult::Type::NUM, "height", "block height when transaction entered pool"},
247+
RPCResult{RPCResult::Type::NUM, "descendantcount", "number of in-mempool descendant transactions (including this one)"},
248+
RPCResult{RPCResult::Type::NUM, "descendantsize", "size of in-mempool descendants (including this one)"},
249+
RPCResult{RPCResult::Type::STR_AMOUNT, "descendantfees", /*optional=*/true,
250+
"transaction fees of in-mempool descendants (including this one) with fee deltas used for mining priority, denominated in " +
251+
CURRENCY_ATOM + "s (DEPRECATED, returned only if config option -deprecatedrpc=fees is passed)"},
252+
RPCResult{RPCResult::Type::NUM, "ancestorcount", "number of in-mempool ancestor transactions (including this one)"},
253+
RPCResult{RPCResult::Type::NUM, "ancestorsize", "size of in-mempool ancestors (including this one)"},
254+
RPCResult{RPCResult::Type::STR_AMOUNT, "ancestorfees", /*optional=*/true,
255+
"transaction fees of in-mempool ancestors (including this one) with fee deltas used for mining priority, denominated in " +
256+
CURRENCY_ATOM + "s (DEPRECATED, returned only if config option -deprecatedrpc=fees is passed)"},
257+
RPCResult{RPCResult::Type::OBJ, "fees", "",
258+
{
259+
RPCResult{RPCResult::Type::STR_AMOUNT, "base", "transaction fee, denominated in " + CURRENCY_UNIT},
260+
RPCResult{RPCResult::Type::STR_AMOUNT, "modified", "transaction fee with fee deltas used for mining priority, denominated in " + CURRENCY_UNIT},
261+
RPCResult{RPCResult::Type::STR_AMOUNT, "ancestor", "transaction fees of in-mempool ancestors (including this one) with fee deltas used for mining priority, denominated in " + CURRENCY_UNIT},
262+
RPCResult{RPCResult::Type::STR_AMOUNT, "descendant", "transaction fees of in-mempool descendants (including this one) with fee deltas used for mining priority, denominated in " + CURRENCY_UNIT},
263+
}},
264+
RPCResult{RPCResult::Type::ARR, "depends", "unconfirmed transactions used as inputs for this transaction",
265+
{RPCResult{RPCResult::Type::STR_HEX, "transactionid", "parent transaction id"}}},
266+
RPCResult{RPCResult::Type::ARR, "spentby", "unconfirmed transactions spending outputs from this transaction",
267+
{RPCResult{RPCResult::Type::STR_HEX, "transactionid", "child transaction id"}}},
268+
RPCResult{RPCResult::Type::BOOL, "instantsend", "True if this transaction was locked via InstantSend"},
269+
RPCResult{RPCResult::Type::BOOL, "unbroadcast", "Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)"}
270270
};
271271
}
272272

0 commit comments

Comments
 (0)