mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Merge bitcoin/bitcoin#30115: rpc: avoid copying into UniValue
d7707d9843
rpc: avoid copying into UniValue (Cory Fields) Pull request description: These are the simple (and hopefully obviously correct) copies that can be moves instead. This is a follow-up from https://github.com/bitcoin/bitcoin/pull/30094#issuecomment-2108751842 As it turns out, there are hundreds of places where we copy UniValues needlessly. It should be the case that moves are always preferred over copies, so there should be no downside to these changes. willcl-ark, however, noticed that memory usage may increase in some cases. Logically this makes no sense to me. The only plausible explanation imo is that because the moves are faster, more ops/second occur in some cases. This list of moves was obtained by changing the function signatures of the UniValue functions to accept only rvalues, then compiling and fixing them up one by one. There still exist many places where copies are being made. These can/should be fixed up, but weren't done here for the sake of doing the easy ones first. I ran these changes through clang-tidy with `performance-move-const-arg` and `bugprone-use-after-move` and no bugs were detected (though that's obviously not to say it can be trusted 100%). As stated above, there are still lots of other less trivial fixups to do after these including: - Using non-const UniValues where possible so that moves can happen - Refactoring code in order to be able to move a UniValue without introducing a use-after-move - Refactoring functions to accept UniValues by value rather than by const reference ACKs for top commit: achow101: ACKd7707d9843
ryanofsky: Code review ACKd7707d9843
. No changes since last review other than rebase. I agree benchmarks showing increased peak memory usage and RSS are surprising, but number of allocations is down as expected, and runtime is also decreased. willcl-ark: ACKd7707d9843
Tree-SHA512: 7f511be73984553c278186286a7d161a34b2574c7f5f1a0edc87c2913b4c025a0af5241ef9af2df17547f2e4ef79710aa5bbb762fc9472435781c0488dba3435
This commit is contained in:
commit
6300438a2e
27 changed files with 183 additions and 183 deletions
|
@ -297,7 +297,7 @@ public:
|
||||||
total += counts.at(i);
|
total += counts.at(i);
|
||||||
}
|
}
|
||||||
addresses.pushKV("total", total);
|
addresses.pushKV("total", total);
|
||||||
result.pushKV("addresses_known", addresses);
|
result.pushKV("addresses_known", std::move(addresses));
|
||||||
return JSONRPCReplyObj(std::move(result), NullUniValue, /*id=*/1, JSONRPCVersion::V1_LEGACY);
|
return JSONRPCReplyObj(std::move(result), NullUniValue, /*id=*/1, JSONRPCVersion::V1_LEGACY);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -348,7 +348,7 @@ public:
|
||||||
connections.pushKV("in", batch[ID_NETWORKINFO]["result"]["connections_in"]);
|
connections.pushKV("in", batch[ID_NETWORKINFO]["result"]["connections_in"]);
|
||||||
connections.pushKV("out", batch[ID_NETWORKINFO]["result"]["connections_out"]);
|
connections.pushKV("out", batch[ID_NETWORKINFO]["result"]["connections_out"]);
|
||||||
connections.pushKV("total", batch[ID_NETWORKINFO]["result"]["connections"]);
|
connections.pushKV("total", batch[ID_NETWORKINFO]["result"]["connections"]);
|
||||||
result.pushKV("connections", connections);
|
result.pushKV("connections", std::move(connections));
|
||||||
|
|
||||||
result.pushKV("networks", batch[ID_NETWORKINFO]["result"]["networks"]);
|
result.pushKV("networks", batch[ID_NETWORKINFO]["result"]["networks"]);
|
||||||
result.pushKV("difficulty", batch[ID_BLOCKCHAININFO]["result"]["difficulty"]);
|
result.pushKV("difficulty", batch[ID_BLOCKCHAININFO]["result"]["difficulty"]);
|
||||||
|
@ -940,7 +940,7 @@ static void GetWalletBalances(UniValue& result)
|
||||||
const UniValue& balance = getbalances.find_value("result")["mine"]["trusted"];
|
const UniValue& balance = getbalances.find_value("result")["mine"]["trusted"];
|
||||||
balances.pushKV(wallet_name, balance);
|
balances.pushKV(wallet_name, balance);
|
||||||
}
|
}
|
||||||
result.pushKV("balances", balances);
|
result.pushKV("balances", std::move(balances));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -201,14 +201,14 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
|
||||||
UniValue o(UniValue::VOBJ);
|
UniValue o(UniValue::VOBJ);
|
||||||
o.pushKV("asm", ScriptToAsmStr(txin.scriptSig, true));
|
o.pushKV("asm", ScriptToAsmStr(txin.scriptSig, true));
|
||||||
o.pushKV("hex", HexStr(txin.scriptSig));
|
o.pushKV("hex", HexStr(txin.scriptSig));
|
||||||
in.pushKV("scriptSig", o);
|
in.pushKV("scriptSig", std::move(o));
|
||||||
}
|
}
|
||||||
if (!tx.vin[i].scriptWitness.IsNull()) {
|
if (!tx.vin[i].scriptWitness.IsNull()) {
|
||||||
UniValue txinwitness(UniValue::VARR);
|
UniValue txinwitness(UniValue::VARR);
|
||||||
for (const auto& item : tx.vin[i].scriptWitness.stack) {
|
for (const auto& item : tx.vin[i].scriptWitness.stack) {
|
||||||
txinwitness.push_back(HexStr(item));
|
txinwitness.push_back(HexStr(item));
|
||||||
}
|
}
|
||||||
in.pushKV("txinwitness", txinwitness);
|
in.pushKV("txinwitness", std::move(txinwitness));
|
||||||
}
|
}
|
||||||
if (have_undo) {
|
if (have_undo) {
|
||||||
const Coin& prev_coin = txundo->vprevout[i];
|
const Coin& prev_coin = txundo->vprevout[i];
|
||||||
|
@ -224,14 +224,14 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
|
||||||
p.pushKV("generated", bool(prev_coin.fCoinBase));
|
p.pushKV("generated", bool(prev_coin.fCoinBase));
|
||||||
p.pushKV("height", uint64_t(prev_coin.nHeight));
|
p.pushKV("height", uint64_t(prev_coin.nHeight));
|
||||||
p.pushKV("value", ValueFromAmount(prev_txout.nValue));
|
p.pushKV("value", ValueFromAmount(prev_txout.nValue));
|
||||||
p.pushKV("scriptPubKey", o_script_pub_key);
|
p.pushKV("scriptPubKey", std::move(o_script_pub_key));
|
||||||
in.pushKV("prevout", p);
|
in.pushKV("prevout", std::move(p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
in.pushKV("sequence", (int64_t)txin.nSequence);
|
in.pushKV("sequence", (int64_t)txin.nSequence);
|
||||||
vin.push_back(in);
|
vin.push_back(std::move(in));
|
||||||
}
|
}
|
||||||
entry.pushKV("vin", vin);
|
entry.pushKV("vin", std::move(vin));
|
||||||
|
|
||||||
UniValue vout(UniValue::VARR);
|
UniValue vout(UniValue::VARR);
|
||||||
for (unsigned int i = 0; i < tx.vout.size(); i++) {
|
for (unsigned int i = 0; i < tx.vout.size(); i++) {
|
||||||
|
@ -244,14 +244,14 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
|
||||||
|
|
||||||
UniValue o(UniValue::VOBJ);
|
UniValue o(UniValue::VOBJ);
|
||||||
ScriptToUniv(txout.scriptPubKey, /*out=*/o, /*include_hex=*/true, /*include_address=*/true);
|
ScriptToUniv(txout.scriptPubKey, /*out=*/o, /*include_hex=*/true, /*include_address=*/true);
|
||||||
out.pushKV("scriptPubKey", o);
|
out.pushKV("scriptPubKey", std::move(o));
|
||||||
vout.push_back(out);
|
vout.push_back(std::move(out));
|
||||||
|
|
||||||
if (have_undo) {
|
if (have_undo) {
|
||||||
amt_total_out += txout.nValue;
|
amt_total_out += txout.nValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entry.pushKV("vout", vout);
|
entry.pushKV("vout", std::move(vout));
|
||||||
|
|
||||||
if (have_undo) {
|
if (have_undo) {
|
||||||
const CAmount fee = amt_total_in - amt_total_out;
|
const CAmount fee = amt_total_in - amt_total_out;
|
||||||
|
|
|
@ -43,7 +43,7 @@ UniValue BanMapToJson(const banmap_t& bans)
|
||||||
const auto& ban_entry = it.second;
|
const auto& ban_entry = it.second;
|
||||||
UniValue j = ban_entry.ToJson();
|
UniValue j = ban_entry.ToJson();
|
||||||
j.pushKV(BANMAN_JSON_ADDR_KEY, address.ToString());
|
j.pushKV(BANMAN_JSON_ADDR_KEY, address.ToString());
|
||||||
bans_json.push_back(j);
|
bans_json.push_back(std::move(j));
|
||||||
}
|
}
|
||||||
return bans_json;
|
return bans_json;
|
||||||
}
|
}
|
||||||
|
|
|
@ -934,10 +934,10 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std::
|
||||||
// include the script in a json output
|
// include the script in a json output
|
||||||
UniValue o(UniValue::VOBJ);
|
UniValue o(UniValue::VOBJ);
|
||||||
ScriptToUniv(coin.out.scriptPubKey, /*out=*/o, /*include_hex=*/true, /*include_address=*/true);
|
ScriptToUniv(coin.out.scriptPubKey, /*out=*/o, /*include_hex=*/true, /*include_address=*/true);
|
||||||
utxo.pushKV("scriptPubKey", o);
|
utxo.pushKV("scriptPubKey", std::move(o));
|
||||||
utxos.push_back(utxo);
|
utxos.push_back(std::move(utxo));
|
||||||
}
|
}
|
||||||
objGetUTXOResponse.pushKV("utxos", utxos);
|
objGetUTXOResponse.pushKV("utxos", std::move(utxos));
|
||||||
|
|
||||||
// return json string
|
// return json string
|
||||||
std::string strJSON = objGetUTXOResponse.write() + "\n";
|
std::string strJSON = objGetUTXOResponse.write() + "\n";
|
||||||
|
|
|
@ -1025,9 +1025,9 @@ static RPCHelpMan gettxoutsetinfo()
|
||||||
unspendables.pushKV("bip30", ValueFromAmount(stats.total_unspendables_bip30 - prev_stats.total_unspendables_bip30));
|
unspendables.pushKV("bip30", ValueFromAmount(stats.total_unspendables_bip30 - prev_stats.total_unspendables_bip30));
|
||||||
unspendables.pushKV("scripts", ValueFromAmount(stats.total_unspendables_scripts - prev_stats.total_unspendables_scripts));
|
unspendables.pushKV("scripts", ValueFromAmount(stats.total_unspendables_scripts - prev_stats.total_unspendables_scripts));
|
||||||
unspendables.pushKV("unclaimed_rewards", ValueFromAmount(stats.total_unspendables_unclaimed_rewards - prev_stats.total_unspendables_unclaimed_rewards));
|
unspendables.pushKV("unclaimed_rewards", ValueFromAmount(stats.total_unspendables_unclaimed_rewards - prev_stats.total_unspendables_unclaimed_rewards));
|
||||||
block_info.pushKV("unspendables", unspendables);
|
block_info.pushKV("unspendables", std::move(unspendables));
|
||||||
|
|
||||||
ret.pushKV("block_info", block_info);
|
ret.pushKV("block_info", std::move(block_info));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to read UTXO set");
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to read UTXO set");
|
||||||
|
@ -1111,7 +1111,7 @@ static RPCHelpMan gettxout()
|
||||||
ret.pushKV("value", ValueFromAmount(coin.out.nValue));
|
ret.pushKV("value", ValueFromAmount(coin.out.nValue));
|
||||||
UniValue o(UniValue::VOBJ);
|
UniValue o(UniValue::VOBJ);
|
||||||
ScriptToUniv(coin.out.scriptPubKey, /*out=*/o, /*include_hex=*/true, /*include_address=*/true);
|
ScriptToUniv(coin.out.scriptPubKey, /*out=*/o, /*include_hex=*/true, /*include_address=*/true);
|
||||||
ret.pushKV("scriptPubKey", o);
|
ret.pushKV("scriptPubKey", std::move(o));
|
||||||
ret.pushKV("coinbase", (bool)coin.fCoinBase);
|
ret.pushKV("coinbase", (bool)coin.fCoinBase);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1161,7 +1161,7 @@ static void SoftForkDescPushBack(const CBlockIndex* blockindex, UniValue& softfo
|
||||||
// one below the activation height
|
// one below the activation height
|
||||||
rv.pushKV("active", DeploymentActiveAfter(blockindex, chainman, dep));
|
rv.pushKV("active", DeploymentActiveAfter(blockindex, chainman, dep));
|
||||||
rv.pushKV("height", chainman.GetConsensus().DeploymentHeight(dep));
|
rv.pushKV("height", chainman.GetConsensus().DeploymentHeight(dep));
|
||||||
softforks.pushKV(DeploymentName(dep), rv);
|
softforks.pushKV(DeploymentName(dep), std::move(rv));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SoftForkDescPushBack(const CBlockIndex* blockindex, UniValue& softforks, const ChainstateManager& chainman, Consensus::DeploymentPos id)
|
static void SoftForkDescPushBack(const CBlockIndex* blockindex, UniValue& softforks, const ChainstateManager& chainman, Consensus::DeploymentPos id)
|
||||||
|
@ -1214,7 +1214,7 @@ static void SoftForkDescPushBack(const CBlockIndex* blockindex, UniValue& softfo
|
||||||
statsUV.pushKV("threshold", statsStruct.threshold);
|
statsUV.pushKV("threshold", statsStruct.threshold);
|
||||||
statsUV.pushKV("possible", statsStruct.possible);
|
statsUV.pushKV("possible", statsStruct.possible);
|
||||||
}
|
}
|
||||||
bip9.pushKV("statistics", statsUV);
|
bip9.pushKV("statistics", std::move(statsUV));
|
||||||
|
|
||||||
std::string sig;
|
std::string sig;
|
||||||
sig.reserve(signals.size());
|
sig.reserve(signals.size());
|
||||||
|
@ -1230,9 +1230,9 @@ static void SoftForkDescPushBack(const CBlockIndex* blockindex, UniValue& softfo
|
||||||
rv.pushKV("height", chainman.m_versionbitscache.StateSinceHeight(blockindex, chainman.GetConsensus(), id));
|
rv.pushKV("height", chainman.m_versionbitscache.StateSinceHeight(blockindex, chainman.GetConsensus(), id));
|
||||||
}
|
}
|
||||||
rv.pushKV("active", ThresholdState::ACTIVE == next_state);
|
rv.pushKV("active", ThresholdState::ACTIVE == next_state);
|
||||||
rv.pushKV("bip9", bip9);
|
rv.pushKV("bip9", std::move(bip9));
|
||||||
|
|
||||||
softforks.pushKV(DeploymentName(id), rv);
|
softforks.pushKV(DeploymentName(id), std::move(rv));
|
||||||
}
|
}
|
||||||
|
|
||||||
// used by rest.cpp:rest_chaininfo, so cannot be static
|
// used by rest.cpp:rest_chaininfo, so cannot be static
|
||||||
|
@ -1498,7 +1498,7 @@ static RPCHelpMan getchaintips()
|
||||||
}
|
}
|
||||||
obj.pushKV("status", status);
|
obj.pushKV("status", status);
|
||||||
|
|
||||||
res.push_back(obj);
|
res.push_back(std::move(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -1978,7 +1978,7 @@ static RPCHelpMan getblockstats()
|
||||||
ret_all.pushKV("avgfeerate", total_weight ? (totalfee * WITNESS_SCALE_FACTOR) / total_weight : 0); // Unit: sat/vbyte
|
ret_all.pushKV("avgfeerate", total_weight ? (totalfee * WITNESS_SCALE_FACTOR) / total_weight : 0); // Unit: sat/vbyte
|
||||||
ret_all.pushKV("avgtxsize", (block.vtx.size() > 1) ? total_size / (block.vtx.size() - 1) : 0);
|
ret_all.pushKV("avgtxsize", (block.vtx.size() > 1) ? total_size / (block.vtx.size() - 1) : 0);
|
||||||
ret_all.pushKV("blockhash", pindex.GetBlockHash().GetHex());
|
ret_all.pushKV("blockhash", pindex.GetBlockHash().GetHex());
|
||||||
ret_all.pushKV("feerate_percentiles", feerates_res);
|
ret_all.pushKV("feerate_percentiles", std::move(feerates_res));
|
||||||
ret_all.pushKV("height", (int64_t)pindex.nHeight);
|
ret_all.pushKV("height", (int64_t)pindex.nHeight);
|
||||||
ret_all.pushKV("ins", inputs);
|
ret_all.pushKV("ins", inputs);
|
||||||
ret_all.pushKV("maxfee", maxfee);
|
ret_all.pushKV("maxfee", maxfee);
|
||||||
|
@ -2262,9 +2262,9 @@ static RPCHelpMan scantxoutset()
|
||||||
unspent.pushKV("coinbase", coin.IsCoinBase());
|
unspent.pushKV("coinbase", coin.IsCoinBase());
|
||||||
unspent.pushKV("height", (int32_t)coin.nHeight);
|
unspent.pushKV("height", (int32_t)coin.nHeight);
|
||||||
|
|
||||||
unspents.push_back(unspent);
|
unspents.push_back(std::move(unspent));
|
||||||
}
|
}
|
||||||
result.pushKV("unspents", unspents);
|
result.pushKV("unspents", std::move(unspents));
|
||||||
result.pushKV("total_amount", ValueFromAmount(total_in));
|
result.pushKV("total_amount", ValueFromAmount(total_in));
|
||||||
} else {
|
} else {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid action '%s'", action));
|
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid action '%s'", action));
|
||||||
|
@ -2504,7 +2504,7 @@ static RPCHelpMan scanblocks()
|
||||||
|
|
||||||
ret.pushKV("from_height", start_block_height);
|
ret.pushKV("from_height", start_block_height);
|
||||||
ret.pushKV("to_height", start_index->nHeight); // start_index is always the last scanned block here
|
ret.pushKV("to_height", start_index->nHeight); // start_index is always the last scanned block here
|
||||||
ret.pushKV("relevant_blocks", blocks);
|
ret.pushKV("relevant_blocks", std::move(blocks));
|
||||||
ret.pushKV("completed", completed);
|
ret.pushKV("completed", completed);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -391,7 +391,7 @@ UniValue RPCConvertNamedValues(const std::string &strMethod, const std::vector<s
|
||||||
// Use pushKVEnd instead of pushKV to avoid overwriting an explicit
|
// Use pushKVEnd instead of pushKV to avoid overwriting an explicit
|
||||||
// "args" value with an implicit one. Let the RPC server handle the
|
// "args" value with an implicit one. Let the RPC server handle the
|
||||||
// request as given.
|
// request as given.
|
||||||
params.pushKVEnd("args", positional_args);
|
params.pushKVEnd("args", std::move(positional_args));
|
||||||
}
|
}
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
|
|
|
@ -53,13 +53,13 @@ static RPCHelpMan enumeratesigners()
|
||||||
UniValue signer_res = UniValue::VOBJ;
|
UniValue signer_res = UniValue::VOBJ;
|
||||||
signer_res.pushKV("fingerprint", signer.m_fingerprint);
|
signer_res.pushKV("fingerprint", signer.m_fingerprint);
|
||||||
signer_res.pushKV("name", signer.m_name);
|
signer_res.pushKV("name", signer.m_name);
|
||||||
signers_res.push_back(signer_res);
|
signers_res.push_back(std::move(signer_res));
|
||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
throw JSONRPCError(RPC_MISC_ERROR, e.what());
|
throw JSONRPCError(RPC_MISC_ERROR, e.what());
|
||||||
}
|
}
|
||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
result.pushKV("signers", signers_res);
|
result.pushKV("signers", std::move(signers_res));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -88,7 +88,7 @@ static RPCHelpMan estimatesmartfee()
|
||||||
result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK()));
|
result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK()));
|
||||||
} else {
|
} else {
|
||||||
errors.push_back("Insufficient data or no feerate found");
|
errors.push_back("Insufficient data or no feerate found");
|
||||||
result.pushKV("errors", errors);
|
result.pushKV("errors", std::move(errors));
|
||||||
}
|
}
|
||||||
result.pushKV("blocks", feeCalc.returnedTarget);
|
result.pushKV("blocks", feeCalc.returnedTarget);
|
||||||
return result;
|
return result;
|
||||||
|
@ -198,18 +198,18 @@ static RPCHelpMan estimaterawfee()
|
||||||
horizon_result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK()));
|
horizon_result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK()));
|
||||||
horizon_result.pushKV("decay", buckets.decay);
|
horizon_result.pushKV("decay", buckets.decay);
|
||||||
horizon_result.pushKV("scale", (int)buckets.scale);
|
horizon_result.pushKV("scale", (int)buckets.scale);
|
||||||
horizon_result.pushKV("pass", passbucket);
|
horizon_result.pushKV("pass", std::move(passbucket));
|
||||||
// buckets.fail.start == -1 indicates that all buckets passed, there is no fail bucket to output
|
// buckets.fail.start == -1 indicates that all buckets passed, there is no fail bucket to output
|
||||||
if (buckets.fail.start != -1) horizon_result.pushKV("fail", failbucket);
|
if (buckets.fail.start != -1) horizon_result.pushKV("fail", std::move(failbucket));
|
||||||
} else {
|
} else {
|
||||||
// Output only information that is still meaningful in the event of error
|
// Output only information that is still meaningful in the event of error
|
||||||
horizon_result.pushKV("decay", buckets.decay);
|
horizon_result.pushKV("decay", buckets.decay);
|
||||||
horizon_result.pushKV("scale", (int)buckets.scale);
|
horizon_result.pushKV("scale", (int)buckets.scale);
|
||||||
horizon_result.pushKV("fail", failbucket);
|
horizon_result.pushKV("fail", std::move(failbucket));
|
||||||
errors.push_back("Insufficient data or no feerate found which meets threshold");
|
errors.push_back("Insufficient data or no feerate found which meets threshold");
|
||||||
horizon_result.pushKV("errors", errors);
|
horizon_result.pushKV("errors", std::move(errors));
|
||||||
}
|
}
|
||||||
result.pushKV(StringForFeeEstimateHorizon(horizon), horizon_result);
|
result.pushKV(StringForFeeEstimateHorizon(horizon), std::move(horizon_result));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
|
@ -202,7 +202,7 @@ static RPCHelpMan testmempoolaccept()
|
||||||
auto it = package_result.m_tx_results.find(tx->GetWitnessHash());
|
auto it = package_result.m_tx_results.find(tx->GetWitnessHash());
|
||||||
if (exit_early || it == package_result.m_tx_results.end()) {
|
if (exit_early || it == package_result.m_tx_results.end()) {
|
||||||
// Validation unfinished. Just return the txid and wtxid.
|
// Validation unfinished. Just return the txid and wtxid.
|
||||||
rpc_result.push_back(result_inner);
|
rpc_result.push_back(std::move(result_inner));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto& tx_result = it->second;
|
const auto& tx_result = it->second;
|
||||||
|
@ -229,8 +229,8 @@ static RPCHelpMan testmempoolaccept()
|
||||||
for (const auto& wtxid : tx_result.m_wtxids_fee_calculations.value()) {
|
for (const auto& wtxid : tx_result.m_wtxids_fee_calculations.value()) {
|
||||||
effective_includes_res.push_back(wtxid.ToString());
|
effective_includes_res.push_back(wtxid.ToString());
|
||||||
}
|
}
|
||||||
fees.pushKV("effective-includes", effective_includes_res);
|
fees.pushKV("effective-includes", std::move(effective_includes_res));
|
||||||
result_inner.pushKV("fees", fees);
|
result_inner.pushKV("fees", std::move(fees));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result_inner.pushKV("allowed", false);
|
result_inner.pushKV("allowed", false);
|
||||||
|
@ -241,7 +241,7 @@ static RPCHelpMan testmempoolaccept()
|
||||||
result_inner.pushKV("reject-reason", state.GetRejectReason());
|
result_inner.pushKV("reject-reason", state.GetRejectReason());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rpc_result.push_back(result_inner);
|
rpc_result.push_back(std::move(result_inner));
|
||||||
}
|
}
|
||||||
return rpc_result;
|
return rpc_result;
|
||||||
},
|
},
|
||||||
|
@ -295,7 +295,7 @@ static void entryToJSON(const CTxMemPool& pool, UniValue& info, const CTxMemPool
|
||||||
fees.pushKV("modified", ValueFromAmount(e.GetModifiedFee()));
|
fees.pushKV("modified", ValueFromAmount(e.GetModifiedFee()));
|
||||||
fees.pushKV("ancestor", ValueFromAmount(e.GetModFeesWithAncestors()));
|
fees.pushKV("ancestor", ValueFromAmount(e.GetModFeesWithAncestors()));
|
||||||
fees.pushKV("descendant", ValueFromAmount(e.GetModFeesWithDescendants()));
|
fees.pushKV("descendant", ValueFromAmount(e.GetModFeesWithDescendants()));
|
||||||
info.pushKV("fees", fees);
|
info.pushKV("fees", std::move(fees));
|
||||||
|
|
||||||
const CTransaction& tx = e.GetTx();
|
const CTransaction& tx = e.GetTx();
|
||||||
std::set<std::string> setDepends;
|
std::set<std::string> setDepends;
|
||||||
|
@ -311,14 +311,14 @@ static void entryToJSON(const CTxMemPool& pool, UniValue& info, const CTxMemPool
|
||||||
depends.push_back(dep);
|
depends.push_back(dep);
|
||||||
}
|
}
|
||||||
|
|
||||||
info.pushKV("depends", depends);
|
info.pushKV("depends", std::move(depends));
|
||||||
|
|
||||||
UniValue spent(UniValue::VARR);
|
UniValue spent(UniValue::VARR);
|
||||||
for (const CTxMemPoolEntry& child : e.GetMemPoolChildrenConst()) {
|
for (const CTxMemPoolEntry& child : e.GetMemPoolChildrenConst()) {
|
||||||
spent.push_back(child.GetTx().GetHash().ToString());
|
spent.push_back(child.GetTx().GetHash().ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
info.pushKV("spentby", spent);
|
info.pushKV("spentby", std::move(spent));
|
||||||
|
|
||||||
// Add opt-in RBF status
|
// Add opt-in RBF status
|
||||||
bool rbfStatus = false;
|
bool rbfStatus = false;
|
||||||
|
@ -347,7 +347,7 @@ UniValue MempoolToJSON(const CTxMemPool& pool, bool verbose, bool include_mempoo
|
||||||
// Mempool has unique entries so there is no advantage in using
|
// Mempool has unique entries so there is no advantage in using
|
||||||
// UniValue::pushKV, which checks if the key already exists in O(N).
|
// UniValue::pushKV, which checks if the key already exists in O(N).
|
||||||
// UniValue::pushKVEnd is used instead which currently is O(1).
|
// UniValue::pushKVEnd is used instead which currently is O(1).
|
||||||
o.pushKVEnd(e.GetTx().GetHash().ToString(), info);
|
o.pushKVEnd(e.GetTx().GetHash().ToString(), std::move(info));
|
||||||
}
|
}
|
||||||
return o;
|
return o;
|
||||||
} else {
|
} else {
|
||||||
|
@ -364,7 +364,7 @@ UniValue MempoolToJSON(const CTxMemPool& pool, bool verbose, bool include_mempoo
|
||||||
return a;
|
return a;
|
||||||
} else {
|
} else {
|
||||||
UniValue o(UniValue::VOBJ);
|
UniValue o(UniValue::VOBJ);
|
||||||
o.pushKV("txids", a);
|
o.pushKV("txids", std::move(a));
|
||||||
o.pushKV("mempool_sequence", mempool_sequence);
|
o.pushKV("mempool_sequence", mempool_sequence);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
@ -474,7 +474,7 @@ static RPCHelpMan getmempoolancestors()
|
||||||
const uint256& _hash = e.GetTx().GetHash();
|
const uint256& _hash = e.GetTx().GetHash();
|
||||||
UniValue info(UniValue::VOBJ);
|
UniValue info(UniValue::VOBJ);
|
||||||
entryToJSON(mempool, info, e);
|
entryToJSON(mempool, info, e);
|
||||||
o.pushKV(_hash.ToString(), info);
|
o.pushKV(_hash.ToString(), std::move(info));
|
||||||
}
|
}
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
@ -539,7 +539,7 @@ static RPCHelpMan getmempooldescendants()
|
||||||
const uint256& _hash = e.GetTx().GetHash();
|
const uint256& _hash = e.GetTx().GetHash();
|
||||||
UniValue info(UniValue::VOBJ);
|
UniValue info(UniValue::VOBJ);
|
||||||
entryToJSON(mempool, info, e);
|
entryToJSON(mempool, info, e);
|
||||||
o.pushKV(_hash.ToString(), info);
|
o.pushKV(_hash.ToString(), std::move(info));
|
||||||
}
|
}
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
@ -653,7 +653,7 @@ static RPCHelpMan gettxspendingprevout()
|
||||||
o.pushKV("spendingtxid", spendingTx->GetHash().ToString());
|
o.pushKV("spendingtxid", spendingTx->GetHash().ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
result.push_back(o);
|
result.push_back(std::move(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -992,20 +992,20 @@ static RPCHelpMan submitpackage()
|
||||||
for (const auto& wtxid : tx_result.m_wtxids_fee_calculations.value()) {
|
for (const auto& wtxid : tx_result.m_wtxids_fee_calculations.value()) {
|
||||||
effective_includes_res.push_back(wtxid.ToString());
|
effective_includes_res.push_back(wtxid.ToString());
|
||||||
}
|
}
|
||||||
fees.pushKV("effective-includes", effective_includes_res);
|
fees.pushKV("effective-includes", std::move(effective_includes_res));
|
||||||
}
|
}
|
||||||
result_inner.pushKV("fees", fees);
|
result_inner.pushKV("fees", std::move(fees));
|
||||||
for (const auto& ptx : it->second.m_replaced_transactions) {
|
for (const auto& ptx : it->second.m_replaced_transactions) {
|
||||||
replaced_txids.insert(ptx->GetHash());
|
replaced_txids.insert(ptx->GetHash());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tx_result_map.pushKV(tx->GetWitnessHash().GetHex(), result_inner);
|
tx_result_map.pushKV(tx->GetWitnessHash().GetHex(), std::move(result_inner));
|
||||||
}
|
}
|
||||||
rpc_result.pushKV("tx-results", tx_result_map);
|
rpc_result.pushKV("tx-results", std::move(tx_result_map));
|
||||||
UniValue replaced_list(UniValue::VARR);
|
UniValue replaced_list(UniValue::VARR);
|
||||||
for (const uint256& hash : replaced_txids) replaced_list.push_back(hash.ToString());
|
for (const uint256& hash : replaced_txids) replaced_list.push_back(hash.ToString());
|
||||||
rpc_result.pushKV("replaced-transactions", replaced_list);
|
rpc_result.pushKV("replaced-transactions", std::move(replaced_list));
|
||||||
return rpc_result;
|
return rpc_result;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -529,7 +529,7 @@ static RPCHelpMan getprioritisedtransactions()
|
||||||
if (delta_info.in_mempool) {
|
if (delta_info.in_mempool) {
|
||||||
result_inner.pushKV("modified_fee", *delta_info.modified_fee);
|
result_inner.pushKV("modified_fee", *delta_info.modified_fee);
|
||||||
}
|
}
|
||||||
rpc_result.pushKV(delta_info.txid.GetHex(), result_inner);
|
rpc_result.pushKV(delta_info.txid.GetHex(), std::move(result_inner));
|
||||||
}
|
}
|
||||||
return rpc_result;
|
return rpc_result;
|
||||||
},
|
},
|
||||||
|
@ -854,7 +854,7 @@ static RPCHelpMan getblocktemplate()
|
||||||
if (setTxIndex.count(in.prevout.hash))
|
if (setTxIndex.count(in.prevout.hash))
|
||||||
deps.push_back(setTxIndex[in.prevout.hash]);
|
deps.push_back(setTxIndex[in.prevout.hash]);
|
||||||
}
|
}
|
||||||
entry.pushKV("depends", deps);
|
entry.pushKV("depends", std::move(deps));
|
||||||
|
|
||||||
int index_in_template = i - 1;
|
int index_in_template = i - 1;
|
||||||
entry.pushKV("fee", pblocktemplate->vTxFees[index_in_template]);
|
entry.pushKV("fee", pblocktemplate->vTxFees[index_in_template]);
|
||||||
|
@ -866,7 +866,7 @@ static RPCHelpMan getblocktemplate()
|
||||||
entry.pushKV("sigops", nTxSigOps);
|
entry.pushKV("sigops", nTxSigOps);
|
||||||
entry.pushKV("weight", GetTransactionWeight(tx));
|
entry.pushKV("weight", GetTransactionWeight(tx));
|
||||||
|
|
||||||
transactions.push_back(entry);
|
transactions.push_back(std::move(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue aux(UniValue::VOBJ);
|
UniValue aux(UniValue::VOBJ);
|
||||||
|
@ -879,7 +879,7 @@ static RPCHelpMan getblocktemplate()
|
||||||
aMutable.push_back("prevblock");
|
aMutable.push_back("prevblock");
|
||||||
|
|
||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
result.pushKV("capabilities", aCaps);
|
result.pushKV("capabilities", std::move(aCaps));
|
||||||
|
|
||||||
UniValue aRules(UniValue::VARR);
|
UniValue aRules(UniValue::VARR);
|
||||||
aRules.push_back("csv");
|
aRules.push_back("csv");
|
||||||
|
@ -931,18 +931,18 @@ static RPCHelpMan getblocktemplate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.pushKV("version", pblock->nVersion);
|
result.pushKV("version", pblock->nVersion);
|
||||||
result.pushKV("rules", aRules);
|
result.pushKV("rules", std::move(aRules));
|
||||||
result.pushKV("vbavailable", vbavailable);
|
result.pushKV("vbavailable", std::move(vbavailable));
|
||||||
result.pushKV("vbrequired", int(0));
|
result.pushKV("vbrequired", int(0));
|
||||||
|
|
||||||
result.pushKV("previousblockhash", pblock->hashPrevBlock.GetHex());
|
result.pushKV("previousblockhash", pblock->hashPrevBlock.GetHex());
|
||||||
result.pushKV("transactions", transactions);
|
result.pushKV("transactions", std::move(transactions));
|
||||||
result.pushKV("coinbaseaux", aux);
|
result.pushKV("coinbaseaux", std::move(aux));
|
||||||
result.pushKV("coinbasevalue", (int64_t)pblock->vtx[0]->vout[0].nValue);
|
result.pushKV("coinbasevalue", (int64_t)pblock->vtx[0]->vout[0].nValue);
|
||||||
result.pushKV("longpollid", active_chain.Tip()->GetBlockHash().GetHex() + ToString(nTransactionsUpdatedLast));
|
result.pushKV("longpollid", active_chain.Tip()->GetBlockHash().GetHex() + ToString(nTransactionsUpdatedLast));
|
||||||
result.pushKV("target", hashTarget.GetHex());
|
result.pushKV("target", hashTarget.GetHex());
|
||||||
result.pushKV("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1);
|
result.pushKV("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1);
|
||||||
result.pushKV("mutable", aMutable);
|
result.pushKV("mutable", std::move(aMutable));
|
||||||
result.pushKV("noncerange", "00000000ffffffff");
|
result.pushKV("noncerange", "00000000ffffffff");
|
||||||
int64_t nSigOpLimit = MAX_BLOCK_SIGOPS_COST;
|
int64_t nSigOpLimit = MAX_BLOCK_SIGOPS_COST;
|
||||||
int64_t nSizeLimit = MAX_BLOCK_SERIALIZED_SIZE;
|
int64_t nSizeLimit = MAX_BLOCK_SERIALIZED_SIZE;
|
||||||
|
|
|
@ -263,7 +263,7 @@ static RPCHelpMan getpeerinfo()
|
||||||
for (const int height : statestats.vHeightInFlight) {
|
for (const int height : statestats.vHeightInFlight) {
|
||||||
heights.push_back(height);
|
heights.push_back(height);
|
||||||
}
|
}
|
||||||
obj.pushKV("inflight", heights);
|
obj.pushKV("inflight", std::move(heights));
|
||||||
obj.pushKV("addr_relay_enabled", statestats.m_addr_relay_enabled);
|
obj.pushKV("addr_relay_enabled", statestats.m_addr_relay_enabled);
|
||||||
obj.pushKV("addr_processed", statestats.m_addr_processed);
|
obj.pushKV("addr_processed", statestats.m_addr_processed);
|
||||||
obj.pushKV("addr_rate_limited", statestats.m_addr_rate_limited);
|
obj.pushKV("addr_rate_limited", statestats.m_addr_rate_limited);
|
||||||
|
@ -271,7 +271,7 @@ static RPCHelpMan getpeerinfo()
|
||||||
for (const auto& permission : NetPermissions::ToStrings(stats.m_permission_flags)) {
|
for (const auto& permission : NetPermissions::ToStrings(stats.m_permission_flags)) {
|
||||||
permissions.push_back(permission);
|
permissions.push_back(permission);
|
||||||
}
|
}
|
||||||
obj.pushKV("permissions", permissions);
|
obj.pushKV("permissions", std::move(permissions));
|
||||||
obj.pushKV("minfeefilter", ValueFromAmount(statestats.m_fee_filter_received));
|
obj.pushKV("minfeefilter", ValueFromAmount(statestats.m_fee_filter_received));
|
||||||
|
|
||||||
UniValue sendPerMsgType(UniValue::VOBJ);
|
UniValue sendPerMsgType(UniValue::VOBJ);
|
||||||
|
@ -279,19 +279,19 @@ static RPCHelpMan getpeerinfo()
|
||||||
if (i.second > 0)
|
if (i.second > 0)
|
||||||
sendPerMsgType.pushKV(i.first, i.second);
|
sendPerMsgType.pushKV(i.first, i.second);
|
||||||
}
|
}
|
||||||
obj.pushKV("bytessent_per_msg", sendPerMsgType);
|
obj.pushKV("bytessent_per_msg", std::move(sendPerMsgType));
|
||||||
|
|
||||||
UniValue recvPerMsgType(UniValue::VOBJ);
|
UniValue recvPerMsgType(UniValue::VOBJ);
|
||||||
for (const auto& i : stats.mapRecvBytesPerMsgType) {
|
for (const auto& i : stats.mapRecvBytesPerMsgType) {
|
||||||
if (i.second > 0)
|
if (i.second > 0)
|
||||||
recvPerMsgType.pushKV(i.first, i.second);
|
recvPerMsgType.pushKV(i.first, i.second);
|
||||||
}
|
}
|
||||||
obj.pushKV("bytesrecv_per_msg", recvPerMsgType);
|
obj.pushKV("bytesrecv_per_msg", std::move(recvPerMsgType));
|
||||||
obj.pushKV("connection_type", ConnectionTypeAsString(stats.m_conn_type));
|
obj.pushKV("connection_type", ConnectionTypeAsString(stats.m_conn_type));
|
||||||
obj.pushKV("transport_protocol_type", TransportTypeAsString(stats.m_transport_type));
|
obj.pushKV("transport_protocol_type", TransportTypeAsString(stats.m_transport_type));
|
||||||
obj.pushKV("session_id", stats.m_session_id);
|
obj.pushKV("session_id", stats.m_session_id);
|
||||||
|
|
||||||
ret.push_back(obj);
|
ret.push_back(std::move(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -532,10 +532,10 @@ static RPCHelpMan getaddednodeinfo()
|
||||||
UniValue address(UniValue::VOBJ);
|
UniValue address(UniValue::VOBJ);
|
||||||
address.pushKV("address", info.resolvedAddress.ToStringAddrPort());
|
address.pushKV("address", info.resolvedAddress.ToStringAddrPort());
|
||||||
address.pushKV("connected", info.fInbound ? "inbound" : "outbound");
|
address.pushKV("connected", info.fInbound ? "inbound" : "outbound");
|
||||||
addresses.push_back(address);
|
addresses.push_back(std::move(address));
|
||||||
}
|
}
|
||||||
obj.pushKV("addresses", addresses);
|
obj.pushKV("addresses", std::move(addresses));
|
||||||
ret.push_back(obj);
|
ret.push_back(std::move(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -587,7 +587,7 @@ static RPCHelpMan getnettotals()
|
||||||
outboundLimit.pushKV("serve_historical_blocks", !connman.OutboundTargetReached(true));
|
outboundLimit.pushKV("serve_historical_blocks", !connman.OutboundTargetReached(true));
|
||||||
outboundLimit.pushKV("bytes_left_in_cycle", connman.GetOutboundTargetBytesLeft());
|
outboundLimit.pushKV("bytes_left_in_cycle", connman.GetOutboundTargetBytesLeft());
|
||||||
outboundLimit.pushKV("time_left_in_cycle", count_seconds(connman.GetMaxOutboundTimeLeftInCycle()));
|
outboundLimit.pushKV("time_left_in_cycle", count_seconds(connman.GetMaxOutboundTimeLeftInCycle()));
|
||||||
obj.pushKV("uploadtarget", outboundLimit);
|
obj.pushKV("uploadtarget", std::move(outboundLimit));
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -607,7 +607,7 @@ static UniValue GetNetworksInfo()
|
||||||
obj.pushKV("reachable", g_reachable_nets.Contains(network));
|
obj.pushKV("reachable", g_reachable_nets.Contains(network));
|
||||||
obj.pushKV("proxy", proxy.IsValid() ? proxy.ToString() : std::string());
|
obj.pushKV("proxy", proxy.IsValid() ? proxy.ToString() : std::string());
|
||||||
obj.pushKV("proxy_randomize_credentials", proxy.m_randomize_credentials);
|
obj.pushKV("proxy_randomize_credentials", proxy.m_randomize_credentials);
|
||||||
networks.push_back(obj);
|
networks.push_back(std::move(obj));
|
||||||
}
|
}
|
||||||
return networks;
|
return networks;
|
||||||
}
|
}
|
||||||
|
@ -709,10 +709,10 @@ static RPCHelpMan getnetworkinfo()
|
||||||
rec.pushKV("address", item.first.ToStringAddr());
|
rec.pushKV("address", item.first.ToStringAddr());
|
||||||
rec.pushKV("port", item.second.nPort);
|
rec.pushKV("port", item.second.nPort);
|
||||||
rec.pushKV("score", item.second.nScore);
|
rec.pushKV("score", item.second.nScore);
|
||||||
localAddresses.push_back(rec);
|
localAddresses.push_back(std::move(rec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
obj.pushKV("localaddresses", localAddresses);
|
obj.pushKV("localaddresses", std::move(localAddresses));
|
||||||
obj.pushKV("warnings", GetNodeWarnings(IsDeprecatedRPCEnabled("warnings")));
|
obj.pushKV("warnings", GetNodeWarnings(IsDeprecatedRPCEnabled("warnings")));
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
@ -843,7 +843,7 @@ static RPCHelpMan listbanned()
|
||||||
rec.pushKV("ban_duration", (banEntry.nBanUntil - banEntry.nCreateTime));
|
rec.pushKV("ban_duration", (banEntry.nBanUntil - banEntry.nCreateTime));
|
||||||
rec.pushKV("time_remaining", (banEntry.nBanUntil - current_time));
|
rec.pushKV("time_remaining", (banEntry.nBanUntil - current_time));
|
||||||
|
|
||||||
bannedAddresses.push_back(rec);
|
bannedAddresses.push_back(std::move(rec));
|
||||||
}
|
}
|
||||||
|
|
||||||
return bannedAddresses;
|
return bannedAddresses;
|
||||||
|
@ -947,7 +947,7 @@ static RPCHelpMan getnodeaddresses()
|
||||||
obj.pushKV("address", addr.ToStringAddr());
|
obj.pushKV("address", addr.ToStringAddr());
|
||||||
obj.pushKV("port", addr.GetPort());
|
obj.pushKV("port", addr.GetPort());
|
||||||
obj.pushKV("network", GetNetworkName(addr.GetNetClass()));
|
obj.pushKV("network", GetNetworkName(addr.GetNetClass()));
|
||||||
ret.push_back(obj);
|
ret.push_back(std::move(obj));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
@ -1087,13 +1087,13 @@ static RPCHelpMan getaddrmaninfo()
|
||||||
obj.pushKV("new", addrman.Size(network, true));
|
obj.pushKV("new", addrman.Size(network, true));
|
||||||
obj.pushKV("tried", addrman.Size(network, false));
|
obj.pushKV("tried", addrman.Size(network, false));
|
||||||
obj.pushKV("total", addrman.Size(network));
|
obj.pushKV("total", addrman.Size(network));
|
||||||
ret.pushKV(GetNetworkName(network), obj);
|
ret.pushKV(GetNetworkName(network), std::move(obj));
|
||||||
}
|
}
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
obj.pushKV("new", addrman.Size(std::nullopt, true));
|
obj.pushKV("new", addrman.Size(std::nullopt, true));
|
||||||
obj.pushKV("tried", addrman.Size(std::nullopt, false));
|
obj.pushKV("tried", addrman.Size(std::nullopt, false));
|
||||||
obj.pushKV("total", addrman.Size());
|
obj.pushKV("total", addrman.Size());
|
||||||
ret.pushKV("all_networks", obj);
|
ret.pushKV("all_networks", std::move(obj));
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -351,7 +351,7 @@ static UniValue SummaryToJSON(const IndexSummary&& summary, std::string index_na
|
||||||
UniValue entry(UniValue::VOBJ);
|
UniValue entry(UniValue::VOBJ);
|
||||||
entry.pushKV("synced", summary.synced);
|
entry.pushKV("synced", summary.synced);
|
||||||
entry.pushKV("best_block_height", summary.best_block_height);
|
entry.pushKV("best_block_height", summary.best_block_height);
|
||||||
ret_summary.pushKV(summary.name, entry);
|
ret_summary.pushKV(summary.name, std::move(entry));
|
||||||
return ret_summary;
|
return ret_summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,11 +72,11 @@ static RPCHelpMan validateaddress()
|
||||||
ret.pushKV("scriptPubKey", HexStr(scriptPubKey));
|
ret.pushKV("scriptPubKey", HexStr(scriptPubKey));
|
||||||
|
|
||||||
UniValue detail = DescribeAddress(dest);
|
UniValue detail = DescribeAddress(dest);
|
||||||
ret.pushKVs(detail);
|
ret.pushKVs(std::move(detail));
|
||||||
} else {
|
} else {
|
||||||
UniValue error_indices(UniValue::VARR);
|
UniValue error_indices(UniValue::VARR);
|
||||||
for (int i : error_locations) error_indices.push_back(i);
|
for (int i : error_locations) error_indices.push_back(i);
|
||||||
ret.pushKV("error_locations", error_indices);
|
ret.pushKV("error_locations", std::move(error_indices));
|
||||||
ret.pushKV("error", error_msg);
|
ret.pushKV("error", error_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -618,7 +618,7 @@ static RPCHelpMan decodescript()
|
||||||
}
|
}
|
||||||
ScriptToUniv(segwitScr, /*out=*/sr, /*include_hex=*/true, /*include_address=*/true, /*provider=*/&provider);
|
ScriptToUniv(segwitScr, /*out=*/sr, /*include_hex=*/true, /*include_address=*/true, /*provider=*/&provider);
|
||||||
sr.pushKV("p2sh-segwit", EncodeDestination(ScriptHash(segwitScr)));
|
sr.pushKV("p2sh-segwit", EncodeDestination(ScriptHash(segwitScr)));
|
||||||
r.pushKV("segwit", sr);
|
r.pushKV("segwit", std::move(sr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1069,7 +1069,7 @@ static RPCHelpMan decodepsbt()
|
||||||
// Add the decoded tx
|
// Add the decoded tx
|
||||||
UniValue tx_univ(UniValue::VOBJ);
|
UniValue tx_univ(UniValue::VOBJ);
|
||||||
TxToUniv(CTransaction(*psbtx.tx), /*block_hash=*/uint256(), /*entry=*/tx_univ, /*include_hex=*/false);
|
TxToUniv(CTransaction(*psbtx.tx), /*block_hash=*/uint256(), /*entry=*/tx_univ, /*include_hex=*/false);
|
||||||
result.pushKV("tx", tx_univ);
|
result.pushKV("tx", std::move(tx_univ));
|
||||||
|
|
||||||
// Add the global xpubs
|
// Add the global xpubs
|
||||||
UniValue global_xpubs(UniValue::VARR);
|
UniValue global_xpubs(UniValue::VARR);
|
||||||
|
@ -1083,10 +1083,10 @@ static RPCHelpMan decodepsbt()
|
||||||
keypath.pushKV("xpub", EncodeBase58Check(ser_xpub));
|
keypath.pushKV("xpub", EncodeBase58Check(ser_xpub));
|
||||||
keypath.pushKV("master_fingerprint", HexStr(Span<unsigned char>(xpub_pair.first.fingerprint, xpub_pair.first.fingerprint + 4)));
|
keypath.pushKV("master_fingerprint", HexStr(Span<unsigned char>(xpub_pair.first.fingerprint, xpub_pair.first.fingerprint + 4)));
|
||||||
keypath.pushKV("path", WriteHDKeypath(xpub_pair.first.path));
|
keypath.pushKV("path", WriteHDKeypath(xpub_pair.first.path));
|
||||||
global_xpubs.push_back(keypath);
|
global_xpubs.push_back(std::move(keypath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.pushKV("global_xpubs", global_xpubs);
|
result.pushKV("global_xpubs", std::move(global_xpubs));
|
||||||
|
|
||||||
// PSBT version
|
// PSBT version
|
||||||
result.pushKV("psbt_version", static_cast<uint64_t>(psbtx.GetVersion()));
|
result.pushKV("psbt_version", static_cast<uint64_t>(psbtx.GetVersion()));
|
||||||
|
@ -1099,16 +1099,16 @@ static RPCHelpMan decodepsbt()
|
||||||
this_prop.pushKV("subtype", entry.subtype);
|
this_prop.pushKV("subtype", entry.subtype);
|
||||||
this_prop.pushKV("key", HexStr(entry.key));
|
this_prop.pushKV("key", HexStr(entry.key));
|
||||||
this_prop.pushKV("value", HexStr(entry.value));
|
this_prop.pushKV("value", HexStr(entry.value));
|
||||||
proprietary.push_back(this_prop);
|
proprietary.push_back(std::move(this_prop));
|
||||||
}
|
}
|
||||||
result.pushKV("proprietary", proprietary);
|
result.pushKV("proprietary", std::move(proprietary));
|
||||||
|
|
||||||
// Unknown data
|
// Unknown data
|
||||||
UniValue unknowns(UniValue::VOBJ);
|
UniValue unknowns(UniValue::VOBJ);
|
||||||
for (auto entry : psbtx.unknown) {
|
for (auto entry : psbtx.unknown) {
|
||||||
unknowns.pushKV(HexStr(entry.first), HexStr(entry.second));
|
unknowns.pushKV(HexStr(entry.first), HexStr(entry.second));
|
||||||
}
|
}
|
||||||
result.pushKV("unknown", unknowns);
|
result.pushKV("unknown", std::move(unknowns));
|
||||||
|
|
||||||
// inputs
|
// inputs
|
||||||
CAmount total_in = 0;
|
CAmount total_in = 0;
|
||||||
|
@ -1128,9 +1128,9 @@ static RPCHelpMan decodepsbt()
|
||||||
|
|
||||||
UniValue out(UniValue::VOBJ);
|
UniValue out(UniValue::VOBJ);
|
||||||
out.pushKV("amount", ValueFromAmount(txout.nValue));
|
out.pushKV("amount", ValueFromAmount(txout.nValue));
|
||||||
out.pushKV("scriptPubKey", o);
|
out.pushKV("scriptPubKey", std::move(o));
|
||||||
|
|
||||||
in.pushKV("witness_utxo", out);
|
in.pushKV("witness_utxo", std::move(out));
|
||||||
|
|
||||||
have_a_utxo = true;
|
have_a_utxo = true;
|
||||||
}
|
}
|
||||||
|
@ -1139,7 +1139,7 @@ static RPCHelpMan decodepsbt()
|
||||||
|
|
||||||
UniValue non_wit(UniValue::VOBJ);
|
UniValue non_wit(UniValue::VOBJ);
|
||||||
TxToUniv(*input.non_witness_utxo, /*block_hash=*/uint256(), /*entry=*/non_wit, /*include_hex=*/false);
|
TxToUniv(*input.non_witness_utxo, /*block_hash=*/uint256(), /*entry=*/non_wit, /*include_hex=*/false);
|
||||||
in.pushKV("non_witness_utxo", non_wit);
|
in.pushKV("non_witness_utxo", std::move(non_wit));
|
||||||
|
|
||||||
have_a_utxo = true;
|
have_a_utxo = true;
|
||||||
}
|
}
|
||||||
|
@ -1160,7 +1160,7 @@ static RPCHelpMan decodepsbt()
|
||||||
for (const auto& sig : input.partial_sigs) {
|
for (const auto& sig : input.partial_sigs) {
|
||||||
partial_sigs.pushKV(HexStr(sig.second.first), HexStr(sig.second.second));
|
partial_sigs.pushKV(HexStr(sig.second.first), HexStr(sig.second.second));
|
||||||
}
|
}
|
||||||
in.pushKV("partial_signatures", partial_sigs);
|
in.pushKV("partial_signatures", std::move(partial_sigs));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sighash
|
// Sighash
|
||||||
|
@ -1172,12 +1172,12 @@ static RPCHelpMan decodepsbt()
|
||||||
if (!input.redeem_script.empty()) {
|
if (!input.redeem_script.empty()) {
|
||||||
UniValue r(UniValue::VOBJ);
|
UniValue r(UniValue::VOBJ);
|
||||||
ScriptToUniv(input.redeem_script, /*out=*/r);
|
ScriptToUniv(input.redeem_script, /*out=*/r);
|
||||||
in.pushKV("redeem_script", r);
|
in.pushKV("redeem_script", std::move(r));
|
||||||
}
|
}
|
||||||
if (!input.witness_script.empty()) {
|
if (!input.witness_script.empty()) {
|
||||||
UniValue r(UniValue::VOBJ);
|
UniValue r(UniValue::VOBJ);
|
||||||
ScriptToUniv(input.witness_script, /*out=*/r);
|
ScriptToUniv(input.witness_script, /*out=*/r);
|
||||||
in.pushKV("witness_script", r);
|
in.pushKV("witness_script", std::move(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
// keypaths
|
// keypaths
|
||||||
|
@ -1189,9 +1189,9 @@ static RPCHelpMan decodepsbt()
|
||||||
|
|
||||||
keypath.pushKV("master_fingerprint", strprintf("%08x", ReadBE32(entry.second.fingerprint)));
|
keypath.pushKV("master_fingerprint", strprintf("%08x", ReadBE32(entry.second.fingerprint)));
|
||||||
keypath.pushKV("path", WriteHDKeypath(entry.second.path));
|
keypath.pushKV("path", WriteHDKeypath(entry.second.path));
|
||||||
keypaths.push_back(keypath);
|
keypaths.push_back(std::move(keypath));
|
||||||
}
|
}
|
||||||
in.pushKV("bip32_derivs", keypaths);
|
in.pushKV("bip32_derivs", std::move(keypaths));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Final scriptSig and scriptwitness
|
// Final scriptSig and scriptwitness
|
||||||
|
@ -1199,14 +1199,14 @@ static RPCHelpMan decodepsbt()
|
||||||
UniValue scriptsig(UniValue::VOBJ);
|
UniValue scriptsig(UniValue::VOBJ);
|
||||||
scriptsig.pushKV("asm", ScriptToAsmStr(input.final_script_sig, true));
|
scriptsig.pushKV("asm", ScriptToAsmStr(input.final_script_sig, true));
|
||||||
scriptsig.pushKV("hex", HexStr(input.final_script_sig));
|
scriptsig.pushKV("hex", HexStr(input.final_script_sig));
|
||||||
in.pushKV("final_scriptSig", scriptsig);
|
in.pushKV("final_scriptSig", std::move(scriptsig));
|
||||||
}
|
}
|
||||||
if (!input.final_script_witness.IsNull()) {
|
if (!input.final_script_witness.IsNull()) {
|
||||||
UniValue txinwitness(UniValue::VARR);
|
UniValue txinwitness(UniValue::VARR);
|
||||||
for (const auto& item : input.final_script_witness.stack) {
|
for (const auto& item : input.final_script_witness.stack) {
|
||||||
txinwitness.push_back(HexStr(item));
|
txinwitness.push_back(HexStr(item));
|
||||||
}
|
}
|
||||||
in.pushKV("final_scriptwitness", txinwitness);
|
in.pushKV("final_scriptwitness", std::move(txinwitness));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ripemd160 hash preimages
|
// Ripemd160 hash preimages
|
||||||
|
@ -1215,7 +1215,7 @@ static RPCHelpMan decodepsbt()
|
||||||
for (const auto& [hash, preimage] : input.ripemd160_preimages) {
|
for (const auto& [hash, preimage] : input.ripemd160_preimages) {
|
||||||
ripemd160_preimages.pushKV(HexStr(hash), HexStr(preimage));
|
ripemd160_preimages.pushKV(HexStr(hash), HexStr(preimage));
|
||||||
}
|
}
|
||||||
in.pushKV("ripemd160_preimages", ripemd160_preimages);
|
in.pushKV("ripemd160_preimages", std::move(ripemd160_preimages));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sha256 hash preimages
|
// Sha256 hash preimages
|
||||||
|
@ -1224,7 +1224,7 @@ static RPCHelpMan decodepsbt()
|
||||||
for (const auto& [hash, preimage] : input.sha256_preimages) {
|
for (const auto& [hash, preimage] : input.sha256_preimages) {
|
||||||
sha256_preimages.pushKV(HexStr(hash), HexStr(preimage));
|
sha256_preimages.pushKV(HexStr(hash), HexStr(preimage));
|
||||||
}
|
}
|
||||||
in.pushKV("sha256_preimages", sha256_preimages);
|
in.pushKV("sha256_preimages", std::move(sha256_preimages));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hash160 hash preimages
|
// Hash160 hash preimages
|
||||||
|
@ -1233,7 +1233,7 @@ static RPCHelpMan decodepsbt()
|
||||||
for (const auto& [hash, preimage] : input.hash160_preimages) {
|
for (const auto& [hash, preimage] : input.hash160_preimages) {
|
||||||
hash160_preimages.pushKV(HexStr(hash), HexStr(preimage));
|
hash160_preimages.pushKV(HexStr(hash), HexStr(preimage));
|
||||||
}
|
}
|
||||||
in.pushKV("hash160_preimages", hash160_preimages);
|
in.pushKV("hash160_preimages", std::move(hash160_preimages));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hash256 hash preimages
|
// Hash256 hash preimages
|
||||||
|
@ -1242,7 +1242,7 @@ static RPCHelpMan decodepsbt()
|
||||||
for (const auto& [hash, preimage] : input.hash256_preimages) {
|
for (const auto& [hash, preimage] : input.hash256_preimages) {
|
||||||
hash256_preimages.pushKV(HexStr(hash), HexStr(preimage));
|
hash256_preimages.pushKV(HexStr(hash), HexStr(preimage));
|
||||||
}
|
}
|
||||||
in.pushKV("hash256_preimages", hash256_preimages);
|
in.pushKV("hash256_preimages", std::move(hash256_preimages));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Taproot key path signature
|
// Taproot key path signature
|
||||||
|
@ -1259,9 +1259,9 @@ static RPCHelpMan decodepsbt()
|
||||||
sigobj.pushKV("pubkey", HexStr(xonly));
|
sigobj.pushKV("pubkey", HexStr(xonly));
|
||||||
sigobj.pushKV("leaf_hash", HexStr(leaf_hash));
|
sigobj.pushKV("leaf_hash", HexStr(leaf_hash));
|
||||||
sigobj.pushKV("sig", HexStr(sig));
|
sigobj.pushKV("sig", HexStr(sig));
|
||||||
script_sigs.push_back(sigobj);
|
script_sigs.push_back(std::move(sigobj));
|
||||||
}
|
}
|
||||||
in.pushKV("taproot_script_path_sigs", script_sigs);
|
in.pushKV("taproot_script_path_sigs", std::move(script_sigs));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Taproot leaf scripts
|
// Taproot leaf scripts
|
||||||
|
@ -1276,10 +1276,10 @@ static RPCHelpMan decodepsbt()
|
||||||
for (const auto& control_block : control_blocks) {
|
for (const auto& control_block : control_blocks) {
|
||||||
control_blocks_univ.push_back(HexStr(control_block));
|
control_blocks_univ.push_back(HexStr(control_block));
|
||||||
}
|
}
|
||||||
script_info.pushKV("control_blocks", control_blocks_univ);
|
script_info.pushKV("control_blocks", std::move(control_blocks_univ));
|
||||||
tap_scripts.push_back(script_info);
|
tap_scripts.push_back(std::move(script_info));
|
||||||
}
|
}
|
||||||
in.pushKV("taproot_scripts", tap_scripts);
|
in.pushKV("taproot_scripts", std::move(tap_scripts));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Taproot bip32 keypaths
|
// Taproot bip32 keypaths
|
||||||
|
@ -1295,10 +1295,10 @@ static RPCHelpMan decodepsbt()
|
||||||
for (const auto& leaf_hash : leaf_hashes) {
|
for (const auto& leaf_hash : leaf_hashes) {
|
||||||
leaf_hashes_arr.push_back(HexStr(leaf_hash));
|
leaf_hashes_arr.push_back(HexStr(leaf_hash));
|
||||||
}
|
}
|
||||||
path_obj.pushKV("leaf_hashes", leaf_hashes_arr);
|
path_obj.pushKV("leaf_hashes", std::move(leaf_hashes_arr));
|
||||||
keypaths.push_back(path_obj);
|
keypaths.push_back(std::move(path_obj));
|
||||||
}
|
}
|
||||||
in.pushKV("taproot_bip32_derivs", keypaths);
|
in.pushKV("taproot_bip32_derivs", std::move(keypaths));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Taproot internal key
|
// Taproot internal key
|
||||||
|
@ -1320,9 +1320,9 @@ static RPCHelpMan decodepsbt()
|
||||||
this_prop.pushKV("subtype", entry.subtype);
|
this_prop.pushKV("subtype", entry.subtype);
|
||||||
this_prop.pushKV("key", HexStr(entry.key));
|
this_prop.pushKV("key", HexStr(entry.key));
|
||||||
this_prop.pushKV("value", HexStr(entry.value));
|
this_prop.pushKV("value", HexStr(entry.value));
|
||||||
proprietary.push_back(this_prop);
|
proprietary.push_back(std::move(this_prop));
|
||||||
}
|
}
|
||||||
in.pushKV("proprietary", proprietary);
|
in.pushKV("proprietary", std::move(proprietary));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unknown data
|
// Unknown data
|
||||||
|
@ -1331,12 +1331,12 @@ static RPCHelpMan decodepsbt()
|
||||||
for (auto entry : input.unknown) {
|
for (auto entry : input.unknown) {
|
||||||
unknowns.pushKV(HexStr(entry.first), HexStr(entry.second));
|
unknowns.pushKV(HexStr(entry.first), HexStr(entry.second));
|
||||||
}
|
}
|
||||||
in.pushKV("unknown", unknowns);
|
in.pushKV("unknown", std::move(unknowns));
|
||||||
}
|
}
|
||||||
|
|
||||||
inputs.push_back(in);
|
inputs.push_back(std::move(in));
|
||||||
}
|
}
|
||||||
result.pushKV("inputs", inputs);
|
result.pushKV("inputs", std::move(inputs));
|
||||||
|
|
||||||
// outputs
|
// outputs
|
||||||
CAmount output_value = 0;
|
CAmount output_value = 0;
|
||||||
|
@ -1348,12 +1348,12 @@ static RPCHelpMan decodepsbt()
|
||||||
if (!output.redeem_script.empty()) {
|
if (!output.redeem_script.empty()) {
|
||||||
UniValue r(UniValue::VOBJ);
|
UniValue r(UniValue::VOBJ);
|
||||||
ScriptToUniv(output.redeem_script, /*out=*/r);
|
ScriptToUniv(output.redeem_script, /*out=*/r);
|
||||||
out.pushKV("redeem_script", r);
|
out.pushKV("redeem_script", std::move(r));
|
||||||
}
|
}
|
||||||
if (!output.witness_script.empty()) {
|
if (!output.witness_script.empty()) {
|
||||||
UniValue r(UniValue::VOBJ);
|
UniValue r(UniValue::VOBJ);
|
||||||
ScriptToUniv(output.witness_script, /*out=*/r);
|
ScriptToUniv(output.witness_script, /*out=*/r);
|
||||||
out.pushKV("witness_script", r);
|
out.pushKV("witness_script", std::move(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
// keypaths
|
// keypaths
|
||||||
|
@ -1364,9 +1364,9 @@ static RPCHelpMan decodepsbt()
|
||||||
keypath.pushKV("pubkey", HexStr(entry.first));
|
keypath.pushKV("pubkey", HexStr(entry.first));
|
||||||
keypath.pushKV("master_fingerprint", strprintf("%08x", ReadBE32(entry.second.fingerprint)));
|
keypath.pushKV("master_fingerprint", strprintf("%08x", ReadBE32(entry.second.fingerprint)));
|
||||||
keypath.pushKV("path", WriteHDKeypath(entry.second.path));
|
keypath.pushKV("path", WriteHDKeypath(entry.second.path));
|
||||||
keypaths.push_back(keypath);
|
keypaths.push_back(std::move(keypath));
|
||||||
}
|
}
|
||||||
out.pushKV("bip32_derivs", keypaths);
|
out.pushKV("bip32_derivs", std::move(keypaths));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Taproot internal key
|
// Taproot internal key
|
||||||
|
@ -1382,9 +1382,9 @@ static RPCHelpMan decodepsbt()
|
||||||
elem.pushKV("depth", (int)depth);
|
elem.pushKV("depth", (int)depth);
|
||||||
elem.pushKV("leaf_ver", (int)leaf_ver);
|
elem.pushKV("leaf_ver", (int)leaf_ver);
|
||||||
elem.pushKV("script", HexStr(script));
|
elem.pushKV("script", HexStr(script));
|
||||||
tree.push_back(elem);
|
tree.push_back(std::move(elem));
|
||||||
}
|
}
|
||||||
out.pushKV("taproot_tree", tree);
|
out.pushKV("taproot_tree", std::move(tree));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Taproot bip32 keypaths
|
// Taproot bip32 keypaths
|
||||||
|
@ -1400,10 +1400,10 @@ static RPCHelpMan decodepsbt()
|
||||||
for (const auto& leaf_hash : leaf_hashes) {
|
for (const auto& leaf_hash : leaf_hashes) {
|
||||||
leaf_hashes_arr.push_back(HexStr(leaf_hash));
|
leaf_hashes_arr.push_back(HexStr(leaf_hash));
|
||||||
}
|
}
|
||||||
path_obj.pushKV("leaf_hashes", leaf_hashes_arr);
|
path_obj.pushKV("leaf_hashes", std::move(leaf_hashes_arr));
|
||||||
keypaths.push_back(path_obj);
|
keypaths.push_back(std::move(path_obj));
|
||||||
}
|
}
|
||||||
out.pushKV("taproot_bip32_derivs", keypaths);
|
out.pushKV("taproot_bip32_derivs", std::move(keypaths));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Proprietary
|
// Proprietary
|
||||||
|
@ -1415,9 +1415,9 @@ static RPCHelpMan decodepsbt()
|
||||||
this_prop.pushKV("subtype", entry.subtype);
|
this_prop.pushKV("subtype", entry.subtype);
|
||||||
this_prop.pushKV("key", HexStr(entry.key));
|
this_prop.pushKV("key", HexStr(entry.key));
|
||||||
this_prop.pushKV("value", HexStr(entry.value));
|
this_prop.pushKV("value", HexStr(entry.value));
|
||||||
proprietary.push_back(this_prop);
|
proprietary.push_back(std::move(this_prop));
|
||||||
}
|
}
|
||||||
out.pushKV("proprietary", proprietary);
|
out.pushKV("proprietary", std::move(proprietary));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unknown data
|
// Unknown data
|
||||||
|
@ -1426,10 +1426,10 @@ static RPCHelpMan decodepsbt()
|
||||||
for (auto entry : output.unknown) {
|
for (auto entry : output.unknown) {
|
||||||
unknowns.pushKV(HexStr(entry.first), HexStr(entry.second));
|
unknowns.pushKV(HexStr(entry.first), HexStr(entry.second));
|
||||||
}
|
}
|
||||||
out.pushKV("unknown", unknowns);
|
out.pushKV("unknown", std::move(unknowns));
|
||||||
}
|
}
|
||||||
|
|
||||||
outputs.push_back(out);
|
outputs.push_back(std::move(out));
|
||||||
|
|
||||||
// Fee calculation
|
// Fee calculation
|
||||||
if (MoneyRange(psbtx.tx->vout[i].nValue) && MoneyRange(output_value + psbtx.tx->vout[i].nValue)) {
|
if (MoneyRange(psbtx.tx->vout[i].nValue) && MoneyRange(output_value + psbtx.tx->vout[i].nValue)) {
|
||||||
|
@ -1439,7 +1439,7 @@ static RPCHelpMan decodepsbt()
|
||||||
have_all_utxos = false;
|
have_all_utxos = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.pushKV("outputs", outputs);
|
result.pushKV("outputs", std::move(outputs));
|
||||||
if (have_all_utxos) {
|
if (have_all_utxos) {
|
||||||
result.pushKV("fee", ValueFromAmount(total_in - output_value));
|
result.pushKV("fee", ValueFromAmount(total_in - output_value));
|
||||||
}
|
}
|
||||||
|
@ -1876,7 +1876,7 @@ static RPCHelpMan analyzepsbt()
|
||||||
for (const CKeyID& pubkey : input.missing_pubkeys) {
|
for (const CKeyID& pubkey : input.missing_pubkeys) {
|
||||||
missing_pubkeys_univ.push_back(HexStr(pubkey));
|
missing_pubkeys_univ.push_back(HexStr(pubkey));
|
||||||
}
|
}
|
||||||
missing.pushKV("pubkeys", missing_pubkeys_univ);
|
missing.pushKV("pubkeys", std::move(missing_pubkeys_univ));
|
||||||
}
|
}
|
||||||
if (!input.missing_redeem_script.IsNull()) {
|
if (!input.missing_redeem_script.IsNull()) {
|
||||||
missing.pushKV("redeemscript", HexStr(input.missing_redeem_script));
|
missing.pushKV("redeemscript", HexStr(input.missing_redeem_script));
|
||||||
|
@ -1889,14 +1889,14 @@ static RPCHelpMan analyzepsbt()
|
||||||
for (const CKeyID& pubkey : input.missing_sigs) {
|
for (const CKeyID& pubkey : input.missing_sigs) {
|
||||||
missing_sigs_univ.push_back(HexStr(pubkey));
|
missing_sigs_univ.push_back(HexStr(pubkey));
|
||||||
}
|
}
|
||||||
missing.pushKV("signatures", missing_sigs_univ);
|
missing.pushKV("signatures", std::move(missing_sigs_univ));
|
||||||
}
|
}
|
||||||
if (!missing.getKeys().empty()) {
|
if (!missing.getKeys().empty()) {
|
||||||
input_univ.pushKV("missing", missing);
|
input_univ.pushKV("missing", std::move(missing));
|
||||||
}
|
}
|
||||||
inputs_result.push_back(input_univ);
|
inputs_result.push_back(std::move(input_univ));
|
||||||
}
|
}
|
||||||
if (!inputs_result.empty()) result.pushKV("inputs", inputs_result);
|
if (!inputs_result.empty()) result.pushKV("inputs", std::move(inputs_result));
|
||||||
|
|
||||||
if (psbta.estimated_vsize != std::nullopt) {
|
if (psbta.estimated_vsize != std::nullopt) {
|
||||||
result.pushKV("estimated_vsize", (int)*psbta.estimated_vsize);
|
result.pushKV("estimated_vsize", (int)*psbta.estimated_vsize);
|
||||||
|
|
|
@ -174,11 +174,11 @@ static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::
|
||||||
for (unsigned int i = 0; i < txin.scriptWitness.stack.size(); i++) {
|
for (unsigned int i = 0; i < txin.scriptWitness.stack.size(); i++) {
|
||||||
witness.push_back(HexStr(txin.scriptWitness.stack[i]));
|
witness.push_back(HexStr(txin.scriptWitness.stack[i]));
|
||||||
}
|
}
|
||||||
entry.pushKV("witness", witness);
|
entry.pushKV("witness", std::move(witness));
|
||||||
entry.pushKV("scriptSig", HexStr(txin.scriptSig));
|
entry.pushKV("scriptSig", HexStr(txin.scriptSig));
|
||||||
entry.pushKV("sequence", (uint64_t)txin.nSequence);
|
entry.pushKV("sequence", (uint64_t)txin.nSequence);
|
||||||
entry.pushKV("error", strMessage);
|
entry.pushKV("error", strMessage);
|
||||||
vErrorsRet.push_back(entry);
|
vErrorsRet.push_back(std::move(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParsePrevouts(const UniValue& prevTxsUnival, FillableSigningProvider* keystore, std::map<COutPoint, Coin>& coins)
|
void ParsePrevouts(const UniValue& prevTxsUnival, FillableSigningProvider* keystore, std::map<COutPoint, Coin>& coins)
|
||||||
|
@ -331,6 +331,6 @@ void SignTransactionResultToJSON(CMutableTransaction& mtx, bool complete, const
|
||||||
if (result.exists("errors")) {
|
if (result.exists("errors")) {
|
||||||
vErrors.push_backV(result["errors"].getValues());
|
vErrors.push_backV(result["errors"].getValues());
|
||||||
}
|
}
|
||||||
result.pushKV("errors", vErrors);
|
result.pushKV("errors", std::move(vErrors));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,15 +241,15 @@ static RPCHelpMan getrpcinfo()
|
||||||
UniValue entry(UniValue::VOBJ);
|
UniValue entry(UniValue::VOBJ);
|
||||||
entry.pushKV("method", info.method);
|
entry.pushKV("method", info.method);
|
||||||
entry.pushKV("duration", int64_t{Ticks<std::chrono::microseconds>(SteadyClock::now() - info.start)});
|
entry.pushKV("duration", int64_t{Ticks<std::chrono::microseconds>(SteadyClock::now() - info.start)});
|
||||||
active_commands.push_back(entry);
|
active_commands.push_back(std::move(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
result.pushKV("active_commands", active_commands);
|
result.pushKV("active_commands", std::move(active_commands));
|
||||||
|
|
||||||
const std::string path = LogInstance().m_file_path.utf8string();
|
const std::string path = LogInstance().m_file_path.utf8string();
|
||||||
UniValue log_path(UniValue::VSTR, path);
|
UniValue log_path(UniValue::VSTR, path);
|
||||||
result.pushKV("logpath", log_path);
|
result.pushKV("logpath", std::move(log_path));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -645,7 +645,7 @@ UniValue RPCHelpMan::HandleRequest(const JSONRPCRequest& request) const
|
||||||
mismatch.setNull();
|
mismatch.setNull();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mismatch.push_back(match);
|
mismatch.push_back(std::move(match));
|
||||||
}
|
}
|
||||||
if (!mismatch.isNull()) {
|
if (!mismatch.isNull()) {
|
||||||
std::string explain{
|
std::string explain{
|
||||||
|
@ -818,7 +818,7 @@ UniValue RPCHelpMan::GetArgMap() const
|
||||||
map.push_back(arg_name);
|
map.push_back(arg_name);
|
||||||
map.push_back(type == RPCArg::Type::STR ||
|
map.push_back(type == RPCArg::Type::STR ||
|
||||||
type == RPCArg::Type::STR_HEX);
|
type == RPCArg::Type::STR_HEX);
|
||||||
arr.push_back(map);
|
arr.push_back(std::move(map));
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i{0}; i < int(m_args.size()); ++i) {
|
for (int i{0}; i < int(m_args.size()); ++i) {
|
||||||
|
@ -1124,7 +1124,7 @@ UniValue RPCResult::MatchesType(const UniValue& result) const
|
||||||
// If there are more results than documented, reuse the last doc_inner.
|
// If there are more results than documented, reuse the last doc_inner.
|
||||||
const RPCResult& doc_inner{m_inner.at(std::min(m_inner.size() - 1, i))};
|
const RPCResult& doc_inner{m_inner.at(std::min(m_inner.size() - 1, i))};
|
||||||
UniValue match{doc_inner.MatchesType(result.get_array()[i])};
|
UniValue match{doc_inner.MatchesType(result.get_array()[i])};
|
||||||
if (!match.isTrue()) errors.pushKV(strprintf("%d", i), match);
|
if (!match.isTrue()) errors.pushKV(strprintf("%d", i), std::move(match));
|
||||||
}
|
}
|
||||||
if (errors.empty()) return true; // empty result array is valid
|
if (errors.empty()) return true; // empty result array is valid
|
||||||
return errors;
|
return errors;
|
||||||
|
@ -1137,7 +1137,7 @@ UniValue RPCResult::MatchesType(const UniValue& result) const
|
||||||
const RPCResult& doc_inner{m_inner.at(0)}; // Assume all types are the same, randomly pick the first
|
const RPCResult& doc_inner{m_inner.at(0)}; // Assume all types are the same, randomly pick the first
|
||||||
for (size_t i{0}; i < result.get_obj().size(); ++i) {
|
for (size_t i{0}; i < result.get_obj().size(); ++i) {
|
||||||
UniValue match{doc_inner.MatchesType(result.get_obj()[i])};
|
UniValue match{doc_inner.MatchesType(result.get_obj()[i])};
|
||||||
if (!match.isTrue()) errors.pushKV(result.getKeys()[i], match);
|
if (!match.isTrue()) errors.pushKV(result.getKeys()[i], std::move(match));
|
||||||
}
|
}
|
||||||
if (errors.empty()) return true; // empty result obj is valid
|
if (errors.empty()) return true; // empty result obj is valid
|
||||||
return errors;
|
return errors;
|
||||||
|
@ -1163,7 +1163,7 @@ UniValue RPCResult::MatchesType(const UniValue& result) const
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
UniValue match{doc_entry.MatchesType(result_it->second)};
|
UniValue match{doc_entry.MatchesType(result_it->second)};
|
||||||
if (!match.isTrue()) errors.pushKV(doc_entry.m_key_name, match);
|
if (!match.isTrue()) errors.pushKV(doc_entry.m_key_name, std::move(match));
|
||||||
}
|
}
|
||||||
if (errors.empty()) return true;
|
if (errors.empty()) return true;
|
||||||
return errors;
|
return errors;
|
||||||
|
|
|
@ -396,7 +396,7 @@ public:
|
||||||
wit.push_back(HexStr(scriptWitness.stack[i]));
|
wit.push_back(HexStr(scriptWitness.stack[i]));
|
||||||
}
|
}
|
||||||
wit.push_back(ValueFromAmount(nValue));
|
wit.push_back(ValueFromAmount(nValue));
|
||||||
array.push_back(wit);
|
array.push_back(std::move(wit));
|
||||||
}
|
}
|
||||||
array.push_back(FormatScript(spendTx.vin[0].scriptSig));
|
array.push_back(FormatScript(spendTx.vin[0].scriptSig));
|
||||||
array.push_back(FormatScript(creditTx->vout[0].scriptPubKey));
|
array.push_back(FormatScript(creditTx->vout[0].scriptPubKey));
|
||||||
|
|
|
@ -206,9 +206,9 @@ RPCHelpMan listaddressgroupings()
|
||||||
addressInfo.push_back(address_book_entry->GetLabel());
|
addressInfo.push_back(address_book_entry->GetLabel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jsonGrouping.push_back(addressInfo);
|
jsonGrouping.push_back(std::move(addressInfo));
|
||||||
}
|
}
|
||||||
jsonGroupings.push_back(jsonGrouping);
|
jsonGroupings.push_back(std::move(jsonGrouping));
|
||||||
}
|
}
|
||||||
return jsonGroupings;
|
return jsonGroupings;
|
||||||
},
|
},
|
||||||
|
@ -407,9 +407,9 @@ public:
|
||||||
// Only when the script corresponds to an address.
|
// Only when the script corresponds to an address.
|
||||||
UniValue subobj(UniValue::VOBJ);
|
UniValue subobj(UniValue::VOBJ);
|
||||||
UniValue detail = DescribeAddress(embedded);
|
UniValue detail = DescribeAddress(embedded);
|
||||||
subobj.pushKVs(detail);
|
subobj.pushKVs(std::move(detail));
|
||||||
UniValue wallet_detail = std::visit(*this, embedded);
|
UniValue wallet_detail = std::visit(*this, embedded);
|
||||||
subobj.pushKVs(wallet_detail);
|
subobj.pushKVs(std::move(wallet_detail));
|
||||||
subobj.pushKV("address", EncodeDestination(embedded));
|
subobj.pushKV("address", EncodeDestination(embedded));
|
||||||
subobj.pushKV("scriptPubKey", HexStr(subscript));
|
subobj.pushKV("scriptPubKey", HexStr(subscript));
|
||||||
// Always report the pubkey at the top level, so that `getnewaddress()['pubkey']` always works.
|
// Always report the pubkey at the top level, so that `getnewaddress()['pubkey']` always works.
|
||||||
|
@ -490,7 +490,7 @@ static UniValue DescribeWalletAddress(const CWallet& wallet, const CTxDestinatio
|
||||||
CScript script = GetScriptForDestination(dest);
|
CScript script = GetScriptForDestination(dest);
|
||||||
std::unique_ptr<SigningProvider> provider = nullptr;
|
std::unique_ptr<SigningProvider> provider = nullptr;
|
||||||
provider = wallet.GetSolvingProvider(script);
|
provider = wallet.GetSolvingProvider(script);
|
||||||
ret.pushKVs(detail);
|
ret.pushKVs(std::move(detail));
|
||||||
ret.pushKVs(std::visit(DescribeWalletAddressVisitor(provider.get()), dest));
|
ret.pushKVs(std::visit(DescribeWalletAddressVisitor(provider.get()), dest));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -607,7 +607,7 @@ RPCHelpMan getaddressinfo()
|
||||||
ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY));
|
ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY));
|
||||||
|
|
||||||
UniValue detail = DescribeWalletAddress(*pwallet, dest);
|
UniValue detail = DescribeWalletAddress(*pwallet, dest);
|
||||||
ret.pushKVs(detail);
|
ret.pushKVs(std::move(detail));
|
||||||
|
|
||||||
ret.pushKV("ischange", ScriptIsChange(*pwallet, scriptPubKey));
|
ret.pushKV("ischange", ScriptIsChange(*pwallet, scriptPubKey));
|
||||||
|
|
||||||
|
@ -688,7 +688,7 @@ RPCHelpMan getaddressesbylabel()
|
||||||
// which currently is O(1).
|
// which currently is O(1).
|
||||||
UniValue value(UniValue::VOBJ);
|
UniValue value(UniValue::VOBJ);
|
||||||
value.pushKV("purpose", _purpose ? PurposeToString(*_purpose) : "unknown");
|
value.pushKV("purpose", _purpose ? PurposeToString(*_purpose) : "unknown");
|
||||||
ret.pushKVEnd(address, value);
|
ret.pushKVEnd(address, std::move(value));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1827,16 +1827,16 @@ RPCHelpMan listdescriptors()
|
||||||
UniValue range(UniValue::VARR);
|
UniValue range(UniValue::VARR);
|
||||||
range.push_back(info.range->first);
|
range.push_back(info.range->first);
|
||||||
range.push_back(info.range->second - 1);
|
range.push_back(info.range->second - 1);
|
||||||
spk.pushKV("range", range);
|
spk.pushKV("range", std::move(range));
|
||||||
spk.pushKV("next", info.next_index);
|
spk.pushKV("next", info.next_index);
|
||||||
spk.pushKV("next_index", info.next_index);
|
spk.pushKV("next_index", info.next_index);
|
||||||
}
|
}
|
||||||
descriptors.push_back(spk);
|
descriptors.push_back(std::move(spk));
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue response(UniValue::VOBJ);
|
UniValue response(UniValue::VOBJ);
|
||||||
response.pushKV("wallet_name", wallet->GetName());
|
response.pushKV("wallet_name", wallet->GetName());
|
||||||
response.pushKV("descriptors", descriptors);
|
response.pushKV("descriptors", std::move(descriptors));
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
|
|
|
@ -416,7 +416,7 @@ RPCHelpMan listlockunspent()
|
||||||
|
|
||||||
o.pushKV("txid", outpt.hash.GetHex());
|
o.pushKV("txid", outpt.hash.GetHex());
|
||||||
o.pushKV("vout", (int)outpt.n);
|
o.pushKV("vout", (int)outpt.n);
|
||||||
ret.push_back(o);
|
ret.push_back(std::move(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -477,7 +477,7 @@ RPCHelpMan getbalances()
|
||||||
const auto full_bal = GetBalance(wallet, 0, false);
|
const auto full_bal = GetBalance(wallet, 0, false);
|
||||||
balances_mine.pushKV("used", ValueFromAmount(full_bal.m_mine_trusted + full_bal.m_mine_untrusted_pending - bal.m_mine_trusted - bal.m_mine_untrusted_pending));
|
balances_mine.pushKV("used", ValueFromAmount(full_bal.m_mine_trusted + full_bal.m_mine_untrusted_pending - bal.m_mine_trusted - bal.m_mine_untrusted_pending));
|
||||||
}
|
}
|
||||||
balances.pushKV("mine", balances_mine);
|
balances.pushKV("mine", std::move(balances_mine));
|
||||||
}
|
}
|
||||||
auto spk_man = wallet.GetLegacyScriptPubKeyMan();
|
auto spk_man = wallet.GetLegacyScriptPubKeyMan();
|
||||||
if (spk_man && spk_man->HaveWatchOnly()) {
|
if (spk_man && spk_man->HaveWatchOnly()) {
|
||||||
|
@ -485,7 +485,7 @@ RPCHelpMan getbalances()
|
||||||
balances_watchonly.pushKV("trusted", ValueFromAmount(bal.m_watchonly_trusted));
|
balances_watchonly.pushKV("trusted", ValueFromAmount(bal.m_watchonly_trusted));
|
||||||
balances_watchonly.pushKV("untrusted_pending", ValueFromAmount(bal.m_watchonly_untrusted_pending));
|
balances_watchonly.pushKV("untrusted_pending", ValueFromAmount(bal.m_watchonly_untrusted_pending));
|
||||||
balances_watchonly.pushKV("immature", ValueFromAmount(bal.m_watchonly_immature));
|
balances_watchonly.pushKV("immature", ValueFromAmount(bal.m_watchonly_immature));
|
||||||
balances.pushKV("watchonly", balances_watchonly);
|
balances.pushKV("watchonly", std::move(balances_watchonly));
|
||||||
}
|
}
|
||||||
|
|
||||||
AppendLastProcessedBlock(balances, wallet);
|
AppendLastProcessedBlock(balances, wallet);
|
||||||
|
@ -724,7 +724,7 @@ RPCHelpMan listunspent()
|
||||||
PushParentDescriptors(*pwallet, scriptPubKey, entry);
|
PushParentDescriptors(*pwallet, scriptPubKey, entry);
|
||||||
if (avoid_reuse) entry.pushKV("reused", reused);
|
if (avoid_reuse) entry.pushKV("reused", reused);
|
||||||
entry.pushKV("safe", out.safe);
|
entry.pushKV("safe", out.safe);
|
||||||
results.push_back(entry);
|
results.push_back(std::move(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
|
|
@ -718,7 +718,7 @@ static void SetOptionsInputWeights(const UniValue& inputs, UniValue& options)
|
||||||
weights.push_back(input);
|
weights.push_back(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
options.pushKV("input_weights", weights);
|
options.pushKV("input_weights", std::move(weights));
|
||||||
}
|
}
|
||||||
|
|
||||||
RPCHelpMan fundrawtransaction()
|
RPCHelpMan fundrawtransaction()
|
||||||
|
@ -1167,7 +1167,7 @@ static RPCHelpMan bumpfee_helper(std::string method_name)
|
||||||
for (const bilingual_str& error : errors) {
|
for (const bilingual_str& error : errors) {
|
||||||
result_errors.push_back(error.original);
|
result_errors.push_back(error.original);
|
||||||
}
|
}
|
||||||
result.pushKV("errors", result_errors);
|
result.pushKV("errors", std::move(result_errors));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
@ -1388,7 +1388,7 @@ RPCHelpMan sendall()
|
||||||
if (recipient.isStr()) {
|
if (recipient.isStr()) {
|
||||||
UniValue rkvp(UniValue::VOBJ);
|
UniValue rkvp(UniValue::VOBJ);
|
||||||
rkvp.pushKV(recipient.get_str(), 0);
|
rkvp.pushKV(recipient.get_str(), 0);
|
||||||
recipient_key_value_pairs.push_back(rkvp);
|
recipient_key_value_pairs.push_back(std::move(rkvp));
|
||||||
addresses_without_amount.insert(recipient.get_str());
|
addresses_without_amount.insert(recipient.get_str());
|
||||||
} else {
|
} else {
|
||||||
recipient_key_value_pairs.push_back(recipient);
|
recipient_key_value_pairs.push_back(recipient);
|
||||||
|
|
|
@ -39,11 +39,11 @@ static void WalletTxToJSON(const CWallet& wallet, const CWalletTx& wtx, UniValue
|
||||||
UniValue conflicts(UniValue::VARR);
|
UniValue conflicts(UniValue::VARR);
|
||||||
for (const uint256& conflict : wallet.GetTxConflicts(wtx))
|
for (const uint256& conflict : wallet.GetTxConflicts(wtx))
|
||||||
conflicts.push_back(conflict.GetHex());
|
conflicts.push_back(conflict.GetHex());
|
||||||
entry.pushKV("walletconflicts", conflicts);
|
entry.pushKV("walletconflicts", std::move(conflicts));
|
||||||
UniValue mempool_conflicts(UniValue::VARR);
|
UniValue mempool_conflicts(UniValue::VARR);
|
||||||
for (const Txid& mempool_conflict : wtx.mempool_conflicts)
|
for (const Txid& mempool_conflict : wtx.mempool_conflicts)
|
||||||
mempool_conflicts.push_back(mempool_conflict.GetHex());
|
mempool_conflicts.push_back(mempool_conflict.GetHex());
|
||||||
entry.pushKV("mempoolconflicts", mempool_conflicts);
|
entry.pushKV("mempoolconflicts", std::move(mempool_conflicts));
|
||||||
entry.pushKV("time", wtx.GetTxTime());
|
entry.pushKV("time", wtx.GetTxTime());
|
||||||
entry.pushKV("timereceived", int64_t{wtx.nTimeReceived});
|
entry.pushKV("timereceived", int64_t{wtx.nTimeReceived});
|
||||||
|
|
||||||
|
@ -172,8 +172,8 @@ static UniValue ListReceived(const CWallet& wallet, const UniValue& params, cons
|
||||||
transactions.push_back(_item.GetHex());
|
transactions.push_back(_item.GetHex());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
obj.pushKV("txids", transactions);
|
obj.pushKV("txids", std::move(transactions));
|
||||||
ret.push_back(obj);
|
ret.push_back(std::move(obj));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ static UniValue ListReceived(const CWallet& wallet, const UniValue& params, cons
|
||||||
obj.pushKV("amount", ValueFromAmount(nAmount));
|
obj.pushKV("amount", ValueFromAmount(nAmount));
|
||||||
obj.pushKV("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
|
obj.pushKV("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
|
||||||
obj.pushKV("label", entry.first);
|
obj.pushKV("label", entry.first);
|
||||||
ret.push_back(obj);
|
ret.push_back(std::move(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ static void ListTransactions(const CWallet& wallet, const CWalletTx& wtx, int nM
|
||||||
if (fLong)
|
if (fLong)
|
||||||
WalletTxToJSON(wallet, wtx, entry);
|
WalletTxToJSON(wallet, wtx, entry);
|
||||||
entry.pushKV("abandoned", wtx.isAbandoned());
|
entry.pushKV("abandoned", wtx.isAbandoned());
|
||||||
ret.push_back(entry);
|
ret.push_back(std::move(entry));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ static void ListTransactions(const CWallet& wallet, const CWalletTx& wtx, int nM
|
||||||
entry.pushKV("abandoned", wtx.isAbandoned());
|
entry.pushKV("abandoned", wtx.isAbandoned());
|
||||||
if (fLong)
|
if (fLong)
|
||||||
WalletTxToJSON(wallet, wtx, entry);
|
WalletTxToJSON(wallet, wtx, entry);
|
||||||
ret.push_back(entry);
|
ret.push_back(std::move(entry));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -682,8 +682,8 @@ RPCHelpMan listsinceblock()
|
||||||
CHECK_NONFATAL(wallet.chain().findAncestorByHeight(wallet.GetLastBlockHash(), wallet.GetLastBlockHeight() + 1 - target_confirms, FoundBlock().hash(lastblock)));
|
CHECK_NONFATAL(wallet.chain().findAncestorByHeight(wallet.GetLastBlockHash(), wallet.GetLastBlockHeight() + 1 - target_confirms, FoundBlock().hash(lastblock)));
|
||||||
|
|
||||||
UniValue ret(UniValue::VOBJ);
|
UniValue ret(UniValue::VOBJ);
|
||||||
ret.pushKV("transactions", transactions);
|
ret.pushKV("transactions", std::move(transactions));
|
||||||
if (include_removed) ret.pushKV("removed", removed);
|
if (include_removed) ret.pushKV("removed", std::move(removed));
|
||||||
ret.pushKV("lastblock", lastblock.GetHex());
|
ret.pushKV("lastblock", lastblock.GetHex());
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -789,14 +789,14 @@ RPCHelpMan gettransaction()
|
||||||
|
|
||||||
UniValue details(UniValue::VARR);
|
UniValue details(UniValue::VARR);
|
||||||
ListTransactions(*pwallet, wtx, 0, false, details, filter, /*filter_label=*/std::nullopt);
|
ListTransactions(*pwallet, wtx, 0, false, details, filter, /*filter_label=*/std::nullopt);
|
||||||
entry.pushKV("details", details);
|
entry.pushKV("details", std::move(details));
|
||||||
|
|
||||||
entry.pushKV("hex", EncodeHexTx(*wtx.tx));
|
entry.pushKV("hex", EncodeHexTx(*wtx.tx));
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
UniValue decoded(UniValue::VOBJ);
|
UniValue decoded(UniValue::VOBJ);
|
||||||
TxToUniv(*wtx.tx, /*block_hash=*/uint256(), /*entry=*/decoded, /*include_hex=*/false);
|
TxToUniv(*wtx.tx, /*block_hash=*/uint256(), /*entry=*/decoded, /*include_hex=*/false);
|
||||||
entry.pushKV("decoded", decoded);
|
entry.pushKV("decoded", std::move(decoded));
|
||||||
}
|
}
|
||||||
|
|
||||||
AppendLastProcessedBlock(entry, *pwallet);
|
AppendLastProcessedBlock(entry, *pwallet);
|
||||||
|
|
|
@ -149,7 +149,7 @@ void PushParentDescriptors(const CWallet& wallet, const CScript& script_pubkey,
|
||||||
for (const auto& desc: wallet.GetWalletDescriptors(script_pubkey)) {
|
for (const auto& desc: wallet.GetWalletDescriptors(script_pubkey)) {
|
||||||
parent_descs.push_back(desc.descriptor->ToString());
|
parent_descs.push_back(desc.descriptor->ToString());
|
||||||
}
|
}
|
||||||
entry.pushKV("parent_descs", parent_descs);
|
entry.pushKV("parent_descs", std::move(parent_descs));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleWalletError(const std::shared_ptr<CWallet> wallet, DatabaseStatus& status, bilingual_str& error)
|
void HandleWalletError(const std::shared_ptr<CWallet> wallet, DatabaseStatus& status, bilingual_str& error)
|
||||||
|
@ -185,7 +185,7 @@ void AppendLastProcessedBlock(UniValue& entry, const CWallet& wallet) EXCLUSIVE_
|
||||||
UniValue lastprocessedblock{UniValue::VOBJ};
|
UniValue lastprocessedblock{UniValue::VOBJ};
|
||||||
lastprocessedblock.pushKV("hash", wallet.GetLastBlockHash().GetHex());
|
lastprocessedblock.pushKV("hash", wallet.GetLastBlockHash().GetHex());
|
||||||
lastprocessedblock.pushKV("height", wallet.GetLastBlockHeight());
|
lastprocessedblock.pushKV("height", wallet.GetLastBlockHeight());
|
||||||
entry.pushKV("lastprocessedblock", lastprocessedblock);
|
entry.pushKV("lastprocessedblock", std::move(lastprocessedblock));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace wallet
|
} // namespace wallet
|
||||||
|
|
|
@ -128,7 +128,7 @@ static RPCHelpMan getwalletinfo()
|
||||||
UniValue scanning(UniValue::VOBJ);
|
UniValue scanning(UniValue::VOBJ);
|
||||||
scanning.pushKV("duration", Ticks<std::chrono::seconds>(pwallet->ScanningDuration()));
|
scanning.pushKV("duration", Ticks<std::chrono::seconds>(pwallet->ScanningDuration()));
|
||||||
scanning.pushKV("progress", pwallet->ScanningProgress());
|
scanning.pushKV("progress", pwallet->ScanningProgress());
|
||||||
obj.pushKV("scanning", scanning);
|
obj.pushKV("scanning", std::move(scanning));
|
||||||
} else {
|
} else {
|
||||||
obj.pushKV("scanning", false);
|
obj.pushKV("scanning", false);
|
||||||
}
|
}
|
||||||
|
@ -172,11 +172,11 @@ static RPCHelpMan listwalletdir()
|
||||||
for (const auto& path : ListDatabases(GetWalletDir())) {
|
for (const auto& path : ListDatabases(GetWalletDir())) {
|
||||||
UniValue wallet(UniValue::VOBJ);
|
UniValue wallet(UniValue::VOBJ);
|
||||||
wallet.pushKV("name", path.utf8string());
|
wallet.pushKV("name", path.utf8string());
|
||||||
wallets.push_back(wallet);
|
wallets.push_back(std::move(wallet));
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
result.pushKV("wallets", wallets);
|
result.pushKV("wallets", std::move(wallets));
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -235,11 +235,11 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup)
|
||||||
key.pushKV("scriptPubKey", HexStr(GetScriptForRawPubKey(futureKey.GetPubKey())));
|
key.pushKV("scriptPubKey", HexStr(GetScriptForRawPubKey(futureKey.GetPubKey())));
|
||||||
key.pushKV("timestamp", newTip->GetBlockTimeMax() + TIMESTAMP_WINDOW + 1);
|
key.pushKV("timestamp", newTip->GetBlockTimeMax() + TIMESTAMP_WINDOW + 1);
|
||||||
key.pushKV("internal", UniValue(true));
|
key.pushKV("internal", UniValue(true));
|
||||||
keys.push_back(key);
|
keys.push_back(std::move(key));
|
||||||
JSONRPCRequest request;
|
JSONRPCRequest request;
|
||||||
request.context = &context;
|
request.context = &context;
|
||||||
request.params.setArray();
|
request.params.setArray();
|
||||||
request.params.push_back(keys);
|
request.params.push_back(std::move(keys));
|
||||||
|
|
||||||
UniValue response = importmulti().HandleRequest(request);
|
UniValue response = importmulti().HandleRequest(request);
|
||||||
BOOST_CHECK_EQUAL(response.write(),
|
BOOST_CHECK_EQUAL(response.write(),
|
||||||
|
|
|
@ -47,7 +47,7 @@ static RPCHelpMan getzmqnotifications()
|
||||||
obj.pushKV("type", n->GetType());
|
obj.pushKV("type", n->GetType());
|
||||||
obj.pushKV("address", n->GetAddress());
|
obj.pushKV("address", n->GetAddress());
|
||||||
obj.pushKV("hwm", n->GetOutboundMessageHighWaterMark());
|
obj.pushKV("hwm", n->GetOutboundMessageHighWaterMark());
|
||||||
result.push_back(obj);
|
result.push_back(std::move(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue