From 3f8a7b20687f066784e7a3598944053efece5147 Mon Sep 17 00:00:00 2001 From: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com> Date: Thu, 18 Jun 2020 09:17:23 +0000 Subject: [PATCH] Merge #12193: RPC: Consistently use UniValue.pushKV instead of push_back(Pair()) (karel-3d) (#3532) * Begin Merge 12193 Squashed 'src/univalue/' changes from 07947ff2da..51d3ab34ba 51d3ab34ba Merge #10: Add pushKV(key, boolean) function (replaces #5) 129bad96d5 [tests] test pushKV for boolean values b3c44c947f Pushing boolean value to univalue correctly git-subtree-dir: src/univalue git-subtree-split: 51d3ab34ba2857f0d03dc07250cb4a2b5e712e67 * scripted-diff: Use UniValue.pushKV instead of push_back(Pair()) (end #12193) -BEGIN VERIFY SCRIPT- git grep -l "push_back(Pair" | xargs sed -i "s/push_back(Pair(\(.*\)));/pushKV(\1);/g" -END VERIFY SCRIPT- Signed-off-by: pasta Co-authored-by: MarcoFalke --- src/core_write.cpp | 30 +-- src/evo/cbtx.h | 8 +- src/evo/deterministicmns.cpp | 36 ++-- src/evo/providertx.h | 50 ++--- src/evo/simplifiedmns.cpp | 36 ++-- src/governance/governance.cpp | 12 +- src/keepass.cpp | 2 +- src/llmq/quorums_commitment.h | 28 +-- src/llmq/quorums_debug.cpp | 36 ++-- src/llmq/quorums_signing.cpp | 12 +- src/masternode/masternode-meta.cpp | 12 +- src/privatesend/privatesend-client.cpp | 32 +-- src/privatesend/privatesend-server.cpp | 8 +- src/rest.cpp | 14 +- src/rpc/blockchain.cpp | 270 ++++++++++++------------- src/rpc/governance.cpp | 174 ++++++++-------- src/rpc/masternode.cpp | 76 +++---- src/rpc/mining.cpp | 146 ++++++------- src/rpc/misc.cpp | 118 +++++------ src/rpc/net.cpp | 144 ++++++------- src/rpc/privatesend.cpp | 2 +- src/rpc/protocol.cpp | 18 +- src/rpc/rawtransaction.cpp | 40 ++-- src/rpc/rpcevo.cpp | 32 +-- src/rpc/rpcquorums.cpp | 50 ++--- src/univalue/include/univalue.h | 4 + src/univalue/test/object.cpp | 14 +- src/wallet/rpcdump.cpp | 22 +- src/wallet/rpcwallet.cpp | 190 ++++++++--------- 29 files changed, 816 insertions(+), 800 deletions(-) diff --git a/src/core_write.cpp b/src/core_write.cpp index fde5a6c149335..dd3d8bcba2f6d 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -188,12 +188,12 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, auto it = ptxSpentInfo->mSpentInfo.find(spentKey); if (it != ptxSpentInfo->mSpentInfo.end()) { auto spentInfo = it->second; - in.push_back(Pair("value", ValueFromAmount(spentInfo.satoshis))); - in.push_back(Pair("valueSat", spentInfo.satoshis)); + in.pushKV("value", ValueFromAmount(spentInfo.satoshis)); + in.pushKV("valueSat", spentInfo.satoshis); if (spentInfo.addressType == 1) { - in.push_back(Pair("address", EncodeDestination(CKeyID(spentInfo.addressHash)))); + in.pushKV("address", EncodeDestination(CKeyID(spentInfo.addressHash))); } else if (spentInfo.addressType == 2) { - in.push_back(Pair("address", EncodeDestination(CScriptID(spentInfo.addressHash)))); + in.pushKV("address", EncodeDestination(CScriptID(spentInfo.addressHash))); } } } @@ -223,9 +223,9 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, auto it = ptxSpentInfo->mSpentInfo.find(spentKey); if (it != ptxSpentInfo->mSpentInfo.end()) { auto spentInfo = it->second; - out.push_back(Pair("spentTxId", spentInfo.txid.GetHex())); - out.push_back(Pair("spentIndex", (int)spentInfo.inputIndex)); - out.push_back(Pair("spentHeight", spentInfo.blockHeight)); + out.pushKV("spentTxId", spentInfo.txid.GetHex()); + out.pushKV("spentIndex", (int)spentInfo.inputIndex); + out.pushKV("spentHeight", spentInfo.blockHeight); } } vout.push_back(out); @@ -233,8 +233,8 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, entry.pushKV("vout", vout); if (!tx.vExtraPayload.empty()) { - entry.push_back(Pair("extraPayloadSize", (int)tx.vExtraPayload.size())); - entry.push_back(Pair("extraPayload", HexStr(tx.vExtraPayload))); + entry.pushKV("extraPayloadSize", (int)tx.vExtraPayload.size()); + entry.pushKV("extraPayload", HexStr(tx.vExtraPayload)); } if (tx.nType == TRANSACTION_PROVIDER_REGISTER) { @@ -242,42 +242,42 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, if (GetTxPayload(tx, proTx)) { UniValue obj; proTx.ToJson(obj); - entry.push_back(Pair("proRegTx", obj)); + entry.pushKV("proRegTx", obj); } } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_SERVICE) { CProUpServTx proTx; if (GetTxPayload(tx, proTx)) { UniValue obj; proTx.ToJson(obj); - entry.push_back(Pair("proUpServTx", obj)); + entry.pushKV("proUpServTx", obj); } } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REGISTRAR) { CProUpRegTx proTx; if (GetTxPayload(tx, proTx)) { UniValue obj; proTx.ToJson(obj); - entry.push_back(Pair("proUpRegTx", obj)); + entry.pushKV("proUpRegTx", obj); } } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REVOKE) { CProUpRevTx proTx; if (GetTxPayload(tx, proTx)) { UniValue obj; proTx.ToJson(obj); - entry.push_back(Pair("proUpRevTx", obj)); + entry.pushKV("proUpRevTx", obj); } } else if (tx.nType == TRANSACTION_COINBASE) { CCbTx cbTx; if (GetTxPayload(tx, cbTx)) { UniValue obj; cbTx.ToJson(obj); - entry.push_back(Pair("cbTx", obj)); + entry.pushKV("cbTx", obj); } } else if (tx.nType == TRANSACTION_QUORUM_COMMITMENT) { llmq::CFinalCommitmentTxPayload qcTx; if (GetTxPayload(tx, qcTx)) { UniValue obj; qcTx.ToJson(obj); - entry.push_back(Pair("qcTx", obj)); + entry.pushKV("qcTx", obj); } } diff --git a/src/evo/cbtx.h b/src/evo/cbtx.h index e44486912725b..b7a749a5b3414 100644 --- a/src/evo/cbtx.h +++ b/src/evo/cbtx.h @@ -45,11 +45,11 @@ class CCbTx { obj.clear(); obj.setObject(); - obj.push_back(Pair("version", (int)nVersion)); - obj.push_back(Pair("height", (int)nHeight)); - obj.push_back(Pair("merkleRootMNList", merkleRootMNList.ToString())); + obj.pushKV("version", (int)nVersion); + obj.pushKV("height", (int)nHeight); + obj.pushKV("merkleRootMNList", merkleRootMNList.ToString()); if (nVersion >= 2) { - obj.push_back(Pair("merkleRootQuorums", merkleRootQuorums.ToString())); + obj.pushKV("merkleRootQuorums", merkleRootQuorums.ToString()); } } }; diff --git a/src/evo/deterministicmns.cpp b/src/evo/deterministicmns.cpp index deacb1d2ceb8d..33c1774695f0c 100644 --- a/src/evo/deterministicmns.cpp +++ b/src/evo/deterministicmns.cpp @@ -45,23 +45,23 @@ void CDeterministicMNState::ToJson(UniValue& obj) const { obj.clear(); obj.setObject(); - obj.push_back(Pair("service", addr.ToStringIPPort(false))); - obj.push_back(Pair("registeredHeight", nRegisteredHeight)); - obj.push_back(Pair("lastPaidHeight", nLastPaidHeight)); - obj.push_back(Pair("PoSePenalty", nPoSePenalty)); - obj.push_back(Pair("PoSeRevivedHeight", nPoSeRevivedHeight)); - obj.push_back(Pair("PoSeBanHeight", nPoSeBanHeight)); - obj.push_back(Pair("revocationReason", nRevocationReason)); - obj.push_back(Pair("ownerAddress", EncodeDestination(keyIDOwner))); - obj.push_back(Pair("votingAddress", EncodeDestination(keyIDVoting))); + obj.pushKV("service", addr.ToStringIPPort(false)); + obj.pushKV("registeredHeight", nRegisteredHeight); + obj.pushKV("lastPaidHeight", nLastPaidHeight); + obj.pushKV("PoSePenalty", nPoSePenalty); + obj.pushKV("PoSeRevivedHeight", nPoSeRevivedHeight); + obj.pushKV("PoSeBanHeight", nPoSeBanHeight); + obj.pushKV("revocationReason", nRevocationReason); + obj.pushKV("ownerAddress", EncodeDestination(keyIDOwner)); + obj.pushKV("votingAddress", EncodeDestination(keyIDVoting)); CTxDestination dest; if (ExtractDestination(scriptPayout, dest)) { - obj.push_back(Pair("payoutAddress", EncodeDestination(dest))); + obj.pushKV("payoutAddress", EncodeDestination(dest)); } - obj.push_back(Pair("pubKeyOperator", pubKeyOperator.Get().ToString())); + obj.pushKV("pubKeyOperator", pubKeyOperator.Get().ToString()); if (ExtractDestination(scriptOperatorPayout, dest)) { - obj.push_back(Pair("operatorPayoutAddress", EncodeDestination(dest))); + obj.pushKV("operatorPayoutAddress", EncodeDestination(dest)); } } @@ -85,20 +85,20 @@ void CDeterministicMN::ToJson(UniValue& obj) const UniValue stateObj; pdmnState->ToJson(stateObj); - obj.push_back(Pair("proTxHash", proTxHash.ToString())); - obj.push_back(Pair("collateralHash", collateralOutpoint.hash.ToString())); - obj.push_back(Pair("collateralIndex", (int)collateralOutpoint.n)); + obj.pushKV("proTxHash", proTxHash.ToString()); + obj.pushKV("collateralHash", collateralOutpoint.hash.ToString()); + obj.pushKV("collateralIndex", (int)collateralOutpoint.n); Coin coin; if (GetUTXOCoin(collateralOutpoint, coin)) { CTxDestination dest; if (ExtractDestination(coin.out.scriptPubKey, dest)) { - obj.push_back(Pair("collateralAddress", EncodeDestination(dest))); + obj.pushKV("collateralAddress", EncodeDestination(dest)); } } - obj.push_back(Pair("operatorReward", (double)nOperatorReward / 100)); - obj.push_back(Pair("state", stateObj)); + obj.pushKV("operatorReward", (double)nOperatorReward / 100); + obj.pushKV("state", stateObj); } bool CDeterministicMNList::IsMNValid(const uint256& proTxHash) const diff --git a/src/evo/providertx.h b/src/evo/providertx.h index ee95ee8de185d..2ba7967fdc6e8 100644 --- a/src/evo/providertx.h +++ b/src/evo/providertx.h @@ -67,21 +67,21 @@ class CProRegTx { obj.clear(); obj.setObject(); - obj.push_back(Pair("version", nVersion)); - obj.push_back(Pair("collateralHash", collateralOutpoint.hash.ToString())); - obj.push_back(Pair("collateralIndex", (int)collateralOutpoint.n)); - obj.push_back(Pair("service", addr.ToString(false))); - obj.push_back(Pair("ownerAddress", EncodeDestination(keyIDOwner))); - obj.push_back(Pair("votingAddress", EncodeDestination(keyIDVoting))); + obj.pushKV("version", nVersion); + obj.pushKV("collateralHash", collateralOutpoint.hash.ToString()); + obj.pushKV("collateralIndex", (int)collateralOutpoint.n); + obj.pushKV("service", addr.ToString(false)); + obj.pushKV("ownerAddress", EncodeDestination(keyIDOwner)); + obj.pushKV("votingAddress", EncodeDestination(keyIDVoting)); CTxDestination dest; if (ExtractDestination(scriptPayout, dest)) { - obj.push_back(Pair("payoutAddress", EncodeDestination(dest))); + obj.pushKV("payoutAddress", EncodeDestination(dest)); } - obj.push_back(Pair("pubKeyOperator", pubKeyOperator.ToString())); - obj.push_back(Pair("operatorReward", (double)nOperatorReward / 100)); + obj.pushKV("pubKeyOperator", pubKeyOperator.ToString()); + obj.pushKV("operatorReward", (double)nOperatorReward / 100); - obj.push_back(Pair("inputsHash", inputsHash.ToString())); + obj.pushKV("inputsHash", inputsHash.ToString()); } }; @@ -121,14 +121,14 @@ class CProUpServTx { obj.clear(); obj.setObject(); - obj.push_back(Pair("version", nVersion)); - obj.push_back(Pair("proTxHash", proTxHash.ToString())); - obj.push_back(Pair("service", addr.ToString(false))); + obj.pushKV("version", nVersion); + obj.pushKV("proTxHash", proTxHash.ToString()); + obj.pushKV("service", addr.ToString(false)); CTxDestination dest; if (ExtractDestination(scriptOperatorPayout, dest)) { - obj.push_back(Pair("operatorPayoutAddress", EncodeDestination(dest))); + obj.pushKV("operatorPayoutAddress", EncodeDestination(dest)); } - obj.push_back(Pair("inputsHash", inputsHash.ToString())); + obj.pushKV("inputsHash", inputsHash.ToString()); } }; @@ -172,15 +172,15 @@ class CProUpRegTx { obj.clear(); obj.setObject(); - obj.push_back(Pair("version", nVersion)); - obj.push_back(Pair("proTxHash", proTxHash.ToString())); - obj.push_back(Pair("votingAddress", EncodeDestination(keyIDVoting))); + obj.pushKV("version", nVersion); + obj.pushKV("proTxHash", proTxHash.ToString()); + obj.pushKV("votingAddress", EncodeDestination(keyIDVoting)); CTxDestination dest; if (ExtractDestination(scriptPayout, dest)) { - obj.push_back(Pair("payoutAddress", EncodeDestination(dest))); + obj.pushKV("payoutAddress", EncodeDestination(dest)); } - obj.push_back(Pair("pubKeyOperator", pubKeyOperator.ToString())); - obj.push_back(Pair("inputsHash", inputsHash.ToString())); + obj.pushKV("pubKeyOperator", pubKeyOperator.ToString()); + obj.pushKV("inputsHash", inputsHash.ToString()); } }; @@ -227,10 +227,10 @@ class CProUpRevTx { obj.clear(); obj.setObject(); - obj.push_back(Pair("version", nVersion)); - obj.push_back(Pair("proTxHash", proTxHash.ToString())); - obj.push_back(Pair("reason", (int)nReason)); - obj.push_back(Pair("inputsHash", inputsHash.ToString())); + obj.pushKV("version", nVersion); + obj.pushKV("proTxHash", proTxHash.ToString()); + obj.pushKV("reason", (int)nReason); + obj.pushKV("inputsHash", inputsHash.ToString()); } }; diff --git a/src/evo/simplifiedmns.cpp b/src/evo/simplifiedmns.cpp index aff3e05162aec..1175e6b5101da 100644 --- a/src/evo/simplifiedmns.cpp +++ b/src/evo/simplifiedmns.cpp @@ -44,12 +44,12 @@ void CSimplifiedMNListEntry::ToJson(UniValue& obj) const { obj.clear(); obj.setObject(); - obj.push_back(Pair("proRegTxHash", proRegTxHash.ToString())); - obj.push_back(Pair("confirmedHash", confirmedHash.ToString())); - obj.push_back(Pair("service", service.ToString(false))); - obj.push_back(Pair("pubKeyOperator", pubKeyOperator.Get().ToString())); - obj.push_back(Pair("votingAddress", EncodeDestination(keyIDVoting))); - obj.push_back(Pair("isValid", isValid)); + obj.pushKV("proRegTxHash", proRegTxHash.ToString()); + obj.pushKV("confirmedHash", confirmedHash.ToString()); + obj.pushKV("service", service.ToString(false)); + obj.pushKV("pubKeyOperator", pubKeyOperator.Get().ToString()); + obj.pushKV("votingAddress", EncodeDestination(keyIDVoting)); + obj.pushKV("isValid", isValid); } CSimplifiedMNList::CSimplifiedMNList(const std::vector& smlEntries) @@ -136,20 +136,20 @@ void CSimplifiedMNListDiff::ToJson(UniValue& obj) const { obj.setObject(); - obj.push_back(Pair("baseBlockHash", baseBlockHash.ToString())); - obj.push_back(Pair("blockHash", blockHash.ToString())); + obj.pushKV("baseBlockHash", baseBlockHash.ToString()); + obj.pushKV("blockHash", blockHash.ToString()); CDataStream ssCbTxMerkleTree(SER_NETWORK, PROTOCOL_VERSION); ssCbTxMerkleTree << cbTxMerkleTree; - obj.push_back(Pair("cbTxMerkleTree", HexStr(ssCbTxMerkleTree.begin(), ssCbTxMerkleTree.end()))); + obj.pushKV("cbTxMerkleTree", HexStr(ssCbTxMerkleTree.begin(), ssCbTxMerkleTree.end())); - obj.push_back(Pair("cbTx", EncodeHexTx(*cbTx))); + obj.pushKV("cbTx", EncodeHexTx(*cbTx)); UniValue deletedMNsArr(UniValue::VARR); for (const auto& h : deletedMNs) { deletedMNsArr.push_back(h.ToString()); } - obj.push_back(Pair("deletedMNs", deletedMNsArr)); + obj.pushKV("deletedMNs", deletedMNsArr); UniValue mnListArr(UniValue::VARR); for (const auto& e : mnList) { @@ -157,16 +157,16 @@ void CSimplifiedMNListDiff::ToJson(UniValue& obj) const e.ToJson(eObj); mnListArr.push_back(eObj); } - obj.push_back(Pair("mnList", mnListArr)); + obj.pushKV("mnList", mnListArr); UniValue deletedQuorumsArr(UniValue::VARR); for (const auto& e : deletedQuorums) { UniValue eObj(UniValue::VOBJ); - eObj.push_back(Pair("llmqType", e.first)); - eObj.push_back(Pair("quorumHash", e.second.ToString())); + eObj.pushKV("llmqType", e.first); + eObj.pushKV("quorumHash", e.second.ToString()); deletedQuorumsArr.push_back(eObj); } - obj.push_back(Pair("deletedQuorums", deletedQuorumsArr)); + obj.pushKV("deletedQuorums", deletedQuorumsArr); UniValue newQuorumsArr(UniValue::VARR); for (const auto& e : newQuorums) { @@ -174,13 +174,13 @@ void CSimplifiedMNListDiff::ToJson(UniValue& obj) const e.ToJson(eObj); newQuorumsArr.push_back(eObj); } - obj.push_back(Pair("newQuorums", newQuorumsArr)); + obj.pushKV("newQuorums", newQuorumsArr); CCbTx cbTxPayload; if (GetTxPayload(*cbTx, cbTxPayload)) { - obj.push_back(Pair("merkleRootMNList", cbTxPayload.merkleRootMNList.ToString())); + obj.pushKV("merkleRootMNList", cbTxPayload.merkleRootMNList.ToString()); if (cbTxPayload.nVersion >= 2) { - obj.push_back(Pair("merkleRootQuorums", cbTxPayload.merkleRootQuorums.ToString())); + obj.pushKV("merkleRootQuorums", cbTxPayload.merkleRootQuorums.ToString()); } } } diff --git a/src/governance/governance.cpp b/src/governance/governance.cpp index 64b61940d1acf..ba98dd14349a4 100644 --- a/src/governance/governance.cpp +++ b/src/governance/governance.cpp @@ -1188,12 +1188,12 @@ UniValue CGovernanceManager::ToJson() const } UniValue jsonObj(UniValue::VOBJ); - jsonObj.push_back(Pair("objects_total", (int)mapObjects.size())); - jsonObj.push_back(Pair("proposals", nProposalCount)); - jsonObj.push_back(Pair("triggers", nTriggerCount)); - jsonObj.push_back(Pair("other", nOtherCount)); - jsonObj.push_back(Pair("erased", (int)mapErasedGovernanceObjects.size())); - jsonObj.push_back(Pair("votes", (int)cmapVoteToObject.GetSize())); + jsonObj.pushKV("objects_total", (int)mapObjects.size()); + jsonObj.pushKV("proposals", nProposalCount); + jsonObj.pushKV("triggers", nTriggerCount); + jsonObj.pushKV("other", nOtherCount); + jsonObj.pushKV("erased", (int)mapErasedGovernanceObjects.size()); + jsonObj.pushKV("votes", (int)cmapVoteToObject.GetSize()); return jsonObj; } diff --git a/src/keepass.cpp b/src/keepass.cpp index 4bd295d6dea6c..e3210bf244e4c 100644 --- a/src/keepass.cpp +++ b/src/keepass.cpp @@ -122,7 +122,7 @@ void CKeePassIntegrator::init() void CKeePassIntegrator::CKeePassRequest::addStrParameter(const std::string& strName, const std::string& strValue) { - requestObj.push_back(Pair(strName, strValue)); + requestObj.pushKV(strName, strValue); } void CKeePassIntegrator::CKeePassRequest::addStrParameter(const std::string& strName, const SecureString& sValue) diff --git a/src/llmq/quorums_commitment.h b/src/llmq/quorums_commitment.h index dfbd1b76c1440..30f30334dde7c 100644 --- a/src/llmq/quorums_commitment.h +++ b/src/llmq/quorums_commitment.h @@ -92,17 +92,17 @@ class CFinalCommitment void ToJson(UniValue& obj) const { obj.setObject(); - obj.push_back(Pair("version", (int)nVersion)); - obj.push_back(Pair("llmqType", (int)llmqType)); - obj.push_back(Pair("quorumHash", quorumHash.ToString())); - obj.push_back(Pair("signersCount", CountSigners())); - obj.push_back(Pair("signers", CLLMQUtils::ToHexStr(signers))); - obj.push_back(Pair("validMembersCount", CountValidMembers())); - obj.push_back(Pair("validMembers", CLLMQUtils::ToHexStr(validMembers))); - obj.push_back(Pair("quorumPublicKey", quorumPublicKey.ToString())); - obj.push_back(Pair("quorumVvecHash", quorumVvecHash.ToString())); - obj.push_back(Pair("quorumSig", quorumSig.ToString())); - obj.push_back(Pair("membersSig", membersSig.ToString())); + obj.pushKV("version", (int)nVersion); + obj.pushKV("llmqType", (int)llmqType); + obj.pushKV("quorumHash", quorumHash.ToString()); + obj.pushKV("signersCount", CountSigners()); + obj.pushKV("signers", CLLMQUtils::ToHexStr(signers)); + obj.pushKV("validMembersCount", CountValidMembers()); + obj.pushKV("validMembers", CLLMQUtils::ToHexStr(validMembers)); + obj.pushKV("quorumPublicKey", quorumPublicKey.ToString()); + obj.pushKV("quorumVvecHash", quorumVvecHash.ToString()); + obj.pushKV("quorumSig", quorumSig.ToString()); + obj.pushKV("membersSig", membersSig.ToString()); } }; @@ -130,12 +130,12 @@ class CFinalCommitmentTxPayload void ToJson(UniValue& obj) const { obj.setObject(); - obj.push_back(Pair("version", (int)nVersion)); - obj.push_back(Pair("height", (int)nHeight)); + obj.pushKV("version", (int)nVersion); + obj.pushKV("height", (int)nHeight); UniValue qcObj; commitment.ToJson(qcObj); - obj.push_back(Pair("commitment", qcObj)); + obj.pushKV("commitment", qcObj); } }; diff --git a/src/llmq/quorums_debug.cpp b/src/llmq/quorums_debug.cpp index ba7da2e2ac1b8..3b8fbebfbffd4 100644 --- a/src/llmq/quorums_debug.cpp +++ b/src/llmq/quorums_debug.cpp @@ -37,16 +37,16 @@ UniValue CDKGDebugSessionStatus::ToJson(int detailLevel) const } } - ret.push_back(Pair("llmqType", llmqType)); - ret.push_back(Pair("quorumHash", quorumHash.ToString())); - ret.push_back(Pair("quorumHeight", (int)quorumHeight)); - ret.push_back(Pair("phase", (int)phase)); + ret.pushKV("llmqType", llmqType); + ret.pushKV("quorumHash", quorumHash.ToString()); + ret.pushKV("quorumHeight", (int)quorumHeight); + ret.pushKV("phase", (int)phase); - ret.push_back(Pair("sentContributions", sentContributions)); - ret.push_back(Pair("sentComplaint", sentComplaint)); - ret.push_back(Pair("sentJustification", sentJustification)); - ret.push_back(Pair("sentPrematureCommitment", sentPrematureCommitment)); - ret.push_back(Pair("aborted", aborted)); + ret.pushKV("sentContributions", sentContributions); + ret.pushKV("sentComplaint", sentComplaint); + ret.pushKV("sentJustification", sentJustification); + ret.pushKV("sentPrematureCommitment", sentPrematureCommitment); + ret.pushKV("aborted", aborted); struct ArrOrCount { int count{0}; @@ -69,9 +69,9 @@ UniValue CDKGDebugSessionStatus::ToJson(int detailLevel) const v.arr.push_back((int)idx); } else if (detailLevel == 2) { UniValue a(UniValue::VOBJ); - a.push_back(Pair("memberIndex", (int)idx)); + a.pushKV("memberIndex", (int)idx); if (idx < dmnMembers.size()) { - a.push_back(Pair("proTxHash", dmnMembers[idx]->proTxHash.ToString())); + a.pushKV("proTxHash", dmnMembers[idx]->proTxHash.ToString()); } v.arr.push_back(a); } @@ -79,9 +79,9 @@ UniValue CDKGDebugSessionStatus::ToJson(int detailLevel) const }; auto push = [&](ArrOrCount& v, const std::string& name) { if (detailLevel == 0) { - ret.push_back(Pair(name, v.count)); + ret.pushKV(name, v.count); } else { - ret.push_back(Pair(name, v.arr)); + ret.pushKV(name, v.arr); } }; @@ -106,7 +106,7 @@ UniValue CDKGDebugSessionStatus::ToJson(int detailLevel) const for (const auto& dmn : dmnMembers) { arr.push_back(dmn->proTxHash.ToString()); } - ret.push_back(Pair("allMembers", arr)); + ret.pushKV("allMembers", arr); } return ret; @@ -120,8 +120,8 @@ UniValue CDKGDebugStatus::ToJson(int detailLevel) const { UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("time", nTime)); - ret.push_back(Pair("timeStr", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nTime))); + ret.pushKV("time", nTime); + ret.pushKV("timeStr", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nTime)); UniValue sessionsJson(UniValue::VOBJ); for (const auto& p : sessions) { @@ -129,10 +129,10 @@ UniValue CDKGDebugStatus::ToJson(int detailLevel) const continue; } const auto& params = Params().GetConsensus().llmqs.at((Consensus::LLMQType)p.first); - sessionsJson.push_back(Pair(params.name, p.second.ToJson(detailLevel))); + sessionsJson.pushKV(params.name, p.second.ToJson(detailLevel)); } - ret.push_back(Pair("session", sessionsJson)); + ret.pushKV("session", sessionsJson); return ret; } diff --git a/src/llmq/quorums_signing.cpp b/src/llmq/quorums_signing.cpp index a975434ffb668..2a4f0577e8f50 100644 --- a/src/llmq/quorums_signing.cpp +++ b/src/llmq/quorums_signing.cpp @@ -27,12 +27,12 @@ CSigningManager* quorumSigningManager; UniValue CRecoveredSig::ToJson() const { UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("llmqType", (int)llmqType)); - ret.push_back(Pair("quorumHash", quorumHash.ToString())); - ret.push_back(Pair("id", id.ToString())); - ret.push_back(Pair("msgHash", msgHash.ToString())); - ret.push_back(Pair("sig", sig.Get().ToString())); - ret.push_back(Pair("hash", sig.Get().GetHash().ToString())); + ret.pushKV("llmqType", (int)llmqType); + ret.pushKV("quorumHash", quorumHash.ToString()); + ret.pushKV("id", id.ToString()); + ret.pushKV("msgHash", msgHash.ToString()); + ret.pushKV("sig", sig.Get().ToString()); + ret.pushKV("hash", sig.Get().GetHash().ToString()); return ret; } diff --git a/src/masternode/masternode-meta.cpp b/src/masternode/masternode-meta.cpp index 129e5b35b492b..f6c049f439575 100644 --- a/src/masternode/masternode-meta.cpp +++ b/src/masternode/masternode-meta.cpp @@ -16,12 +16,12 @@ UniValue CMasternodeMetaInfo::ToJson() const auto now = GetAdjustedTime(); - ret.push_back(Pair("lastDSQ", nLastDsq)); - ret.push_back(Pair("mixingTxCount", nMixingTxCount)); - ret.push_back(Pair("lastOutboundAttempt", lastOutboundAttempt)); - ret.push_back(Pair("lastOutboundAttemptElapsed", now - lastOutboundAttempt)); - ret.push_back(Pair("lastOutboundSuccess", lastOutboundSuccess)); - ret.push_back(Pair("lastOutboundSuccessElapsed", now - lastOutboundSuccess)); + ret.pushKV("lastDSQ", nLastDsq); + ret.pushKV("mixingTxCount", nMixingTxCount); + ret.pushKV("lastOutboundAttempt", lastOutboundAttempt); + ret.pushKV("lastOutboundAttemptElapsed", now - lastOutboundAttempt); + ret.pushKV("lastOutboundSuccess", lastOutboundSuccess); + ret.pushKV("lastOutboundSuccessElapsed", now - lastOutboundSuccess); return ret; } diff --git a/src/privatesend/privatesend-client.cpp b/src/privatesend/privatesend-client.cpp index e77c5828b8090..75792b13a6c53 100644 --- a/src/privatesend/privatesend-client.cpp +++ b/src/privatesend/privatesend-client.cpp @@ -1741,13 +1741,13 @@ void CPrivateSendClientSession::GetJsonInfo(UniValue& obj) const obj.setObject(); if (mixingMasternode != nullptr) { assert(mixingMasternode->pdmnState); - obj.push_back(Pair("protxhash", mixingMasternode->proTxHash.ToString())); - obj.push_back(Pair("outpoint", mixingMasternode->collateralOutpoint.ToStringShort())); - obj.push_back(Pair("service", mixingMasternode->pdmnState->addr.ToString())); + obj.pushKV("protxhash", mixingMasternode->proTxHash.ToString()); + obj.pushKV("outpoint", mixingMasternode->collateralOutpoint.ToStringShort()); + obj.pushKV("service", mixingMasternode->pdmnState->addr.ToString()); } - obj.push_back(Pair("denomination", ValueFromAmount(CPrivateSend::DenominationToAmount(nSessionDenom)))); - obj.push_back(Pair("state", GetStateString())); - obj.push_back(Pair("entries_count", GetEntriesCount())); + obj.pushKV("denomination", ValueFromAmount(CPrivateSend::DenominationToAmount(nSessionDenom))); + obj.pushKV("state", GetStateString()); + obj.pushKV("entries_count", GetEntriesCount()); } void CPrivateSendClientManager::GetJsonInfo(UniValue& obj) const @@ -1755,15 +1755,15 @@ void CPrivateSendClientManager::GetJsonInfo(UniValue& obj) const LOCK(cs_deqsessions); obj.clear(); obj.setObject(); - obj.push_back(Pair("enabled", fEnablePrivateSend)); - obj.push_back(Pair("running", fPrivateSendRunning)); - obj.push_back(Pair("multisession", fPrivateSendMultiSession)); - obj.push_back(Pair("max_sessions", nPrivateSendSessions)); - obj.push_back(Pair("max_rounds", nPrivateSendRounds)); - obj.push_back(Pair("max_amount", nPrivateSendAmount)); - obj.push_back(Pair("denoms_goal", nPrivateSendDenomsGoal)); - obj.push_back(Pair("denoms_hardcap", nPrivateSendDenomsHardCap)); - obj.push_back(Pair("queue_size", GetQueueSize())); + obj.pushKV("enabled", fEnablePrivateSend); + obj.pushKV("running", fPrivateSendRunning); + obj.pushKV("multisession", fPrivateSendMultiSession); + obj.pushKV("max_sessions", nPrivateSendSessions); + obj.pushKV("max_rounds", nPrivateSendRounds); + obj.pushKV("max_amount", nPrivateSendAmount); + obj.pushKV("denoms_goal", nPrivateSendDenomsGoal); + obj.pushKV("denoms_hardcap", nPrivateSendDenomsHardCap); + obj.pushKV("queue_size", GetQueueSize()); UniValue arrSessions(UniValue::VARR); for (const auto& session : deqSessions) { @@ -1773,5 +1773,5 @@ void CPrivateSendClientManager::GetJsonInfo(UniValue& obj) const arrSessions.push_back(objSession); } } - obj.push_back(Pair("sessions", arrSessions)); + obj.pushKV("sessions", arrSessions); } diff --git a/src/privatesend/privatesend-server.cpp b/src/privatesend/privatesend-server.cpp index 386fe98e37e83..5213b8b40c3cf 100644 --- a/src/privatesend/privatesend-server.cpp +++ b/src/privatesend/privatesend-server.cpp @@ -882,8 +882,8 @@ void CPrivateSendServer::GetJsonInfo(UniValue& obj) const { obj.clear(); obj.setObject(); - obj.push_back(Pair("queue_size", GetQueueSize())); - obj.push_back(Pair("denomination", ValueFromAmount(CPrivateSend::DenominationToAmount(nSessionDenom)))); - obj.push_back(Pair("state", GetStateString())); - obj.push_back(Pair("entries_count", GetEntriesCount())); + obj.pushKV("queue_size", GetQueueSize()); + obj.pushKV("denomination", ValueFromAmount(CPrivateSend::DenominationToAmount(nSessionDenom))); + obj.pushKV("state", GetStateString()); + obj.pushKV("entries_count", GetEntriesCount()); } diff --git a/src/rest.cpp b/src/rest.cpp index f3236dd61e97d..f25f2c7088361 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -540,23 +540,23 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart) // pack in some essentials // use more or less the same output as mentioned in Bip64 - objGetUTXOResponse.push_back(Pair("chainHeight", chainActive.Height())); - objGetUTXOResponse.push_back(Pair("chaintipHash", chainActive.Tip()->GetBlockHash().GetHex())); - objGetUTXOResponse.push_back(Pair("bitmap", bitmapStringRepresentation)); + objGetUTXOResponse.pushKV("chainHeight", chainActive.Height()); + objGetUTXOResponse.pushKV("chaintipHash", chainActive.Tip()->GetBlockHash().GetHex()); + objGetUTXOResponse.pushKV("bitmap", bitmapStringRepresentation); 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); ScriptPubKeyToUniv(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/blockchain.cpp b/src/rpc/blockchain.cpp index a887bb766eb30..5308ecfc59bae 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -98,31 +98,31 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex) { AssertLockHeld(cs_main); 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.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.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.push_back(Pair("nTx", (uint64_t)blockindex->nTx)); + result.pushKV("confirmations", confirmations); + result.pushKV("height", blockindex->nHeight); + result.pushKV("version", blockindex->nVersion); + result.pushKV("versionHex", strprintf("%08x", blockindex->nVersion)); + result.pushKV("merkleroot", blockindex->hashMerkleRoot.GetHex()); + result.pushKV("time", (int64_t)blockindex->nTime); + result.pushKV("mediantime", (int64_t)blockindex->GetMedianTimePast()); + 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()); + result.pushKV("nTx", (uint64_t)blockindex->nTx); if (blockindex->pprev) - result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex())); + result.pushKV("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()); CBlockIndex *pnext = chainActive.Next(blockindex); if (pnext) - result.push_back(Pair("nextblockhash", pnext->GetBlockHash().GetHex())); + result.pushKV("nextblockhash", pnext->GetBlockHash().GetHex()); - result.push_back(Pair("chainlock", llmq::chainLocksHandler->HasChainLock(blockindex->nHeight, blockindex->GetBlockHash()))); + result.pushKV("chainlock", llmq::chainLocksHandler->HasChainLock(blockindex->nHeight, blockindex->GetBlockHash())); return result; } @@ -131,17 +131,17 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx { AssertLockHeld(cs_main); 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("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("confirmations", confirmations); + result.pushKV("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION)); + result.pushKV("height", blockindex->nHeight); + result.pushKV("version", block.nVersion); + result.pushKV("versionHex", strprintf("%08x", block.nVersion)); + result.pushKV("merkleroot", block.hashMerkleRoot.GetHex()); bool chainLock = llmq::chainLocksHandler->HasChainLock(blockindex->nHeight, blockindex->GetBlockHash()); UniValue txs(UniValue::VARR); for(const auto& tx : block.vtx) @@ -151,37 +151,37 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx UniValue objTx(UniValue::VOBJ); TxToUniv(*tx, uint256(), objTx, true); bool fLocked = llmq::quorumInstantSendManager->IsLocked(tx->GetHash()); - objTx.push_back(Pair("instantlock", fLocked || chainLock)); - objTx.push_back(Pair("instantlock_internal", fLocked)); + objTx.pushKV("instantlock", fLocked || chainLock); + objTx.pushKV("instantlock_internal", fLocked); txs.push_back(objTx); } else txs.push_back(tx->GetHash().GetHex()); } - result.push_back(Pair("tx", txs)); + result.pushKV("tx", txs); if (!block.vtx[0]->vExtraPayload.empty()) { CCbTx cbTx; if (GetTxPayload(block.vtx[0]->vExtraPayload, cbTx)) { UniValue cbTxObj; cbTx.ToJson(cbTxObj); - result.push_back(Pair("cbTx", cbTxObj)); + result.pushKV("cbTx", cbTxObj); } } - result.push_back(Pair("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.push_back(Pair("nTx", (uint64_t)blockindex->nTx)); + result.pushKV("time", block.GetBlockTime()); + result.pushKV("mediantime", (int64_t)blockindex->GetMedianTimePast()); + 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()); + result.pushKV("nTx", (uint64_t)blockindex->nTx); if (blockindex->pprev) - result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex())); + result.pushKV("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()); CBlockIndex *pnext = chainActive.Next(blockindex); if (pnext) - result.push_back(Pair("nextblockhash", pnext->GetBlockHash().GetHex())); + result.pushKV("nextblockhash", pnext->GetBlockHash().GetHex()); - result.push_back(Pair("chainlock", chainLock)); + result.pushKV("chainlock", chainLock); return result; } @@ -242,10 +242,10 @@ UniValue getbestchainlock(const JSONRPCRequest& request) if (clsig.IsNull()) { throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to find any chainlock"); } - result.push_back(Pair("blockhash", clsig.blockHash.GetHex())); - result.push_back(Pair("height", clsig.nHeight)); + result.pushKV("blockhash", clsig.blockHash.GetHex()); + result.pushKV("height", clsig.nHeight); LOCK(cs_main); - result.push_back(Pair("known_block", mapBlockIndex.count(clsig.blockHash) > 0)); + result.pushKV("known_block", mapBlockIndex.count(clsig.blockHash) > 0); return result; } @@ -292,8 +292,8 @@ UniValue waitfornewblock(const JSONRPCRequest& request) 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; } @@ -334,8 +334,8 @@ UniValue waitforblock(const JSONRPCRequest& request) } 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; } @@ -376,8 +376,8 @@ UniValue waitforblockheight(const JSONRPCRequest& request) 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; } @@ -424,17 +424,17 @@ 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("descendantcount", e.GetCountWithDescendants())); - info.push_back(Pair("descendantsize", e.GetSizeWithDescendants())); - info.push_back(Pair("descendantfees", e.GetModFeesWithDescendants())); - info.push_back(Pair("ancestorcount", e.GetCountWithAncestors())); - info.push_back(Pair("ancestorsize", e.GetSizeWithAncestors())); - info.push_back(Pair("ancestorfees", e.GetModFeesWithAncestors())); + 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("descendantcount", e.GetCountWithDescendants()); + info.pushKV("descendantsize", e.GetSizeWithDescendants()); + info.pushKV("descendantfees", e.GetModFeesWithDescendants()); + info.pushKV("ancestorcount", e.GetCountWithAncestors()); + info.pushKV("ancestorsize", e.GetSizeWithAncestors()); + info.pushKV("ancestorfees", e.GetModFeesWithAncestors()); const CTransaction& tx = e.GetTx(); std::set setDepends; for (const CTxIn& txin : tx.vin) @@ -449,7 +449,7 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) depends.push_back(dep); } - info.push_back(Pair("depends", depends)); + info.pushKV("depends", depends); UniValue spent(UniValue::VARR); const CTxMemPool::txiter &it = mempool.mapTx.find(tx.GetHash()); @@ -458,8 +458,8 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) spent.push_back(childiter->GetTx().GetHash().ToString()); } - info.push_back(Pair("spentby", spent)); - info.push_back(Pair("instantlock", llmq::quorumInstantSendManager->IsLocked(tx.GetHash()))); + info.pushKV("spentby", spent); + info.pushKV("instantlock", llmq::quorumInstantSendManager->IsLocked(tx.GetHash())); } UniValue mempoolToJSON(bool fVerbose) @@ -473,7 +473,7 @@ UniValue mempoolToJSON(bool fVerbose) const uint256& hash = e.GetTx().GetHash(); UniValue info(UniValue::VOBJ); entryToJSON(info, e); - o.push_back(Pair(hash.ToString(), info)); + o.pushKV(hash.ToString(), info); } return o; } @@ -580,7 +580,7 @@ UniValue getmempoolancestors(const JSONRPCRequest& request) const uint256& _hash = e.GetTx().GetHash(); UniValue info(UniValue::VOBJ); entryToJSON(info, e); - o.push_back(Pair(_hash.ToString(), info)); + o.pushKV(_hash.ToString(), info); } return o; } @@ -644,7 +644,7 @@ UniValue getmempooldescendants(const JSONRPCRequest& request) const uint256& _hash = e.GetTx().GetHash(); UniValue info(UniValue::VOBJ); entryToJSON(info, e); - o.push_back(Pair(_hash.ToString(), info)); + o.pushKV(_hash.ToString(), info); } return o; } @@ -1220,14 +1220,14 @@ UniValue gettxoutsetinfo(const JSONRPCRequest& request) 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_2", stats.hashSerialized.GetHex())); - ret.push_back(Pair("disk_size", stats.nDiskSize)); - ret.push_back(Pair("total_amount", ValueFromAmount(stats.nTotalAmount))); + 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_2", stats.hashSerialized.GetHex()); + ret.pushKV("disk_size", stats.nDiskSize); + ret.pushKV("total_amount", ValueFromAmount(stats.nTotalAmount)); } else { throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to read UTXO set"); } @@ -1299,17 +1299,17 @@ UniValue gettxout(const JSONRPCRequest& request) 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.nHeight == MEMPOOL_HEIGHT) { - ret.push_back(Pair("confirmations", 0)); + ret.pushKV("confirmations", 0); } else { - ret.push_back(Pair("confirmations", (int64_t)(pindex->nHeight - coin.nHeight + 1))); + ret.pushKV("confirmations", (int64_t)(pindex->nHeight - coin.nHeight + 1)); } - ret.push_back(Pair("value", ValueFromAmount(coin.out.nValue))); + ret.pushKV("value", ValueFromAmount(coin.out.nValue)); UniValue o(UniValue::VOBJ); ScriptPubKeyToUniv(coin.out.scriptPubKey, o, true); - ret.push_back(Pair("scriptPubKey", o)); - ret.push_back(Pair("coinbase", (bool)coin.fCoinBase)); + ret.pushKV("scriptPubKey", o); + ret.pushKV("coinbase", (bool)coin.fCoinBase); return ret; } @@ -1359,16 +1359,16 @@ static UniValue SoftForkMajorityDesc(int version, CBlockIndex* pindex, const Con activated = pindex->nHeight >= consensusParams.BIP65Height; break; } - rv.push_back(Pair("status", activated)); + rv.pushKV("status", activated); return rv; } static UniValue SoftForkDesc(const std::string &name, int version, CBlockIndex* pindex, const Consensus::Params& consensusParams) { UniValue rv(UniValue::VOBJ); - rv.push_back(Pair("id", name)); - rv.push_back(Pair("version", version)); - rv.push_back(Pair("reject", SoftForkMajorityDesc(version, pindex, consensusParams))); + rv.pushKV("id", name); + rv.pushKV("version", version); + rv.pushKV("reject", SoftForkMajorityDesc(version, pindex, consensusParams)); return rv; } @@ -1377,29 +1377,29 @@ static UniValue BIP9SoftForkDesc(const Consensus::Params& consensusParams, Conse UniValue rv(UniValue::VOBJ); const ThresholdState thresholdState = VersionBitsTipState(consensusParams, id); switch (thresholdState) { - case ThresholdState::DEFINED: rv.push_back(Pair("status", "defined")); break; - case ThresholdState::STARTED: rv.push_back(Pair("status", "started")); break; - case ThresholdState::LOCKED_IN: rv.push_back(Pair("status", "locked_in")); break; - case ThresholdState::ACTIVE: rv.push_back(Pair("status", "active")); break; - case ThresholdState::FAILED: rv.push_back(Pair("status", "failed")); break; + case ThresholdState::DEFINED: rv.pushKV("status", "defined"); break; + case ThresholdState::STARTED: rv.pushKV("status", "started"); break; + case ThresholdState::LOCKED_IN: rv.pushKV("status", "locked_in"); break; + case ThresholdState::ACTIVE: rv.pushKV("status", "active"); break; + case ThresholdState::FAILED: rv.pushKV("status", "failed"); break; } if (ThresholdState::STARTED == thresholdState) { - rv.push_back(Pair("bit", consensusParams.vDeployments[id].bit)); + rv.pushKV("bit", consensusParams.vDeployments[id].bit); } - rv.push_back(Pair("startTime", consensusParams.vDeployments[id].nStartTime)); - rv.push_back(Pair("timeout", consensusParams.vDeployments[id].nTimeout)); - rv.push_back(Pair("since", VersionBitsTipStateSinceHeight(consensusParams, id))); + rv.pushKV("startTime", consensusParams.vDeployments[id].nStartTime); + rv.pushKV("timeout", consensusParams.vDeployments[id].nTimeout); + rv.pushKV("since", VersionBitsTipStateSinceHeight(consensusParams, id)); if (ThresholdState::STARTED == thresholdState) { UniValue statsUV(UniValue::VOBJ); BIP9Stats statsStruct = VersionBitsTipStatistics(consensusParams, id); - statsUV.push_back(Pair("period", statsStruct.period)); - statsUV.push_back(Pair("threshold", statsStruct.threshold)); - statsUV.push_back(Pair("elapsed", statsStruct.elapsed)); - statsUV.push_back(Pair("count", statsStruct.count)); - statsUV.push_back(Pair("possible", statsStruct.possible)); - rv.push_back(Pair("statistics", statsUV)); + statsUV.pushKV("period", statsStruct.period); + statsUV.pushKV("threshold", statsStruct.threshold); + statsUV.pushKV("elapsed", statsStruct.elapsed); + statsUV.pushKV("count", statsStruct.count); + statsUV.pushKV("possible", statsStruct.possible); + rv.pushKV("statistics", statsUV); } return rv; } @@ -1410,7 +1410,7 @@ void BIP9SoftForkDescPushBack(UniValue& bip9_softforks, const Consensus::Params& // A timeout value of 0 guarantees a softfork will never be activated. // This is used when softfork codes are merged without specifying the deployment schedule. if (consensusParams.vDeployments[id].nTimeout > 0) - bip9_softforks.push_back(Pair(VersionBitsDeploymentInfo[id].name, BIP9SoftForkDesc(consensusParams, id))); + bip9_softforks.pushKV(VersionBitsDeploymentInfo[id].name, BIP9SoftForkDesc(consensusParams, id)); } UniValue getblockchaininfo(const JSONRPCRequest& request) @@ -1470,17 +1470,17 @@ UniValue getblockchaininfo(const JSONRPCRequest& request) LOCK(cs_main); UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("chain", Params().NetworkIDString())); - obj.push_back(Pair("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())); - obj.push_back(Pair("mediantime", (int64_t)chainActive.Tip()->GetMedianTimePast())); - obj.push_back(Pair("verificationprogress", GuessVerificationProgress(Params().TxData(), chainActive.Tip()))); - obj.push_back(Pair("initialblockdownload", IsInitialBlockDownload())); - obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex())); - obj.push_back(Pair("size_on_disk", CalculateCurrentUsage())); - obj.push_back(Pair("pruned", fPruneMode)); + obj.pushKV("chain", Params().NetworkIDString()); + obj.pushKV("blocks", (int)chainActive.Height()); + obj.pushKV("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1); + obj.pushKV("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()); + obj.pushKV("difficulty", (double)GetDifficulty()); + obj.pushKV("mediantime", (int64_t)chainActive.Tip()->GetMedianTimePast()); + obj.pushKV("verificationprogress", GuessVerificationProgress(Params().TxData(), chainActive.Tip())); + obj.pushKV("initialblockdownload", IsInitialBlockDownload()); + obj.pushKV("chainwork", chainActive.Tip()->nChainWork.GetHex()); + obj.pushKV("size_on_disk", CalculateCurrentUsage()); + obj.pushKV("pruned", fPruneMode); if (fPruneMode) { CBlockIndex* block = chainActive.Tip(); assert(block); @@ -1488,13 +1488,13 @@ UniValue getblockchaininfo(const JSONRPCRequest& request) block = block->pprev; } - obj.push_back(Pair("pruneheight", block->nHeight)); + obj.pushKV("pruneheight", block->nHeight); // if 0, execution bypasses the whole if block. bool automatic_pruning = (gArgs.GetArg("-prune", 0) != 1); - obj.push_back(Pair("automatic_pruning", automatic_pruning)); + obj.pushKV("automatic_pruning", automatic_pruning); if (automatic_pruning) { - obj.push_back(Pair("prune_target_size", nPruneTarget)); + obj.pushKV("prune_target_size", nPruneTarget); } } @@ -1509,10 +1509,10 @@ UniValue getblockchaininfo(const JSONRPCRequest& request) for (int pos = Consensus::DEPLOYMENT_CSV; pos != Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++pos) { BIP9SoftForkDescPushBack(bip9_softforks, consensusParams, static_cast(pos)); } - obj.push_back(Pair("softforks", softforks)); - obj.push_back(Pair("bip9_softforks", bip9_softforks)); + obj.pushKV("softforks", softforks); + obj.pushKV("bip9_softforks", bip9_softforks); - obj.push_back(Pair("warnings", GetWarnings("statusbar"))); + obj.pushKV("warnings", GetWarnings("statusbar")); return obj; } @@ -1624,12 +1624,12 @@ UniValue getchaintips(const JSONRPCRequest& request) if(nCountMax-- < 1) break; UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("height", block->nHeight)); - obj.push_back(Pair("hash", block->phashBlock->GetHex())); - obj.push_back(Pair("difficulty", GetDifficulty(block))); - obj.push_back(Pair("chainwork", block->nChainWork.GetHex())); - obj.push_back(Pair("branchlen", branchLen)); - obj.push_back(Pair("forkpoint", pindexFork->phashBlock->GetHex())); + obj.pushKV("height", block->nHeight); + obj.pushKV("hash", block->phashBlock->GetHex()); + obj.pushKV("difficulty", GetDifficulty(block)); + obj.pushKV("chainwork", block->nChainWork.GetHex()); + obj.pushKV("branchlen", branchLen); + obj.pushKV("forkpoint", pindexFork->phashBlock->GetHex()); std::string status; if (chainActive.Contains(block)) { @@ -1651,7 +1651,7 @@ UniValue getchaintips(const JSONRPCRequest& request) // No clue. status = "unknown"; } - obj.push_back(Pair("status", status)); + obj.pushKV("status", status); res.push_back(obj); } @@ -1662,14 +1662,14 @@ UniValue getchaintips(const JSONRPCRequest& request) 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.push_back(Pair("mempoolminfee", ValueFromAmount(std::max(mempool.GetMinFee(maxmempool), ::minRelayTxFee).GetFeePerK()))); - ret.push_back(Pair("minrelaytxfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); - ret.push_back(Pair("instantsendlocks", (int64_t)llmq::quorumInstantSendManager->GetInstantSendLockCount())); + ret.pushKV("maxmempool", (int64_t) maxmempool); + ret.pushKV("mempoolminfee", ValueFromAmount(std::max(mempool.GetMinFee(maxmempool), ::minRelayTxFee).GetFeePerK())); + ret.pushKV("minrelaytxfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())); + ret.pushKV("instantsendlocks", (int64_t)llmq::quorumInstantSendManager->GetInstantSendLockCount()); return ret; } @@ -1871,15 +1871,15 @@ UniValue getchaintxstats(const JSONRPCRequest& request) 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_final_block_hash", pindex->GetBlockHash().GetHex())); - 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_final_block_hash", pindex->GetBlockHash().GetHex()); + 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/governance.cpp b/src/rpc/governance.cpp index 1423b75324c2a..d6c925af8cfb7 100644 --- a/src/rpc/governance.cpp +++ b/src/rpc/governance.cpp @@ -112,7 +112,7 @@ UniValue gobject_check(const JSONRPCRequest& request) UniValue objResult(UniValue::VOBJ); - objResult.push_back(Pair("Object status", "OK")); + objResult.pushKV("Object status", "OK"); return objResult; } @@ -396,11 +396,11 @@ UniValue gobject_vote_conf(const JSONRPCRequest& request) if (!dmn) { nFailed++; - statusObj.push_back(Pair("result", "failed")); - statusObj.push_back(Pair("errorMessage", "Can't find masternode by collateral output")); - resultsObj.push_back(Pair("dash.conf", statusObj)); - returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed))); - returnObj.push_back(Pair("detail", resultsObj)); + statusObj.pushKV("result", "failed"); + statusObj.pushKV("errorMessage", "Can't find masternode by collateral output"); + resultsObj.pushKV("dash.conf", statusObj); + returnObj.pushKV("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed)); + returnObj.pushKV("detail", resultsObj); return returnObj; } @@ -416,28 +416,28 @@ UniValue gobject_vote_conf(const JSONRPCRequest& request) if (!signSuccess) { nFailed++; - statusObj.push_back(Pair("result", "failed")); - statusObj.push_back(Pair("errorMessage", "Failure to sign.")); - resultsObj.push_back(Pair("dash.conf", statusObj)); - returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed))); - returnObj.push_back(Pair("detail", resultsObj)); + statusObj.pushKV("result", "failed"); + statusObj.pushKV("errorMessage", "Failure to sign."); + resultsObj.pushKV("dash.conf", statusObj); + returnObj.pushKV("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed)); + returnObj.pushKV("detail", resultsObj); return returnObj; } CGovernanceException exception; if (governance.ProcessVoteAndRelay(vote, exception, *g_connman)) { nSuccessful++; - statusObj.push_back(Pair("result", "success")); + statusObj.pushKV("result", "success"); } else { nFailed++; - statusObj.push_back(Pair("result", "failed")); - statusObj.push_back(Pair("errorMessage", exception.GetMessage())); + statusObj.pushKV("result", "failed"); + statusObj.pushKV("errorMessage", exception.GetMessage()); } - resultsObj.push_back(Pair("dash.conf", statusObj)); + resultsObj.pushKV("dash.conf", statusObj); - returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed))); - returnObj.push_back(Pair("detail", resultsObj)); + returnObj.pushKV("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed)); + returnObj.pushKV("detail", resultsObj); return returnObj; } @@ -472,37 +472,37 @@ UniValue VoteWithMasternodes(const std::map& keys, auto dmn = mnList.GetValidMN(proTxHash); if (!dmn) { nFailed++; - statusObj.push_back(Pair("result", "failed")); - statusObj.push_back(Pair("errorMessage", "Can't find masternode by proTxHash")); - resultsObj.push_back(Pair(proTxHash.ToString(), statusObj)); + statusObj.pushKV("result", "failed"); + statusObj.pushKV("errorMessage", "Can't find masternode by proTxHash"); + resultsObj.pushKV(proTxHash.ToString(), statusObj); continue; } CGovernanceVote vote(dmn->collateralOutpoint, hash, eVoteSignal, eVoteOutcome); if (!vote.Sign(key, key.GetPubKey().GetID())) { nFailed++; - statusObj.push_back(Pair("result", "failed")); - statusObj.push_back(Pair("errorMessage", "Failure to sign.")); - resultsObj.push_back(Pair(proTxHash.ToString(), statusObj)); + statusObj.pushKV("result", "failed"); + statusObj.pushKV("errorMessage", "Failure to sign."); + resultsObj.pushKV(proTxHash.ToString(), statusObj); continue; } CGovernanceException exception; if (governance.ProcessVoteAndRelay(vote, exception, *g_connman)) { nSuccessful++; - statusObj.push_back(Pair("result", "success")); + statusObj.pushKV("result", "success"); } else { nFailed++; - statusObj.push_back(Pair("result", "failed")); - statusObj.push_back(Pair("errorMessage", exception.GetMessage())); + statusObj.pushKV("result", "failed"); + statusObj.pushKV("errorMessage", exception.GetMessage()); } - resultsObj.push_back(Pair(proTxHash.ToString(), statusObj)); + resultsObj.pushKV(proTxHash.ToString(), statusObj); } UniValue returnObj(UniValue::VOBJ); - returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed))); - returnObj.push_back(Pair("detail", resultsObj)); + returnObj.pushKV("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed)); + returnObj.pushKV("detail", resultsObj); return returnObj; } @@ -643,33 +643,33 @@ UniValue ListObjects(const std::string& strCachedSignal, const std::string& strT if (strType == "triggers" && pGovObj->GetObjectType() != GOVERNANCE_OBJECT_TRIGGER) continue; UniValue bObj(UniValue::VOBJ); - bObj.push_back(Pair("DataHex", pGovObj->GetDataAsHexString())); - bObj.push_back(Pair("DataString", pGovObj->GetDataAsPlainString())); - bObj.push_back(Pair("Hash", pGovObj->GetHash().ToString())); - bObj.push_back(Pair("CollateralHash", pGovObj->GetCollateralHash().ToString())); - bObj.push_back(Pair("ObjectType", pGovObj->GetObjectType())); - bObj.push_back(Pair("CreationTime", pGovObj->GetCreationTime())); + bObj.pushKV("DataHex", pGovObj->GetDataAsHexString()); + bObj.pushKV("DataString", pGovObj->GetDataAsPlainString()); + bObj.pushKV("Hash", pGovObj->GetHash().ToString()); + bObj.pushKV("CollateralHash", pGovObj->GetCollateralHash().ToString()); + bObj.pushKV("ObjectType", pGovObj->GetObjectType()); + bObj.pushKV("CreationTime", pGovObj->GetCreationTime()); const COutPoint& masternodeOutpoint = pGovObj->GetMasternodeOutpoint(); if (masternodeOutpoint != COutPoint()) { - bObj.push_back(Pair("SigningMasternode", masternodeOutpoint.ToStringShort())); + bObj.pushKV("SigningMasternode", masternodeOutpoint.ToStringShort()); } // REPORT STATUS FOR FUNDING VOTES SPECIFICALLY - bObj.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING))); - bObj.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_FUNDING))); - bObj.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_FUNDING))); - bObj.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_FUNDING))); + bObj.pushKV("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING)); + bObj.pushKV("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_FUNDING)); + bObj.pushKV("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_FUNDING)); + bObj.pushKV("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_FUNDING)); // REPORT VALIDITY AND CACHING FLAGS FOR VARIOUS SETTINGS std::string strError = ""; - bObj.push_back(Pair("fBlockchainValidity", pGovObj->IsValidLocally(strError, false))); - bObj.push_back(Pair("IsValidReason", strError.c_str())); - bObj.push_back(Pair("fCachedValid", pGovObj->IsSetCachedValid())); - bObj.push_back(Pair("fCachedFunding", pGovObj->IsSetCachedFunding())); - bObj.push_back(Pair("fCachedDelete", pGovObj->IsSetCachedDelete())); - bObj.push_back(Pair("fCachedEndorsed", pGovObj->IsSetCachedEndorsed())); - - objResult.push_back(Pair(pGovObj->GetHash().ToString(), bObj)); + bObj.pushKV("fBlockchainValidity", pGovObj->IsValidLocally(strError, false)); + bObj.pushKV("IsValidReason", strError.c_str()); + bObj.pushKV("fCachedValid", pGovObj->IsSetCachedValid()); + bObj.pushKV("fCachedFunding", pGovObj->IsSetCachedFunding()); + bObj.pushKV("fCachedDelete", pGovObj->IsSetCachedDelete()); + bObj.pushKV("fCachedEndorsed", pGovObj->IsSetCachedEndorsed()); + + objResult.pushKV(pGovObj->GetHash().ToString(), bObj); } return objResult; @@ -771,59 +771,59 @@ UniValue gobject_get(const JSONRPCRequest& request) // REPORT BASIC OBJECT STATS UniValue objResult(UniValue::VOBJ); - objResult.push_back(Pair("DataHex", pGovObj->GetDataAsHexString())); - objResult.push_back(Pair("DataString", pGovObj->GetDataAsPlainString())); - objResult.push_back(Pair("Hash", pGovObj->GetHash().ToString())); - objResult.push_back(Pair("CollateralHash", pGovObj->GetCollateralHash().ToString())); - objResult.push_back(Pair("ObjectType", pGovObj->GetObjectType())); - objResult.push_back(Pair("CreationTime", pGovObj->GetCreationTime())); + objResult.pushKV("DataHex", pGovObj->GetDataAsHexString()); + objResult.pushKV("DataString", pGovObj->GetDataAsPlainString()); + objResult.pushKV("Hash", pGovObj->GetHash().ToString()); + objResult.pushKV("CollateralHash", pGovObj->GetCollateralHash().ToString()); + objResult.pushKV("ObjectType", pGovObj->GetObjectType()); + objResult.pushKV("CreationTime", pGovObj->GetCreationTime()); const COutPoint& masternodeOutpoint = pGovObj->GetMasternodeOutpoint(); if (masternodeOutpoint != COutPoint()) { - objResult.push_back(Pair("SigningMasternode", masternodeOutpoint.ToStringShort())); + objResult.pushKV("SigningMasternode", masternodeOutpoint.ToStringShort()); } // SHOW (MUCH MORE) INFORMATION ABOUT VOTES FOR GOVERNANCE OBJECT (THAN LIST/DIFF ABOVE) // -- FUNDING VOTING RESULTS UniValue objFundingResult(UniValue::VOBJ); - objFundingResult.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING))); - objFundingResult.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_FUNDING))); - objFundingResult.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_FUNDING))); - objFundingResult.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_FUNDING))); - objResult.push_back(Pair("FundingResult", objFundingResult)); + objFundingResult.pushKV("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING)); + objFundingResult.pushKV("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_FUNDING)); + objFundingResult.pushKV("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_FUNDING)); + objFundingResult.pushKV("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_FUNDING)); + objResult.pushKV("FundingResult", objFundingResult); // -- VALIDITY VOTING RESULTS UniValue objValid(UniValue::VOBJ); - objValid.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_VALID))); - objValid.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_VALID))); - objValid.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_VALID))); - objValid.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_VALID))); - objResult.push_back(Pair("ValidResult", objValid)); + objValid.pushKV("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_VALID)); + objValid.pushKV("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_VALID)); + objValid.pushKV("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_VALID)); + objValid.pushKV("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_VALID)); + objResult.pushKV("ValidResult", objValid); // -- DELETION CRITERION VOTING RESULTS UniValue objDelete(UniValue::VOBJ); - objDelete.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_DELETE))); - objDelete.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_DELETE))); - objDelete.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_DELETE))); - objDelete.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_DELETE))); - objResult.push_back(Pair("DeleteResult", objDelete)); + objDelete.pushKV("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_DELETE)); + objDelete.pushKV("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_DELETE)); + objDelete.pushKV("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_DELETE)); + objDelete.pushKV("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_DELETE)); + objResult.pushKV("DeleteResult", objDelete); // -- ENDORSED VIA MASTERNODE-ELECTED BOARD UniValue objEndorsed(UniValue::VOBJ); - objEndorsed.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_ENDORSED))); - objEndorsed.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_ENDORSED))); - objEndorsed.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_ENDORSED))); - objEndorsed.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_ENDORSED))); - objResult.push_back(Pair("EndorsedResult", objEndorsed)); + objEndorsed.pushKV("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_ENDORSED)); + objEndorsed.pushKV("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_ENDORSED)); + objEndorsed.pushKV("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_ENDORSED)); + objEndorsed.pushKV("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_ENDORSED)); + objResult.pushKV("EndorsedResult", objEndorsed); // -- std::string strError = ""; - objResult.push_back(Pair("fLocalValidity", pGovObj->IsValidLocally(strError, false))); - objResult.push_back(Pair("IsValidReason", strError.c_str())); - objResult.push_back(Pair("fCachedValid", pGovObj->IsSetCachedValid())); - objResult.push_back(Pair("fCachedFunding", pGovObj->IsSetCachedFunding())); - objResult.push_back(Pair("fCachedDelete", pGovObj->IsSetCachedDelete())); - objResult.push_back(Pair("fCachedEndorsed", pGovObj->IsSetCachedEndorsed())); + objResult.pushKV("fLocalValidity", pGovObj->IsValidLocally(strError, false)); + objResult.pushKV("IsValidReason", strError.c_str()); + objResult.pushKV("fCachedValid", pGovObj->IsSetCachedValid()); + objResult.pushKV("fCachedFunding", pGovObj->IsSetCachedFunding()); + objResult.pushKV("fCachedDelete", pGovObj->IsSetCachedDelete()); + objResult.pushKV("fCachedEndorsed", pGovObj->IsSetCachedEndorsed()); return objResult; } @@ -873,7 +873,7 @@ UniValue gobject_getcurrentvotes(const JSONRPCRequest& request) std::vector vecVotes = governance.GetCurrentVotes(hash, mnCollateralOutpoint); for (const auto& vote : vecVotes) { - bResult.push_back(Pair(vote.GetHash().ToString(), vote.ToString())); + bResult.pushKV(vote.GetHash().ToString(), vote.ToString()); } return bResult; @@ -1060,11 +1060,11 @@ UniValue getgovernanceinfo(const JSONRPCRequest& request) CSuperblock::GetNearestSuperblocksHeights(nBlockHeight, nLastSuperblock, nNextSuperblock); UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("governanceminquorum", Params().GetConsensus().nGovernanceMinQuorum)); - obj.push_back(Pair("proposalfee", ValueFromAmount(GOVERNANCE_PROPOSAL_FEE_TX))); - obj.push_back(Pair("superblockcycle", Params().GetConsensus().nSuperblockCycle)); - obj.push_back(Pair("lastsuperblock", nLastSuperblock)); - obj.push_back(Pair("nextsuperblock", nNextSuperblock)); + obj.pushKV("governanceminquorum", Params().GetConsensus().nGovernanceMinQuorum); + obj.pushKV("proposalfee", ValueFromAmount(GOVERNANCE_PROPOSAL_FEE_TX)); + obj.pushKV("superblockcycle", Params().GetConsensus().nSuperblockCycle); + obj.pushKV("lastsuperblock", nLastSuperblock); + obj.pushKV("nextsuperblock", nNextSuperblock); return obj; } diff --git a/src/rpc/masternode.cpp b/src/rpc/masternode.cpp index 93c16adfe994d..52a0a0936c15b 100644 --- a/src/rpc/masternode.cpp +++ b/src/rpc/masternode.cpp @@ -132,8 +132,8 @@ UniValue masternode_count(const JSONRPCRequest& request) if (request.params.size() == 1) { UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("total", total)); - obj.push_back(Pair("enabled", enabled)); + obj.pushKV("total", total); + obj.pushKV("enabled", enabled); return obj; } @@ -167,11 +167,11 @@ UniValue GetNextMasternodeForPayment(int heightShift) UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("height", mnList.GetHeight() + heightShift)); - obj.push_back(Pair("IP:port", payee->pdmnState->addr.ToString())); - obj.push_back(Pair("proTxHash", payee->proTxHash.ToString())); - obj.push_back(Pair("outpoint", payee->collateralOutpoint.ToStringShort())); - obj.push_back(Pair("payee", IsValidDestination(payeeDest) ? EncodeDestination(payeeDest) : "UNKNOWN")); + obj.pushKV("height", mnList.GetHeight() + heightShift); + obj.pushKV("IP:port", payee->pdmnState->addr.ToString()); + obj.pushKV("proTxHash", payee->proTxHash.ToString()); + obj.pushKV("outpoint", payee->collateralOutpoint.ToStringShort()); + obj.pushKV("payee", IsValidDestination(payeeDest) ? EncodeDestination(payeeDest) : "UNKNOWN"); return obj; } @@ -233,7 +233,7 @@ UniValue masternode_outputs(const JSONRPCRequest& request) UniValue obj(UniValue::VOBJ); for (const auto& out : vPossibleCoins) { - obj.push_back(Pair(out.tx->GetHash().ToString(), strprintf("%d", out.i))); + obj.pushKV(out.tx->GetHash().ToString(), strprintf("%d", out.i)); } return obj; @@ -260,20 +260,20 @@ UniValue masternode_status(const JSONRPCRequest& request) UniValue mnObj(UniValue::VOBJ); // keep compatibility with legacy status for now (might get deprecated/removed later) - mnObj.push_back(Pair("outpoint", activeMasternodeInfo.outpoint.ToStringShort())); - mnObj.push_back(Pair("service", activeMasternodeInfo.service.ToString())); + mnObj.pushKV("outpoint", activeMasternodeInfo.outpoint.ToStringShort()); + mnObj.pushKV("service", activeMasternodeInfo.service.ToString()); auto dmn = deterministicMNManager->GetListAtChainTip().GetMN(activeMasternodeInfo.proTxHash); if (dmn) { - mnObj.push_back(Pair("proTxHash", dmn->proTxHash.ToString())); - mnObj.push_back(Pair("collateralHash", dmn->collateralOutpoint.hash.ToString())); - mnObj.push_back(Pair("collateralIndex", (int)dmn->collateralOutpoint.n)); + mnObj.pushKV("proTxHash", dmn->proTxHash.ToString()); + mnObj.pushKV("collateralHash", dmn->collateralOutpoint.hash.ToString()); + mnObj.pushKV("collateralIndex", (int)dmn->collateralOutpoint.n); UniValue stateObj; dmn->pdmnState->ToJson(stateObj); - mnObj.push_back(Pair("dmnState", stateObj)); + mnObj.pushKV("dmnState", stateObj); } - mnObj.push_back(Pair("state", activeMasternodeManager->GetStateString())); - mnObj.push_back(Pair("status", activeMasternodeManager->GetStatus())); + mnObj.pushKV("state", activeMasternodeManager->GetStateString()); + mnObj.pushKV("status", activeMasternodeManager->GetStatus()); return mnObj; } @@ -317,7 +317,7 @@ UniValue masternode_winners(const JSONRPCRequest& request) UniValue obj(UniValue::VOBJ); auto mapPayments = GetRequiredPaymentsStrings(nHeight - nLast, nHeight + 20); for (const auto &p : mapPayments) { - obj.push_back(Pair(strprintf("%d", p.first), p.second)); + obj.pushKV(strprintf("%d", p.first), p.second); } return obj; @@ -441,7 +441,7 @@ UniValue masternodelist(const JSONRPCRequest& request) std::string strAddress = dmn->pdmnState->addr.ToString(false); if (strFilter !="" && strAddress.find(strFilter) == std::string::npos && strOutpoint.find(strFilter) == std::string::npos) return; - obj.push_back(Pair(strOutpoint, strAddress)); + obj.pushKV(strOutpoint, strAddress); } else if (strMode == "full") { std::ostringstream streamFull; streamFull << std::setw(18) << @@ -453,7 +453,7 @@ UniValue masternodelist(const JSONRPCRequest& request) std::string strFull = streamFull.str(); if (strFilter !="" && strFull.find(strFilter) == std::string::npos && strOutpoint.find(strFilter) == std::string::npos) return; - obj.push_back(Pair(strOutpoint, strFull)); + obj.pushKV(strOutpoint, strFull); } else if (strMode == "info") { std::ostringstream streamInfo; streamInfo << std::setw(18) << @@ -463,7 +463,7 @@ UniValue masternodelist(const JSONRPCRequest& request) std::string strInfo = streamInfo.str(); if (strFilter !="" && strInfo.find(strFilter) == std::string::npos && strOutpoint.find(strFilter) == std::string::npos) return; - obj.push_back(Pair(strOutpoint, strInfo)); + obj.pushKV(strOutpoint, strInfo); } else if (strMode == "json") { std::ostringstream streamInfo; streamInfo << dmn->proTxHash.ToString() << " " << @@ -480,41 +480,41 @@ UniValue masternodelist(const JSONRPCRequest& request) if (strFilter !="" && strInfo.find(strFilter) == std::string::npos && strOutpoint.find(strFilter) == std::string::npos) return; UniValue objMN(UniValue::VOBJ); - objMN.push_back(Pair("proTxHash", dmn->proTxHash.ToString())); - objMN.push_back(Pair("address", dmn->pdmnState->addr.ToString())); - objMN.push_back(Pair("payee", payeeStr)); - objMN.push_back(Pair("status", dmnToStatus(dmn))); - objMN.push_back(Pair("lastpaidtime", dmnToLastPaidTime(dmn))); - objMN.push_back(Pair("lastpaidblock", dmn->pdmnState->nLastPaidHeight)); - objMN.push_back(Pair("owneraddress", EncodeDestination(dmn->pdmnState->keyIDOwner))); - objMN.push_back(Pair("votingaddress", EncodeDestination(dmn->pdmnState->keyIDVoting))); - objMN.push_back(Pair("collateraladdress", collateralAddressStr)); - objMN.push_back(Pair("pubkeyoperator", dmn->pdmnState->pubKeyOperator.Get().ToString())); - obj.push_back(Pair(strOutpoint, objMN)); + objMN.pushKV("proTxHash", dmn->proTxHash.ToString()); + objMN.pushKV("address", dmn->pdmnState->addr.ToString()); + objMN.pushKV("payee", payeeStr); + objMN.pushKV("status", dmnToStatus(dmn)); + objMN.pushKV("lastpaidtime", dmnToLastPaidTime(dmn)); + objMN.pushKV("lastpaidblock", dmn->pdmnState->nLastPaidHeight); + objMN.pushKV("owneraddress", EncodeDestination(dmn->pdmnState->keyIDOwner)); + objMN.pushKV("votingaddress", EncodeDestination(dmn->pdmnState->keyIDVoting)); + objMN.pushKV("collateraladdress", collateralAddressStr); + objMN.pushKV("pubkeyoperator", dmn->pdmnState->pubKeyOperator.Get().ToString()); + obj.pushKV(strOutpoint, objMN); } else if (strMode == "lastpaidblock") { if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) return; - obj.push_back(Pair(strOutpoint, dmn->pdmnState->nLastPaidHeight)); + obj.pushKV(strOutpoint, dmn->pdmnState->nLastPaidHeight); } else if (strMode == "lastpaidtime") { if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) return; - obj.push_back(Pair(strOutpoint, dmnToLastPaidTime(dmn))); + obj.pushKV(strOutpoint, dmnToLastPaidTime(dmn)); } else if (strMode == "payee") { if (strFilter !="" && payeeStr.find(strFilter) == std::string::npos && strOutpoint.find(strFilter) == std::string::npos) return; - obj.push_back(Pair(strOutpoint, payeeStr)); + obj.pushKV(strOutpoint, payeeStr); } else if (strMode == "owneraddress") { if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) return; - obj.push_back(Pair(strOutpoint, EncodeDestination(dmn->pdmnState->keyIDOwner))); + obj.pushKV(strOutpoint, EncodeDestination(dmn->pdmnState->keyIDOwner)); } else if (strMode == "pubkeyoperator") { if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) return; - obj.push_back(Pair(strOutpoint, dmn->pdmnState->pubKeyOperator.Get().ToString())); + obj.pushKV(strOutpoint, dmn->pdmnState->pubKeyOperator.Get().ToString()); } else if (strMode == "status") { std::string strStatus = dmnToStatus(dmn); if (strFilter !="" && strStatus.find(strFilter) == std::string::npos && strOutpoint.find(strFilter) == std::string::npos) return; - obj.push_back(Pair(strOutpoint, strStatus)); + obj.pushKV(strOutpoint, strStatus); } else if (strMode == "votingaddress") { if (strFilter !="" && strOutpoint.find(strFilter) == std::string::npos) return; - obj.push_back(Pair(strOutpoint, EncodeDestination(dmn->pdmnState->keyIDVoting))); + obj.pushKV(strOutpoint, EncodeDestination(dmn->pdmnState->keyIDVoting)); } }); diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 641d0777dc754..8baf5b60f112d 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -223,14 +223,14 @@ UniValue getmininginfo(const JSONRPCRequest& request) 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())); - obj.push_back(Pair("networkhashps", getnetworkhashps(request))); - obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); - obj.push_back(Pair("chain", Params().NetworkIDString())); - obj.push_back(Pair("warnings", GetWarnings("statusbar"))); + obj.pushKV("blocks", (int)chainActive.Height()); + obj.pushKV("currentblocksize", (uint64_t)nLastBlockSize); + obj.pushKV("currentblocktx", (uint64_t)nLastBlockTx); + obj.pushKV("difficulty", (double)GetDifficulty()); + obj.pushKV("networkhashps", getnetworkhashps(request)); + obj.pushKV("pooledtx", (uint64_t)mempool.size()); + obj.pushKV("chain", Params().NetworkIDString()); + obj.pushKV("warnings", GetWarnings("statusbar")); return obj; } @@ -571,9 +571,9 @@ UniValue getblocktemplate(const JSONRPCRequest& request) UniValue entry(UniValue::VOBJ); - entry.push_back(Pair("data", EncodeHexTx(tx))); + entry.pushKV("data", EncodeHexTx(tx)); - entry.push_back(Pair("hash", txHash.GetHex())); + entry.pushKV("hash", txHash.GetHex()); UniValue deps(UniValue::VARR); for (const CTxIn &in : tx.vin) @@ -581,17 +581,17 @@ UniValue getblocktemplate(const JSONRPCRequest& request) if (setTxIndex.count(in.prevout.hash)) deps.push_back(setTxIndex[in.prevout.hash]); } - 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])); - entry.push_back(Pair("sigops", pblocktemplate->vTxSigOps[index_in_template])); + entry.pushKV("fee", pblocktemplate->vTxFees[index_in_template]); + entry.pushKV("sigops", pblocktemplate->vTxSigOps[index_in_template]); transactions.push_back(entry); } UniValue aux(UniValue::VOBJ); - aux.push_back(Pair("flags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end()))); + aux.pushKV("flags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end())); arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits); @@ -601,7 +601,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request) aMutable.push_back("prevblock"); UniValue result(UniValue::VOBJ); - result.push_back(Pair("capabilities", aCaps)); + result.pushKV("capabilities", aCaps); UniValue aRules(UniValue::VARR); UniValue vbavailable(UniValue::VOBJ); @@ -620,7 +620,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request) case ThresholdState::STARTED: { const struct VBDeploymentInfo& vbinfo = VersionBitsDeploymentInfo[pos]; - vbavailable.push_back(Pair(gbt_vb_name(pos), consensusParams.vDeployments[pos].bit)); + vbavailable.pushKV(gbt_vb_name(pos), consensusParams.vDeployments[pos].bit); if (setClientRules.find(vbinfo.name) == setClientRules.end()) { if (!vbinfo.gbt_force) { // If the client doesn't support this, don't indicate it in the [default] version @@ -645,10 +645,10 @@ UniValue getblocktemplate(const JSONRPCRequest& request) } } } - result.push_back(Pair("version", pblock->nVersion)); - result.push_back(Pair("rules", aRules)); - result.push_back(Pair("vbavailable", vbavailable)); - result.push_back(Pair("vbrequired", int(0))); + result.pushKV("version", pblock->nVersion); + result.pushKV("rules", aRules); + result.pushKV("vbavailable", vbavailable); + result.pushKV("vbrequired", int(0)); if (nMaxVersionPreVB >= 2) { // If VB is supported by the client, nMaxVersionPreVB is -1, so we won't get here @@ -658,21 +658,21 @@ UniValue getblocktemplate(const JSONRPCRequest& request) aMutable.push_back("version/force"); } - result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex())); - result.push_back(Pair("transactions", transactions)); - result.push_back(Pair("coinbaseaux", aux)); - result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0]->GetValueOut())); - result.push_back(Pair("longpollid", chainActive.Tip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast))); - result.push_back(Pair("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.push_back(Pair("sigoplimit", (int64_t)MaxBlockSigOps(fDIP0001ActiveAtTip))); - result.push_back(Pair("sizelimit", (int64_t)MaxBlockSize(fDIP0001ActiveAtTip))); - result.push_back(Pair("curtime", pblock->GetBlockTime())); - result.push_back(Pair("bits", strprintf("%08x", pblock->nBits))); - result.push_back(Pair("previousbits", strprintf("%08x", pblocktemplate->nPrevBits))); - result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1))); + result.pushKV("previousblockhash", pblock->hashPrevBlock.GetHex()); + result.pushKV("transactions", transactions); + result.pushKV("coinbaseaux", aux); + result.pushKV("coinbasevalue", (int64_t)pblock->vtx[0]->GetValueOut()); + result.pushKV("longpollid", chainActive.Tip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast)); + result.pushKV("target", hashTarget.GetHex()); + result.pushKV("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1); + result.pushKV("mutable", aMutable); + result.pushKV("noncerange", "00000000ffffffff"); + result.pushKV("sigoplimit", (int64_t)MaxBlockSigOps(fDIP0001ActiveAtTip)); + result.pushKV("sizelimit", (int64_t)MaxBlockSize(fDIP0001ActiveAtTip)); + result.pushKV("curtime", pblock->GetBlockTime()); + result.pushKV("bits", strprintf("%08x", pblock->nBits)); + result.pushKV("previousbits", strprintf("%08x", pblocktemplate->nPrevBits)); + result.pushKV("height", (int64_t)(pindexPrev->nHeight+1)); UniValue masternodeObj(UniValue::VARR); for (const auto& txout : pblocktemplate->voutMasternodePayments) { @@ -680,15 +680,15 @@ UniValue getblocktemplate(const JSONRPCRequest& request) ExtractDestination(txout.scriptPubKey, dest); UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("payee", EncodeDestination(dest).c_str())); - obj.push_back(Pair("script", HexStr(txout.scriptPubKey))); - obj.push_back(Pair("amount", txout.nValue)); + obj.pushKV("payee", EncodeDestination(dest).c_str()); + obj.pushKV("script", HexStr(txout.scriptPubKey)); + obj.pushKV("amount", txout.nValue); masternodeObj.push_back(obj); } - result.push_back(Pair("masternode", masternodeObj)); - result.push_back(Pair("masternode_payments_started", pindexPrev->nHeight + 1 > consensusParams.nMasternodePaymentsStartBlock)); - result.push_back(Pair("masternode_payments_enforced", true)); + result.pushKV("masternode", masternodeObj); + result.pushKV("masternode_payments_started", pindexPrev->nHeight + 1 > consensusParams.nMasternodePaymentsStartBlock); + result.pushKV("masternode_payments_enforced", true); UniValue superblockObjArray(UniValue::VARR); if(pblocktemplate->voutSuperblockPayments.size()) { @@ -696,17 +696,17 @@ UniValue getblocktemplate(const JSONRPCRequest& request) UniValue entry(UniValue::VOBJ); CTxDestination dest; ExtractDestination(txout.scriptPubKey, dest); - entry.push_back(Pair("payee", EncodeDestination(dest).c_str())); - entry.push_back(Pair("script", HexStr(txout.scriptPubKey))); - entry.push_back(Pair("amount", txout.nValue)); + entry.pushKV("payee", EncodeDestination(dest).c_str()); + entry.pushKV("script", HexStr(txout.scriptPubKey)); + entry.pushKV("amount", txout.nValue); superblockObjArray.push_back(entry); } } - result.push_back(Pair("superblock", superblockObjArray)); - result.push_back(Pair("superblocks_started", pindexPrev->nHeight + 1 > consensusParams.nSuperblockStartBlock)); - result.push_back(Pair("superblocks_enabled", sporkManager.IsSporkActive(SPORK_9_SUPERBLOCKS_ENABLED))); + result.pushKV("superblock", superblockObjArray); + result.pushKV("superblocks_started", pindexPrev->nHeight + 1 > consensusParams.nSuperblockStartBlock); + result.pushKV("superblocks_enabled", sporkManager.IsSporkActive(SPORK_9_SUPERBLOCKS_ENABLED)); - result.push_back(Pair("coinbase_payload", HexStr(pblock->vtx[0]->vExtraPayload))); + result.pushKV("coinbase_payload", HexStr(pblock->vtx[0]->vExtraPayload)); return result; } @@ -849,12 +849,12 @@ UniValue estimatesmartfee(const JSONRPCRequest& request) FeeCalculation feeCalc; CFeeRate feeRate = ::feeEstimator.estimateSmartFee(conf_target, &feeCalc, conservative); if (feeRate != CFeeRate(0)) { - result.push_back(Pair("feerate", ValueFromAmount(feeRate.GetFeePerK()))); + result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK())); } else { errors.push_back("Insufficient data or no feerate found"); - result.push_back(Pair("errors", errors)); + result.pushKV("errors", errors); } - result.push_back(Pair("blocks", feeCalc.returnedTarget)); + result.pushKV("blocks", feeCalc.returnedTarget); return result; } @@ -924,37 +924,37 @@ UniValue estimaterawfee(const JSONRPCRequest& request) UniValue horizon_result(UniValue::VOBJ); UniValue errors(UniValue::VARR); UniValue passbucket(UniValue::VOBJ); - passbucket.push_back(Pair("startrange", round(buckets.pass.start))); - passbucket.push_back(Pair("endrange", round(buckets.pass.end))); - passbucket.push_back(Pair("withintarget", round(buckets.pass.withinTarget * 100.0) / 100.0)); - passbucket.push_back(Pair("totalconfirmed", round(buckets.pass.totalConfirmed * 100.0) / 100.0)); - passbucket.push_back(Pair("inmempool", round(buckets.pass.inMempool * 100.0) / 100.0)); - passbucket.push_back(Pair("leftmempool", round(buckets.pass.leftMempool * 100.0) / 100.0)); + passbucket.pushKV("startrange", round(buckets.pass.start)); + passbucket.pushKV("endrange", round(buckets.pass.end)); + passbucket.pushKV("withintarget", round(buckets.pass.withinTarget * 100.0) / 100.0); + passbucket.pushKV("totalconfirmed", round(buckets.pass.totalConfirmed * 100.0) / 100.0); + passbucket.pushKV("inmempool", round(buckets.pass.inMempool * 100.0) / 100.0); + passbucket.pushKV("leftmempool", round(buckets.pass.leftMempool * 100.0) / 100.0); UniValue failbucket(UniValue::VOBJ); - failbucket.push_back(Pair("startrange", round(buckets.fail.start))); - failbucket.push_back(Pair("endrange", round(buckets.fail.end))); - failbucket.push_back(Pair("withintarget", round(buckets.fail.withinTarget * 100.0) / 100.0)); - failbucket.push_back(Pair("totalconfirmed", round(buckets.fail.totalConfirmed * 100.0) / 100.0)); - failbucket.push_back(Pair("inmempool", round(buckets.fail.inMempool * 100.0) / 100.0)); - failbucket.push_back(Pair("leftmempool", round(buckets.fail.leftMempool * 100.0) / 100.0)); + failbucket.pushKV("startrange", round(buckets.fail.start)); + failbucket.pushKV("endrange", round(buckets.fail.end)); + failbucket.pushKV("withintarget", round(buckets.fail.withinTarget * 100.0) / 100.0); + failbucket.pushKV("totalconfirmed", round(buckets.fail.totalConfirmed * 100.0) / 100.0); + failbucket.pushKV("inmempool", round(buckets.fail.inMempool * 100.0) / 100.0); + failbucket.pushKV("leftmempool", round(buckets.fail.leftMempool * 100.0) / 100.0); // CFeeRate(0) is used to indicate error as a return value from estimateRawFee if (feeRate != CFeeRate(0)) { - horizon_result.push_back(Pair("feerate", ValueFromAmount(feeRate.GetFeePerK()))); - horizon_result.push_back(Pair("decay", buckets.decay)); - horizon_result.push_back(Pair("scale", (int)buckets.scale)); - horizon_result.push_back(Pair("pass", passbucket)); + horizon_result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK())); + horizon_result.pushKV("decay", buckets.decay); + horizon_result.pushKV("scale", (int)buckets.scale); + horizon_result.pushKV("pass", passbucket); // buckets.fail.start == -1 indicates that all buckets passed, there is no fail bucket to output - if (buckets.fail.start != -1) horizon_result.push_back(Pair("fail", failbucket)); + if (buckets.fail.start != -1) horizon_result.pushKV("fail", failbucket); } else { // Output only information that is still meaningful in the event of error - horizon_result.push_back(Pair("decay", buckets.decay)); - horizon_result.push_back(Pair("scale", (int)buckets.scale)); - horizon_result.push_back(Pair("fail", failbucket)); + horizon_result.pushKV("decay", buckets.decay); + horizon_result.pushKV("scale", (int)buckets.scale); + horizon_result.pushKV("fail", failbucket); errors.push_back("Insufficient data or no feerate found which meets threshold"); - horizon_result.push_back(Pair("errors",errors)); + horizon_result.pushKV("errors",errors); } - result.push_back(Pair(StringForFeeEstimateHorizon(horizon), horizon_result)); + result.pushKV(StringForFeeEstimateHorizon(horizon), horizon_result); } return result; } diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 5f6c4cb01f09a..e25f7e3a0e1eb 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -91,13 +91,13 @@ UniValue mnsync(const JSONRPCRequest& request) if(strMode == "status") { UniValue objStatus(UniValue::VOBJ); - objStatus.push_back(Pair("AssetID", masternodeSync.GetAssetID())); - objStatus.push_back(Pair("AssetName", masternodeSync.GetAssetName())); - objStatus.push_back(Pair("AssetStartTime", masternodeSync.GetAssetStartTime())); - objStatus.push_back(Pair("Attempt", masternodeSync.GetAttempt())); - objStatus.push_back(Pair("IsBlockchainSynced", masternodeSync.IsBlockchainSynced())); - objStatus.push_back(Pair("IsSynced", masternodeSync.IsSynced())); - objStatus.push_back(Pair("IsFailed", masternodeSync.IsFailed())); + objStatus.pushKV("AssetID", masternodeSync.GetAssetID()); + objStatus.pushKV("AssetName", masternodeSync.GetAssetName()); + objStatus.pushKV("AssetStartTime", masternodeSync.GetAssetStartTime()); + objStatus.pushKV("Attempt", masternodeSync.GetAttempt()); + objStatus.pushKV("IsBlockchainSynced", masternodeSync.IsBlockchainSynced()); + objStatus.pushKV("IsSynced", masternodeSync.IsSynced()); + objStatus.pushKV("IsFailed", masternodeSync.IsFailed()); return objStatus; } @@ -129,10 +129,10 @@ class DescribeAddressVisitor : public boost::static_visitor 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; } @@ -140,21 +140,21 @@ class DescribeAddressVisitor : public boost::static_visitor 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.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end()))); + obj.pushKV("script", GetTxnOutputType(whichType)); + obj.pushKV("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; } @@ -172,13 +172,13 @@ UniValue spork(const JSONRPCRequest& request) if (strCommand == "show") { UniValue ret(UniValue::VOBJ); for (const auto& sporkDef : sporkDefs) { - ret.push_back(Pair(sporkDef.name, sporkManager.GetSporkValue(sporkDef.sporkId))); + ret.pushKV(sporkDef.name, sporkManager.GetSporkValue(sporkDef.sporkId)); } return ret; } else if(strCommand == "active"){ UniValue ret(UniValue::VOBJ); for (const auto& sporkDef : sporkDefs) { - ret.push_back(Pair(sporkDef.name, sporkManager.IsSporkActive(sporkDef.sporkId))); + ret.pushKV(sporkDef.name, sporkManager.IsSporkActive(sporkDef.sporkId)); } return ret; } @@ -285,23 +285,23 @@ UniValue validateaddress(const JSONRPCRequest& request) 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", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); + ret.pushKV("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end())); #ifdef ENABLE_WALLET isminetype mine = pwallet ? IsMine(*pwallet, dest) : ISMINE_NO; - ret.push_back(Pair("ismine", bool(mine & ISMINE_SPENDABLE))); - ret.push_back(Pair("iswatchonly", bool(mine & ISMINE_WATCH_ONLY))); + ret.pushKV("ismine", bool(mine & ISMINE_SPENDABLE)); + ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY)); 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 CKeyMetadata* meta = nullptr; @@ -319,13 +319,13 @@ UniValue validateaddress(const JSONRPCRequest& request) } } if (meta) { - ret.push_back(Pair("timestamp", meta->nCreateTime)); + ret.pushKV("timestamp", meta->nCreateTime); } CHDChain hdChainCurrent; if (keyID && pwallet->mapHdPubKeys.count(*keyID) && pwallet->GetHDChain(hdChainCurrent)) { - ret.push_back(Pair("hdkeypath", pwallet->mapHdPubKeys[*keyID].GetKeyPath())); - ret.push_back(Pair("hdchainid", hdChainCurrent.GetID().GetHex())); + ret.pushKV("hdkeypath", pwallet->mapHdPubKeys[*keyID].GetKeyPath()); + ret.pushKV("hdchainid", hdChainCurrent.GetID().GetHex()); } } #endif @@ -385,8 +385,8 @@ UniValue createmultisig(const JSONRPCRequest& request) 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; } @@ -642,14 +642,14 @@ UniValue getaddressmempool(const JSONRPCRequest& request) } UniValue delta(UniValue::VOBJ); - delta.push_back(Pair("address", address)); - delta.push_back(Pair("txid", it->first.txhash.GetHex())); - delta.push_back(Pair("index", (int)it->first.index)); - delta.push_back(Pair("satoshis", it->second.amount)); - delta.push_back(Pair("timestamp", it->second.time)); + delta.pushKV("address", address); + delta.pushKV("txid", it->first.txhash.GetHex()); + delta.pushKV("index", (int)it->first.index); + delta.pushKV("satoshis", it->second.amount); + delta.pushKV("timestamp", it->second.time); if (it->second.amount < 0) { - delta.push_back(Pair("prevtxid", it->second.prevhash.GetHex())); - delta.push_back(Pair("prevout", (int)it->second.prevout)); + delta.pushKV("prevtxid", it->second.prevhash.GetHex()); + delta.pushKV("prevout", (int)it->second.prevout); } result.push_back(delta); } @@ -712,12 +712,12 @@ UniValue getaddressutxos(const JSONRPCRequest& request) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type"); } - output.push_back(Pair("address", address)); - output.push_back(Pair("txid", it->first.txhash.GetHex())); - output.push_back(Pair("outputIndex", (int)it->first.index)); - output.push_back(Pair("script", HexStr(it->second.script.begin(), it->second.script.end()))); - output.push_back(Pair("satoshis", it->second.satoshis)); - output.push_back(Pair("height", it->second.blockHeight)); + output.pushKV("address", address); + output.pushKV("txid", it->first.txhash.GetHex()); + output.pushKV("outputIndex", (int)it->first.index); + output.pushKV("script", HexStr(it->second.script.begin(), it->second.script.end())); + output.pushKV("satoshis", it->second.satoshis); + output.pushKV("height", it->second.blockHeight); result.push_back(output); } @@ -800,12 +800,12 @@ UniValue getaddressdeltas(const JSONRPCRequest& request) } UniValue delta(UniValue::VOBJ); - delta.push_back(Pair("satoshis", it->second)); - delta.push_back(Pair("txid", it->first.txhash.GetHex())); - delta.push_back(Pair("index", (int)it->first.index)); - delta.push_back(Pair("blockindex", (int)it->first.txindex)); - delta.push_back(Pair("height", it->first.blockHeight)); - delta.push_back(Pair("address", address)); + delta.pushKV("satoshis", it->second); + delta.pushKV("txid", it->first.txhash.GetHex()); + delta.pushKV("index", (int)it->first.index); + delta.pushKV("blockindex", (int)it->first.txindex); + delta.pushKV("height", it->first.blockHeight); + delta.pushKV("address", address); result.push_back(delta); } @@ -861,8 +861,8 @@ UniValue getaddressbalance(const JSONRPCRequest& request) } UniValue result(UniValue::VOBJ); - result.push_back(Pair("balance", balance)); - result.push_back(Pair("received", received)); + result.pushKV("balance", balance); + result.pushKV("received", received); return result; @@ -991,9 +991,9 @@ UniValue getspentinfo(const JSONRPCRequest& request) } UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("txid", value.txid.GetHex())); - obj.push_back(Pair("index", (int)value.inputIndex)); - obj.push_back(Pair("height", value.blockHeight)); + obj.pushKV("txid", value.txid.GetHex()); + obj.pushKV("index", (int)value.inputIndex); + obj.pushKV("height", value.blockHeight); return obj; } @@ -1002,12 +1002,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; } @@ -1064,7 +1064,7 @@ UniValue getmemoryinfo(const JSONRPCRequest& request) std::string mode = request.params[0].isNull() ? "stats" : 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 index 870fd322f5d4d..6a9bdfb24fcfb 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -135,63 +135,63 @@ UniValue getpeerinfo(const JSONRPCRequest& request) 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.push_back(Pair("services", strprintf("%016x", stats.nServices))); + obj.pushKV("addrbind", stats.addrBind.ToString()); + obj.pushKV("services", strprintf("%016x", stats.nServices)); if (!stats.verifiedProRegTxHash.IsNull()) { - obj.push_back(Pair("verified_proregtx_hash", stats.verifiedProRegTxHash.ToString())); + obj.pushKV("verified_proregtx_hash", stats.verifiedProRegTxHash.ToString()); } - 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("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 < static_cast(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.push_back(Pair("version", stats.nVersion)); + obj.pushKV("pingwait", stats.dPingWait); + 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("masternode", stats.fMasternode)); - 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("masternode", stats.fMasternode); + 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); } @@ -341,16 +341,16 @@ UniValue getaddednodeinfo(const JSONRPCRequest& request) 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.push_back(Pair("connected", info.fInbound ? "inbound" : "outbound")); + address.pushKV("address", info.resolvedAddress.ToString()); + address.pushKV("connected", info.fInbound ? "inbound" : "outbound"); addresses.push_back(address); } - obj.push_back(Pair("addresses", addresses)); + obj.pushKV("addresses", addresses); ret.push_back(obj); } @@ -387,18 +387,18 @@ UniValue getnettotals(const JSONRPCRequest& request) throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); 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.push_back(Pair("target_reached", g_connman->OutboundTargetReached(false))); - outboundLimit.push_back(Pair("serve_historical_blocks", !g_connman->OutboundTargetReached(true))); - outboundLimit.push_back(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)); + outboundLimit.pushKV("timeframe", g_connman->GetMaxOutboundTimeframe()); + outboundLimit.pushKV("target", g_connman->GetMaxOutboundTarget()); + outboundLimit.pushKV("target_reached", g_connman->OutboundTargetReached(false)); + outboundLimit.pushKV("serve_historical_blocks", !g_connman->OutboundTargetReached(true)); + outboundLimit.pushKV("bytes_left_in_cycle", g_connman->GetOutboundTargetBytesLeft()); + outboundLimit.pushKV("time_left_in_cycle", g_connman->GetMaxOutboundTimeLeftInCycle()); + obj.pushKV("uploadtarget", outboundLimit); return obj; } @@ -413,11 +413,11 @@ static UniValue GetNetworksInfo() 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.push_back(Pair("proxy", proxy.IsValid() ? proxy.proxy.ToStringIPPort() : std::string())); - obj.push_back(Pair("proxy_randomize_credentials", proxy.randomize_credentials)); + obj.pushKV("name", GetNetworkName(network)); + obj.pushKV("limited", IsLimited(network)); + obj.pushKV("reachable", IsReachable(network)); + obj.pushKV("proxy", proxy.IsValid() ? proxy.proxy.ToStringIPPort() : std::string()); + obj.pushKV("proxy_randomize_credentials", proxy.randomize_credentials); networks.push_back(obj); } return networks; @@ -469,16 +469,16 @@ UniValue getnetworkinfo(const JSONRPCRequest& request) LOCK(cs_main); UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("version", CLIENT_VERSION)); - obj.push_back(Pair("subversion", strSubVersion)); - obj.push_back(Pair("protocolversion",PROTOCOL_VERSION)); + obj.pushKV("version", CLIENT_VERSION); + obj.pushKV("subversion", strSubVersion); + 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("localservices", strprintf("%016x", g_connman->GetLocalServices())); + obj.pushKV("localrelay", fRelayTxes); + obj.pushKV("timeoffset", GetTimeOffset()); if (g_connman) { - obj.push_back(Pair("networkactive", g_connman->GetNetworkActive())); - obj.push_back(Pair("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL))); + obj.pushKV("networkactive", g_connman->GetNetworkActive()); + obj.pushKV("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL)); std::string strSocketEvents; switch (g_connman->GetSocketEventsMode()) { case CConnman::SOCKETEVENTS_SELECT: @@ -493,25 +493,25 @@ UniValue getnetworkinfo(const JSONRPCRequest& request) default: assert(false); } - obj.push_back(Pair("socketevents", strSocketEvents)); + obj.pushKV("socketevents", strSocketEvents); } - obj.push_back(Pair("networks", GetNetworksInfo())); - obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); - obj.push_back(Pair("incrementalfee", ValueFromAmount(::incrementalRelayFee.GetFeePerK()))); + obj.pushKV("networks", GetNetworksInfo()); + obj.pushKV("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())); + obj.pushKV("incrementalfee", ValueFromAmount(::incrementalRelayFee.GetFeePerK())); UniValue localAddresses(UniValue::VARR); { 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; } @@ -601,10 +601,10 @@ UniValue listbanned(const JSONRPCRequest& request) { const CBanEntry& banEntry = entry.second; UniValue rec(UniValue::VOBJ); - rec.push_back(Pair("address", entry.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", entry.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/privatesend.cpp b/src/rpc/privatesend.cpp index 56e358e79c08c..c186c357519ee 100644 --- a/src/rpc/privatesend.cpp +++ b/src/rpc/privatesend.cpp @@ -140,7 +140,7 @@ UniValue getprivatesendinfo(const JSONRPCRequest& request) return obj; } - obj.push_back(Pair("keys_left", pwallet->nKeysLeftSinceAutoBackup)); + obj.pushKV("keys_left", pwallet->nKeysLeftSinceAutoBackup); obj.push_back(Pair("warnings", pwallet->nKeysLeftSinceAutoBackup < PRIVATESEND_KEYS_THRESHOLD_WARNING ? "WARNING: keypool is almost depleted!" : "")); #endif // ENABLE_WALLET diff --git a/src/rpc/protocol.cpp b/src/rpc/protocol.cpp index 93a1afc34ac09..04dcda6ac1d97 100644 --- a/src/rpc/protocol.cpp +++ b/src/rpc/protocol.cpp @@ -27,9 +27,9 @@ UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params, 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,11 +37,11 @@ UniValue JSONRPCReplyObj(const UniValue& result, const UniValue& error, const Un { 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.push_back(Pair("error", error)); - reply.push_back(Pair("id", id)); + reply.pushKV("result", result); + reply.pushKV("error", error); + reply.pushKV("id", id); return reply; } @@ -54,8 +54,8 @@ std::string JSONRPCReply(const UniValue& result, const UniValue& error, const Un 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 index b132db162c493..6de0766f5efb1 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -78,28 +78,28 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) bool chainLock = false; 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; if (chainActive.Contains(pindex)) { - entry.push_back(Pair("height", pindex->nHeight)); - 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("height", pindex->nHeight); + entry.pushKV("confirmations", 1 + chainActive.Height() - pindex->nHeight); + entry.pushKV("time", pindex->GetBlockTime()); + entry.pushKV("blocktime", pindex->GetBlockTime()); chainLock = llmq::chainLocksHandler->HasChainLock(pindex->nHeight, pindex->GetBlockHash()); } else { - entry.push_back(Pair("height", -1)); - entry.push_back(Pair("confirmations", 0)); + entry.pushKV("height", -1); + entry.pushKV("confirmations", 0); } } } bool fLocked = llmq::quorumInstantSendManager->IsLocked(txid); - entry.push_back(Pair("instantlock", fLocked || chainLock)); - entry.push_back(Pair("instantlock_internal", fLocked)); - entry.push_back(Pair("chainlock", chainLock)); + entry.pushKV("instantlock", fLocked || chainLock); + entry.pushKV("instantlock_internal", fLocked); + entry.pushKV("chainlock", chainLock); } UniValue getrawtransaction(const JSONRPCRequest& request) @@ -233,7 +233,7 @@ UniValue getrawtransaction(const JSONRPCRequest& request) } UniValue result(UniValue::VOBJ); - if (blockindex) result.push_back(Pair("in_active_chain", in_active_chain)); + if (blockindex) result.pushKV("in_active_chain", in_active_chain); TxToJSON(*tx, hash_block, result); return result; } @@ -623,7 +623,7 @@ UniValue decodescript(const JSONRPCRequest& request) 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; @@ -633,11 +633,11 @@ UniValue decodescript(const JSONRPCRequest& request) static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::string& strMessage) { UniValue entry(UniValue::VOBJ); - entry.push_back(Pair("txid", txin.prevout.hash.ToString())); - entry.push_back(Pair("vout", (uint64_t)txin.prevout.n)); - 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("txid", txin.prevout.hash.ToString()); + entry.pushKV("vout", (uint64_t)txin.prevout.n); + entry.pushKV("scriptSig", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())); + entry.pushKV("sequence", (uint64_t)txin.nSequence); + entry.pushKV("error", strMessage); vErrorsRet.push_back(entry); } @@ -974,10 +974,10 @@ UniValue signrawtransaction(const JSONRPCRequest& request) bool fComplete = vErrors.empty(); UniValue result(UniValue::VOBJ); - result.push_back(Pair("hex", EncodeHexTx(mtx))); - result.push_back(Pair("complete", fComplete)); + result.pushKV("hex", EncodeHexTx(mtx)); + result.pushKV("complete", fComplete); if (!vErrors.empty()) { - result.push_back(Pair("errors", vErrors)); + result.pushKV("errors", vErrors); } return result; diff --git a/src/rpc/rpcevo.cpp b/src/rpc/rpcevo.cpp index 9f18ad322af76..9b81b24b78a26 100644 --- a/src/rpc/rpcevo.cpp +++ b/src/rpc/rpcevo.cpp @@ -555,9 +555,9 @@ UniValue protx_register(const JSONRPCRequest& request) SetTxPayload(tx, ptx); UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("tx", EncodeHexTx(tx))); - ret.push_back(Pair("collateralAddress", EncodeDestination(txDest))); - ret.push_back(Pair("signMessage", ptx.MakeSignString())); + ret.pushKV("tx", EncodeHexTx(tx)); + ret.pushKV("collateralAddress", EncodeDestination(txDest)); + ret.pushKV("signMessage", ptx.MakeSignString()); return ret; } else { // lets prove we own the collateral @@ -941,7 +941,7 @@ UniValue BuildDMNListEntry(CWallet* pwallet, const CDeterministicMNCPtr& dmn, bo dmn->ToJson(o); int confirmations = GetUTXOConfirmations(dmn->collateralOutpoint); - o.push_back(Pair("confirmations", confirmations)); + o.pushKV("confirmations", confirmations); bool hasOwnerKey = CheckWalletOwnsKey(pwallet, dmn->pdmnState->keyIDOwner); bool hasOperatorKey = false; //CheckWalletOwnsKey(dmn->pdmnState->keyIDOperator); @@ -957,18 +957,18 @@ UniValue BuildDMNListEntry(CWallet* pwallet, const CDeterministicMNCPtr& dmn, bo #ifdef ENABLE_WALLET if (pwallet) { UniValue walletObj(UniValue::VOBJ); - walletObj.push_back(Pair("hasOwnerKey", hasOwnerKey)); - walletObj.push_back(Pair("hasOperatorKey", hasOperatorKey)); - walletObj.push_back(Pair("hasVotingKey", hasVotingKey)); - walletObj.push_back(Pair("ownsCollateral", ownsCollateral)); - walletObj.push_back(Pair("ownsPayeeScript", CheckWalletOwnsScript(pwallet, dmn->pdmnState->scriptPayout))); - walletObj.push_back(Pair("ownsOperatorRewardScript", CheckWalletOwnsScript(pwallet, dmn->pdmnState->scriptOperatorPayout))); - o.push_back(Pair("wallet", walletObj)); + walletObj.pushKV("hasOwnerKey", hasOwnerKey); + walletObj.pushKV("hasOperatorKey", hasOperatorKey); + walletObj.pushKV("hasVotingKey", hasVotingKey); + walletObj.pushKV("ownsCollateral", ownsCollateral); + walletObj.pushKV("ownsPayeeScript", CheckWalletOwnsScript(pwallet, dmn->pdmnState->scriptPayout)); + walletObj.pushKV("ownsOperatorRewardScript", CheckWalletOwnsScript(pwallet, dmn->pdmnState->scriptOperatorPayout)); + o.pushKV("wallet", walletObj); } #endif auto metaInfo = mmetaman.GetMetaInfo(dmn->proTxHash); - o.push_back(Pair("metaInfo", metaInfo->ToJson())); + o.pushKV("metaInfo", metaInfo->ToJson()); return o; } @@ -1224,8 +1224,8 @@ UniValue bls_generate(const JSONRPCRequest& request) sk.MakeNewKey(); UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("secret", sk.ToString())); - ret.push_back(Pair("public", sk.GetPublicKey().ToString())); + ret.pushKV("secret", sk.ToString()); + ret.pushKV("public", sk.GetPublicKey().ToString()); return ret; } @@ -1258,8 +1258,8 @@ UniValue bls_fromsecret(const JSONRPCRequest& request) } UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("secret", sk.ToString())); - ret.push_back(Pair("public", sk.GetPublicKey().ToString())); + ret.pushKV("secret", sk.ToString()); + ret.pushKV("public", sk.GetPublicKey().ToString()); return ret; } diff --git a/src/rpc/rpcquorums.cpp b/src/rpc/rpcquorums.cpp index 87e5b4d53bc0d..f226cf031c908 100644 --- a/src/rpc/rpcquorums.cpp +++ b/src/rpc/rpcquorums.cpp @@ -62,7 +62,7 @@ UniValue quorum_list(const JSONRPCRequest& request) v.push_back(q->qc.quorumHash.ToString()); } - ret.push_back(Pair(p.second.name, v)); + ret.pushKV(p.second.name, v); } @@ -85,34 +85,34 @@ UniValue BuildQuorumInfo(const llmq::CQuorumCPtr& quorum, bool includeMembers, b { UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("height", quorum->pindexQuorum->nHeight)); - ret.push_back(Pair("type", quorum->params.name)); - ret.push_back(Pair("quorumHash", quorum->qc.quorumHash.ToString())); - ret.push_back(Pair("minedBlock", quorum->minedBlockHash.ToString())); + ret.pushKV("height", quorum->pindexQuorum->nHeight); + ret.pushKV("type", quorum->params.name); + ret.pushKV("quorumHash", quorum->qc.quorumHash.ToString()); + ret.pushKV("minedBlock", quorum->minedBlockHash.ToString()); if (includeMembers) { UniValue membersArr(UniValue::VARR); for (size_t i = 0; i < quorum->members.size(); i++) { auto& dmn = quorum->members[i]; UniValue mo(UniValue::VOBJ); - mo.push_back(Pair("proTxHash", dmn->proTxHash.ToString())); - mo.push_back(Pair("pubKeyOperator", dmn->pdmnState->pubKeyOperator.Get().ToString())); - mo.push_back(Pair("valid", quorum->qc.validMembers[i])); + mo.pushKV("proTxHash", dmn->proTxHash.ToString()); + mo.pushKV("pubKeyOperator", dmn->pdmnState->pubKeyOperator.Get().ToString()); + mo.pushKV("valid", quorum->qc.validMembers[i]); if (quorum->qc.validMembers[i]) { CBLSPublicKey pubKey = quorum->GetPubKeyShare(i); if (pubKey.IsValid()) { - mo.push_back(Pair("pubKeyShare", pubKey.ToString())); + mo.pushKV("pubKeyShare", pubKey.ToString()); } } membersArr.push_back(mo); } - ret.push_back(Pair("members", membersArr)); + ret.pushKV("members", membersArr); } - ret.push_back(Pair("quorumPublicKey", quorum->qc.quorumPublicKey.ToString())); + ret.pushKV("quorumPublicKey", quorum->qc.quorumPublicKey.ToString()); CBLSSecretKey skShare = quorum->GetSkShare(); if (includeSkShare && skShare.IsValid()) { - ret.push_back(Pair("secretKeyShare", skShare.ToString())); + ret.pushKV("secretKeyShare", skShare.ToString()); } return ret; } @@ -197,29 +197,29 @@ UniValue quorum_dkgstatus(const JSONRPCRequest& request) UniValue arr(UniValue::VARR); for (auto& ec : allConnections) { UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("proTxHash", ec.ToString())); + obj.pushKV("proTxHash", ec.ToString()); if (foundConnections.count(ec)) { - obj.push_back(Pair("connected", true)); - obj.push_back(Pair("address", foundConnections[ec].ToString(false))); + obj.pushKV("connected", true); + obj.pushKV("address", foundConnections[ec].ToString(false)); } else { - obj.push_back(Pair("connected", false)); + obj.pushKV("connected", false); } - obj.push_back(Pair("outbound", outboundConnections.count(ec) != 0)); + obj.pushKV("outbound", outboundConnections.count(ec) != 0); arr.push_back(obj); } - quorumConnections.push_back(Pair(params.name, arr)); + quorumConnections.pushKV(params.name, arr); } llmq::CFinalCommitment fqc; if (llmq::quorumBlockProcessor->GetMinableCommitment(params.type, tipHeight, fqc)) { UniValue obj(UniValue::VOBJ); fqc.ToJson(obj); - minableCommitments.push_back(Pair(params.name, obj)); + minableCommitments.pushKV(params.name, obj); } } - ret.push_back(Pair("minableCommitments", minableCommitments)); - ret.push_back(Pair("quorumConnections", quorumConnections)); + ret.pushKV("minableCommitments", minableCommitments); + ret.pushKV("quorumConnections", quorumConnections); return ret; } @@ -275,8 +275,8 @@ UniValue quorum_memberof(const JSONRPCRequest& request) for (auto& quorum : quorums) { if (quorum->IsMember(dmn->proTxHash)) { auto json = BuildQuorumInfo(quorum, false, false); - json.push_back(Pair("isValidMember", quorum->IsValidMember(dmn->proTxHash))); - json.push_back(Pair("memberIndex", quorum->GetMemberIndex(dmn->proTxHash))); + json.pushKV("isValidMember", quorum->IsValidMember(dmn->proTxHash)); + json.pushKV("memberIndex", quorum->GetMemberIndex(dmn->proTxHash)); result.push_back(json); } } @@ -429,14 +429,14 @@ UniValue quorum_selectquorum(const JSONRPCRequest& request) if (!quorum) { throw JSONRPCError(RPC_MISC_ERROR, "no quorums active"); } - ret.push_back(Pair("quorumHash", quorum->qc.quorumHash.ToString())); + ret.pushKV("quorumHash", quorum->qc.quorumHash.ToString()); UniValue recoveryMembers(UniValue::VARR); for (int i = 0; i < quorum->params.recoveryMembers; i++) { auto dmn = llmq::quorumSigSharesManager->SelectMemberForRecovery(quorum, id, i); recoveryMembers.push_back(dmn->proTxHash.ToString()); } - ret.push_back(Pair("recoveryMembers", recoveryMembers)); + ret.pushKV("recoveryMembers", recoveryMembers); return ret; } diff --git a/src/univalue/include/univalue.h b/src/univalue/include/univalue.h index 5f1cf2699c222..98c7df267820d 100644 --- a/src/univalue/include/univalue.h +++ b/src/univalue/include/univalue.h @@ -129,6 +129,10 @@ class UniValue { UniValue tmpVal(val_); return pushKV(key, tmpVal); } + bool pushKV(const std::string& key, bool val_) { + UniValue tmpVal((bool)val_); + return pushKV(key, tmpVal); + } bool pushKV(const std::string& key, int val_) { UniValue tmpVal((int64_t)val_); return pushKV(key, tmpVal); diff --git a/src/univalue/test/object.cpp b/src/univalue/test/object.cpp index 679cc9f143da3..70ccc0d08a5ef 100644 --- a/src/univalue/test/object.cpp +++ b/src/univalue/test/object.cpp @@ -261,6 +261,12 @@ BOOST_AUTO_TEST_CASE(univalue_object) strKey = "temperature"; BOOST_CHECK(obj.pushKV(strKey, (double) 90.012)); + strKey = "moon"; + BOOST_CHECK(obj.pushKV(strKey, true)); + + strKey = "spoon"; + BOOST_CHECK(obj.pushKV(strKey, false)); + UniValue obj2(UniValue::VOBJ); BOOST_CHECK(obj2.pushKV("cat1", 9000)); BOOST_CHECK(obj2.pushKV("cat2", 12345)); @@ -268,7 +274,7 @@ BOOST_AUTO_TEST_CASE(univalue_object) BOOST_CHECK(obj.pushKVs(obj2)); BOOST_CHECK_EQUAL(obj.empty(), false); - BOOST_CHECK_EQUAL(obj.size(), 9); + BOOST_CHECK_EQUAL(obj.size(), 11); BOOST_CHECK_EQUAL(obj["age"].getValStr(), "100"); BOOST_CHECK_EQUAL(obj["first"].getValStr(), "John"); @@ -277,6 +283,8 @@ BOOST_AUTO_TEST_CASE(univalue_object) BOOST_CHECK_EQUAL(obj["time"].getValStr(), "3600"); BOOST_CHECK_EQUAL(obj["calories"].getValStr(), "12"); BOOST_CHECK_EQUAL(obj["temperature"].getValStr(), "90.012"); + BOOST_CHECK_EQUAL(obj["moon"].getValStr(), "1"); + BOOST_CHECK_EQUAL(obj["spoon"].getValStr(), ""); BOOST_CHECK_EQUAL(obj["cat1"].getValStr(), "9000"); BOOST_CHECK_EQUAL(obj["cat2"].getValStr(), "12345"); @@ -289,6 +297,8 @@ BOOST_AUTO_TEST_CASE(univalue_object) BOOST_CHECK(obj.exists("time")); BOOST_CHECK(obj.exists("calories")); BOOST_CHECK(obj.exists("temperature")); + BOOST_CHECK(obj.exists("moon")); + BOOST_CHECK(obj.exists("spoon")); BOOST_CHECK(obj.exists("cat1")); BOOST_CHECK(obj.exists("cat2")); @@ -302,6 +312,8 @@ BOOST_AUTO_TEST_CASE(univalue_object) objTypes["time"] = UniValue::VNUM; objTypes["calories"] = UniValue::VNUM; objTypes["temperature"] = UniValue::VNUM; + objTypes["moon"] = UniValue::VBOOL; + objTypes["spoon"] = UniValue::VBOOL; objTypes["cat1"] = UniValue::VNUM; objTypes["cat2"] = UniValue::VNUM; BOOST_CHECK(obj.checkObject(objTypes)); diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 914598bf9dbbf..ec904bd3d66a8 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -807,9 +807,9 @@ UniValue dumphdinfo(const JSONRPCRequest& request) hdChainCurrent.GetMnemonic(ssMnemonic, ssMnemonicPassphrase); UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("hdseed", HexStr(hdChainCurrent.GetSeed()))); - obj.push_back(Pair("mnemonic", ssMnemonic.c_str())); - obj.push_back(Pair("mnemonicpassphrase", ssMnemonicPassphrase.c_str())); + obj.pushKV("hdseed", HexStr(hdChainCurrent.GetSeed())); + obj.pushKV("mnemonic", ssMnemonic.c_str()); + obj.pushKV("mnemonicpassphrase", ssMnemonicPassphrase.c_str()); return obj; } @@ -881,10 +881,10 @@ UniValue dumpwallet(const JSONRPCRequest& request) file << "\n"; UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("dashcoreversion", CLIENT_BUILD)); - obj.push_back(Pair("lastblockheight", chainActive.Height())); - obj.push_back(Pair("lastblockhash", chainActive.Tip()->GetBlockHash().ToString())); - obj.push_back(Pair("lastblocktime", EncodeDumpTime(chainActive.Tip()->GetBlockTime()))); + obj.pushKV("dashcoreversion", CLIENT_BUILD); + obj.pushKV("lastblockheight", chainActive.Height()); + obj.pushKV("lastblockhash", chainActive.Tip()->GetBlockHash().ToString()); + obj.pushKV("lastblocktime", EncodeDumpTime(chainActive.Tip()->GetBlockTime())); // add the base58check encoded extended master if the wallet uses HD CHDChain hdChainCurrent; @@ -928,7 +928,7 @@ UniValue dumpwallet(const JSONRPCRequest& request) file << "# WARNING: ACCOUNT " << i << " IS MISSING!" << "\n\n"; } } - obj.push_back(Pair("hdaccounts", int(hdChainCurrent.CountAccounts()))); + obj.pushKV("hdaccounts", int(hdChainCurrent.CountAccounts())); } for (std::vector >::const_iterator it = vKeyBirth.begin(); it != vKeyBirth.end(); it++) { @@ -968,9 +968,9 @@ UniValue dumpwallet(const JSONRPCRequest& request) file.close(); std::string strWarning = strprintf(_("%s file contains all private keys from this wallet. Do not share it with anyone!"), request.params[0].get_str().c_str()); - obj.push_back(Pair("keys", int(vKeyBirth.size()))); - obj.push_back(Pair("file", request.params[0].get_str().c_str())); - obj.push_back(Pair("warning", strWarning)); + obj.pushKV("keys", int(vKeyBirth.size())); + obj.pushKV("file", request.params[0].get_str().c_str()); + obj.pushKV("warning", strWarning); return obj; } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 04eec9f9080c3..5789e4bf0ebe4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -96,31 +96,31 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) if (confirms > 0) { chainlock = llmq::chainLocksHandler->HasChainLock(mapBlockIndex[wtx.hashBlock]->nHeight, wtx.hashBlock); } - entry.push_back(Pair("confirmations", confirms)); - entry.push_back(Pair("instantlock", fLocked || chainlock)); - entry.push_back(Pair("instantlock_internal", fLocked)); - entry.push_back(Pair("chainlock", chainlock)); + entry.pushKV("confirmations", confirms); + entry.pushKV("instantlock", fLocked || chainlock); + entry.pushKV("instantlock_internal", fLocked); + entry.pushKV("chainlock", chainlock); 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.push_back(Pair("blocktime", mapBlockIndex[wtx.hashBlock]->GetBlockTime())); + entry.pushKV("blockhash", wtx.hashBlock.GetHex()); + entry.pushKV("blockindex", wtx.nIndex); + entry.pushKV("blocktime", mapBlockIndex[wtx.hashBlock]->GetBlockTime()); } else { - entry.push_back(Pair("trusted", wtx.IsTrusted())); + entry.pushKV("trusted", wtx.IsTrusted()); } uint256 hash = wtx.GetHash(); - 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); } std::string AccountFromValue(const UniValue& value) @@ -619,7 +619,7 @@ UniValue listaddressbalances(const JSONRPCRequest& request) std::map balances = pwallet->GetAddressBalances(); for (auto& balance : balances) if (balance.second >= nMinAmount) - jsonBalances.push_back(Pair(EncodeDestination(balance.first), ValueFromAmount(balance.second))); + jsonBalances.pushKV(EncodeDestination(balance.first), ValueFromAmount(balance.second)); return jsonBalances; } @@ -1377,13 +1377,13 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA { UniValue obj(UniValue::VOBJ); if(fIsWatchonly) - obj.push_back(Pair("involvesWatchonly", true)); - obj.push_back(Pair("address", EncodeDestination(dest))); - obj.push_back(Pair("account", strAccount)); - obj.push_back(Pair("amount", ValueFromAmount(nAmount))); - obj.push_back(Pair("confirmations", (nConf == std::numeric_limits::max() ? 0 : nConf))); + obj.pushKV("involvesWatchonly", true); + obj.pushKV("address", EncodeDestination(dest)); + obj.pushKV("account", strAccount); + obj.pushKV("amount", ValueFromAmount(nAmount)); + obj.pushKV("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()) { @@ -1392,7 +1392,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA transactions.push_back(_item.GetHex()); } } - obj.push_back(Pair("txids", transactions)); + obj.pushKV("txids", transactions); ret.push_back(obj); } } @@ -1405,10 +1405,10 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA int nConf = entry.second.nConf; UniValue obj(UniValue::VOBJ); if (entry.second.fIsWatchonly) - obj.push_back(Pair("involvesWatchonly", true)); - obj.push_back(Pair("account", entry.first)); - obj.push_back(Pair("amount", ValueFromAmount(nAmount))); - obj.push_back(Pair("confirmations", (nConf == std::numeric_limits::max() ? 0 : nConf))); + obj.pushKV("involvesWatchonly", true); + obj.pushKV("account", entry.first); + obj.pushKV("amount", ValueFromAmount(nAmount)); + obj.pushKV("confirmations", (nConf == std::numeric_limits::max() ? 0 : nConf)); ret.push_back(obj); } } @@ -1518,7 +1518,7 @@ UniValue listreceivedbyaccount(const JSONRPCRequest& request) static void MaybePushAddress(UniValue & entry, const CTxDestination &dest) { if (IsValidDestination(dest)) { - entry.push_back(Pair("address", EncodeDestination(dest))); + entry.pushKV("address", EncodeDestination(dest)); } } @@ -1552,21 +1552,21 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const std:: { 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); std::map::const_iterator it = wtx.mapValue.find("DS"); - entry.push_back(Pair("category", (it != wtx.mapValue.end() && it->second == "1") ? "privatesend" : "send")); - entry.push_back(Pair("amount", ValueFromAmount(-s.amount))); + entry.pushKV("category", (it != wtx.mapValue.end() && it->second == "1") ? "privatesend" : "send"); + entry.pushKV("amount", ValueFromAmount(-s.amount)); if (pwallet->mapAddressBook.count(s.destination)) { - entry.push_back(Pair("label", pwallet->mapAddressBook[s.destination].name)); + entry.pushKV("label", pwallet->mapAddressBook[s.destination].name); } - entry.push_back(Pair("vout", s.vout)); - entry.push_back(Pair("fee", ValueFromAmount(-nFee))); + entry.pushKV("vout", s.vout); + entry.pushKV("fee", ValueFromAmount(-nFee)); if (fLong) WalletTxToJSON(wtx, entry); - entry.push_back(Pair("abandoned", wtx.isAbandoned())); + entry.pushKV("abandoned", wtx.isAbandoned()); ret.push_back(entry); } } @@ -1584,28 +1584,28 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const std:: { 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.GetBlocksToMaturity() > 0) - 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); ret.push_back(entry); @@ -1621,12 +1621,12 @@ void AcentryToJSON(const CAccountingEntry& acentry, const std::string& strAccoun 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); } } @@ -1858,7 +1858,7 @@ UniValue listaccounts(const JSONRPCRequest& request) UniValue ret(UniValue::VOBJ); for (const std::pair& accountBalance : mapAccountBalances) { - ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second))); + ret.pushKV(accountBalance.first, ValueFromAmount(accountBalance.second)); } return ret; } @@ -1999,9 +1999,9 @@ UniValue listsinceblock(const JSONRPCRequest& request) uint256 lastblock = pblockLast ? pblockLast->GetBlockHash() : uint256(); UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("transactions", transactions)); - if (include_removed) ret.push_back(Pair("removed", removed)); - ret.push_back(Pair("lastblock", lastblock.GetHex())); + ret.pushKV("transactions", transactions); + if (include_removed) ret.pushKV("removed", removed); + ret.pushKV("lastblock", lastblock.GetHex()); return ret; } @@ -2087,18 +2087,18 @@ UniValue gettransaction(const JSONRPCRequest& request) CAmount nNet = nCredit - nDebit; CAmount nFee = (wtx.IsFromMe(filter) ? wtx.tx->GetValueOut() - nDebit : 0); - 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(*wtx.tx); - entry.push_back(Pair("hex", strHex)); + entry.pushKV("hex", strHex); return entry; } @@ -2626,8 +2626,8 @@ UniValue listlockunspent(const JSONRPCRequest& request) for (COutPoint &outpt : vOutpts) { UniValue o(UniValue::VOBJ); - o.push_back(Pair("txid", outpt.hash.GetHex())); - o.push_back(Pair("vout", (int)outpt.n)); + o.pushKV("txid", outpt.hash.GetHex()); + o.pushKV("vout", (int)outpt.n); ret.push_back(o); } @@ -2773,40 +2773,40 @@ UniValue getwalletinfo(const JSONRPCRequest& request) bool fHDEnabled = pwallet->GetHDChain(hdChainCurrent); UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("walletname", pwallet->GetName())); - obj.push_back(Pair("walletversion", pwallet->GetVersion())); - obj.push_back(Pair("balance", ValueFromAmount(pwallet->GetBalance()))); - obj.push_back(Pair("privatesend_balance", ValueFromAmount(pwallet->GetAnonymizedBalance()))); - 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)pwallet->KeypoolCountExternalKeys())); + obj.pushKV("walletname", pwallet->GetName()); + obj.pushKV("walletversion", pwallet->GetVersion()); + obj.pushKV("balance", ValueFromAmount(pwallet->GetBalance())); + obj.pushKV("privatesend_balance", ValueFromAmount(pwallet->GetAnonymizedBalance())); + obj.pushKV("unconfirmed_balance", ValueFromAmount(pwallet->GetUnconfirmedBalance())); + obj.pushKV("immature_balance", ValueFromAmount(pwallet->GetImmatureBalance())); + obj.pushKV("txcount", (int)pwallet->mapWallet.size()); + obj.pushKV("keypoololdest", pwallet->GetOldestKeyPoolTime()); + obj.pushKV("keypoolsize", (int64_t)pwallet->KeypoolCountExternalKeys()); if (fHDEnabled) { - obj.push_back(Pair("keypoolsize_hd_internal", (int64_t)(pwallet->KeypoolCountInternalKeys()))); + obj.pushKV("keypoolsize_hd_internal", (int64_t)(pwallet->KeypoolCountInternalKeys())); } - obj.push_back(Pair("keys_left", pwallet->nKeysLeftSinceAutoBackup)); + obj.pushKV("keys_left", pwallet->nKeysLeftSinceAutoBackup); if (pwallet->IsCrypted()) - obj.push_back(Pair("unlocked_until", pwallet->nRelockTime)); - obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); + obj.pushKV("unlocked_until", pwallet->nRelockTime); + obj.pushKV("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())); if (fHDEnabled) { - obj.push_back(Pair("hdchainid", hdChainCurrent.GetID().GetHex())); - obj.push_back(Pair("hdaccountcount", (int64_t)hdChainCurrent.CountAccounts())); + obj.pushKV("hdchainid", hdChainCurrent.GetID().GetHex()); + obj.pushKV("hdaccountcount", (int64_t)hdChainCurrent.CountAccounts()); UniValue accounts(UniValue::VARR); for (size_t i = 0; i < hdChainCurrent.CountAccounts(); ++i) { CHDAccount acc; UniValue account(UniValue::VOBJ); - account.push_back(Pair("hdaccountindex", (int64_t)i)); + account.pushKV("hdaccountindex", (int64_t)i); if(hdChainCurrent.GetAccount(i, acc)) { - account.push_back(Pair("hdexternalkeyindex", (int64_t)acc.nExternalChainCounter)); - account.push_back(Pair("hdinternalkeyindex", (int64_t)acc.nInternalChainCounter)); + account.pushKV("hdexternalkeyindex", (int64_t)acc.nExternalChainCounter); + account.pushKV("hdinternalkeyindex", (int64_t)acc.nInternalChainCounter); } else { - account.push_back(Pair("error", strprintf("account %d is missing", i))); + account.pushKV("error", strprintf("account %d is missing", i)); } accounts.push_back(account); } - obj.push_back(Pair("hdaccounts", accounts)); + obj.pushKV("hdaccounts", accounts); } return obj; } @@ -3144,32 +3144,32 @@ UniValue listunspent(const JSONRPCRequest& request) continue; UniValue entry(UniValue::VOBJ); - entry.push_back(Pair("txid", out.tx->GetHash().GetHex())); - entry.push_back(Pair("vout", out.i)); + entry.pushKV("txid", out.tx->GetHash().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(Pair("account", pwallet->mapAddressBook[address].name)); + entry.pushKV("account", pwallet->mapAddressBook[address].name); } if (scriptPubKey.IsPayToScriptHash()) { const CScriptID& hash = boost::get(address); CScript redeemScript; if (pwallet->GetCScript(hash, redeemScript)) { - entry.push_back(Pair("redeemScript", HexStr(redeemScript.begin(), redeemScript.end()))); + entry.pushKV("redeemScript", HexStr(redeemScript.begin(), redeemScript.end())); } } } - entry.push_back(Pair("scriptPubKey", 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.push_back(Pair("ps_rounds", pwallet->GetCappedOutpointPrivateSendRounds(COutPoint(out.tx->GetHash(), out.i)))); + entry.pushKV("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end())); + entry.pushKV("amount", ValueFromAmount(out.tx->tx->vout[out.i].nValue)); + entry.pushKV("confirmations", out.nDepth); + entry.pushKV("spendable", out.fSpendable); + entry.pushKV("solvable", out.fSolvable); + entry.pushKV("safe", out.fSafe); + entry.pushKV("ps_rounds", pwallet->GetCappedOutpointPrivateSendRounds(COutPoint(out.tx->GetHash(), out.i))); results.push_back(entry); } @@ -3345,9 +3345,9 @@ UniValue fundrawtransaction(const JSONRPCRequest& request) } UniValue result(UniValue::VOBJ); - result.push_back(Pair("hex", EncodeHexTx(tx))); - result.push_back(Pair("changepos", changePosition)); - result.push_back(Pair("fee", ValueFromAmount(nFeeOut))); + result.pushKV("hex", EncodeHexTx(tx)); + result.pushKV("changepos", changePosition); + result.pushKV("fee", ValueFromAmount(nFeeOut)); return result; }