diff --git a/src/rest.cpp b/src/rest.cpp --- a/src/rest.cpp +++ b/src/rest.cpp @@ -638,16 +638,16 @@ UniValue utxos(UniValue::VARR); for (const CCoin &coin : outs) { UniValue utxo(UniValue::VOBJ); - utxo.push_back(Pair("height", int32_t(coin.nHeight))); - utxo.push_back(Pair("value", ValueFromAmount(coin.out.nValue))); + utxo.pushKV("height", int32_t(coin.nHeight)); + utxo.pushKV("value", ValueFromAmount(coin.out.nValue)); // include the script in a json output UniValue o(UniValue::VOBJ); ScriptPubKeyToJSON(config, coin.out.scriptPubKey, o, true); - utxo.push_back(Pair("scriptPubKey", o)); + utxo.pushKV("scriptPubKey", o); utxos.push_back(utxo); } - objGetUTXOResponse.push_back(Pair("utxos", utxos)); + objGetUTXOResponse.pushKV("utxos", utxos); // return json string std::string strJSON = objGetUTXOResponse.write() + "\n"; diff --git a/src/rpc/abc.cpp b/src/rpc/abc.cpp --- a/src/rpc/abc.cpp +++ b/src/rpc/abc.cpp @@ -26,7 +26,7 @@ } UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("excessiveBlockSize", config.GetMaxBlockSize())); + ret.pushKV("excessiveBlockSize", config.GetMaxBlockSize()); return ret; } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -69,25 +69,25 @@ UniValue blockheaderToJSON(const CBlockIndex *blockindex) { UniValue result(UniValue::VOBJ); - result.push_back(Pair("hash", blockindex->GetBlockHash().GetHex())); + result.pushKV("hash", blockindex->GetBlockHash().GetHex()); int confirmations = -1; // Only report confirmations if the block is on the main chain if (chainActive.Contains(blockindex)) { confirmations = chainActive.Height() - blockindex->nHeight + 1; } - result.push_back(Pair("confirmations", confirmations)); - result.push_back(Pair("height", blockindex->nHeight)); - result.push_back(Pair("version", blockindex->nVersion)); + result.pushKV("confirmations", confirmations); + result.pushKV("height", blockindex->nHeight); + result.pushKV("version", blockindex->nVersion); result.push_back( Pair("versionHex", strprintf("%08x", blockindex->nVersion))); - result.push_back(Pair("merkleroot", blockindex->hashMerkleRoot.GetHex())); - result.push_back(Pair("time", int64_t(blockindex->nTime))); + result.pushKV("merkleroot", blockindex->hashMerkleRoot.GetHex()); + result.pushKV("time", int64_t(blockindex->nTime)); result.push_back( Pair("mediantime", int64_t(blockindex->GetMedianTimePast()))); - result.push_back(Pair("nonce", uint64_t(blockindex->nNonce))); - result.push_back(Pair("bits", strprintf("%08x", blockindex->nBits))); - result.push_back(Pair("difficulty", GetDifficulty(blockindex))); - result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex())); + result.pushKV("nonce", uint64_t(blockindex->nNonce)); + result.pushKV("bits", strprintf("%08x", blockindex->nBits)); + result.pushKV("difficulty", GetDifficulty(blockindex)); + result.pushKV("chainwork", blockindex->nChainWork.GetHex()); if (blockindex->pprev) { result.push_back(Pair("previousblockhash", @@ -95,7 +95,7 @@ } CBlockIndex *pnext = chainActive.Next(blockindex); if (pnext) { - result.push_back(Pair("nextblockhash", pnext->GetBlockHash().GetHex())); + result.pushKV("nextblockhash", pnext->GetBlockHash().GetHex()); } return result; } @@ -103,19 +103,19 @@ UniValue blockToJSON(const Config &config, const CBlock &block, const CBlockIndex *blockindex, bool txDetails) { UniValue result(UniValue::VOBJ); - result.push_back(Pair("hash", blockindex->GetBlockHash().GetHex())); + result.pushKV("hash", blockindex->GetBlockHash().GetHex()); int confirmations = -1; // Only report confirmations if the block is on the main chain if (chainActive.Contains(blockindex)) { confirmations = chainActive.Height() - blockindex->nHeight + 1; } - result.push_back(Pair("confirmations", confirmations)); + result.pushKV("confirmations", confirmations); result.push_back(Pair( "size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION))); - result.push_back(Pair("height", blockindex->nHeight)); - result.push_back(Pair("version", block.nVersion)); - result.push_back(Pair("versionHex", strprintf("%08x", block.nVersion))); - result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex())); + result.pushKV("height", blockindex->nHeight); + result.pushKV("version", block.nVersion); + result.pushKV("versionHex", strprintf("%08x", block.nVersion)); + result.pushKV("merkleroot", block.hashMerkleRoot.GetHex()); UniValue txs(UniValue::VARR); for (const auto &tx : block.vtx) { if (txDetails) { @@ -126,14 +126,14 @@ txs.push_back(tx->GetId().GetHex()); } } - result.push_back(Pair("tx", txs)); - result.push_back(Pair("time", block.GetBlockTime())); + result.pushKV("tx", txs); + result.pushKV("time", block.GetBlockTime()); result.push_back( Pair("mediantime", int64_t(blockindex->GetMedianTimePast()))); - result.push_back(Pair("nonce", uint64_t(block.nNonce))); - result.push_back(Pair("bits", strprintf("%08x", block.nBits))); - result.push_back(Pair("difficulty", GetDifficulty(blockindex))); - result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex())); + result.pushKV("nonce", uint64_t(block.nNonce)); + result.pushKV("bits", strprintf("%08x", block.nBits)); + result.pushKV("difficulty", GetDifficulty(blockindex)); + result.pushKV("chainwork", blockindex->nChainWork.GetHex()); if (blockindex->pprev) { result.push_back(Pair("previousblockhash", @@ -141,7 +141,7 @@ } CBlockIndex *pnext = chainActive.Next(blockindex); if (pnext) { - result.push_back(Pair("nextblockhash", pnext->GetBlockHash().GetHex())); + result.pushKV("nextblockhash", pnext->GetBlockHash().GetHex()); } return result; } @@ -233,8 +233,8 @@ block = latestblock; } UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("hash", block.hash.GetHex())); - ret.push_back(Pair("height", block.height)); + ret.pushKV("hash", block.hash.GetHex()); + ret.pushKV("height", block.height); return ret; } @@ -289,8 +289,8 @@ } UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("hash", block.hash.GetHex())); - ret.push_back(Pair("height", block.height)); + ret.pushKV("hash", block.hash.GetHex()); + ret.pushKV("height", block.height); return ret; } @@ -342,8 +342,8 @@ block = latestblock; } UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("hash", block.hash.GetHex())); - ret.push_back(Pair("height", block.height)); + ret.pushKV("hash", block.hash.GetHex()); + ret.pushKV("height", block.height); return ret; } @@ -401,21 +401,21 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) { AssertLockHeld(mempool.cs); - info.push_back(Pair("size", (int)e.GetTxSize())); - info.push_back(Pair("fee", ValueFromAmount(e.GetFee()))); - info.push_back(Pair("modifiedfee", ValueFromAmount(e.GetModifiedFee()))); - info.push_back(Pair("time", e.GetTime())); - info.push_back(Pair("height", (int)e.GetHeight())); - info.push_back(Pair("startingpriority", e.GetPriority(e.GetHeight()))); + info.pushKV("size", (int)e.GetTxSize()); + info.pushKV("fee", ValueFromAmount(e.GetFee())); + info.pushKV("modifiedfee", ValueFromAmount(e.GetModifiedFee())); + info.pushKV("time", e.GetTime()); + info.pushKV("height", (int)e.GetHeight()); + info.pushKV("startingpriority", e.GetPriority(e.GetHeight())); info.push_back( Pair("currentpriority", e.GetPriority(chainActive.Height()))); - info.push_back(Pair("descendantcount", e.GetCountWithDescendants())); - info.push_back(Pair("descendantsize", e.GetSizeWithDescendants())); + info.pushKV("descendantcount", e.GetCountWithDescendants()); + info.pushKV("descendantsize", e.GetSizeWithDescendants()); info.push_back( Pair("descendantfees", e.GetModFeesWithDescendants() / SATOSHI)); - info.push_back(Pair("ancestorcount", e.GetCountWithAncestors())); - info.push_back(Pair("ancestorsize", e.GetSizeWithAncestors())); - info.push_back(Pair("ancestorfees", e.GetModFeesWithAncestors() / SATOSHI)); + info.pushKV("ancestorcount", e.GetCountWithAncestors()); + info.pushKV("ancestorsize", e.GetSizeWithAncestors()); + info.pushKV("ancestorfees", e.GetModFeesWithAncestors() / SATOSHI); const CTransaction &tx = e.GetTx(); std::set setDepends; for (const CTxIn &txin : tx.vin) { @@ -429,7 +429,7 @@ depends.push_back(dep); } - info.push_back(Pair("depends", depends)); + info.pushKV("depends", depends); } UniValue mempoolToJSON(bool fVerbose = false) { @@ -440,7 +440,7 @@ const uint256 &txid = e.GetTx().GetId(); UniValue info(UniValue::VOBJ); entryToJSON(info, e); - o.push_back(Pair(txid.ToString(), info)); + o.pushKV(txid.ToString(), info); } return o; } else { @@ -551,7 +551,7 @@ const uint256 &_hash = e.GetTx().GetId(); UniValue info(UniValue::VOBJ); entryToJSON(info, e); - o.push_back(Pair(_hash.ToString(), info)); + o.pushKV(_hash.ToString(), info); } return o; } @@ -617,7 +617,7 @@ const uint256 &_hash = e.GetTx().GetId(); UniValue info(UniValue::VOBJ); entryToJSON(info, e); - o.push_back(Pair(_hash.ToString(), info)); + o.pushKV(_hash.ToString(), info); } return o; } @@ -1033,13 +1033,13 @@ CCoinsStats stats; FlushStateToDisk(); if (GetUTXOStats(pcoinsdbview.get(), stats)) { - ret.push_back(Pair("height", int64_t(stats.nHeight))); - ret.push_back(Pair("bestblock", stats.hashBlock.GetHex())); - ret.push_back(Pair("transactions", int64_t(stats.nTransactions))); - ret.push_back(Pair("txouts", int64_t(stats.nTransactionOutputs))); - ret.push_back(Pair("bogosize", int64_t(stats.nBogoSize))); - ret.push_back(Pair("hash_serialized", stats.hashSerialized.GetHex())); - ret.push_back(Pair("disk_size", stats.nDiskSize)); + ret.pushKV("height", int64_t(stats.nHeight)); + ret.pushKV("bestblock", stats.hashBlock.GetHex()); + ret.pushKV("transactions", int64_t(stats.nTransactions)); + ret.pushKV("txouts", int64_t(stats.nTransactionOutputs)); + ret.pushKV("bogosize", int64_t(stats.nBogoSize)); + ret.pushKV("hash_serialized", stats.hashSerialized.GetHex()); + ret.pushKV("disk_size", stats.nDiskSize); ret.push_back( Pair("total_amount", ValueFromAmount(stats.nTotalAmount))); } else { @@ -1122,18 +1122,18 @@ BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock()); CBlockIndex *pindex = it->second; - ret.push_back(Pair("bestblock", pindex->GetBlockHash().GetHex())); + ret.pushKV("bestblock", pindex->GetBlockHash().GetHex()); if (coin.GetHeight() == MEMPOOL_HEIGHT) { - ret.push_back(Pair("confirmations", 0)); + ret.pushKV("confirmations", 0); } else { ret.push_back(Pair("confirmations", int64_t(pindex->nHeight - coin.GetHeight() + 1))); } - ret.push_back(Pair("value", ValueFromAmount(coin.GetTxOut().nValue))); + ret.pushKV("value", ValueFromAmount(coin.GetTxOut().nValue)); UniValue o(UniValue::VOBJ); ScriptPubKeyToJSON(config, coin.GetTxOut().scriptPubKey, o, true); - ret.push_back(Pair("scriptPubKey", o)); - ret.push_back(Pair("coinbase", coin.IsCoinBase())); + ret.pushKV("scriptPubKey", o); + ret.pushKV("coinbase", coin.IsCoinBase()); return ret; } @@ -1191,7 +1191,7 @@ activated = pindex->nHeight >= consensusParams.CSVHeight; break; } - rv.push_back(Pair("status", activated)); + rv.pushKV("status", activated); return rv; } @@ -1199,8 +1199,8 @@ CBlockIndex *pindex, const Consensus::Params &consensusParams) { UniValue rv(UniValue::VOBJ); - rv.push_back(Pair("id", name)); - rv.push_back(Pair("version", version)); + rv.pushKV("id", name); + rv.pushKV("version", version); rv.push_back( Pair("reject", SoftForkMajorityDesc(version, pindex, consensusParams))); return rv; @@ -1255,21 +1255,21 @@ LOCK(cs_main); UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("chain", config.GetChainParams().NetworkIDString())); - obj.push_back(Pair("blocks", int(chainActive.Height()))); + obj.pushKV("chain", config.GetChainParams().NetworkIDString()); + obj.pushKV("blocks", int(chainActive.Height())); obj.push_back( Pair("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1)); obj.push_back( Pair("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex())); - obj.push_back(Pair("difficulty", double(GetDifficulty(chainActive.Tip())))); + obj.pushKV("difficulty", double(GetDifficulty(chainActive.Tip()))); obj.push_back( Pair("mediantime", int64_t(chainActive.Tip()->GetMedianTimePast()))); obj.push_back( Pair("verificationprogress", GuessVerificationProgress(config.GetChainParams().TxData(), chainActive.Tip()))); - obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex())); - obj.push_back(Pair("pruned", fPruneMode)); + obj.pushKV("chainwork", chainActive.Tip()->nChainWork.GetHex()); + obj.pushKV("pruned", fPruneMode); const Consensus::Params &consensusParams = config.GetChainParams().GetConsensus(); @@ -1279,7 +1279,7 @@ softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams)); softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams)); softforks.push_back(SoftForkDesc("csv", 5, tip, consensusParams)); - obj.push_back(Pair("softforks", softforks)); + obj.pushKV("softforks", softforks); if (fPruneMode) { CBlockIndex *block = chainActive.Tip(); @@ -1287,7 +1287,7 @@ block = block->pprev; } - obj.push_back(Pair("pruneheight", block->nHeight)); + obj.pushKV("pruneheight", block->nHeight); } return obj; } @@ -1382,12 +1382,12 @@ UniValue res(UniValue::VARR); for (const CBlockIndex *block : setTips) { UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("height", block->nHeight)); - obj.push_back(Pair("hash", block->phashBlock->GetHex())); + obj.pushKV("height", block->nHeight); + obj.pushKV("hash", block->phashBlock->GetHex()); const int branchLen = block->nHeight - chainActive.FindFork(block)->nHeight; - obj.push_back(Pair("branchlen", branchLen)); + obj.pushKV("branchlen", branchLen); std::string status; if (chainActive.Contains(block)) { @@ -1413,7 +1413,7 @@ // No clue. status = "unknown"; } - obj.push_back(Pair("status", status)); + obj.pushKV("status", status); res.push_back(obj); } @@ -1423,12 +1423,12 @@ UniValue mempoolInfoToJSON() { UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("size", (int64_t)mempool.size())); - ret.push_back(Pair("bytes", (int64_t)mempool.GetTotalTxSize())); - ret.push_back(Pair("usage", (int64_t)mempool.DynamicMemoryUsage())); + ret.pushKV("size", (int64_t)mempool.size()); + ret.pushKV("bytes", (int64_t)mempool.GetTotalTxSize()); + ret.pushKV("usage", (int64_t)mempool.DynamicMemoryUsage()); size_t maxmempool = gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; - ret.push_back(Pair("maxmempool", (int64_t)maxmempool)); + ret.pushKV("maxmempool", (int64_t)maxmempool); ret.push_back( Pair("mempoolminfee", ValueFromAmount(mempool.GetMinFee(maxmempool).GetFeePerK()))); @@ -1743,14 +1743,14 @@ int nTxDiff = pindex->nChainTx - pindexPast->nChainTx; UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("time", int64_t(pindex->nTime))); - ret.push_back(Pair("txcount", int64_t(pindex->nChainTx))); - ret.push_back(Pair("window_block_count", blockcount)); + ret.pushKV("time", int64_t(pindex->nTime)); + ret.pushKV("txcount", int64_t(pindex->nChainTx)); + ret.pushKV("window_block_count", blockcount); if (blockcount > 0) { - ret.push_back(Pair("window_tx_count", nTxDiff)); - ret.push_back(Pair("window_interval", nTimeDiff)); + ret.pushKV("window_tx_count", nTxDiff); + ret.pushKV("window_interval", nTimeDiff); if (nTimeDiff > 0) { - ret.push_back(Pair("txrate", double(nTxDiff) / nTimeDiff)); + ret.pushKV("txrate", double(nTxDiff) / nTimeDiff); } } diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -248,18 +248,18 @@ LOCK(cs_main); UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("blocks", int(chainActive.Height()))); - obj.push_back(Pair("currentblocksize", uint64_t(nLastBlockSize))); - obj.push_back(Pair("currentblocktx", uint64_t(nLastBlockTx))); - obj.push_back(Pair("difficulty", double(GetDifficulty(chainActive.Tip())))); + obj.pushKV("blocks", int(chainActive.Height())); + obj.pushKV("currentblocksize", uint64_t(nLastBlockSize)); + obj.pushKV("currentblocktx", uint64_t(nLastBlockTx)); + obj.pushKV("difficulty", double(GetDifficulty(chainActive.Tip()))); obj.push_back( Pair("blockprioritypercentage", uint8_t(gArgs.GetArg("-blockprioritypercentage", DEFAULT_BLOCK_PRIORITY_PERCENTAGE)))); - obj.push_back(Pair("errors", GetWarnings("statusbar"))); - obj.push_back(Pair("networkhashps", getnetworkhashps(config, request))); - obj.push_back(Pair("pooledtx", uint64_t(mempool.size()))); - obj.push_back(Pair("chain", config.GetChainParams().NetworkIDString())); + obj.pushKV("errors", GetWarnings("statusbar")); + obj.pushKV("networkhashps", getnetworkhashps(config, request)); + obj.pushKV("pooledtx", uint64_t(mempool.size())); + obj.pushKV("chain", config.GetChainParams().NetworkIDString()); return obj; } @@ -619,9 +619,9 @@ UniValue entry(UniValue::VOBJ); - entry.push_back(Pair("data", EncodeHexTx(tx))); - entry.push_back(Pair("txid", txId.GetHex())); - entry.push_back(Pair("hash", tx.GetHash().GetHex())); + entry.pushKV("data", EncodeHexTx(tx)); + entry.pushKV("txid", txId.GetHex()); + entry.pushKV("hash", tx.GetHash().GetHex()); UniValue deps(UniValue::VARR); for (const CTxIn &in : tx.vin) { @@ -629,13 +629,13 @@ deps.push_back(setTxIndex[in.prevout.GetTxId()]); } } - entry.push_back(Pair("depends", deps)); + entry.pushKV("depends", deps); int index_in_template = i - 1; entry.push_back( Pair("fee", pblocktemplate->vTxFees[index_in_template] / SATOSHI)); int64_t nTxSigOps = pblocktemplate->vTxSigOpsCount[index_in_template]; - entry.push_back(Pair("sigops", nTxSigOps)); + entry.pushKV("sigops", nTxSigOps); transactions.push_back(entry); } @@ -652,30 +652,30 @@ aMutable.push_back("prevblock"); UniValue result(UniValue::VOBJ); - result.push_back(Pair("capabilities", aCaps)); + result.pushKV("capabilities", aCaps); - result.push_back(Pair("version", pblock->nVersion)); + result.pushKV("version", pblock->nVersion); - result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex())); - result.push_back(Pair("transactions", transactions)); - result.push_back(Pair("coinbaseaux", aux)); + result.pushKV("previousblockhash", pblock->hashPrevBlock.GetHex()); + result.pushKV("transactions", transactions); + result.pushKV("coinbaseaux", aux); result.push_back(Pair("coinbasevalue", int64_t(pblock->vtx[0]->vout[0].nValue / SATOSHI))); result.push_back(Pair("longpollid", chainActive.Tip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast))); - result.push_back(Pair("target", hashTarget.GetHex())); + result.pushKV("target", hashTarget.GetHex()); result.push_back( Pair("mintime", int64_t(pindexPrev->GetMedianTimePast()) + 1)); - result.push_back(Pair("mutable", aMutable)); - result.push_back(Pair("noncerange", "00000000ffffffff")); + result.pushKV("mutable", aMutable); + result.pushKV("noncerange", "00000000ffffffff"); // FIXME: Allow for mining block greater than 1M. result.push_back( Pair("sigoplimit", GetMaxBlockSigOpsCount(DEFAULT_MAX_BLOCK_SIZE))); - result.push_back(Pair("sizelimit", DEFAULT_MAX_BLOCK_SIZE)); - result.push_back(Pair("curtime", pblock->GetBlockTime())); - result.push_back(Pair("bits", strprintf("%08x", pblock->nBits))); - result.push_back(Pair("height", int64_t(pindexPrev->nHeight) + 1)); + result.pushKV("sizelimit", DEFAULT_MAX_BLOCK_SIZE); + result.pushKV("curtime", pblock->GetBlockTime()); + result.pushKV("bits", strprintf("%08x", pblock->nBits)); + result.pushKV("height", int64_t(pindexPrev->nHeight) + 1); return result; } diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -98,16 +98,16 @@ GetProxy(NET_IPV4, proxy); UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("version", CLIENT_VERSION)); - obj.push_back(Pair("protocolversion", PROTOCOL_VERSION)); + obj.pushKV("version", CLIENT_VERSION); + obj.pushKV("protocolversion", PROTOCOL_VERSION); #ifdef ENABLE_WALLET if (pwallet) { - obj.push_back(Pair("walletversion", pwallet->GetVersion())); - obj.push_back(Pair("balance", ValueFromAmount(pwallet->GetBalance()))); + obj.pushKV("walletversion", pwallet->GetVersion()); + obj.pushKV("balance", ValueFromAmount(pwallet->GetBalance())); } #endif - obj.push_back(Pair("blocks", (int)chainActive.Height())); - obj.push_back(Pair("timeoffset", GetTimeOffset())); + obj.pushKV("blocks", (int)chainActive.Height()); + obj.pushKV("timeoffset", GetTimeOffset()); if (g_connman) { obj.push_back( Pair("connections", @@ -115,23 +115,23 @@ } obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : std::string()))); - obj.push_back(Pair("difficulty", double(GetDifficulty(chainActive.Tip())))); + obj.pushKV("difficulty", double(GetDifficulty(chainActive.Tip()))); obj.push_back(Pair("testnet", config.GetChainParams().NetworkIDString() == CBaseChainParams::TESTNET)); #ifdef ENABLE_WALLET if (pwallet) { - obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime())); - obj.push_back(Pair("keypoolsize", (int)pwallet->GetKeyPoolSize())); + obj.pushKV("keypoololdest", pwallet->GetOldestKeyPoolTime()); + obj.pushKV("keypoolsize", (int)pwallet->GetKeyPoolSize()); } if (pwallet && pwallet->IsCrypted()) { - obj.push_back(Pair("unlocked_until", pwallet->nRelockTime)); + obj.pushKV("unlocked_until", pwallet->nRelockTime); } - obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); + obj.pushKV("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())); #endif obj.push_back(Pair("relayfee", ValueFromAmount(config.GetMinFeePerKB().GetFeePerK()))); - obj.push_back(Pair("errors", GetWarnings("statusbar"))); + obj.pushKV("errors", GetWarnings("statusbar")); return obj; } @@ -149,10 +149,10 @@ UniValue operator()(const CKeyID &keyID) const { UniValue obj(UniValue::VOBJ); CPubKey vchPubKey; - obj.push_back(Pair("isscript", false)); + obj.pushKV("isscript", false); if (pwallet && pwallet->GetPubKey(keyID, vchPubKey)) { - obj.push_back(Pair("pubkey", HexStr(vchPubKey))); - obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed())); + obj.pushKV("pubkey", HexStr(vchPubKey)); + obj.pushKV("iscompressed", vchPubKey.IsCompressed()); } return obj; } @@ -160,22 +160,22 @@ UniValue operator()(const CScriptID &scriptID) const { UniValue obj(UniValue::VOBJ); CScript subscript; - obj.push_back(Pair("isscript", true)); + obj.pushKV("isscript", true); if (pwallet && pwallet->GetCScript(scriptID, subscript)) { std::vector addresses; txnouttype whichType; int nRequired; ExtractDestinations(subscript, whichType, addresses, nRequired); - obj.push_back(Pair("script", GetTxnOutputType(whichType))); + obj.pushKV("script", GetTxnOutputType(whichType)); obj.push_back( Pair("hex", HexStr(subscript.begin(), subscript.end()))); UniValue a(UniValue::VARR); for (const CTxDestination &addr : addresses) { a.push_back(EncodeDestination(addr)); } - obj.push_back(Pair("addresses", a)); + obj.pushKV("addresses", a); if (whichType == TX_MULTISIG) { - obj.push_back(Pair("sigsrequired", nRequired)); + obj.pushKV("sigsrequired", nRequired); } } return obj; @@ -240,10 +240,10 @@ bool isValid = IsValidDestination(dest); UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("isvalid", isValid)); + ret.pushKV("isvalid", isValid); if (isValid) { std::string currentAddress = EncodeDestination(dest); - ret.push_back(Pair("address", currentAddress)); + ret.pushKV("address", currentAddress); CScript scriptPubKey = GetScriptForDestination(dest); ret.push_back(Pair("scriptPubKey", @@ -251,14 +251,14 @@ #ifdef ENABLE_WALLET isminetype mine = pwallet ? IsMine(*pwallet, dest) : ISMINE_NO; - ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); + ret.pushKV("ismine", (mine & ISMINE_SPENDABLE) ? true : false); ret.push_back( Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true : false)); UniValue detail = boost::apply_visitor(DescribeAddressVisitor(pwallet), dest); ret.pushKVs(detail); if (pwallet && pwallet->mapAddressBook.count(dest)) { - ret.push_back(Pair("account", pwallet->mapAddressBook[dest].name)); + ret.pushKV("account", pwallet->mapAddressBook[dest].name); } if (pwallet) { const auto &meta = pwallet->mapKeyMetadata; @@ -268,9 +268,9 @@ it = meta.find(CScriptID(scriptPubKey)); } if (it != meta.end()) { - ret.push_back(Pair("timestamp", it->second.nCreateTime)); + ret.pushKV("timestamp", it->second.nCreateTime); if (!it->second.hdKeypath.empty()) { - ret.push_back(Pair("hdkeypath", it->second.hdKeypath)); + ret.pushKV("hdkeypath", it->second.hdKeypath); ret.push_back(Pair("hdmasterkeyid", it->second.hdMasterKeyID.GetHex())); } @@ -412,8 +412,8 @@ CScriptID innerID(inner); UniValue result(UniValue::VOBJ); - result.push_back(Pair("address", EncodeDestination(innerID))); - result.push_back(Pair("redeemScript", HexStr(inner.begin(), inner.end()))); + result.pushKV("address", EncodeDestination(innerID)); + result.pushKV("redeemScript", HexStr(inner.begin(), inner.end())); return result; } @@ -572,12 +572,12 @@ static UniValue RPCLockedMemoryInfo() { LockedPool::Stats stats = LockedPoolManager::Instance().stats(); UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("used", uint64_t(stats.used))); - obj.push_back(Pair("free", uint64_t(stats.free))); - obj.push_back(Pair("total", uint64_t(stats.total))); - obj.push_back(Pair("locked", uint64_t(stats.locked))); - obj.push_back(Pair("chunks_used", uint64_t(stats.chunks_used))); - obj.push_back(Pair("chunks_free", uint64_t(stats.chunks_free))); + obj.pushKV("used", uint64_t(stats.used)); + obj.pushKV("free", uint64_t(stats.free)); + obj.pushKV("total", uint64_t(stats.total)); + obj.pushKV("locked", uint64_t(stats.locked)); + obj.pushKV("chunks_used", uint64_t(stats.chunks_used)); + obj.pushKV("chunks_free", uint64_t(stats.chunks_free)); return obj; } @@ -644,7 +644,7 @@ : request.params[0].get_str(); if (mode == "stats") { UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("locked", RPCLockedMemoryInfo())); + obj.pushKV("locked", RPCLockedMemoryInfo()); return obj; } else if (mode == "mallocinfo") { #ifdef HAVE_MALLOC_INFO diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -163,66 +163,66 @@ UniValue obj(UniValue::VOBJ); CNodeStateStats statestats; bool fStateStats = GetNodeStateStats(stats.nodeid, statestats); - obj.push_back(Pair("id", stats.nodeid)); - obj.push_back(Pair("addr", stats.addrName)); + obj.pushKV("id", stats.nodeid); + obj.pushKV("addr", stats.addrName); if (!(stats.addrLocal.empty())) { - obj.push_back(Pair("addrlocal", stats.addrLocal)); + obj.pushKV("addrlocal", stats.addrLocal); } if (stats.addrBind.IsValid()) { - obj.push_back(Pair("addrbind", stats.addrBind.ToString())); + obj.pushKV("addrbind", stats.addrBind.ToString()); } - obj.push_back(Pair("services", strprintf("%016x", stats.nServices))); - obj.push_back(Pair("relaytxes", stats.fRelayTxes)); - obj.push_back(Pair("lastsend", stats.nLastSend)); - obj.push_back(Pair("lastrecv", stats.nLastRecv)); - obj.push_back(Pair("bytessent", stats.nSendBytes)); - obj.push_back(Pair("bytesrecv", stats.nRecvBytes)); - obj.push_back(Pair("conntime", stats.nTimeConnected)); - obj.push_back(Pair("timeoffset", stats.nTimeOffset)); + obj.pushKV("services", strprintf("%016x", stats.nServices)); + obj.pushKV("relaytxes", stats.fRelayTxes); + obj.pushKV("lastsend", stats.nLastSend); + obj.pushKV("lastrecv", stats.nLastRecv); + obj.pushKV("bytessent", stats.nSendBytes); + obj.pushKV("bytesrecv", stats.nRecvBytes); + obj.pushKV("conntime", stats.nTimeConnected); + obj.pushKV("timeoffset", stats.nTimeOffset); if (stats.dPingTime > 0.0) { - obj.push_back(Pair("pingtime", stats.dPingTime)); + obj.pushKV("pingtime", stats.dPingTime); } if (stats.dMinPing < std::numeric_limits::max() / 1e6) { - obj.push_back(Pair("minping", stats.dMinPing)); + obj.pushKV("minping", stats.dMinPing); } if (stats.dPingWait > 0.0) { - obj.push_back(Pair("pingwait", stats.dPingWait)); + obj.pushKV("pingwait", stats.dPingWait); } - obj.push_back(Pair("version", stats.nVersion)); + obj.pushKV("version", stats.nVersion); // Use the sanitized form of subver here, to avoid tricksy remote peers // from corrupting or modifying the JSON output by putting special // characters in their ver message. - obj.push_back(Pair("subver", stats.cleanSubVer)); - obj.push_back(Pair("inbound", stats.fInbound)); - obj.push_back(Pair("addnode", stats.m_manual_connection)); - obj.push_back(Pair("startingheight", stats.nStartingHeight)); + obj.pushKV("subver", stats.cleanSubVer); + obj.pushKV("inbound", stats.fInbound); + obj.pushKV("addnode", stats.m_manual_connection); + obj.pushKV("startingheight", stats.nStartingHeight); if (fStateStats) { - obj.push_back(Pair("banscore", statestats.nMisbehavior)); - obj.push_back(Pair("synced_headers", statestats.nSyncHeight)); - obj.push_back(Pair("synced_blocks", statestats.nCommonHeight)); + obj.pushKV("banscore", statestats.nMisbehavior); + obj.pushKV("synced_headers", statestats.nSyncHeight); + obj.pushKV("synced_blocks", statestats.nCommonHeight); UniValue heights(UniValue::VARR); for (int height : statestats.vHeightInFlight) { heights.push_back(height); } - obj.push_back(Pair("inflight", heights)); + obj.pushKV("inflight", heights); } - obj.push_back(Pair("whitelisted", stats.fWhitelisted)); + obj.pushKV("whitelisted", stats.fWhitelisted); UniValue sendPerMsgCmd(UniValue::VOBJ); for (const mapMsgCmdSize::value_type &i : stats.mapSendBytesPerMsgCmd) { if (i.second > 0) { - sendPerMsgCmd.push_back(Pair(i.first, i.second)); + sendPerMsgCmd.pushKV(i.first, i.second); } } - obj.push_back(Pair("bytessent_per_msg", sendPerMsgCmd)); + obj.pushKV("bytessent_per_msg", sendPerMsgCmd); UniValue recvPerMsgCmd(UniValue::VOBJ); for (const mapMsgCmdSize::value_type &i : stats.mapRecvBytesPerMsgCmd) { if (i.second > 0) { - recvPerMsgCmd.push_back(Pair(i.first, i.second)); + recvPerMsgCmd.pushKV(i.first, i.second); } } - obj.push_back(Pair("bytesrecv_per_msg", recvPerMsgCmd)); + obj.pushKV("bytesrecv_per_msg", recvPerMsgCmd); ret.push_back(obj); } @@ -403,17 +403,17 @@ for (const AddedNodeInfo &info : vInfo) { UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("addednode", info.strAddedNode)); - obj.push_back(Pair("connected", info.fConnected)); + obj.pushKV("addednode", info.strAddedNode); + obj.pushKV("connected", info.fConnected); UniValue addresses(UniValue::VARR); if (info.fConnected) { UniValue address(UniValue::VOBJ); - address.push_back(Pair("address", info.resolvedAddress.ToString())); + address.pushKV("address", info.resolvedAddress.ToString()); address.push_back( Pair("connected", info.fInbound ? "inbound" : "outbound")); addresses.push_back(address); } - obj.push_back(Pair("addresses", addresses)); + obj.pushKV("addresses", addresses); ret.push_back(obj); } @@ -462,14 +462,14 @@ } UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("totalbytesrecv", g_connman->GetTotalBytesRecv())); - obj.push_back(Pair("totalbytessent", g_connman->GetTotalBytesSent())); - obj.push_back(Pair("timemillis", GetTimeMillis())); + obj.pushKV("totalbytesrecv", g_connman->GetTotalBytesRecv()); + obj.pushKV("totalbytessent", g_connman->GetTotalBytesSent()); + obj.pushKV("timemillis", GetTimeMillis()); UniValue outboundLimit(UniValue::VOBJ); outboundLimit.push_back( Pair("timeframe", g_connman->GetMaxOutboundTimeframe())); - outboundLimit.push_back(Pair("target", g_connman->GetMaxOutboundTarget())); + outboundLimit.pushKV("target", g_connman->GetMaxOutboundTarget()); outboundLimit.push_back( Pair("target_reached", g_connman->OutboundTargetReached(false))); outboundLimit.push_back(Pair("serve_historical_blocks", @@ -478,7 +478,7 @@ Pair("bytes_left_in_cycle", g_connman->GetOutboundTargetBytesLeft())); outboundLimit.push_back( Pair("time_left_in_cycle", g_connman->GetMaxOutboundTimeLeftInCycle())); - obj.push_back(Pair("uploadtarget", outboundLimit)); + obj.pushKV("uploadtarget", outboundLimit); return obj; } @@ -492,9 +492,9 @@ proxyType proxy; UniValue obj(UniValue::VOBJ); GetProxy(network, proxy); - obj.push_back(Pair("name", GetNetworkName(network))); - obj.push_back(Pair("limited", IsLimited(network))); - obj.push_back(Pair("reachable", IsReachable(network))); + obj.pushKV("name", GetNetworkName(network)); + obj.pushKV("limited", IsLimited(network)); + obj.pushKV("reachable", IsReachable(network)); obj.push_back(Pair("proxy", proxy.IsValid() ? proxy.proxy.ToStringIPPort() : std::string())); @@ -575,21 +575,21 @@ LOCK(cs_main); UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("version", CLIENT_VERSION)); - obj.push_back(Pair("subversion", userAgent(config))); - obj.push_back(Pair("protocolversion", PROTOCOL_VERSION)); + obj.pushKV("version", CLIENT_VERSION); + obj.pushKV("subversion", userAgent(config)); + obj.pushKV("protocolversion", PROTOCOL_VERSION); if (g_connman) { obj.push_back(Pair("localservices", strprintf("%016x", g_connman->GetLocalServices()))); } - obj.push_back(Pair("localrelay", fRelayTxes)); - obj.push_back(Pair("timeoffset", GetTimeOffset())); + obj.pushKV("localrelay", fRelayTxes); + obj.pushKV("timeoffset", GetTimeOffset()); if (g_connman) { - obj.push_back(Pair("networkactive", g_connman->GetNetworkActive())); + obj.pushKV("networkactive", g_connman->GetNetworkActive()); obj.push_back(Pair("connections", int(g_connman->GetNodeCount( CConnman::CONNECTIONS_ALL)))); } - obj.push_back(Pair("networks", GetNetworksInfo())); + obj.pushKV("networks", GetNetworksInfo()); obj.push_back(Pair("relayfee", ValueFromAmount(config.GetMinFeePerKB().GetFeePerK()))); obj.push_back(Pair("excessutxocharge", @@ -599,14 +599,14 @@ LOCK(cs_mapLocalHost); for (const std::pair &item : mapLocalHost) { UniValue rec(UniValue::VOBJ); - rec.push_back(Pair("address", item.first.ToString())); - rec.push_back(Pair("port", item.second.nPort)); - rec.push_back(Pair("score", item.second.nScore)); + rec.pushKV("address", item.first.ToString()); + rec.pushKV("port", item.second.nPort); + rec.pushKV("score", item.second.nScore); localAddresses.push_back(rec); } } - obj.push_back(Pair("localaddresses", localAddresses)); - obj.push_back(Pair("warnings", GetWarnings("statusbar"))); + obj.pushKV("localaddresses", localAddresses); + obj.pushKV("warnings", GetWarnings("statusbar")); return obj; } @@ -722,10 +722,10 @@ for (banmap_t::iterator it = banMap.begin(); it != banMap.end(); it++) { CBanEntry banEntry = (*it).second; UniValue rec(UniValue::VOBJ); - rec.push_back(Pair("address", (*it).first.ToString())); - rec.push_back(Pair("banned_until", banEntry.nBanUntil)); - rec.push_back(Pair("ban_created", banEntry.nCreateTime)); - rec.push_back(Pair("ban_reason", banEntry.banReasonToString())); + rec.pushKV("address", (*it).first.ToString()); + rec.pushKV("banned_until", banEntry.nBanUntil); + rec.pushKV("ban_created", banEntry.nCreateTime); + rec.pushKV("ban_reason", banEntry.banReasonToString()); bannedAddresses.push_back(rec); } diff --git a/src/rpc/protocol.cpp b/src/rpc/protocol.cpp --- a/src/rpc/protocol.cpp +++ b/src/rpc/protocol.cpp @@ -27,9 +27,9 @@ UniValue JSONRPCRequestObj(const std::string &strMethod, const UniValue ¶ms, const UniValue &id) { UniValue request(UniValue::VOBJ); - request.push_back(Pair("method", strMethod)); - request.push_back(Pair("params", params)); - request.push_back(Pair("id", id)); + request.pushKV("method", strMethod); + request.pushKV("params", params); + request.pushKV("id", id); return request; } @@ -37,12 +37,12 @@ const UniValue &id) { UniValue reply(UniValue::VOBJ); if (!error.isNull()) { - reply.push_back(Pair("result", NullUniValue)); + reply.pushKV("result", NullUniValue); } else { - reply.push_back(Pair("result", result)); + reply.pushKV("result", result); } - reply.push_back(Pair("error", error)); - reply.push_back(Pair("id", id)); + reply.pushKV("error", error); + reply.pushKV("id", id); return reply; } @@ -54,8 +54,8 @@ UniValue JSONRPCError(int code, const std::string &message) { UniValue error(UniValue::VOBJ); - error.push_back(Pair("code", code)); - error.push_back(Pair("message", message)); + error.pushKV("code", code); + error.pushKV("message", message); return error; } diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -42,36 +42,36 @@ std::vector addresses; int nRequired; - out.push_back(Pair("asm", ScriptToAsmStr(scriptPubKey))); + out.pushKV("asm", ScriptToAsmStr(scriptPubKey)); if (fIncludeHex) { out.push_back( Pair("hex", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); } if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired)) { - out.push_back(Pair("type", GetTxnOutputType(type))); + out.pushKV("type", GetTxnOutputType(type)); return; } - out.push_back(Pair("reqSigs", nRequired)); - out.push_back(Pair("type", GetTxnOutputType(type))); + out.pushKV("reqSigs", nRequired); + out.pushKV("type", GetTxnOutputType(type)); UniValue a(UniValue::VARR); for (const CTxDestination &addr : addresses) { a.push_back(EncodeDestination(addr)); } - out.push_back(Pair("addresses", a)); + out.pushKV("addresses", a); } void TxToJSON(const Config &config, const CTransaction &tx, const uint256 hashBlock, UniValue &entry) { - entry.push_back(Pair("txid", tx.GetId().GetHex())); - entry.push_back(Pair("hash", tx.GetHash().GetHex())); + entry.pushKV("txid", tx.GetId().GetHex()); + entry.pushKV("hash", tx.GetHash().GetHex()); entry.push_back(Pair( "size", int(::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION)))); - entry.push_back(Pair("version", tx.nVersion)); - entry.push_back(Pair("locktime", int64_t(tx.nLockTime))); + entry.pushKV("version", tx.nVersion); + entry.pushKV("locktime", int64_t(tx.nLockTime)); UniValue vin(UniValue::VARR); for (unsigned int i = 0; i < tx.vin.size(); i++) { @@ -81,36 +81,36 @@ in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); } else { - in.push_back(Pair("txid", txin.prevout.GetTxId().GetHex())); - in.push_back(Pair("vout", int64_t(txin.prevout.GetN()))); + in.pushKV("txid", txin.prevout.GetTxId().GetHex()); + in.pushKV("vout", int64_t(txin.prevout.GetN())); UniValue o(UniValue::VOBJ); - o.push_back(Pair("asm", ScriptToAsmStr(txin.scriptSig, true))); + o.pushKV("asm", ScriptToAsmStr(txin.scriptSig, true)); o.push_back(Pair( "hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); - in.push_back(Pair("scriptSig", o)); + in.pushKV("scriptSig", o); } - in.push_back(Pair("sequence", int64_t(txin.nSequence))); + in.pushKV("sequence", int64_t(txin.nSequence)); vin.push_back(in); } - entry.push_back(Pair("vin", vin)); + entry.pushKV("vin", vin); UniValue vout(UniValue::VARR); for (unsigned int i = 0; i < tx.vout.size(); i++) { const CTxOut &txout = tx.vout[i]; UniValue out(UniValue::VOBJ); - out.push_back(Pair("value", ValueFromAmount(txout.nValue))); - out.push_back(Pair("n", int64_t(i))); + out.pushKV("value", ValueFromAmount(txout.nValue)); + out.pushKV("n", int64_t(i)); UniValue o(UniValue::VOBJ); ScriptPubKeyToJSON(config, txout.scriptPubKey, o, true); - out.push_back(Pair("scriptPubKey", o)); + out.pushKV("scriptPubKey", o); vout.push_back(out); } - entry.push_back(Pair("vout", vout)); + entry.pushKV("vout", vout); if (!hashBlock.IsNull()) { - entry.push_back(Pair("blockhash", hashBlock.GetHex())); + entry.pushKV("blockhash", hashBlock.GetHex()); BlockMap::iterator mi = mapBlockIndex.find(hashBlock); if (mi != mapBlockIndex.end() && (*mi).second) { CBlockIndex *pindex = (*mi).second; @@ -118,10 +118,10 @@ entry.push_back( Pair("confirmations", 1 + chainActive.Height() - pindex->nHeight)); - entry.push_back(Pair("time", pindex->GetBlockTime())); - entry.push_back(Pair("blocktime", pindex->GetBlockTime())); + entry.pushKV("time", pindex->GetBlockTime()); + entry.pushKV("blocktime", pindex->GetBlockTime()); } else { - entry.push_back(Pair("confirmations", 0)); + entry.pushKV("confirmations", 0); } } } @@ -253,7 +253,7 @@ } UniValue result(UniValue::VOBJ); - result.push_back(Pair("hex", strHex)); + result.pushKV("hex", strHex); TxToJSON(config, *tx, hashBlock, result); return result; } @@ -703,7 +703,7 @@ if (type.isStr() && type.get_str() != "scripthash") { // P2SH cannot be wrapped in a P2SH. If this script is already a P2SH, // don't return the address for a P2SH of the P2SH. - r.push_back(Pair("p2sh", EncodeDestination(CScriptID(script)))); + r.pushKV("p2sh", EncodeDestination(CScriptID(script))); } return r; @@ -715,12 +715,12 @@ static void TxInErrorToJSON(const CTxIn &txin, UniValue &vErrorsRet, const std::string &strMessage) { UniValue entry(UniValue::VOBJ); - entry.push_back(Pair("txid", txin.prevout.GetTxId().ToString())); - entry.push_back(Pair("vout", uint64_t(txin.prevout.GetN()))); + entry.pushKV("txid", txin.prevout.GetTxId().ToString()); + entry.pushKV("vout", uint64_t(txin.prevout.GetN())); entry.push_back(Pair("scriptSig", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); - entry.push_back(Pair("sequence", uint64_t(txin.nSequence))); - entry.push_back(Pair("error", strMessage)); + entry.pushKV("sequence", uint64_t(txin.nSequence)); + entry.pushKV("error", strMessage); vErrorsRet.push_back(entry); } @@ -1080,10 +1080,10 @@ bool fComplete = vErrors.empty(); UniValue result(UniValue::VOBJ); - result.push_back(Pair("hex", EncodeHexTx(CTransaction(mergedTx)))); - result.push_back(Pair("complete", fComplete)); + result.pushKV("hex", EncodeHexTx(CTransaction(mergedTx))); + result.pushKV("complete", fComplete); if (!vErrors.empty()) { - result.push_back(Pair("errors", vErrors)); + result.pushKV("errors", vErrors); } return result; diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -825,7 +825,7 @@ file.close(); UniValue reply(UniValue::VOBJ); - reply.push_back(Pair("filename", filepath.string())); + reply.pushKV("filename", filepath.string()); return reply; } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -108,30 +108,30 @@ void WalletTxToJSON(const CWalletTx &wtx, UniValue &entry) { int confirms = wtx.GetDepthInMainChain(); - entry.push_back(Pair("confirmations", confirms)); + entry.pushKV("confirmations", confirms); if (wtx.IsCoinBase()) { - entry.push_back(Pair("generated", true)); + entry.pushKV("generated", true); } if (confirms > 0) { - entry.push_back(Pair("blockhash", wtx.hashBlock.GetHex())); - entry.push_back(Pair("blockindex", wtx.nIndex)); + entry.pushKV("blockhash", wtx.hashBlock.GetHex()); + entry.pushKV("blockindex", wtx.nIndex); entry.push_back( Pair("blocktime", mapBlockIndex[wtx.hashBlock]->GetBlockTime())); } else { - entry.push_back(Pair("trusted", wtx.IsTrusted())); + entry.pushKV("trusted", wtx.IsTrusted()); } uint256 hash = wtx.GetId(); - entry.push_back(Pair("txid", hash.GetHex())); + entry.pushKV("txid", hash.GetHex()); UniValue conflicts(UniValue::VARR); for (const uint256 &conflict : wtx.GetConflicts()) { conflicts.push_back(conflict.GetHex()); } - entry.push_back(Pair("walletconflicts", conflicts)); - entry.push_back(Pair("time", wtx.GetTxTime())); - entry.push_back(Pair("timereceived", (int64_t)wtx.nTimeReceived)); + entry.pushKV("walletconflicts", conflicts); + entry.pushKV("time", wtx.GetTxTime()); + entry.pushKV("timereceived", (int64_t)wtx.nTimeReceived); for (const std::pair &item : wtx.mapValue) { - entry.push_back(Pair(item.first, item.second)); + entry.pushKV(item.first, item.second); } } @@ -1508,16 +1508,16 @@ } else { UniValue obj(UniValue::VOBJ); if (fIsWatchonly) { - obj.push_back(Pair("involvesWatchonly", true)); + obj.pushKV("involvesWatchonly", true); } - obj.push_back(Pair("address", EncodeDestination(address))); - obj.push_back(Pair("account", strAccount)); - obj.push_back(Pair("amount", ValueFromAmount(nAmount))); + obj.pushKV("address", EncodeDestination(address)); + obj.pushKV("account", strAccount); + obj.pushKV("amount", ValueFromAmount(nAmount)); obj.push_back( Pair("confirmations", (nConf == std::numeric_limits::max() ? 0 : nConf))); if (!fByAccounts) { - obj.push_back(Pair("label", strAccount)); + obj.pushKV("label", strAccount); } UniValue transactions(UniValue::VARR); if (it != mapTally.end()) { @@ -1525,7 +1525,7 @@ transactions.push_back(_item.GetHex()); } } - obj.push_back(Pair("txids", transactions)); + obj.pushKV("txids", transactions); ret.push_back(obj); } } @@ -1538,10 +1538,10 @@ int nConf = (*it).second.nConf; UniValue obj(UniValue::VOBJ); if ((*it).second.fIsWatchonly) { - obj.push_back(Pair("involvesWatchonly", true)); + obj.pushKV("involvesWatchonly", true); } - obj.push_back(Pair("account", (*it).first)); - obj.push_back(Pair("amount", ValueFromAmount(nAmount))); + obj.pushKV("account", (*it).first); + obj.pushKV("amount", ValueFromAmount(nAmount)); obj.push_back( Pair("confirmations", (nConf == std::numeric_limits::max() ? 0 : nConf))); @@ -1663,7 +1663,7 @@ static void MaybePushAddress(UniValue &entry, const CTxDestination &dest) { if (IsValidDestination(dest)) { - entry.push_back(Pair("address", EncodeDestination(dest))); + entry.pushKV("address", EncodeDestination(dest)); } } @@ -1687,22 +1687,22 @@ UniValue entry(UniValue::VOBJ); if (involvesWatchonly || (::IsMine(*pwallet, s.destination) & ISMINE_WATCH_ONLY)) { - entry.push_back(Pair("involvesWatchonly", true)); + entry.pushKV("involvesWatchonly", true); } - entry.push_back(Pair("account", strSentAccount)); + entry.pushKV("account", strSentAccount); MaybePushAddress(entry, s.destination); - entry.push_back(Pair("category", "send")); - entry.push_back(Pair("amount", ValueFromAmount(-s.amount))); + entry.pushKV("category", "send"); + entry.pushKV("amount", ValueFromAmount(-s.amount)); if (pwallet->mapAddressBook.count(s.destination)) { entry.push_back( Pair("label", pwallet->mapAddressBook[s.destination].name)); } - entry.push_back(Pair("vout", s.vout)); - entry.push_back(Pair("fee", ValueFromAmount(-1 * nFee))); + entry.pushKV("vout", s.vout); + entry.pushKV("fee", ValueFromAmount(-1 * nFee)); if (fLong) { WalletTxToJSON(wtx, entry); } - entry.push_back(Pair("abandoned", wtx.isAbandoned())); + entry.pushKV("abandoned", wtx.isAbandoned()); ret.push_back(entry); } } @@ -1718,26 +1718,26 @@ UniValue entry(UniValue::VOBJ); if (involvesWatchonly || (::IsMine(*pwallet, r.destination) & ISMINE_WATCH_ONLY)) { - entry.push_back(Pair("involvesWatchonly", true)); + entry.pushKV("involvesWatchonly", true); } - entry.push_back(Pair("account", account)); + entry.pushKV("account", account); MaybePushAddress(entry, r.destination); if (wtx.IsCoinBase()) { if (wtx.GetDepthInMainChain() < 1) { - entry.push_back(Pair("category", "orphan")); + entry.pushKV("category", "orphan"); } else if (wtx.IsImmatureCoinBase()) { - entry.push_back(Pair("category", "immature")); + entry.pushKV("category", "immature"); } else { - entry.push_back(Pair("category", "generate")); + entry.pushKV("category", "generate"); } } else { - entry.push_back(Pair("category", "receive")); + entry.pushKV("category", "receive"); } - entry.push_back(Pair("amount", ValueFromAmount(r.amount))); + entry.pushKV("amount", ValueFromAmount(r.amount)); if (pwallet->mapAddressBook.count(r.destination)) { - entry.push_back(Pair("label", account)); + entry.pushKV("label", account); } - entry.push_back(Pair("vout", r.vout)); + entry.pushKV("vout", r.vout); if (fLong) { WalletTxToJSON(wtx, entry); } @@ -1753,12 +1753,12 @@ if (fAllAccounts || acentry.strAccount == strAccount) { UniValue entry(UniValue::VOBJ); - entry.push_back(Pair("account", acentry.strAccount)); - entry.push_back(Pair("category", "move")); - entry.push_back(Pair("time", acentry.nTime)); - entry.push_back(Pair("amount", ValueFromAmount(acentry.nCreditDebit))); - entry.push_back(Pair("otheraccount", acentry.strOtherAccount)); - entry.push_back(Pair("comment", acentry.strComment)); + entry.pushKV("account", acentry.strAccount); + entry.pushKV("category", "move"); + entry.pushKV("time", acentry.nTime); + entry.pushKV("amount", ValueFromAmount(acentry.nCreditDebit)); + entry.pushKV("otheraccount", acentry.strOtherAccount); + entry.pushKV("comment", acentry.strComment); ret.push_back(entry); } } @@ -2192,8 +2192,8 @@ uint256 lastblock = pblockLast ? pblockLast->GetBlockHash() : uint256(); UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("transactions", transactions)); - ret.push_back(Pair("lastblock", lastblock.GetHex())); + ret.pushKV("transactions", transactions); + ret.pushKV("lastblock", lastblock.GetHex()); return ret; } @@ -2314,20 +2314,20 @@ Amount nFee = (wtx.IsFromMe(filter) ? wtx.tx->GetValueOut() - nDebit : Amount::zero()); - entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee))); + entry.pushKV("amount", ValueFromAmount(nNet - nFee)); if (wtx.IsFromMe(filter)) { - entry.push_back(Pair("fee", ValueFromAmount(nFee))); + entry.pushKV("fee", ValueFromAmount(nFee)); } WalletTxToJSON(wtx, entry); UniValue details(UniValue::VARR); ListTransactions(pwallet, wtx, "*", 0, false, details, filter); - entry.push_back(Pair("details", details)); + entry.pushKV("details", details); std::string strHex = EncodeHexTx(static_cast(wtx), RPCSerializationFlags()); - entry.push_back(Pair("hex", strHex)); + entry.pushKV("hex", strHex); return entry; } @@ -2894,8 +2894,8 @@ for (COutPoint &output : vOutpts) { UniValue o(UniValue::VOBJ); - o.push_back(Pair("txid", output.GetTxId().GetHex())); - o.push_back(Pair("vout", int(output.GetN()))); + o.pushKV("txid", output.GetTxId().GetHex()); + o.pushKV("vout", int(output.GetN())); ret.push_back(o); } @@ -2992,16 +2992,16 @@ UniValue obj(UniValue::VOBJ); size_t kpExternalSize = pwallet->KeypoolCountExternalKeys(); - obj.push_back(Pair("walletname", pwallet->GetName())); - obj.push_back(Pair("walletversion", pwallet->GetVersion())); - obj.push_back(Pair("balance", ValueFromAmount(pwallet->GetBalance()))); + obj.pushKV("walletname", pwallet->GetName()); + obj.pushKV("walletversion", pwallet->GetVersion()); + obj.pushKV("balance", ValueFromAmount(pwallet->GetBalance())); obj.push_back(Pair("unconfirmed_balance", ValueFromAmount(pwallet->GetUnconfirmedBalance()))); obj.push_back(Pair("immature_balance", ValueFromAmount(pwallet->GetImmatureBalance()))); - obj.push_back(Pair("txcount", (int)pwallet->mapWallet.size())); - obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime())); - obj.push_back(Pair("keypoolsize", (int64_t)kpExternalSize)); + obj.pushKV("txcount", (int)pwallet->mapWallet.size()); + obj.pushKV("keypoololdest", pwallet->GetOldestKeyPoolTime()); + obj.pushKV("keypoolsize", (int64_t)kpExternalSize); CKeyID masterKeyID = pwallet->GetHDChain().masterKeyID; if (!masterKeyID.IsNull() && pwallet->CanSupportFeature(FEATURE_HD_SPLIT)) { obj.push_back( @@ -3009,11 +3009,11 @@ int64_t(pwallet->GetKeyPoolSize() - kpExternalSize))); } if (pwallet->IsCrypted()) { - obj.push_back(Pair("unlocked_until", pwallet->nRelockTime)); + obj.pushKV("unlocked_until", pwallet->nRelockTime); } - obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); + obj.pushKV("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())); if (!masterKeyID.IsNull()) { - obj.push_back(Pair("hdmasterkeyid", masterKeyID.GetHex())); + obj.pushKV("hdmasterkeyid", masterKeyID.GetHex()); } return obj; } @@ -3273,11 +3273,11 @@ } UniValue entry(UniValue::VOBJ); - entry.push_back(Pair("txid", out.tx->GetId().GetHex())); - entry.push_back(Pair("vout", out.i)); + entry.pushKV("txid", out.tx->GetId().GetHex()); + entry.pushKV("vout", out.i); if (fValidAddress) { - entry.push_back(Pair("address", EncodeDestination(address))); + entry.pushKV("address", EncodeDestination(address)); if (pwallet->mapAddressBook.count(address)) { entry.push_back( @@ -3299,10 +3299,10 @@ HexStr(scriptPubKey.begin(), scriptPubKey.end()))); entry.push_back( Pair("amount", ValueFromAmount(out.tx->tx->vout[out.i].nValue))); - entry.push_back(Pair("confirmations", out.nDepth)); - entry.push_back(Pair("spendable", out.fSpendable)); - entry.push_back(Pair("solvable", out.fSolvable)); - entry.push_back(Pair("safe", out.fSafe)); + entry.pushKV("confirmations", out.nDepth); + entry.pushKV("spendable", out.fSpendable); + entry.pushKV("solvable", out.fSolvable); + entry.pushKV("safe", out.fSafe); results.push_back(entry); } @@ -3521,9 +3521,9 @@ } UniValue result(UniValue::VOBJ); - result.push_back(Pair("hex", EncodeHexTx(CTransaction(tx)))); - result.push_back(Pair("changepos", changePosition)); - result.push_back(Pair("fee", ValueFromAmount(nFeeOut))); + result.pushKV("hex", EncodeHexTx(CTransaction(tx))); + result.pushKV("changepos", changePosition); + result.pushKV("fee", ValueFromAmount(nFeeOut)); return result; }