aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2024-05-13 20:20:10 +0000
committerCory Fields <cory-nospam-@coryfields.com>2024-05-20 16:48:19 +0000
commitd7707d9843b03f20d2a8c5a45d7b3db58e169e6f (patch)
tree30b3b88003c41ef7521e1b2e7bbb6add06892505 /src/rpc
parentecd23656db174adef61d3bd753d02698c3528192 (diff)
downloadbitcoin-d7707d9843b03f20d2a8c5a45d7b3db58e169e6f.tar.xz
rpc: avoid copying into UniValue
These are simple (and hopefully obviously correct) copies that can be moves instead.
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/blockchain.cpp24
-rw-r--r--src/rpc/client.cpp2
-rw-r--r--src/rpc/external_signer.cpp4
-rw-r--r--src/rpc/fees.cpp12
-rw-r--r--src/rpc/mempool.cpp34
-rw-r--r--src/rpc/mining.cpp18
-rw-r--r--src/rpc/net.cpp32
-rw-r--r--src/rpc/node.cpp2
-rw-r--r--src/rpc/output_script.cpp4
-rw-r--r--src/rpc/rawtransaction.cpp106
-rw-r--r--src/rpc/rawtransaction_util.cpp6
-rw-r--r--src/rpc/server.cpp6
-rw-r--r--src/rpc/util.cpp10
13 files changed, 130 insertions, 130 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 1abaeafb2a..263d9f1e0a 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -1025,9 +1025,9 @@ static RPCHelpMan gettxoutsetinfo()
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("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 {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to read UTXO set");
@@ -1111,7 +1111,7 @@ static RPCHelpMan gettxout()
ret.pushKV("value", ValueFromAmount(coin.out.nValue));
UniValue o(UniValue::VOBJ);
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);
return ret;
@@ -1161,7 +1161,7 @@ static void SoftForkDescPushBack(const CBlockIndex* blockindex, UniValue& softfo
// one below the activation height
rv.pushKV("active", DeploymentActiveAfter(blockindex, chainman, 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)
@@ -1214,7 +1214,7 @@ static void SoftForkDescPushBack(const CBlockIndex* blockindex, UniValue& softfo
statsUV.pushKV("threshold", statsStruct.threshold);
statsUV.pushKV("possible", statsStruct.possible);
}
- bip9.pushKV("statistics", statsUV);
+ bip9.pushKV("statistics", std::move(statsUV));
std::string sig;
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("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
@@ -1498,7 +1498,7 @@ static RPCHelpMan getchaintips()
}
obj.pushKV("status", status);
- res.push_back(obj);
+ res.push_back(std::move(obj));
}
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("avgtxsize", (block.vtx.size() > 1) ? total_size / (block.vtx.size() - 1) : 0);
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("ins", inputs);
ret_all.pushKV("maxfee", maxfee);
@@ -2262,9 +2262,9 @@ static RPCHelpMan scantxoutset()
unspent.pushKV("coinbase", coin.IsCoinBase());
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));
} else {
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("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);
}
else {
diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp
index b8dc148eae..7dfe69a6c5 100644
--- a/src/rpc/client.cpp
+++ b/src/rpc/client.cpp
@@ -391,7 +391,7 @@ UniValue RPCConvertNamedValues(const std::string &strMethod, const std::vector<s
// Use pushKVEnd instead of pushKV to avoid overwriting an explicit
// "args" value with an implicit one. Let the RPC server handle the
// request as given.
- params.pushKVEnd("args", positional_args);
+ params.pushKVEnd("args", std::move(positional_args));
}
return params;
diff --git a/src/rpc/external_signer.cpp b/src/rpc/external_signer.cpp
index 27c7394909..3ad7a940e0 100644
--- a/src/rpc/external_signer.cpp
+++ b/src/rpc/external_signer.cpp
@@ -53,13 +53,13 @@ static RPCHelpMan enumeratesigners()
UniValue signer_res = UniValue::VOBJ;
signer_res.pushKV("fingerprint", signer.m_fingerprint);
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) {
throw JSONRPCError(RPC_MISC_ERROR, e.what());
}
UniValue result(UniValue::VOBJ);
- result.pushKV("signers", signers_res);
+ result.pushKV("signers", std::move(signers_res));
return result;
}
};
diff --git a/src/rpc/fees.cpp b/src/rpc/fees.cpp
index b933d8c647..a7cec96746 100644
--- a/src/rpc/fees.cpp
+++ b/src/rpc/fees.cpp
@@ -88,7 +88,7 @@ static RPCHelpMan estimatesmartfee()
result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK()));
} else {
errors.push_back("Insufficient data or no feerate found");
- result.pushKV("errors", errors);
+ result.pushKV("errors", std::move(errors));
}
result.pushKV("blocks", feeCalc.returnedTarget);
return result;
@@ -198,18 +198,18 @@ static RPCHelpMan estimaterawfee()
horizon_result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK()));
horizon_result.pushKV("decay", buckets.decay);
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
- if (buckets.fail.start != -1) horizon_result.pushKV("fail", failbucket);
+ if (buckets.fail.start != -1) horizon_result.pushKV("fail", std::move(failbucket));
} else {
// Output only information that is still meaningful in the event of error
horizon_result.pushKV("decay", buckets.decay);
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");
- 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;
},
diff --git a/src/rpc/mempool.cpp b/src/rpc/mempool.cpp
index e599c7dc92..edd45d9731 100644
--- a/src/rpc/mempool.cpp
+++ b/src/rpc/mempool.cpp
@@ -202,7 +202,7 @@ static RPCHelpMan testmempoolaccept()
auto it = package_result.m_tx_results.find(tx->GetWitnessHash());
if (exit_early || it == package_result.m_tx_results.end()) {
// Validation unfinished. Just return the txid and wtxid.
- rpc_result.push_back(result_inner);
+ rpc_result.push_back(std::move(result_inner));
continue;
}
const auto& tx_result = it->second;
@@ -229,8 +229,8 @@ static RPCHelpMan testmempoolaccept()
for (const auto& wtxid : tx_result.m_wtxids_fee_calculations.value()) {
effective_includes_res.push_back(wtxid.ToString());
}
- fees.pushKV("effective-includes", effective_includes_res);
- result_inner.pushKV("fees", fees);
+ fees.pushKV("effective-includes", std::move(effective_includes_res));
+ result_inner.pushKV("fees", std::move(fees));
}
} else {
result_inner.pushKV("allowed", false);
@@ -241,7 +241,7 @@ static RPCHelpMan testmempoolaccept()
result_inner.pushKV("reject-reason", state.GetRejectReason());
}
}
- rpc_result.push_back(result_inner);
+ rpc_result.push_back(std::move(result_inner));
}
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("ancestor", ValueFromAmount(e.GetModFeesWithAncestors()));
fees.pushKV("descendant", ValueFromAmount(e.GetModFeesWithDescendants()));
- info.pushKV("fees", fees);
+ info.pushKV("fees", std::move(fees));
const CTransaction& tx = e.GetTx();
std::set<std::string> setDepends;
@@ -311,14 +311,14 @@ static void entryToJSON(const CTxMemPool& pool, UniValue& info, const CTxMemPool
depends.push_back(dep);
}
- info.pushKV("depends", depends);
+ info.pushKV("depends", std::move(depends));
UniValue spent(UniValue::VARR);
for (const CTxMemPoolEntry& child : e.GetMemPoolChildrenConst()) {
spent.push_back(child.GetTx().GetHash().ToString());
}
- info.pushKV("spentby", spent);
+ info.pushKV("spentby", std::move(spent));
// Add opt-in RBF status
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
// UniValue::pushKV, which checks if the key already exists in O(N).
// 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;
} else {
@@ -364,7 +364,7 @@ UniValue MempoolToJSON(const CTxMemPool& pool, bool verbose, bool include_mempoo
return a;
} else {
UniValue o(UniValue::VOBJ);
- o.pushKV("txids", a);
+ o.pushKV("txids", std::move(a));
o.pushKV("mempool_sequence", mempool_sequence);
return o;
}
@@ -474,7 +474,7 @@ static RPCHelpMan getmempoolancestors()
const uint256& _hash = e.GetTx().GetHash();
UniValue info(UniValue::VOBJ);
entryToJSON(mempool, info, e);
- o.pushKV(_hash.ToString(), info);
+ o.pushKV(_hash.ToString(), std::move(info));
}
return o;
}
@@ -539,7 +539,7 @@ static RPCHelpMan getmempooldescendants()
const uint256& _hash = e.GetTx().GetHash();
UniValue info(UniValue::VOBJ);
entryToJSON(mempool, info, e);
- o.pushKV(_hash.ToString(), info);
+ o.pushKV(_hash.ToString(), std::move(info));
}
return o;
}
@@ -653,7 +653,7 @@ static RPCHelpMan gettxspendingprevout()
o.pushKV("spendingtxid", spendingTx->GetHash().ToString());
}
- result.push_back(o);
+ result.push_back(std::move(o));
}
return result;
@@ -992,20 +992,20 @@ static RPCHelpMan submitpackage()
for (const auto& wtxid : tx_result.m_wtxids_fee_calculations.value()) {
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) {
replaced_txids.insert(ptx->GetHash());
}
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);
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;
},
};
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index 2391392bd7..606fc62dbe 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -529,7 +529,7 @@ static RPCHelpMan getprioritisedtransactions()
if (delta_info.in_mempool) {
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;
},
@@ -854,7 +854,7 @@ static RPCHelpMan getblocktemplate()
if (setTxIndex.count(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;
entry.pushKV("fee", pblocktemplate->vTxFees[index_in_template]);
@@ -866,7 +866,7 @@ static RPCHelpMan getblocktemplate()
entry.pushKV("sigops", nTxSigOps);
entry.pushKV("weight", GetTransactionWeight(tx));
- transactions.push_back(entry);
+ transactions.push_back(std::move(entry));
}
UniValue aux(UniValue::VOBJ);
@@ -879,7 +879,7 @@ static RPCHelpMan getblocktemplate()
aMutable.push_back("prevblock");
UniValue result(UniValue::VOBJ);
- result.pushKV("capabilities", aCaps);
+ result.pushKV("capabilities", std::move(aCaps));
UniValue aRules(UniValue::VARR);
aRules.push_back("csv");
@@ -931,18 +931,18 @@ static RPCHelpMan getblocktemplate()
}
}
result.pushKV("version", pblock->nVersion);
- result.pushKV("rules", aRules);
- result.pushKV("vbavailable", vbavailable);
+ result.pushKV("rules", std::move(aRules));
+ result.pushKV("vbavailable", std::move(vbavailable));
result.pushKV("vbrequired", int(0));
result.pushKV("previousblockhash", pblock->hashPrevBlock.GetHex());
- result.pushKV("transactions", transactions);
- result.pushKV("coinbaseaux", aux);
+ result.pushKV("transactions", std::move(transactions));
+ result.pushKV("coinbaseaux", std::move(aux));
result.pushKV("coinbasevalue", (int64_t)pblock->vtx[0]->vout[0].nValue);
result.pushKV("longpollid", active_chain.Tip()->GetBlockHash().GetHex() + ToString(nTransactionsUpdatedLast));
result.pushKV("target", hashTarget.GetHex());
result.pushKV("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1);
- result.pushKV("mutable", aMutable);
+ result.pushKV("mutable", std::move(aMutable));
result.pushKV("noncerange", "00000000ffffffff");
int64_t nSigOpLimit = MAX_BLOCK_SIGOPS_COST;
int64_t nSizeLimit = MAX_BLOCK_SERIALIZED_SIZE;
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
index 59397aa84d..b001b9c352 100644
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -263,7 +263,7 @@ static RPCHelpMan getpeerinfo()
for (const int height : statestats.vHeightInFlight) {
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_processed", statestats.m_addr_processed);
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)) {
permissions.push_back(permission);
}
- obj.pushKV("permissions", permissions);
+ obj.pushKV("permissions", std::move(permissions));
obj.pushKV("minfeefilter", ValueFromAmount(statestats.m_fee_filter_received));
UniValue sendPerMsgType(UniValue::VOBJ);
@@ -279,19 +279,19 @@ static RPCHelpMan getpeerinfo()
if (i.second > 0)
sendPerMsgType.pushKV(i.first, i.second);
}
- obj.pushKV("bytessent_per_msg", sendPerMsgType);
+ obj.pushKV("bytessent_per_msg", std::move(sendPerMsgType));
UniValue recvPerMsgType(UniValue::VOBJ);
for (const auto& i : stats.mapRecvBytesPerMsgType) {
if (i.second > 0)
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("transport_protocol_type", TransportTypeAsString(stats.m_transport_type));
obj.pushKV("session_id", stats.m_session_id);
- ret.push_back(obj);
+ ret.push_back(std::move(obj));
}
return ret;
@@ -532,10 +532,10 @@ static RPCHelpMan getaddednodeinfo()
UniValue address(UniValue::VOBJ);
address.pushKV("address", info.resolvedAddress.ToStringAddrPort());
address.pushKV("connected", info.fInbound ? "inbound" : "outbound");
- addresses.push_back(address);
+ addresses.push_back(std::move(address));
}
- obj.pushKV("addresses", addresses);
- ret.push_back(obj);
+ obj.pushKV("addresses", std::move(addresses));
+ ret.push_back(std::move(obj));
}
return ret;
@@ -587,7 +587,7 @@ static RPCHelpMan getnettotals()
outboundLimit.pushKV("serve_historical_blocks", !connman.OutboundTargetReached(true));
outboundLimit.pushKV("bytes_left_in_cycle", connman.GetOutboundTargetBytesLeft());
outboundLimit.pushKV("time_left_in_cycle", count_seconds(connman.GetMaxOutboundTimeLeftInCycle()));
- obj.pushKV("uploadtarget", outboundLimit);
+ obj.pushKV("uploadtarget", std::move(outboundLimit));
return obj;
},
};
@@ -607,7 +607,7 @@ static UniValue GetNetworksInfo()
obj.pushKV("reachable", g_reachable_nets.Contains(network));
obj.pushKV("proxy", proxy.IsValid() ? proxy.ToString() : std::string());
obj.pushKV("proxy_randomize_credentials", proxy.m_randomize_credentials);
- networks.push_back(obj);
+ networks.push_back(std::move(obj));
}
return networks;
}
@@ -709,10 +709,10 @@ static RPCHelpMan getnetworkinfo()
rec.pushKV("address", item.first.ToStringAddr());
rec.pushKV("port", item.second.nPort);
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")));
return obj;
},
@@ -843,7 +843,7 @@ static RPCHelpMan listbanned()
rec.pushKV("ban_duration", (banEntry.nBanUntil - banEntry.nCreateTime));
rec.pushKV("time_remaining", (banEntry.nBanUntil - current_time));
- bannedAddresses.push_back(rec);
+ bannedAddresses.push_back(std::move(rec));
}
return bannedAddresses;
@@ -947,7 +947,7 @@ static RPCHelpMan getnodeaddresses()
obj.pushKV("address", addr.ToStringAddr());
obj.pushKV("port", addr.GetPort());
obj.pushKV("network", GetNetworkName(addr.GetNetClass()));
- ret.push_back(obj);
+ ret.push_back(std::move(obj));
}
return ret;
},
@@ -1087,13 +1087,13 @@ static RPCHelpMan getaddrmaninfo()
obj.pushKV("new", addrman.Size(network, true));
obj.pushKV("tried", addrman.Size(network, false));
obj.pushKV("total", addrman.Size(network));
- ret.pushKV(GetNetworkName(network), obj);
+ ret.pushKV(GetNetworkName(network), std::move(obj));
}
UniValue obj(UniValue::VOBJ);
obj.pushKV("new", addrman.Size(std::nullopt, true));
obj.pushKV("tried", addrman.Size(std::nullopt, false));
obj.pushKV("total", addrman.Size());
- ret.pushKV("all_networks", obj);
+ ret.pushKV("all_networks", std::move(obj));
return ret;
},
};
diff --git a/src/rpc/node.cpp b/src/rpc/node.cpp
index 447be2cf64..65b0a93cdd 100644
--- a/src/rpc/node.cpp
+++ b/src/rpc/node.cpp
@@ -351,7 +351,7 @@ static UniValue SummaryToJSON(const IndexSummary&& summary, std::string index_na
UniValue entry(UniValue::VOBJ);
entry.pushKV("synced", summary.synced);
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;
}
diff --git a/src/rpc/output_script.cpp b/src/rpc/output_script.cpp
index 474d9076be..f771b31db0 100644
--- a/src/rpc/output_script.cpp
+++ b/src/rpc/output_script.cpp
@@ -72,11 +72,11 @@ static RPCHelpMan validateaddress()
ret.pushKV("scriptPubKey", HexStr(scriptPubKey));
UniValue detail = DescribeAddress(dest);
- ret.pushKVs(detail);
+ ret.pushKVs(std::move(detail));
} else {
UniValue error_indices(UniValue::VARR);
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);
}
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
index 634be2f7fb..7fa6652f9e 100644
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -618,7 +618,7 @@ static RPCHelpMan decodescript()
}
ScriptToUniv(segwitScr, /*out=*/sr, /*include_hex=*/true, /*include_address=*/true, /*provider=*/&provider);
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
UniValue tx_univ(UniValue::VOBJ);
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
UniValue global_xpubs(UniValue::VARR);
@@ -1083,10 +1083,10 @@ static RPCHelpMan decodepsbt()
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("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
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("key", HexStr(entry.key));
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
UniValue unknowns(UniValue::VOBJ);
for (auto entry : psbtx.unknown) {
unknowns.pushKV(HexStr(entry.first), HexStr(entry.second));
}
- result.pushKV("unknown", unknowns);
+ result.pushKV("unknown", std::move(unknowns));
// inputs
CAmount total_in = 0;
@@ -1128,9 +1128,9 @@ static RPCHelpMan decodepsbt()
UniValue out(UniValue::VOBJ);
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;
}
@@ -1139,7 +1139,7 @@ static RPCHelpMan decodepsbt()
UniValue non_wit(UniValue::VOBJ);
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;
}
@@ -1160,7 +1160,7 @@ static RPCHelpMan decodepsbt()
for (const auto& sig : input.partial_sigs) {
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
@@ -1172,12 +1172,12 @@ static RPCHelpMan decodepsbt()
if (!input.redeem_script.empty()) {
UniValue r(UniValue::VOBJ);
ScriptToUniv(input.redeem_script, /*out=*/r);
- in.pushKV("redeem_script", r);
+ in.pushKV("redeem_script", std::move(r));
}
if (!input.witness_script.empty()) {
UniValue r(UniValue::VOBJ);
ScriptToUniv(input.witness_script, /*out=*/r);
- in.pushKV("witness_script", r);
+ in.pushKV("witness_script", std::move(r));
}
// keypaths
@@ -1189,9 +1189,9 @@ static RPCHelpMan decodepsbt()
keypath.pushKV("master_fingerprint", strprintf("%08x", ReadBE32(entry.second.fingerprint)));
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
@@ -1199,14 +1199,14 @@ static RPCHelpMan decodepsbt()
UniValue scriptsig(UniValue::VOBJ);
scriptsig.pushKV("asm", ScriptToAsmStr(input.final_script_sig, true));
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()) {
UniValue txinwitness(UniValue::VARR);
for (const auto& item : input.final_script_witness.stack) {
txinwitness.push_back(HexStr(item));
}
- in.pushKV("final_scriptwitness", txinwitness);
+ in.pushKV("final_scriptwitness", std::move(txinwitness));
}
// Ripemd160 hash preimages
@@ -1215,7 +1215,7 @@ static RPCHelpMan decodepsbt()
for (const auto& [hash, preimage] : input.ripemd160_preimages) {
ripemd160_preimages.pushKV(HexStr(hash), HexStr(preimage));
}
- in.pushKV("ripemd160_preimages", ripemd160_preimages);
+ in.pushKV("ripemd160_preimages", std::move(ripemd160_preimages));
}
// Sha256 hash preimages
@@ -1224,7 +1224,7 @@ static RPCHelpMan decodepsbt()
for (const auto& [hash, preimage] : input.sha256_preimages) {
sha256_preimages.pushKV(HexStr(hash), HexStr(preimage));
}
- in.pushKV("sha256_preimages", sha256_preimages);
+ in.pushKV("sha256_preimages", std::move(sha256_preimages));
}
// Hash160 hash preimages
@@ -1233,7 +1233,7 @@ static RPCHelpMan decodepsbt()
for (const auto& [hash, preimage] : input.hash160_preimages) {
hash160_preimages.pushKV(HexStr(hash), HexStr(preimage));
}
- in.pushKV("hash160_preimages", hash160_preimages);
+ in.pushKV("hash160_preimages", std::move(hash160_preimages));
}
// Hash256 hash preimages
@@ -1242,7 +1242,7 @@ static RPCHelpMan decodepsbt()
for (const auto& [hash, preimage] : input.hash256_preimages) {
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
@@ -1259,9 +1259,9 @@ static RPCHelpMan decodepsbt()
sigobj.pushKV("pubkey", HexStr(xonly));
sigobj.pushKV("leaf_hash", HexStr(leaf_hash));
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
@@ -1276,10 +1276,10 @@ static RPCHelpMan decodepsbt()
for (const auto& control_block : control_blocks) {
control_blocks_univ.push_back(HexStr(control_block));
}
- script_info.pushKV("control_blocks", control_blocks_univ);
- tap_scripts.push_back(script_info);
+ script_info.pushKV("control_blocks", std::move(control_blocks_univ));
+ 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
@@ -1295,10 +1295,10 @@ static RPCHelpMan decodepsbt()
for (const auto& leaf_hash : leaf_hashes) {
leaf_hashes_arr.push_back(HexStr(leaf_hash));
}
- path_obj.pushKV("leaf_hashes", leaf_hashes_arr);
- keypaths.push_back(path_obj);
+ path_obj.pushKV("leaf_hashes", std::move(leaf_hashes_arr));
+ keypaths.push_back(std::move(path_obj));
}
- in.pushKV("taproot_bip32_derivs", keypaths);
+ in.pushKV("taproot_bip32_derivs", std::move(keypaths));
}
// Taproot internal key
@@ -1320,9 +1320,9 @@ static RPCHelpMan decodepsbt()
this_prop.pushKV("subtype", entry.subtype);
this_prop.pushKV("key", HexStr(entry.key));
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
@@ -1331,12 +1331,12 @@ static RPCHelpMan decodepsbt()
for (auto entry : input.unknown) {
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
CAmount output_value = 0;
@@ -1348,12 +1348,12 @@ static RPCHelpMan decodepsbt()
if (!output.redeem_script.empty()) {
UniValue r(UniValue::VOBJ);
ScriptToUniv(output.redeem_script, /*out=*/r);
- out.pushKV("redeem_script", r);
+ out.pushKV("redeem_script", std::move(r));
}
if (!output.witness_script.empty()) {
UniValue r(UniValue::VOBJ);
ScriptToUniv(output.witness_script, /*out=*/r);
- out.pushKV("witness_script", r);
+ out.pushKV("witness_script", std::move(r));
}
// keypaths
@@ -1364,9 +1364,9 @@ static RPCHelpMan decodepsbt()
keypath.pushKV("pubkey", HexStr(entry.first));
keypath.pushKV("master_fingerprint", strprintf("%08x", ReadBE32(entry.second.fingerprint)));
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
@@ -1382,9 +1382,9 @@ static RPCHelpMan decodepsbt()
elem.pushKV("depth", (int)depth);
elem.pushKV("leaf_ver", (int)leaf_ver);
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
@@ -1400,10 +1400,10 @@ static RPCHelpMan decodepsbt()
for (const auto& leaf_hash : leaf_hashes) {
leaf_hashes_arr.push_back(HexStr(leaf_hash));
}
- path_obj.pushKV("leaf_hashes", leaf_hashes_arr);
- keypaths.push_back(path_obj);
+ path_obj.pushKV("leaf_hashes", std::move(leaf_hashes_arr));
+ keypaths.push_back(std::move(path_obj));
}
- out.pushKV("taproot_bip32_derivs", keypaths);
+ out.pushKV("taproot_bip32_derivs", std::move(keypaths));
}
// Proprietary
@@ -1415,9 +1415,9 @@ static RPCHelpMan decodepsbt()
this_prop.pushKV("subtype", entry.subtype);
this_prop.pushKV("key", HexStr(entry.key));
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
@@ -1426,10 +1426,10 @@ static RPCHelpMan decodepsbt()
for (auto entry : output.unknown) {
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
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;
}
}
- result.pushKV("outputs", outputs);
+ result.pushKV("outputs", std::move(outputs));
if (have_all_utxos) {
result.pushKV("fee", ValueFromAmount(total_in - output_value));
}
@@ -1876,7 +1876,7 @@ static RPCHelpMan analyzepsbt()
for (const CKeyID& pubkey : input.missing_pubkeys) {
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()) {
missing.pushKV("redeemscript", HexStr(input.missing_redeem_script));
@@ -1889,14 +1889,14 @@ static RPCHelpMan analyzepsbt()
for (const CKeyID& pubkey : input.missing_sigs) {
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()) {
- 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) {
result.pushKV("estimated_vsize", (int)*psbta.estimated_vsize);
diff --git a/src/rpc/rawtransaction_util.cpp b/src/rpc/rawtransaction_util.cpp
index a9e11622a7..a62f90215a 100644
--- a/src/rpc/rawtransaction_util.cpp
+++ b/src/rpc/rawtransaction_util.cpp
@@ -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++) {
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("sequence", (uint64_t)txin.nSequence);
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)
@@ -331,6 +331,6 @@ void SignTransactionResultToJSON(CMutableTransaction& mtx, bool complete, const
if (result.exists("errors")) {
vErrors.push_backV(result["errors"].getValues());
}
- result.pushKV("errors", vErrors);
+ result.pushKV("errors", std::move(vErrors));
}
}
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index 1ed406354a..838068bc19 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -241,15 +241,15 @@ static RPCHelpMan getrpcinfo()
UniValue entry(UniValue::VOBJ);
entry.pushKV("method", info.method);
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);
- result.pushKV("active_commands", active_commands);
+ result.pushKV("active_commands", std::move(active_commands));
const std::string path = LogInstance().m_file_path.utf8string();
UniValue log_path(UniValue::VSTR, path);
- result.pushKV("logpath", log_path);
+ result.pushKV("logpath", std::move(log_path));
return result;
}
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index f5a2e9eb63..ed32af7646 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -645,7 +645,7 @@ UniValue RPCHelpMan::HandleRequest(const JSONRPCRequest& request) const
mismatch.setNull();
break;
}
- mismatch.push_back(match);
+ mismatch.push_back(std::move(match));
}
if (!mismatch.isNull()) {
std::string explain{
@@ -818,7 +818,7 @@ UniValue RPCHelpMan::GetArgMap() const
map.push_back(arg_name);
map.push_back(type == RPCArg::Type::STR ||
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) {
@@ -1124,7 +1124,7 @@ UniValue RPCResult::MatchesType(const UniValue& result) const
// 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))};
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
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
for (size_t i{0}; i < result.get_obj().size(); ++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
return errors;
@@ -1163,7 +1163,7 @@ UniValue RPCResult::MatchesType(const UniValue& result) const
continue;
}
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;
return errors;