diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 9c8fe99123..8ac5900a23 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -297,7 +297,7 @@ public: total += counts.at(i); } 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); } }; @@ -348,7 +348,7 @@ public: connections.pushKV("in", batch[ID_NETWORKINFO]["result"]["connections_in"]); connections.pushKV("out", batch[ID_NETWORKINFO]["result"]["connections_out"]); 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("difficulty", batch[ID_BLOCKCHAININFO]["result"]["difficulty"]); @@ -949,7 +949,7 @@ static void GetWalletBalances(UniValue& result) const UniValue& balance = getbalances.find_value("result")["mine"]["trusted"]; balances.pushKV(wallet_name, balance); } - result.pushKV("balances", balances); + result.pushKV("balances", std::move(balances)); } /** diff --git a/src/core_write.cpp b/src/core_write.cpp index 4e770a86d4..c377e32bf1 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -345,7 +345,7 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry vin.push_back(in); } - entry.pushKV("vin", vin); + entry.pushKV("vin", std::move(vin)); CAmountMap fee_map{}; UniValue vout(UniValue::VARR); @@ -402,7 +402,7 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry out.pushKV("scriptPubKey", o); vout.push_back(out); } - entry.pushKV("vout", vout); + entry.pushKV("vout", std::move(vout)); // ELEMENTS: add fee map rather than single fee. Unlike other areas of the RPC, // we do not look up labels here and will always use the asset hex (contrast diff --git a/src/net_types.cpp b/src/net_types.cpp index fd6ad80404..fb6ad59599 100644 --- a/src/net_types.cpp +++ b/src/net_types.cpp @@ -43,7 +43,7 @@ UniValue BanMapToJson(const banmap_t& bans) const auto& ban_entry = it.second; UniValue j = ban_entry.ToJson(); j.pushKV(BANMAN_JSON_ADDR_KEY, address.ToString()); - bans_json.push_back(j); + bans_json.push_back(std::move(j)); } return bans_json; } diff --git a/src/rest.cpp b/src/rest.cpp index 4025deefb5..517e10fb4e 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -942,10 +942,10 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std:: // include the script in a json output UniValue o(UniValue::VOBJ); ScriptToUniv(coin.out.scriptPubKey, /*out=*/o, /*include_hex=*/true, /*include_address=*/true); - utxo.pushKV("scriptPubKey", o); - utxos.push_back(utxo); + utxo.pushKV("scriptPubKey", std::move(o)); + utxos.push_back(std::move(utxo)); } - objGetUTXOResponse.pushKV("utxos", utxos); + objGetUTXOResponse.pushKV("utxos", std::move(utxos)); // return json string std::string strJSON = objGetUTXOResponse.write() + "\n"; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index d7dcec650c..42108b2a56 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1159,9 +1159,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"); @@ -1262,7 +1262,7 @@ static RPCHelpMan gettxout() } 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; @@ -1312,7 +1312,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) @@ -1365,7 +1365,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()); @@ -1381,9 +1381,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 @@ -1706,7 +1706,7 @@ static RPCHelpMan getchaintips() } obj.pushKV("status", status); - res.push_back(obj); + res.push_back(std::move(obj)); } return res; @@ -2215,7 +2215,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); @@ -2778,7 +2778,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 c684d327e0..a504f3c13b 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -432,7 +432,7 @@ UniValue RPCConvertNamedValues(const std::string &strMethod, const std::vectorGetWitnessHash()); 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; @@ -240,8 +240,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); @@ -252,7 +252,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; }, @@ -306,7 +306,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 setDepends; @@ -322,14 +322,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; @@ -358,7 +358,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 { @@ -375,7 +375,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; } @@ -485,7 +485,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; } @@ -550,7 +550,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; } @@ -664,7 +664,7 @@ static RPCHelpMan gettxspendingprevout() o.pushKV("spendingtxid", spendingTx->GetHash().ToString()); } - result.push_back(o); + result.push_back(std::move(o)); } return result; @@ -1004,20 +1004,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 dcf6b9bd74..0c9e290951 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -551,7 +551,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; }, @@ -876,7 +876,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]); @@ -888,7 +888,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); @@ -901,7 +901,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"); @@ -953,18 +953,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.GetAmount()); 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 0238f671f8..553a3a433d 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 f87ea5af1b..1083495812 100644 --- a/src/rpc/node.cpp +++ b/src/rpc/node.cpp @@ -358,7 +358,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/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 7786078106..cc592648b8 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -695,7 +695,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)); } } @@ -1212,7 +1212,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 @@ -1227,10 +1227,10 @@ static RPCHelpMan decodepsbt() keypath.pushKV("xpub", EncodeBase58Check(ser_xpub)); keypath.pushKV("master_fingerprint", HexStr(Span(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)); // Add PSBTv2 stuff if (psbtx.GetVersion() == 2) { @@ -1269,9 +1269,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)); } - result.pushKV("proprietary", proprietary); + result.pushKV("proprietary", std::move(proprietary)); result.pushKV("fees", AmountMapToUniv(GetFeeMap(CTransaction(psbtx.GetUnsignedTx())), "")); @@ -1280,7 +1280,7 @@ static RPCHelpMan decodepsbt() for (auto entry : psbtx.unknown) { unknowns.pushKV(HexStr(entry.first), HexStr(entry.second)); } - result.pushKV("unknown", unknowns); + result.pushKV("unknown", std::move(unknowns)); // inputs UniValue inputs(UniValue::VARR); @@ -1307,9 +1307,9 @@ static RPCHelpMan decodepsbt() } else { out.pushKV("assetcommitment", txout.nAsset.GetHex()); } - out.pushKV("scriptPubKey", o); + out.pushKV("scriptPubKey", std::move(o)); - in.pushKV("witness_utxo", out); + in.pushKV("witness_utxo", std::move(out)); } if (input.non_witness_utxo) { if (*input.prev_out < input.non_witness_utxo->vout.size()) { @@ -1327,7 +1327,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 @@ -1339,12 +1339,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 @@ -1356,9 +1356,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 @@ -1366,14 +1366,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)); } // PSBTv2 @@ -1547,7 +1547,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 @@ -1556,7 +1556,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 @@ -1565,7 +1565,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 @@ -1574,7 +1574,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 @@ -1591,9 +1591,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 @@ -1608,10 +1608,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 @@ -1627,10 +1627,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 @@ -1652,9 +1652,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 @@ -1663,12 +1663,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 UniValue outputs(UniValue::VARR); @@ -1679,12 +1679,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 @@ -1695,9 +1695,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)); } // PSBTv2 stuff @@ -1796,9 +1796,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 @@ -1814,10 +1814,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 @@ -1829,9 +1829,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 @@ -1840,10 +1840,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)); } result.pushKV("outputs", outputs); @@ -2486,7 +2486,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)); @@ -2499,14 +2499,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)); UniValue outputs_result(UniValue::VARR); for (const auto& output : psbta.outputs) { diff --git a/src/rpc/rawtransaction_util.cpp b/src/rpc/rawtransaction_util.cpp index 207cc7fea8..f87f3be6ba 100644 --- a/src/rpc/rawtransaction_util.cpp +++ b/src/rpc/rawtransaction_util.cpp @@ -453,11 +453,11 @@ static void TxInErrorToJSON(const CTxIn& txin, const CTxInWitness& txinwit, UniV for (unsigned int i = 0; i < txinwit.scriptWitness.stack.size(); i++) { witness.push_back(HexStr(txinwit.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& coins) @@ -638,7 +638,7 @@ 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)); } if (immature_pegin) { result.pushKV("warning", "Possibly immature peg-in input(s) detected, signed anyways."); 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(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 f30866bab8..2cc47d4f63 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -655,7 +655,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{ @@ -828,7 +828,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) { diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index c18a44e958..3474d31dc7 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -434,7 +434,7 @@ public: wit.push_back(HexStr(scriptWitness.stack[i])); } 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(creditTx->vout[0].scriptPubKey)); diff --git a/src/wallet/rpc/addresses.cpp b/src/wallet/rpc/addresses.cpp index 1fcf0ec305..5745842b17 100644 --- a/src/wallet/rpc/addresses.cpp +++ b/src/wallet/rpc/addresses.cpp @@ -224,9 +224,9 @@ RPCHelpMan listaddressgroupings() 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; }, @@ -425,9 +425,9 @@ public: // Only when the script corresponds to an address. UniValue subobj(UniValue::VOBJ); UniValue detail = DescribeAddress(embedded); - subobj.pushKVs(detail); + subobj.pushKVs(std::move(detail)); UniValue wallet_detail = std::visit(*this, embedded); - subobj.pushKVs(wallet_detail); + subobj.pushKVs(std::move(wallet_detail)); subobj.pushKV("address", EncodeDestination(embedded)); subobj.pushKV("scriptPubKey", HexStr(subscript)); // Always report the pubkey at the top level, so that `getnewaddress()['pubkey']` always works. @@ -509,7 +509,7 @@ static UniValue DescribeWalletAddress(const CWallet& wallet, const CTxDestinatio CScript script = GetScriptForDestination(dest); std::unique_ptr provider = nullptr; provider = wallet.GetSolvingProvider(script); - ret.pushKVs(detail); + ret.pushKVs(std::move(detail)); ret.pushKVs(std::visit(DescribeWalletAddressVisitor(provider.get()), dest)); return ret; } @@ -726,7 +726,7 @@ RPCHelpMan getaddressinfo() ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY)); UniValue detail = DescribeWalletAddress(*pwallet, dest); - ret.pushKVs(detail); + ret.pushKVs(std::move(detail)); // Elements blinding info UniValue blind_detail = DescribeWalletBlindAddress(*pwallet, dest, mine); ret.pushKVs(blind_detail); @@ -812,7 +812,7 @@ RPCHelpMan getaddressesbylabel() // which currently is O(1). UniValue value(UniValue::VOBJ); value.pushKV("purpose", _purpose ? PurposeToString(*_purpose) : "unknown"); - ret.pushKVEnd(address, value); + ret.pushKVEnd(address, std::move(value)); } }); diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp index 14501dec58..a5488bc1a5 100644 --- a/src/wallet/rpc/backup.cpp +++ b/src/wallet/rpc/backup.cpp @@ -1877,16 +1877,16 @@ RPCHelpMan listdescriptors() UniValue range(UniValue::VARR); range.push_back(info.range->first); 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_index", info.next_index); } - descriptors.push_back(spk); + descriptors.push_back(std::move(spk)); } UniValue response(UniValue::VOBJ); response.pushKV("wallet_name", wallet->GetName()); - response.pushKV("descriptors", descriptors); + response.pushKV("descriptors", std::move(descriptors)); return response; }, diff --git a/src/wallet/rpc/coins.cpp b/src/wallet/rpc/coins.cpp index b0f80a5a08..c3c73c1143 100644 --- a/src/wallet/rpc/coins.cpp +++ b/src/wallet/rpc/coins.cpp @@ -470,7 +470,7 @@ RPCHelpMan listlockunspent() o.pushKV("txid", outpt.hash.GetHex()); o.pushKV("vout", (int)outpt.n); - ret.push_back(o); + ret.push_back(std::move(o)); } return ret; @@ -559,7 +559,7 @@ RPCHelpMan getbalances() const auto full_bal = GetBalance(wallet, 0, false); balances_mine.pushKV("used", AmountMapToUniv(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(); if (spk_man && spk_man->HaveWatchOnly()) { @@ -567,7 +567,7 @@ RPCHelpMan getbalances() balances_watchonly.pushKV("trusted", AmountMapToUniv(bal.m_watchonly_trusted, "")); balances_watchonly.pushKV("untrusted_pending", AmountMapToUniv(bal.m_watchonly_untrusted_pending, "")); balances_watchonly.pushKV("immature", AmountMapToUniv(bal.m_watchonly_immature, "")); - balances.pushKV("watchonly", balances_watchonly); + balances.pushKV("watchonly", std::move(balances_watchonly)); } AppendLastProcessedBlock(balances, wallet); @@ -846,7 +846,7 @@ RPCHelpMan listunspent() PushParentDescriptors(*pwallet, scriptPubKey, entry); if (avoid_reuse) entry.pushKV("reused", reused); entry.pushKV("safe", out.safe); - results.push_back(entry); + results.push_back(std::move(entry)); } return results; diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp index 5d18863f09..cd0f57a150 100644 --- a/src/wallet/rpc/spend.cpp +++ b/src/wallet/rpc/spend.cpp @@ -823,7 +823,7 @@ static void SetOptionsInputWeights(const UniValue& inputs, UniValue& options) weights.push_back(input); } } - options.pushKV("input_weights", weights); + options.pushKV("input_weights", std::move(weights)); } RPCHelpMan fundrawtransaction() @@ -1283,7 +1283,7 @@ static RPCHelpMan bumpfee_helper(std::string method_name) for (const bilingual_str& error : errors) { result_errors.push_back(error.original); } - result.pushKV("errors", result_errors); + result.pushKV("errors", std::move(result_errors)); return result; }, @@ -1504,7 +1504,7 @@ RPCHelpMan sendall() if (recipient.isStr()) { UniValue rkvp(UniValue::VOBJ); 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(DecodeDestination(recipient.get_str())); } else { recipient_key_value_pairs.push_back(recipient); diff --git a/src/wallet/rpc/transactions.cpp b/src/wallet/rpc/transactions.cpp index c637a74e70..0f47b4cbb8 100644 --- a/src/wallet/rpc/transactions.cpp +++ b/src/wallet/rpc/transactions.cpp @@ -40,11 +40,11 @@ static void WalletTxToJSON(const CWallet& wallet, const CWalletTx& wtx, UniValue UniValue conflicts(UniValue::VARR); for (const uint256& conflict : wallet.GetTxConflicts(wtx)) conflicts.push_back(conflict.GetHex()); - entry.pushKV("walletconflicts", conflicts); + entry.pushKV("walletconflicts", std::move(conflicts)); UniValue mempool_conflicts(UniValue::VARR); for (const Txid& mempool_conflict : wtx.mempool_conflicts) 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("timereceived", int64_t{wtx.nTimeReceived}); @@ -197,8 +197,8 @@ static UniValue ListReceived(const CWallet& wallet, const UniValue& params, cons transactions.push_back(_item.GetHex()); } } - obj.pushKV("txids", transactions); - ret.push_back(obj); + obj.pushKV("txids", std::move(transactions)); + ret.push_back(std::move(obj)); } }; @@ -220,7 +220,7 @@ static UniValue ListReceived(const CWallet& wallet, const UniValue& params, cons obj.pushKV("amount", AmountMapToUniv(mapAmount, "")); obj.pushKV("confirmations", (nConf == std::numeric_limits::max() ? 0 : nConf)); obj.pushKV("label", entry.first); - ret.push_back(obj); + ret.push_back(std::move(obj)); } } @@ -386,7 +386,7 @@ static void ListTransactions(const CWallet& wallet, const CWalletTx& wtx, int nM if (fLong) WalletTxToJSON(wallet, wtx, entry); entry.pushKV("abandoned", wtx.isAbandoned()); - ret.push_back(entry); + ret.push_back(std::move(entry)); } } @@ -434,7 +434,7 @@ static void ListTransactions(const CWallet& wallet, const CWalletTx& wtx, int nM entry.pushKV("abandoned", wtx.isAbandoned()); if (fLong) WalletTxToJSON(wallet, wtx, entry); - ret.push_back(entry); + ret.push_back(std::move(entry)); } } } @@ -726,8 +726,8 @@ RPCHelpMan listsinceblock() CHECK_NONFATAL(wallet.chain().findAncestorByHeight(wallet.GetLastBlockHash(), wallet.GetLastBlockHeight() + 1 - target_confirms, FoundBlock().hash(lastblock))); UniValue ret(UniValue::VOBJ); - ret.pushKV("transactions", transactions); - if (include_removed) ret.pushKV("removed", removed); + ret.pushKV("transactions", std::move(transactions)); + if (include_removed) ret.pushKV("removed", std::move(removed)); ret.pushKV("lastblock", lastblock.GetHex()); return ret; @@ -851,14 +851,14 @@ RPCHelpMan gettransaction() UniValue details(UniValue::VARR); 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)); if (verbose) { UniValue decoded(UniValue::VOBJ); TxToUniv(*wtx.tx, /*block_hash=*/uint256(), /*entry=*/decoded, /*include_hex=*/false); - entry.pushKV("decoded", decoded); + entry.pushKV("decoded", std::move(decoded)); } AppendLastProcessedBlock(entry, *pwallet); diff --git a/src/wallet/rpc/util.cpp b/src/wallet/rpc/util.cpp index 1252843e9d..eb23c4555b 100644 --- a/src/wallet/rpc/util.cpp +++ b/src/wallet/rpc/util.cpp @@ -149,7 +149,7 @@ void PushParentDescriptors(const CWallet& wallet, const CScript& script_pubkey, for (const auto& desc: wallet.GetWalletDescriptors(script_pubkey)) { 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 wallet, DatabaseStatus& status, bilingual_str& error) @@ -185,7 +185,7 @@ void AppendLastProcessedBlock(UniValue& entry, const CWallet& wallet) EXCLUSIVE_ UniValue lastprocessedblock{UniValue::VOBJ}; lastprocessedblock.pushKV("hash", wallet.GetLastBlockHash().GetHex()); lastprocessedblock.pushKV("height", wallet.GetLastBlockHeight()); - entry.pushKV("lastprocessedblock", lastprocessedblock); + entry.pushKV("lastprocessedblock", std::move(lastprocessedblock)); } } // namespace wallet diff --git a/src/wallet/rpc/wallet.cpp b/src/wallet/rpc/wallet.cpp index f75a6464a1..15f80e7188 100644 --- a/src/wallet/rpc/wallet.cpp +++ b/src/wallet/rpc/wallet.cpp @@ -137,7 +137,7 @@ static RPCHelpMan getwalletinfo() UniValue scanning(UniValue::VOBJ); scanning.pushKV("duration", Ticks(pwallet->ScanningDuration())); scanning.pushKV("progress", pwallet->ScanningProgress()); - obj.pushKV("scanning", scanning); + obj.pushKV("scanning", std::move(scanning)); } else { obj.pushKV("scanning", false); } @@ -181,11 +181,11 @@ static RPCHelpMan listwalletdir() for (const auto& path : ListDatabases(GetWalletDir())) { UniValue wallet(UniValue::VOBJ); wallet.pushKV("name", path.utf8string()); - wallets.push_back(wallet); + wallets.push_back(std::move(wallet)); } UniValue result(UniValue::VOBJ); - result.pushKV("wallets", wallets); + result.pushKV("wallets", std::move(wallets)); return result; }, }; diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index ebe2db796e..a4d440c2e2 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -236,11 +236,11 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup) key.pushKV("scriptPubKey", HexStr(GetScriptForRawPubKey(futureKey.GetPubKey()))); key.pushKV("timestamp", newTip->GetBlockTimeMax() + TIMESTAMP_WINDOW + 1); key.pushKV("internal", UniValue(true)); - keys.push_back(key); + keys.push_back(std::move(key)); JSONRPCRequest request; request.context = &context; request.params.setArray(); - request.params.push_back(keys); + request.params.push_back(std::move(keys)); UniValue response = importmulti().HandleRequest(request); BOOST_CHECK_EQUAL(response.write(), diff --git a/src/zmq/zmqrpc.cpp b/src/zmq/zmqrpc.cpp index fcc2608262..84995d12d3 100644 --- a/src/zmq/zmqrpc.cpp +++ b/src/zmq/zmqrpc.cpp @@ -47,7 +47,7 @@ static RPCHelpMan getzmqnotifications() obj.pushKV("type", n->GetType()); obj.pushKV("address", n->GetAddress()); obj.pushKV("hwm", n->GetOutboundMessageHighWaterMark()); - result.push_back(obj); + result.push_back(std::move(obj)); } }