scripted-diff: Use UniValue.pushKV instead of push_back(Pair())

-BEGIN VERIFY SCRIPT-
git grep -l "push_back(Pair" | xargs sed -i "s/push_back(Pair(\(.*\)));/pushKV(\1);/g"
-END VERIFY SCRIPT-

Copied from: bitcoin/bitcoin#91986ed2
This commit is contained in:
Patrick Lodder 2021-10-17 20:26:04 +00:00
parent d81d2329f2
commit edd0da7968
No known key found for this signature in database
GPG key ID: 2D3A345B98D0DC1F
8 changed files with 419 additions and 419 deletions

View file

@ -568,24 +568,24 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
// pack in some essentials // pack in some essentials
// use more or less the same output as mentioned in Bip64 // use more or less the same output as mentioned in Bip64
objGetUTXOResponse.push_back(Pair("chainHeight", chainActive.Height())); objGetUTXOResponse.pushKV("chainHeight", chainActive.Height());
objGetUTXOResponse.push_back(Pair("chaintipHash", chainActive.Tip()->GetBlockHash().GetHex())); objGetUTXOResponse.pushKV("chaintipHash", chainActive.Tip()->GetBlockHash().GetHex());
objGetUTXOResponse.push_back(Pair("bitmap", bitmapStringRepresentation)); objGetUTXOResponse.pushKV("bitmap", bitmapStringRepresentation);
UniValue utxos(UniValue::VARR); UniValue utxos(UniValue::VARR);
BOOST_FOREACH (const CCoin& coin, outs) { BOOST_FOREACH (const CCoin& coin, outs) {
UniValue utxo(UniValue::VOBJ); UniValue utxo(UniValue::VOBJ);
utxo.push_back(Pair("txvers", (int32_t)coin.nTxVer)); utxo.pushKV("txvers", (int32_t)coin.nTxVer);
utxo.push_back(Pair("height", (int32_t)coin.nHeight)); utxo.pushKV("height", (int32_t)coin.nHeight);
utxo.push_back(Pair("value", ValueFromAmount(coin.out.nValue))); utxo.pushKV("value", ValueFromAmount(coin.out.nValue));
// include the script in a json output // include the script in a json output
UniValue o(UniValue::VOBJ); UniValue o(UniValue::VOBJ);
ScriptPubKeyToJSON(coin.out.scriptPubKey, o, true); ScriptPubKeyToJSON(coin.out.scriptPubKey, o, true);
utxo.push_back(Pair("scriptPubKey", o)); utxo.pushKV("scriptPubKey", o);
utxos.push_back(utxo); utxos.push_back(utxo);
} }
objGetUTXOResponse.push_back(Pair("utxos", utxos)); objGetUTXOResponse.pushKV("utxos", utxos);
// return json string // return json string
std::string strJSON = objGetUTXOResponse.write() + "\n"; std::string strJSON = objGetUTXOResponse.write() + "\n";

View file

@ -81,32 +81,32 @@ UniValue AuxpowToJSON(const CAuxPow& auxpow)
{ {
UniValue tx(UniValue::VOBJ); UniValue tx(UniValue::VOBJ);
tx.push_back(Pair("hex", EncodeHexTx(auxpow))); tx.pushKV("hex", EncodeHexTx(auxpow));
TxToJSON(auxpow, auxpow.parentBlock.GetHash(), tx); TxToJSON(auxpow, auxpow.parentBlock.GetHash(), tx);
result.push_back(Pair("tx", tx)); result.pushKV("tx", tx);
} }
result.push_back(Pair("index", auxpow.nIndex)); result.pushKV("index", auxpow.nIndex);
result.push_back(Pair("chainindex", auxpow.nChainIndex)); result.pushKV("chainindex", auxpow.nChainIndex);
{ {
UniValue branch(UniValue::VARR); UniValue branch(UniValue::VARR);
BOOST_FOREACH(const uint256& node, auxpow.vMerkleBranch) BOOST_FOREACH(const uint256& node, auxpow.vMerkleBranch)
branch.push_back(node.GetHex()); branch.push_back(node.GetHex());
result.push_back(Pair("merklebranch", branch)); result.pushKV("merklebranch", branch);
} }
{ {
UniValue branch(UniValue::VARR); UniValue branch(UniValue::VARR);
BOOST_FOREACH(const uint256& node, auxpow.vChainMerkleBranch) BOOST_FOREACH(const uint256& node, auxpow.vChainMerkleBranch)
branch.push_back(node.GetHex()); branch.push_back(node.GetHex());
result.push_back(Pair("chainmerklebranch", branch)); result.pushKV("chainmerklebranch", branch);
} }
CDataStream ssParent(SER_NETWORK, PROTOCOL_VERSION); CDataStream ssParent(SER_NETWORK, PROTOCOL_VERSION);
ssParent << auxpow.parentBlock; ssParent << auxpow.parentBlock;
const std::string strHex = HexStr(ssParent.begin(), ssParent.end()); const std::string strHex = HexStr(ssParent.begin(), ssParent.end());
result.push_back(Pair("parentblock", strHex)); result.pushKV("parentblock", strHex);
return result; return result;
} }
@ -114,47 +114,47 @@ UniValue AuxpowToJSON(const CAuxPow& auxpow)
UniValue blockheaderToJSON(const CBlockIndex* blockindex) UniValue blockheaderToJSON(const CBlockIndex* blockindex)
{ {
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
result.push_back(Pair("hash", blockindex->GetBlockHash().GetHex())); result.pushKV("hash", blockindex->GetBlockHash().GetHex());
int confirmations = -1; int confirmations = -1;
// Only report confirmations if the block is on the main chain // Only report confirmations if the block is on the main chain
if (chainActive.Contains(blockindex)) if (chainActive.Contains(blockindex))
confirmations = chainActive.Height() - blockindex->nHeight + 1; confirmations = chainActive.Height() - blockindex->nHeight + 1;
result.push_back(Pair("confirmations", confirmations)); result.pushKV("confirmations", confirmations);
result.push_back(Pair("height", blockindex->nHeight)); result.pushKV("height", blockindex->nHeight);
result.push_back(Pair("version", blockindex->nVersion)); result.pushKV("version", blockindex->nVersion);
result.push_back(Pair("versionHex", strprintf("%08x", blockindex->nVersion))); result.pushKV("versionHex", strprintf("%08x", blockindex->nVersion));
result.push_back(Pair("merkleroot", blockindex->hashMerkleRoot.GetHex())); result.pushKV("merkleroot", blockindex->hashMerkleRoot.GetHex());
result.push_back(Pair("time", (int64_t)blockindex->nTime)); result.pushKV("time", (int64_t)blockindex->nTime);
result.push_back(Pair("mediantime", (int64_t)blockindex->GetMedianTimePast())); result.pushKV("mediantime", (int64_t)blockindex->GetMedianTimePast());
result.push_back(Pair("nonce", (uint64_t)blockindex->nNonce)); result.pushKV("nonce", (uint64_t)blockindex->nNonce);
result.push_back(Pair("bits", strprintf("%08x", blockindex->nBits))); result.pushKV("bits", strprintf("%08x", blockindex->nBits));
result.push_back(Pair("difficulty", GetDifficulty(blockindex))); result.pushKV("difficulty", GetDifficulty(blockindex));
result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex())); result.pushKV("chainwork", blockindex->nChainWork.GetHex());
if (blockindex->pprev) if (blockindex->pprev)
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex())); result.pushKV("previousblockhash", blockindex->pprev->GetBlockHash().GetHex());
CBlockIndex *pnext = chainActive.Next(blockindex); CBlockIndex *pnext = chainActive.Next(blockindex);
if (pnext) if (pnext)
result.push_back(Pair("nextblockhash", pnext->GetBlockHash().GetHex())); result.pushKV("nextblockhash", pnext->GetBlockHash().GetHex());
return result; return result;
} }
UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false) UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false)
{ {
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
result.push_back(Pair("hash", blockindex->GetBlockHash().GetHex())); result.pushKV("hash", blockindex->GetBlockHash().GetHex());
int confirmations = -1; int confirmations = -1;
// Only report confirmations if the block is on the main chain // Only report confirmations if the block is on the main chain
if (chainActive.Contains(blockindex)) if (chainActive.Contains(blockindex))
confirmations = chainActive.Height() - blockindex->nHeight + 1; confirmations = chainActive.Height() - blockindex->nHeight + 1;
result.push_back(Pair("confirmations", confirmations)); result.pushKV("confirmations", confirmations);
result.push_back(Pair("strippedsize", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS))); result.pushKV("strippedsize", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS));
result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION))); result.pushKV("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION));
result.push_back(Pair("weight", (int)::GetBlockWeight(block))); result.pushKV("weight", (int)::GetBlockWeight(block));
result.push_back(Pair("height", blockindex->nHeight)); result.pushKV("height", blockindex->nHeight);
result.push_back(Pair("version", block.nVersion)); result.pushKV("version", block.nVersion);
result.push_back(Pair("versionHex", strprintf("%08x", block.nVersion))); result.pushKV("versionHex", strprintf("%08x", block.nVersion));
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex())); result.pushKV("merkleroot", block.hashMerkleRoot.GetHex());
UniValue txs(UniValue::VARR); UniValue txs(UniValue::VARR);
for(const auto& tx : block.vtx) for(const auto& tx : block.vtx)
{ {
@ -167,22 +167,22 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
else else
txs.push_back(tx->GetHash().GetHex()); txs.push_back(tx->GetHash().GetHex());
} }
result.push_back(Pair("tx", txs)); result.pushKV("tx", txs);
result.push_back(Pair("time", block.GetBlockTime())); result.pushKV("time", block.GetBlockTime());
result.push_back(Pair("mediantime", (int64_t)blockindex->GetMedianTimePast())); result.pushKV("mediantime", (int64_t)blockindex->GetMedianTimePast());
result.push_back(Pair("nonce", (uint64_t)block.nNonce)); result.pushKV("nonce", (uint64_t)block.nNonce);
result.push_back(Pair("bits", strprintf("%08x", block.nBits))); result.pushKV("bits", strprintf("%08x", block.nBits));
result.push_back(Pair("difficulty", GetDifficulty(blockindex))); result.pushKV("difficulty", GetDifficulty(blockindex));
result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex())); result.pushKV("chainwork", blockindex->nChainWork.GetHex());
if (block.auxpow) if (block.auxpow)
result.push_back(Pair("auxpow", AuxpowToJSON(*block.auxpow))); result.pushKV("auxpow", AuxpowToJSON(*block.auxpow));
if (blockindex->pprev) if (blockindex->pprev)
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex())); result.pushKV("previousblockhash", blockindex->pprev->GetBlockHash().GetHex());
CBlockIndex *pnext = chainActive.Next(blockindex); CBlockIndex *pnext = chainActive.Next(blockindex);
if (pnext) if (pnext)
result.push_back(Pair("nextblockhash", pnext->GetBlockHash().GetHex())); result.pushKV("nextblockhash", pnext->GetBlockHash().GetHex());
return result; return result;
} }
@ -263,8 +263,8 @@ UniValue waitfornewblock(const JSONRPCRequest& request)
block = latestblock; block = latestblock;
} }
UniValue ret(UniValue::VOBJ); UniValue ret(UniValue::VOBJ);
ret.push_back(Pair("hash", block.hash.GetHex())); ret.pushKV("hash", block.hash.GetHex());
ret.push_back(Pair("height", block.height)); ret.pushKV("height", block.height);
return ret; return ret;
} }
@ -305,8 +305,8 @@ UniValue waitforblock(const JSONRPCRequest& request)
} }
UniValue ret(UniValue::VOBJ); UniValue ret(UniValue::VOBJ);
ret.push_back(Pair("hash", block.hash.GetHex())); ret.pushKV("hash", block.hash.GetHex());
ret.push_back(Pair("height", block.height)); ret.pushKV("height", block.height);
return ret; return ret;
} }
@ -347,8 +347,8 @@ UniValue waitforblockheight(const JSONRPCRequest& request)
block = latestblock; block = latestblock;
} }
UniValue ret(UniValue::VOBJ); UniValue ret(UniValue::VOBJ);
ret.push_back(Pair("hash", block.hash.GetHex())); ret.pushKV("hash", block.hash.GetHex());
ret.push_back(Pair("height", block.height)); ret.pushKV("height", block.height);
return ret; return ret;
} }
@ -393,19 +393,19 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
{ {
AssertLockHeld(mempool.cs); AssertLockHeld(mempool.cs);
info.push_back(Pair("size", (int)e.GetTxSize())); info.pushKV("size", (int)e.GetTxSize());
info.push_back(Pair("fee", ValueFromAmount(e.GetFee()))); info.pushKV("fee", ValueFromAmount(e.GetFee()));
info.push_back(Pair("modifiedfee", ValueFromAmount(e.GetModifiedFee()))); info.pushKV("modifiedfee", ValueFromAmount(e.GetModifiedFee()));
info.push_back(Pair("time", e.GetTime())); info.pushKV("time", e.GetTime());
info.push_back(Pair("height", (int)e.GetHeight())); info.pushKV("height", (int)e.GetHeight());
info.push_back(Pair("startingpriority", e.GetPriority(e.GetHeight()))); info.pushKV("startingpriority", e.GetPriority(e.GetHeight()));
info.push_back(Pair("currentpriority", e.GetPriority(chainActive.Height()))); info.pushKV("currentpriority", e.GetPriority(chainActive.Height()));
info.push_back(Pair("descendantcount", e.GetCountWithDescendants())); info.pushKV("descendantcount", e.GetCountWithDescendants());
info.push_back(Pair("descendantsize", e.GetSizeWithDescendants())); info.pushKV("descendantsize", e.GetSizeWithDescendants());
info.push_back(Pair("descendantfees", e.GetModFeesWithDescendants())); info.pushKV("descendantfees", e.GetModFeesWithDescendants());
info.push_back(Pair("ancestorcount", e.GetCountWithAncestors())); info.pushKV("ancestorcount", e.GetCountWithAncestors());
info.push_back(Pair("ancestorsize", e.GetSizeWithAncestors())); info.pushKV("ancestorsize", e.GetSizeWithAncestors());
info.push_back(Pair("ancestorfees", e.GetModFeesWithAncestors())); info.pushKV("ancestorfees", e.GetModFeesWithAncestors());
const CTransaction& tx = e.GetTx(); const CTransaction& tx = e.GetTx();
set<string> setDepends; set<string> setDepends;
BOOST_FOREACH(const CTxIn& txin, tx.vin) BOOST_FOREACH(const CTxIn& txin, tx.vin)
@ -420,7 +420,7 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
depends.push_back(dep); depends.push_back(dep);
} }
info.push_back(Pair("depends", depends)); info.pushKV("depends", depends);
} }
UniValue mempoolToJSON(bool fVerbose = false) UniValue mempoolToJSON(bool fVerbose = false)
@ -434,7 +434,7 @@ UniValue mempoolToJSON(bool fVerbose = false)
const uint256& hash = e.GetTx().GetHash(); const uint256& hash = e.GetTx().GetHash();
UniValue info(UniValue::VOBJ); UniValue info(UniValue::VOBJ);
entryToJSON(info, e); entryToJSON(info, e);
o.push_back(Pair(hash.ToString(), info)); o.pushKV(hash.ToString(), info);
} }
return o; return o;
} }
@ -541,7 +541,7 @@ UniValue getmempoolancestors(const JSONRPCRequest& request)
const uint256& _hash = e.GetTx().GetHash(); const uint256& _hash = e.GetTx().GetHash();
UniValue info(UniValue::VOBJ); UniValue info(UniValue::VOBJ);
entryToJSON(info, e); entryToJSON(info, e);
o.push_back(Pair(_hash.ToString(), info)); o.pushKV(_hash.ToString(), info);
} }
return o; return o;
} }
@ -605,7 +605,7 @@ UniValue getmempooldescendants(const JSONRPCRequest& request)
const uint256& _hash = e.GetTx().GetHash(); const uint256& _hash = e.GetTx().GetHash();
UniValue info(UniValue::VOBJ); UniValue info(UniValue::VOBJ);
entryToJSON(info, e); entryToJSON(info, e);
o.push_back(Pair(_hash.ToString(), info)); o.pushKV(_hash.ToString(), info);
} }
return o; return o;
} }
@ -936,13 +936,13 @@ UniValue gettxoutsetinfo(const JSONRPCRequest& request)
CCoinsStats stats; CCoinsStats stats;
FlushStateToDisk(); FlushStateToDisk();
if (GetUTXOStats(pcoinsTip, stats)) { if (GetUTXOStats(pcoinsTip, stats)) {
ret.push_back(Pair("height", (int64_t)stats.nHeight)); ret.pushKV("height", (int64_t)stats.nHeight);
ret.push_back(Pair("bestblock", stats.hashBlock.GetHex())); ret.pushKV("bestblock", stats.hashBlock.GetHex());
ret.push_back(Pair("transactions", (int64_t)stats.nTransactions)); ret.pushKV("transactions", (int64_t)stats.nTransactions);
ret.push_back(Pair("txouts", (int64_t)stats.nTransactionOutputs)); ret.pushKV("txouts", (int64_t)stats.nTransactionOutputs);
ret.push_back(Pair("bytes_serialized", (int64_t)stats.nSerializedSize)); ret.pushKV("bytes_serialized", (int64_t)stats.nSerializedSize);
ret.push_back(Pair("hash_serialized", stats.hashSerialized.GetHex())); ret.pushKV("hash_serialized", stats.hashSerialized.GetHex());
ret.push_back(Pair("total_amount", ValueFromAmount(stats.nTotalAmount))); ret.pushKV("total_amount", ValueFromAmount(stats.nTotalAmount));
} else { } else {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to read UTXO set"); throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to read UTXO set");
} }
@ -1014,17 +1014,17 @@ UniValue gettxout(const JSONRPCRequest& request)
BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock()); BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
CBlockIndex *pindex = it->second; CBlockIndex *pindex = it->second;
ret.push_back(Pair("bestblock", pindex->GetBlockHash().GetHex())); ret.pushKV("bestblock", pindex->GetBlockHash().GetHex());
if ((unsigned int)coins.nHeight == MEMPOOL_HEIGHT) if ((unsigned int)coins.nHeight == MEMPOOL_HEIGHT)
ret.push_back(Pair("confirmations", 0)); ret.pushKV("confirmations", 0);
else else
ret.push_back(Pair("confirmations", pindex->nHeight - coins.nHeight + 1)); ret.pushKV("confirmations", pindex->nHeight - coins.nHeight + 1);
ret.push_back(Pair("value", ValueFromAmount(coins.vout[n].nValue))); ret.pushKV("value", ValueFromAmount(coins.vout[n].nValue));
UniValue o(UniValue::VOBJ); UniValue o(UniValue::VOBJ);
ScriptPubKeyToJSON(coins.vout[n].scriptPubKey, o, true); ScriptPubKeyToJSON(coins.vout[n].scriptPubKey, o, true);
ret.push_back(Pair("scriptPubKey", o)); ret.pushKV("scriptPubKey", o);
ret.push_back(Pair("version", coins.nVersion)); ret.pushKV("version", coins.nVersion);
ret.push_back(Pair("coinbase", coins.fCoinBase)); ret.pushKV("coinbase", coins.fCoinBase);
return ret; return ret;
} }
@ -1074,16 +1074,16 @@ static UniValue SoftForkMajorityDesc(int version, CBlockIndex* pindex, const Con
activated = pindex->nHeight >= consensusParams.BIP65Height; activated = pindex->nHeight >= consensusParams.BIP65Height;
break; break;
} }
rv.push_back(Pair("status", activated)); rv.pushKV("status", activated);
return rv; return rv;
} }
static UniValue SoftForkDesc(const std::string &name, int version, CBlockIndex* pindex, const Consensus::Params& consensusParams) static UniValue SoftForkDesc(const std::string &name, int version, CBlockIndex* pindex, const Consensus::Params& consensusParams)
{ {
UniValue rv(UniValue::VOBJ); UniValue rv(UniValue::VOBJ);
rv.push_back(Pair("id", name)); rv.pushKV("id", name);
rv.push_back(Pair("version", version)); rv.pushKV("version", version);
rv.push_back(Pair("reject", SoftForkMajorityDesc(version, pindex, consensusParams))); rv.pushKV("reject", SoftForkMajorityDesc(version, pindex, consensusParams));
return rv; return rv;
} }
@ -1092,19 +1092,19 @@ static UniValue BIP9SoftForkDesc(const Consensus::Params& consensusParams, Conse
UniValue rv(UniValue::VOBJ); UniValue rv(UniValue::VOBJ);
const ThresholdState thresholdState = VersionBitsTipState(consensusParams, id); const ThresholdState thresholdState = VersionBitsTipState(consensusParams, id);
switch (thresholdState) { switch (thresholdState) {
case THRESHOLD_DEFINED: rv.push_back(Pair("status", "defined")); break; case THRESHOLD_DEFINED: rv.pushKV("status", "defined"); break;
case THRESHOLD_STARTED: rv.push_back(Pair("status", "started")); break; case THRESHOLD_STARTED: rv.pushKV("status", "started"); break;
case THRESHOLD_LOCKED_IN: rv.push_back(Pair("status", "locked_in")); break; case THRESHOLD_LOCKED_IN: rv.pushKV("status", "locked_in"); break;
case THRESHOLD_ACTIVE: rv.push_back(Pair("status", "active")); break; case THRESHOLD_ACTIVE: rv.pushKV("status", "active"); break;
case THRESHOLD_FAILED: rv.push_back(Pair("status", "failed")); break; case THRESHOLD_FAILED: rv.pushKV("status", "failed"); break;
} }
if (THRESHOLD_STARTED == thresholdState) if (THRESHOLD_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.pushKV("startTime", consensusParams.vDeployments[id].nStartTime);
rv.push_back(Pair("timeout", consensusParams.vDeployments[id].nTimeout)); rv.pushKV("timeout", consensusParams.vDeployments[id].nTimeout);
rv.push_back(Pair("since", VersionBitsTipStateSinceHeight(consensusParams, id))); rv.pushKV("since", VersionBitsTipStateSinceHeight(consensusParams, id));
return rv; return rv;
} }
@ -1114,7 +1114,7 @@ void BIP9SoftForkDescPushBack(UniValue& bip9_softforks, const std::string &name,
// A timeout value of 0 guarantees a softfork will never be activated. // 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. // This is used when softfork codes are merged without specifying the deployment schedule.
if (consensusParams.vDeployments[id].nTimeout > 0) if (consensusParams.vDeployments[id].nTimeout > 0)
bip9_softforks.push_back(Pair(name, BIP9SoftForkDesc(consensusParams, id))); bip9_softforks.pushKV(name, BIP9SoftForkDesc(consensusParams, id));
} }
UniValue getblockchaininfo(const JSONRPCRequest& request) UniValue getblockchaininfo(const JSONRPCRequest& request)
@ -1166,17 +1166,17 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
LOCK(cs_main); LOCK(cs_main);
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("chain", Params().NetworkIDString())); obj.pushKV("chain", Params().NetworkIDString());
obj.push_back(Pair("blocks", (int)chainActive.Height())); obj.pushKV("blocks", (int)chainActive.Height());
obj.push_back(Pair("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1)); obj.pushKV("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1);
obj.push_back(Pair("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex())); obj.pushKV("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex());
obj.push_back(Pair("difficulty", (double)GetDifficulty())); obj.pushKV("difficulty", (double)GetDifficulty());
obj.push_back(Pair("mediantime", (int64_t)chainActive.Tip()->GetMedianTimePast())); obj.pushKV("mediantime", (int64_t)chainActive.Tip()->GetMedianTimePast());
obj.push_back(Pair("verificationprogress", GuessVerificationProgress(Params().TxData(), chainActive.Tip()))); obj.pushKV("verificationprogress", GuessVerificationProgress(Params().TxData(), chainActive.Tip()));
obj.push_back(Pair("initialblockdownload", IsInitialBlockDownload())); obj.pushKV("initialblockdownload", IsInitialBlockDownload());
obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex())); obj.pushKV("chainwork", chainActive.Tip()->nChainWork.GetHex());
obj.push_back(Pair("size_on_disk", CalculateCurrentUsage())); obj.pushKV("size_on_disk", CalculateCurrentUsage());
obj.push_back(Pair("pruned", fPruneMode)); obj.pushKV("pruned", fPruneMode);
if (fPruneMode) { if (fPruneMode) {
CBlockIndex* block = chainActive.Tip(); CBlockIndex* block = chainActive.Tip();
assert(block); assert(block);
@ -1184,13 +1184,13 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
block = block->pprev; block = block->pprev;
} }
obj.push_back(Pair("pruneheight", block->nHeight)); obj.pushKV("pruneheight", block->nHeight);
// if 0, execution bypasses the whole if block. // if 0, execution bypasses the whole if block.
bool automatic_pruning = (GetArg("-prune", 0) != 1); bool automatic_pruning = (GetArg("-prune", 0) != 1);
obj.push_back(Pair("automatic_pruning", automatic_pruning)); obj.pushKV("automatic_pruning", automatic_pruning);
if (automatic_pruning) { if (automatic_pruning) {
obj.push_back(Pair("prune_target_size", nPruneTarget)); obj.pushKV("prune_target_size", nPruneTarget);
} }
} }
@ -1203,9 +1203,9 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams)); softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams));
BIP9SoftForkDescPushBack(bip9_softforks, "csv", consensusParams, Consensus::DEPLOYMENT_CSV); BIP9SoftForkDescPushBack(bip9_softforks, "csv", consensusParams, Consensus::DEPLOYMENT_CSV);
BIP9SoftForkDescPushBack(bip9_softforks, "segwit", consensusParams, Consensus::DEPLOYMENT_SEGWIT); BIP9SoftForkDescPushBack(bip9_softforks, "segwit", consensusParams, Consensus::DEPLOYMENT_SEGWIT);
obj.push_back(Pair("softforks", softforks)); obj.pushKV("softforks", softforks);
obj.push_back(Pair("bip9_softforks", bip9_softforks)); obj.pushKV("bip9_softforks", bip9_softforks);
obj.push_back(Pair("warnings", GetWarnings("statusbar"))); obj.pushKV("warnings", GetWarnings("statusbar"));
return obj; return obj;
} }
@ -1293,11 +1293,11 @@ UniValue getchaintips(const JSONRPCRequest& request)
BOOST_FOREACH(const CBlockIndex* block, setTips) BOOST_FOREACH(const CBlockIndex* block, setTips)
{ {
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("height", block->nHeight)); obj.pushKV("height", block->nHeight);
obj.push_back(Pair("hash", block->phashBlock->GetHex())); obj.pushKV("hash", block->phashBlock->GetHex());
const int branchLen = block->nHeight - chainActive.FindFork(block)->nHeight; const int branchLen = block->nHeight - chainActive.FindFork(block)->nHeight;
obj.push_back(Pair("branchlen", branchLen)); obj.pushKV("branchlen", branchLen);
string status; string status;
if (chainActive.Contains(block)) { if (chainActive.Contains(block)) {
@ -1319,7 +1319,7 @@ UniValue getchaintips(const JSONRPCRequest& request)
// No clue. // No clue.
status = "unknown"; status = "unknown";
} }
obj.push_back(Pair("status", status)); obj.pushKV("status", status);
res.push_back(obj); res.push_back(obj);
} }
@ -1330,12 +1330,12 @@ UniValue getchaintips(const JSONRPCRequest& request)
UniValue mempoolInfoToJSON() UniValue mempoolInfoToJSON()
{ {
UniValue ret(UniValue::VOBJ); UniValue ret(UniValue::VOBJ);
ret.push_back(Pair("size", (int64_t) mempool.size())); ret.pushKV("size", (int64_t) mempool.size());
ret.push_back(Pair("bytes", (int64_t) mempool.GetTotalTxSize())); ret.pushKV("bytes", (int64_t) mempool.GetTotalTxSize());
ret.push_back(Pair("usage", (int64_t) mempool.DynamicMemoryUsage())); ret.pushKV("usage", (int64_t) mempool.DynamicMemoryUsage());
size_t maxmempool = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; size_t maxmempool = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
ret.push_back(Pair("maxmempool", (int64_t) maxmempool)); ret.pushKV("maxmempool", (int64_t) maxmempool);
ret.push_back(Pair("mempoolminfee", ValueFromAmount(mempool.GetMinFee(maxmempool).GetFeePerK()))); ret.pushKV("mempoolminfee", ValueFromAmount(mempool.GetMinFee(maxmempool).GetFeePerK()));
return ret; return ret;
} }

View file

@ -278,15 +278,15 @@ UniValue getmininginfo(const JSONRPCRequest& request)
LOCK(cs_main); LOCK(cs_main);
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("blocks", (int)chainActive.Height())); obj.pushKV("blocks", (int)chainActive.Height());
obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize)); obj.pushKV("currentblocksize", (uint64_t)nLastBlockSize);
obj.push_back(Pair("currentblockweight", (uint64_t)nLastBlockWeight)); obj.pushKV("currentblockweight", (uint64_t)nLastBlockWeight);
obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx)); obj.pushKV("currentblocktx", (uint64_t)nLastBlockTx);
obj.push_back(Pair("difficulty", (double)GetDifficulty())); obj.pushKV("difficulty", (double)GetDifficulty());
obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.pushKV("errors", GetWarnings("statusbar"));
obj.push_back(Pair("networkhashps", getnetworkhashps(request))); obj.pushKV("networkhashps", getnetworkhashps(request));
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); obj.pushKV("pooledtx", (uint64_t)mempool.size());
obj.push_back(Pair("chain", Params().NetworkIDString())); obj.pushKV("chain", Params().NetworkIDString());
return obj; return obj;
} }
@ -617,9 +617,9 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
UniValue entry(UniValue::VOBJ); UniValue entry(UniValue::VOBJ);
entry.push_back(Pair("data", EncodeHexTx(tx))); entry.pushKV("data", EncodeHexTx(tx));
entry.push_back(Pair("txid", txHash.GetHex())); entry.pushKV("txid", txHash.GetHex());
entry.push_back(Pair("hash", tx.GetWitnessHash().GetHex())); entry.pushKV("hash", tx.GetWitnessHash().GetHex());
UniValue deps(UniValue::VARR); UniValue deps(UniValue::VARR);
BOOST_FOREACH (const CTxIn &in, tx.vin) BOOST_FOREACH (const CTxIn &in, tx.vin)
@ -627,23 +627,23 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
if (setTxIndex.count(in.prevout.hash)) if (setTxIndex.count(in.prevout.hash))
deps.push_back(setTxIndex[in.prevout.hash]); deps.push_back(setTxIndex[in.prevout.hash]);
} }
entry.push_back(Pair("depends", deps)); entry.pushKV("depends", deps);
int index_in_template = i - 1; int index_in_template = i - 1;
entry.push_back(Pair("fee", pblocktemplate->vTxFees[index_in_template])); entry.pushKV("fee", pblocktemplate->vTxFees[index_in_template]);
int64_t nTxSigOps = pblocktemplate->vTxSigOpsCost[index_in_template]; int64_t nTxSigOps = pblocktemplate->vTxSigOpsCost[index_in_template];
if (fPreSegWit) { if (fPreSegWit) {
assert(nTxSigOps % WITNESS_SCALE_FACTOR == 0); assert(nTxSigOps % WITNESS_SCALE_FACTOR == 0);
nTxSigOps /= WITNESS_SCALE_FACTOR; nTxSigOps /= WITNESS_SCALE_FACTOR;
} }
entry.push_back(Pair("sigops", nTxSigOps)); entry.pushKV("sigops", nTxSigOps);
entry.push_back(Pair("weight", GetTransactionWeight(tx))); entry.pushKV("weight", GetTransactionWeight(tx));
transactions.push_back(entry); transactions.push_back(entry);
} }
UniValue aux(UniValue::VOBJ); 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); arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits);
@ -653,7 +653,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
aMutable.push_back("prevblock"); aMutable.push_back("prevblock");
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
result.push_back(Pair("capabilities", aCaps)); result.pushKV("capabilities", aCaps);
UniValue aRules(UniValue::VARR); UniValue aRules(UniValue::VARR);
UniValue vbavailable(UniValue::VOBJ); UniValue vbavailable(UniValue::VOBJ);
@ -674,7 +674,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
case THRESHOLD_STARTED: case THRESHOLD_STARTED:
{ {
const struct BIP9DeploymentInfo& vbinfo = VersionBitsDeploymentInfo[pos]; const struct BIP9DeploymentInfo& 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 (setClientRules.find(vbinfo.name) == setClientRules.end()) {
if (!vbinfo.gbt_force) { if (!vbinfo.gbt_force) {
// If the client doesn't support this, don't indicate it in the [default] version // If the client doesn't support this, don't indicate it in the [default] version
@ -699,10 +699,10 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
} }
} }
} }
result.push_back(Pair("version", pblock->nVersion)); result.pushKV("version", pblock->nVersion);
result.push_back(Pair("rules", aRules)); result.pushKV("rules", aRules);
result.push_back(Pair("vbavailable", vbavailable)); result.pushKV("vbavailable", vbavailable);
result.push_back(Pair("vbrequired", int(0))); result.pushKV("vbrequired", int(0));
if (nMaxVersionPreVB >= 2) { if (nMaxVersionPreVB >= 2) {
// If VB is supported by the client, nMaxVersionPreVB is -1, so we won't get here // If VB is supported by the client, nMaxVersionPreVB is -1, so we won't get here
@ -712,33 +712,33 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
aMutable.push_back("version/force"); aMutable.push_back("version/force");
} }
result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex())); result.pushKV("previousblockhash", pblock->hashPrevBlock.GetHex());
result.push_back(Pair("transactions", transactions)); result.pushKV("transactions", transactions);
result.push_back(Pair("coinbaseaux", aux)); result.pushKV("coinbaseaux", aux);
result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0]->vout[0].nValue)); result.pushKV("coinbasevalue", (int64_t)pblock->vtx[0]->vout[0].nValue);
result.push_back(Pair("longpollid", chainActive.Tip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast))); result.pushKV("longpollid", chainActive.Tip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast));
result.push_back(Pair("target", hashTarget.GetHex())); result.pushKV("target", hashTarget.GetHex());
result.push_back(Pair("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1)); result.pushKV("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1);
result.push_back(Pair("mutable", aMutable)); result.pushKV("mutable", aMutable);
result.push_back(Pair("noncerange", "00000000ffffffff")); result.pushKV("noncerange", "00000000ffffffff");
int64_t nSigOpLimit = MAX_BLOCK_SIGOPS_COST; int64_t nSigOpLimit = MAX_BLOCK_SIGOPS_COST;
if (fPreSegWit) { if (fPreSegWit) {
assert(nSigOpLimit % WITNESS_SCALE_FACTOR == 0); assert(nSigOpLimit % WITNESS_SCALE_FACTOR == 0);
nSigOpLimit /= WITNESS_SCALE_FACTOR; nSigOpLimit /= WITNESS_SCALE_FACTOR;
} }
result.push_back(Pair("sigoplimit", nSigOpLimit)); result.pushKV("sigoplimit", nSigOpLimit);
if (fPreSegWit) { if (fPreSegWit) {
result.push_back(Pair("sizelimit", (int64_t)MAX_BLOCK_BASE_SIZE)); result.pushKV("sizelimit", (int64_t)MAX_BLOCK_BASE_SIZE);
} else { } else {
result.push_back(Pair("sizelimit", (int64_t)MAX_BLOCK_SERIALIZED_SIZE)); result.pushKV("sizelimit", (int64_t)MAX_BLOCK_SERIALIZED_SIZE);
result.push_back(Pair("weightlimit", (int64_t)MAX_BLOCK_WEIGHT)); result.pushKV("weightlimit", (int64_t)MAX_BLOCK_WEIGHT);
} }
result.push_back(Pair("curtime", pblock->GetBlockTime())); result.pushKV("curtime", pblock->GetBlockTime());
result.push_back(Pair("bits", strprintf("%08x", pblock->nBits))); result.pushKV("bits", strprintf("%08x", pblock->nBits));
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1))); result.pushKV("height", (int64_t)(pindexPrev->nHeight+1));
if (!pblocktemplate->vchCoinbaseCommitment.empty() && fSupportsSegwit) { if (!pblocktemplate->vchCoinbaseCommitment.empty() && fSupportsSegwit) {
result.push_back(Pair("default_witness_commitment", HexStr(pblocktemplate->vchCoinbaseCommitment.begin(), pblocktemplate->vchCoinbaseCommitment.end()))); result.pushKV("default_witness_commitment", HexStr(pblocktemplate->vchCoinbaseCommitment.begin(), pblocktemplate->vchCoinbaseCommitment.end()));
} }
return result; return result;
@ -925,8 +925,8 @@ UniValue estimatesmartfee(const JSONRPCRequest& request)
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
int answerFound; int answerFound;
CFeeRate feeRate = mempool.estimateSmartFee(nBlocks, &answerFound); CFeeRate feeRate = mempool.estimateSmartFee(nBlocks, &answerFound);
result.push_back(Pair("feerate", feeRate == CFeeRate(0) ? -1.0 : ValueFromAmount(feeRate.GetFeePerK()))); result.pushKV("feerate", feeRate == CFeeRate(0) ? -1.0 : ValueFromAmount(feeRate.GetFeePerK()));
result.push_back(Pair("blocks", answerFound)); result.pushKV("blocks", answerFound);
return result; return result;
} }
@ -961,8 +961,8 @@ UniValue estimatesmartpriority(const JSONRPCRequest& request)
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
int answerFound; int answerFound;
double priority = mempool.estimateSmartPriority(nBlocks, &answerFound); double priority = mempool.estimateSmartPriority(nBlocks, &answerFound);
result.push_back(Pair("priority", priority)); result.pushKV("priority", priority);
result.push_back(Pair("blocks", answerFound)); result.pushKV("blocks", answerFound);
return result; return result;
} }
@ -1091,13 +1091,13 @@ UniValue getauxblockbip22(const JSONRPCRequest& request)
throw std::runtime_error("invalid difficulty bits in block"); throw std::runtime_error("invalid difficulty bits in block");
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
result.push_back(Pair("hash", pblock->GetHash().GetHex())); result.pushKV("hash", pblock->GetHash().GetHex());
result.push_back(Pair("chainid", pblock->GetChainId())); result.pushKV("chainid", pblock->GetChainId());
result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex())); result.pushKV("previousblockhash", pblock->hashPrevBlock.GetHex());
result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0]->vout[0].nValue)); result.pushKV("coinbasevalue", (int64_t)pblock->vtx[0]->vout[0].nValue);
result.push_back(Pair("bits", strprintf("%08x", pblock->nBits))); result.pushKV("bits", strprintf("%08x", pblock->nBits));
result.push_back(Pair("height", static_cast<int64_t> (pindexPrev->nHeight + 1))); result.pushKV("height", static_cast<int64_t> (pindexPrev->nHeight + 1));
result.push_back(Pair("target", HexStr(BEGIN(target), END(target)))); result.pushKV("target", HexStr(BEGIN(target), END(target)));
return result; return result;
} }

View file

@ -79,32 +79,32 @@ UniValue getinfo(const JSONRPCRequest& request)
GetProxy(NET_IPV4, proxy); GetProxy(NET_IPV4, proxy);
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("version", CLIENT_VERSION)); obj.pushKV("version", CLIENT_VERSION);
obj.push_back(Pair("protocolversion", PROTOCOL_VERSION)); obj.pushKV("protocolversion", PROTOCOL_VERSION);
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if (pwalletMain) { if (pwalletMain) {
obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); obj.pushKV("walletversion", pwalletMain->GetVersion());
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); obj.pushKV("balance", ValueFromAmount(pwalletMain->GetBalance()));
} }
#endif #endif
obj.push_back(Pair("blocks", (int)chainActive.Height())); obj.pushKV("blocks", (int)chainActive.Height());
obj.push_back(Pair("timeoffset", GetTimeOffset())); obj.pushKV("timeoffset", GetTimeOffset());
if(g_connman) if(g_connman)
obj.push_back(Pair("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL))); obj.pushKV("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL));
obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string()))); obj.pushKV("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string()));
obj.push_back(Pair("difficulty", (double)GetDifficulty())); obj.pushKV("difficulty", (double)GetDifficulty());
obj.push_back(Pair("testnet", Params().NetworkIDString() == CBaseChainParams::TESTNET)); obj.pushKV("testnet", Params().NetworkIDString() == CBaseChainParams::TESTNET);
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if (pwalletMain) { if (pwalletMain) {
obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime())); obj.pushKV("keypoololdest", pwalletMain->GetOldestKeyPoolTime());
obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); obj.pushKV("keypoolsize", (int)pwalletMain->GetKeyPoolSize());
} }
if (pwalletMain && pwalletMain->IsCrypted()) if (pwalletMain && pwalletMain->IsCrypted())
obj.push_back(Pair("unlocked_until", nWalletUnlockTime)); obj.pushKV("unlocked_until", nWalletUnlockTime);
obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); obj.pushKV("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()));
#endif #endif
obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFeeRate.GetFeePerK()))); obj.pushKV("relayfee", ValueFromAmount(::minRelayTxFeeRate.GetFeePerK()));
obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.pushKV("errors", GetWarnings("statusbar"));
return obj; return obj;
} }
@ -117,10 +117,10 @@ public:
UniValue operator()(const CKeyID &keyID) const { UniValue operator()(const CKeyID &keyID) const {
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
CPubKey vchPubKey; CPubKey vchPubKey;
obj.push_back(Pair("isscript", false)); obj.pushKV("isscript", false);
if (pwalletMain && pwalletMain->GetPubKey(keyID, vchPubKey)) { if (pwalletMain && pwalletMain->GetPubKey(keyID, vchPubKey)) {
obj.push_back(Pair("pubkey", HexStr(vchPubKey))); obj.pushKV("pubkey", HexStr(vchPubKey));
obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed())); obj.pushKV("iscompressed", vchPubKey.IsCompressed());
} }
return obj; return obj;
} }
@ -128,20 +128,20 @@ public:
UniValue operator()(const CScriptID &scriptID) const { UniValue operator()(const CScriptID &scriptID) const {
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
CScript subscript; CScript subscript;
obj.push_back(Pair("isscript", true)); obj.pushKV("isscript", true);
if (pwalletMain && pwalletMain->GetCScript(scriptID, subscript)) { if (pwalletMain && pwalletMain->GetCScript(scriptID, subscript)) {
std::vector<CTxDestination> addresses; std::vector<CTxDestination> addresses;
txnouttype whichType; txnouttype whichType;
int nRequired; int nRequired;
ExtractDestinations(subscript, whichType, addresses, nRequired); ExtractDestinations(subscript, whichType, addresses, nRequired);
obj.push_back(Pair("script", GetTxnOutputType(whichType))); obj.pushKV("script", GetTxnOutputType(whichType));
obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end()))); obj.pushKV("hex", HexStr(subscript.begin(), subscript.end()));
UniValue a(UniValue::VARR); UniValue a(UniValue::VARR);
BOOST_FOREACH(const CTxDestination& addr, addresses) BOOST_FOREACH(const CTxDestination& addr, addresses)
a.push_back(CBitcoinAddress(addr).ToString()); a.push_back(CBitcoinAddress(addr).ToString());
obj.push_back(Pair("addresses", a)); obj.pushKV("addresses", a);
if (whichType == TX_MULTISIG) if (whichType == TX_MULTISIG)
obj.push_back(Pair("sigsrequired", nRequired)); obj.pushKV("sigsrequired", nRequired);
} }
return obj; return obj;
} }
@ -186,24 +186,24 @@ UniValue validateaddress(const JSONRPCRequest& request)
bool isValid = address.IsValid(); bool isValid = address.IsValid();
UniValue ret(UniValue::VOBJ); UniValue ret(UniValue::VOBJ);
ret.push_back(Pair("isvalid", isValid)); ret.pushKV("isvalid", isValid);
if (isValid) if (isValid)
{ {
CTxDestination dest = address.Get(); CTxDestination dest = address.Get();
string currentAddress = address.ToString(); string currentAddress = address.ToString();
ret.push_back(Pair("address", currentAddress)); ret.pushKV("address", currentAddress);
CScript scriptPubKey = GetScriptForDestination(dest); 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 #ifdef ENABLE_WALLET
isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO;
ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); ret.pushKV("ismine", (mine & ISMINE_SPENDABLE) ? true : false);
ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false)); ret.pushKV("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false);
UniValue detail = boost::apply_visitor(DescribeAddressVisitor(), dest); UniValue detail = boost::apply_visitor(DescribeAddressVisitor(), dest);
ret.pushKVs(detail); ret.pushKVs(detail);
if (pwalletMain && pwalletMain->mapAddressBook.count(dest)) if (pwalletMain && pwalletMain->mapAddressBook.count(dest))
ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest].name)); ret.pushKV("account", pwalletMain->mapAddressBook[dest].name);
CKeyID keyID; CKeyID keyID;
if (pwalletMain) { if (pwalletMain) {
const auto& meta = pwalletMain->mapKeyMetadata; const auto& meta = pwalletMain->mapKeyMetadata;
@ -212,10 +212,10 @@ UniValue validateaddress(const JSONRPCRequest& request)
it = meta.find(CScriptID(scriptPubKey)); it = meta.find(CScriptID(scriptPubKey));
} }
if (it != meta.end()) { if (it != meta.end()) {
ret.push_back(Pair("timestamp", it->second.nCreateTime)); ret.pushKV("timestamp", it->second.nCreateTime);
if (!it->second.hdKeypath.empty()) { if (!it->second.hdKeypath.empty()) {
ret.push_back(Pair("hdkeypath", it->second.hdKeypath)); ret.pushKV("hdkeypath", it->second.hdKeypath);
ret.push_back(Pair("hdmasterkeyid", it->second.hdMasterKeyID.GetHex())); ret.pushKV("hdmasterkeyid", it->second.hdMasterKeyID.GetHex());
} }
} }
} }
@ -325,8 +325,8 @@ UniValue createmultisig(const JSONRPCRequest& request)
CBitcoinAddress address(innerID); CBitcoinAddress address(innerID);
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
result.push_back(Pair("address", address.ToString())); result.pushKV("address", address.ToString());
result.push_back(Pair("redeemScript", HexStr(inner.begin(), inner.end()))); result.pushKV("redeemScript", HexStr(inner.begin(), inner.end()));
return result; return result;
} }
@ -458,12 +458,12 @@ static UniValue RPCLockedMemoryInfo()
{ {
LockedPool::Stats stats = LockedPoolManager::Instance().stats(); LockedPool::Stats stats = LockedPoolManager::Instance().stats();
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("used", uint64_t(stats.used))); obj.pushKV("used", uint64_t(stats.used));
obj.push_back(Pair("free", uint64_t(stats.free))); obj.pushKV("free", uint64_t(stats.free));
obj.push_back(Pair("total", uint64_t(stats.total))); obj.pushKV("total", uint64_t(stats.total));
obj.push_back(Pair("locked", uint64_t(stats.locked))); obj.pushKV("locked", uint64_t(stats.locked));
obj.push_back(Pair("chunks_used", uint64_t(stats.chunks_used))); obj.pushKV("chunks_used", uint64_t(stats.chunks_used));
obj.push_back(Pair("chunks_free", uint64_t(stats.chunks_free))); obj.pushKV("chunks_free", uint64_t(stats.chunks_free));
return obj; return obj;
} }
@ -492,7 +492,7 @@ UniValue getmemoryinfo(const JSONRPCRequest& request)
+ HelpExampleRpc("getmemoryinfo", "") + HelpExampleRpc("getmemoryinfo", "")
); );
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("locked", RPCLockedMemoryInfo())); obj.pushKV("locked", RPCLockedMemoryInfo());
return obj; return obj;
} }

View file

@ -133,58 +133,58 @@ UniValue getpeerinfo(const JSONRPCRequest& request)
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
CNodeStateStats statestats; CNodeStateStats statestats;
bool fStateStats = GetNodeStateStats(stats.nodeid, statestats); bool fStateStats = GetNodeStateStats(stats.nodeid, statestats);
obj.push_back(Pair("id", stats.nodeid)); obj.pushKV("id", stats.nodeid);
obj.push_back(Pair("addr", stats.addrName)); obj.pushKV("addr", stats.addrName);
if (!(stats.addrLocal.empty())) if (!(stats.addrLocal.empty()))
obj.push_back(Pair("addrlocal", stats.addrLocal)); obj.pushKV("addrlocal", stats.addrLocal);
obj.push_back(Pair("services", strprintf("%016x", stats.nServices))); obj.pushKV("services", strprintf("%016x", stats.nServices));
obj.push_back(Pair("relaytxes", stats.fRelayTxes)); obj.pushKV("relaytxes", stats.fRelayTxes);
obj.push_back(Pair("lastsend", stats.nLastSend)); obj.pushKV("lastsend", stats.nLastSend);
obj.push_back(Pair("lastrecv", stats.nLastRecv)); obj.pushKV("lastrecv", stats.nLastRecv);
obj.push_back(Pair("bytessent", stats.nSendBytes)); obj.pushKV("bytessent", stats.nSendBytes);
obj.push_back(Pair("bytesrecv", stats.nRecvBytes)); obj.pushKV("bytesrecv", stats.nRecvBytes);
obj.push_back(Pair("conntime", stats.nTimeConnected)); obj.pushKV("conntime", stats.nTimeConnected);
obj.push_back(Pair("timeoffset", stats.nTimeOffset)); obj.pushKV("timeoffset", stats.nTimeOffset);
if (stats.dPingTime > 0.0) if (stats.dPingTime > 0.0)
obj.push_back(Pair("pingtime", stats.dPingTime)); obj.pushKV("pingtime", stats.dPingTime);
if (stats.dMinPing < std::numeric_limits<int64_t>::max()/1e6) if (stats.dMinPing < std::numeric_limits<int64_t>::max()/1e6)
obj.push_back(Pair("minping", stats.dMinPing)); obj.pushKV("minping", stats.dMinPing);
if (stats.dPingWait > 0.0) if (stats.dPingWait > 0.0)
obj.push_back(Pair("pingwait", stats.dPingWait)); obj.pushKV("pingwait", stats.dPingWait);
obj.push_back(Pair("version", stats.nVersion)); obj.pushKV("version", stats.nVersion);
// Use the sanitized form of subver here, to avoid tricksy remote peers from // Use the sanitized form of subver here, to avoid tricksy remote peers from
// corrupting or modifying the JSON output by putting special characters in // corrupting or modifying the JSON output by putting special characters in
// their ver message. // their ver message.
obj.push_back(Pair("subver", stats.cleanSubVer)); obj.pushKV("subver", stats.cleanSubVer);
obj.push_back(Pair("inbound", stats.fInbound)); obj.pushKV("inbound", stats.fInbound);
obj.push_back(Pair("addnode", stats.fAddnode)); obj.pushKV("addnode", stats.fAddnode);
obj.push_back(Pair("startingheight", stats.nStartingHeight)); obj.pushKV("startingheight", stats.nStartingHeight);
obj.push_back(Pair("feefilter", FormatMoney(stats.minFeeFilter))); obj.pushKV("feefilter", FormatMoney(stats.minFeeFilter));
if (fStateStats) { if (fStateStats) {
obj.push_back(Pair("banscore", statestats.nMisbehavior)); obj.pushKV("banscore", statestats.nMisbehavior);
obj.push_back(Pair("synced_headers", statestats.nSyncHeight)); obj.pushKV("synced_headers", statestats.nSyncHeight);
obj.push_back(Pair("synced_blocks", statestats.nCommonHeight)); obj.pushKV("synced_blocks", statestats.nCommonHeight);
UniValue heights(UniValue::VARR); UniValue heights(UniValue::VARR);
BOOST_FOREACH(int height, statestats.vHeightInFlight) { BOOST_FOREACH(int height, statestats.vHeightInFlight) {
heights.push_back(height); 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); UniValue sendPerMsgCmd(UniValue::VOBJ);
BOOST_FOREACH(const mapMsgCmdSize::value_type &i, stats.mapSendBytesPerMsgCmd) { BOOST_FOREACH(const mapMsgCmdSize::value_type &i, stats.mapSendBytesPerMsgCmd) {
if (i.second > 0) 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); UniValue recvPerMsgCmd(UniValue::VOBJ);
BOOST_FOREACH(const mapMsgCmdSize::value_type &i, stats.mapRecvBytesPerMsgCmd) { BOOST_FOREACH(const mapMsgCmdSize::value_type &i, stats.mapRecvBytesPerMsgCmd) {
if (i.second > 0) 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); ret.push_back(obj);
} }
@ -312,16 +312,16 @@ UniValue getaddednodeinfo(const JSONRPCRequest& request)
for (const AddedNodeInfo& info : vInfo) { for (const AddedNodeInfo& info : vInfo) {
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("addednode", info.strAddedNode)); obj.pushKV("addednode", info.strAddedNode);
obj.push_back(Pair("connected", info.fConnected)); obj.pushKV("connected", info.fConnected);
UniValue addresses(UniValue::VARR); UniValue addresses(UniValue::VARR);
if (info.fConnected) { if (info.fConnected) {
UniValue address(UniValue::VOBJ); UniValue address(UniValue::VOBJ);
address.push_back(Pair("address", info.resolvedAddress.ToString())); address.pushKV("address", info.resolvedAddress.ToString());
address.push_back(Pair("connected", info.fInbound ? "inbound" : "outbound")); address.pushKV("connected", info.fInbound ? "inbound" : "outbound");
addresses.push_back(address); addresses.push_back(address);
} }
obj.push_back(Pair("addresses", addresses)); obj.pushKV("addresses", addresses);
ret.push_back(obj); ret.push_back(obj);
} }
@ -358,18 +358,18 @@ UniValue getnettotals(const JSONRPCRequest& request)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("totalbytesrecv", g_connman->GetTotalBytesRecv())); obj.pushKV("totalbytesrecv", g_connman->GetTotalBytesRecv());
obj.push_back(Pair("totalbytessent", g_connman->GetTotalBytesSent())); obj.pushKV("totalbytessent", g_connman->GetTotalBytesSent());
obj.push_back(Pair("timemillis", GetTimeMillis())); obj.pushKV("timemillis", GetTimeMillis());
UniValue outboundLimit(UniValue::VOBJ); UniValue outboundLimit(UniValue::VOBJ);
outboundLimit.push_back(Pair("timeframe", g_connman->GetMaxOutboundTimeframe())); outboundLimit.pushKV("timeframe", g_connman->GetMaxOutboundTimeframe());
outboundLimit.push_back(Pair("target", g_connman->GetMaxOutboundTarget())); outboundLimit.pushKV("target", g_connman->GetMaxOutboundTarget());
outboundLimit.push_back(Pair("target_reached", g_connman->OutboundTargetReached(false))); outboundLimit.pushKV("target_reached", g_connman->OutboundTargetReached(false));
outboundLimit.push_back(Pair("serve_historical_blocks", !g_connman->OutboundTargetReached(true))); outboundLimit.pushKV("serve_historical_blocks", !g_connman->OutboundTargetReached(true));
outboundLimit.push_back(Pair("bytes_left_in_cycle", g_connman->GetOutboundTargetBytesLeft())); outboundLimit.pushKV("bytes_left_in_cycle", g_connman->GetOutboundTargetBytesLeft());
outboundLimit.push_back(Pair("time_left_in_cycle", g_connman->GetMaxOutboundTimeLeftInCycle())); outboundLimit.pushKV("time_left_in_cycle", g_connman->GetMaxOutboundTimeLeftInCycle());
obj.push_back(Pair("uploadtarget", outboundLimit)); obj.pushKV("uploadtarget", outboundLimit);
return obj; return obj;
} }
@ -384,11 +384,11 @@ static UniValue GetNetworksInfo()
proxyType proxy; proxyType proxy;
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
GetProxy(network, proxy); GetProxy(network, proxy);
obj.push_back(Pair("name", GetNetworkName(network))); obj.pushKV("name", GetNetworkName(network));
obj.push_back(Pair("limited", IsLimited(network))); obj.pushKV("limited", IsLimited(network));
obj.push_back(Pair("reachable", IsReachable(network))); obj.pushKV("reachable", IsReachable(network));
obj.push_back(Pair("proxy", proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string())); obj.pushKV("proxy", proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string());
obj.push_back(Pair("proxy_randomize_credentials", proxy.randomize_credentials)); obj.pushKV("proxy_randomize_credentials", proxy.randomize_credentials);
networks.push_back(obj); networks.push_back(obj);
} }
return networks; return networks;
@ -439,34 +439,34 @@ UniValue getnetworkinfo(const JSONRPCRequest& request)
LOCK(cs_main); LOCK(cs_main);
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("version", CLIENT_VERSION)); obj.pushKV("version", CLIENT_VERSION);
obj.push_back(Pair("subversion", strSubVersion)); obj.pushKV("subversion", strSubVersion);
obj.push_back(Pair("protocolversion",PROTOCOL_VERSION)); obj.pushKV("protocolversion",PROTOCOL_VERSION);
if(g_connman) if(g_connman)
obj.push_back(Pair("localservices", strprintf("%016x", g_connman->GetLocalServices()))); obj.pushKV("localservices", strprintf("%016x", g_connman->GetLocalServices()));
obj.push_back(Pair("localrelay", fRelayTxes)); obj.pushKV("localrelay", fRelayTxes);
obj.push_back(Pair("timeoffset", GetTimeOffset())); obj.pushKV("timeoffset", GetTimeOffset());
if (g_connman) { if (g_connman) {
obj.push_back(Pair("networkactive", g_connman->GetNetworkActive())); obj.pushKV("networkactive", g_connman->GetNetworkActive());
obj.push_back(Pair("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL))); obj.pushKV("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL));
} }
obj.push_back(Pair("networks", GetNetworksInfo())); obj.pushKV("networks", GetNetworksInfo());
obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFeeRate.GetFeePerK()))); obj.pushKV("relayfee", ValueFromAmount(::minRelayTxFeeRate.GetFeePerK()));
obj.push_back(Pair("incrementalfee", ValueFromAmount(::incrementalRelayFee.GetFeePerK()))); obj.pushKV("incrementalfee", ValueFromAmount(::incrementalRelayFee.GetFeePerK()));
UniValue localAddresses(UniValue::VARR); UniValue localAddresses(UniValue::VARR);
{ {
LOCK(cs_mapLocalHost); LOCK(cs_mapLocalHost);
BOOST_FOREACH(const PAIRTYPE(CNetAddr, LocalServiceInfo) &item, mapLocalHost) BOOST_FOREACH(const PAIRTYPE(CNetAddr, LocalServiceInfo) &item, mapLocalHost)
{ {
UniValue rec(UniValue::VOBJ); UniValue rec(UniValue::VOBJ);
rec.push_back(Pair("address", item.first.ToString())); rec.pushKV("address", item.first.ToString());
rec.push_back(Pair("port", item.second.nPort)); rec.pushKV("port", item.second.nPort);
rec.push_back(Pair("score", item.second.nScore)); rec.pushKV("score", item.second.nScore);
localAddresses.push_back(rec); localAddresses.push_back(rec);
} }
} }
obj.push_back(Pair("localaddresses", localAddresses)); obj.pushKV("localaddresses", localAddresses);
obj.push_back(Pair("warnings", GetWarnings("statusbar"))); obj.pushKV("warnings", GetWarnings("statusbar"));
return obj; return obj;
} }
@ -556,10 +556,10 @@ UniValue listbanned(const JSONRPCRequest& request)
{ {
CBanEntry banEntry = (*it).second; CBanEntry banEntry = (*it).second;
UniValue rec(UniValue::VOBJ); UniValue rec(UniValue::VOBJ);
rec.push_back(Pair("address", (*it).first.ToString())); rec.pushKV("address", (*it).first.ToString());
rec.push_back(Pair("banned_until", banEntry.nBanUntil)); rec.pushKV("banned_until", banEntry.nBanUntil);
rec.push_back(Pair("ban_created", banEntry.nCreateTime)); rec.pushKV("ban_created", banEntry.nCreateTime);
rec.push_back(Pair("ban_reason", banEntry.banReasonToString())); rec.pushKV("ban_reason", banEntry.banReasonToString());
bannedAddresses.push_back(rec); bannedAddresses.push_back(rec);
} }

View file

@ -29,9 +29,9 @@ using namespace std;
UniValue JSONRPCRequestObj(const string& strMethod, const UniValue& params, const UniValue& id) UniValue JSONRPCRequestObj(const string& strMethod, const UniValue& params, const UniValue& id)
{ {
UniValue request(UniValue::VOBJ); UniValue request(UniValue::VOBJ);
request.push_back(Pair("method", strMethod)); request.pushKV("method", strMethod);
request.push_back(Pair("params", params)); request.pushKV("params", params);
request.push_back(Pair("id", id)); request.pushKV("id", id);
return request; return request;
} }
@ -39,11 +39,11 @@ UniValue JSONRPCReplyObj(const UniValue& result, const UniValue& error, const Un
{ {
UniValue reply(UniValue::VOBJ); UniValue reply(UniValue::VOBJ);
if (!error.isNull()) if (!error.isNull())
reply.push_back(Pair("result", NullUniValue)); reply.pushKV("result", NullUniValue);
else else
reply.push_back(Pair("result", result)); reply.pushKV("result", result);
reply.push_back(Pair("error", error)); reply.pushKV("error", error);
reply.push_back(Pair("id", id)); reply.pushKV("id", id);
return reply; return reply;
} }
@ -56,8 +56,8 @@ string JSONRPCReply(const UniValue& result, const UniValue& error, const UniValu
UniValue JSONRPCError(int code, const string& message) UniValue JSONRPCError(int code, const string& message)
{ {
UniValue error(UniValue::VOBJ); UniValue error(UniValue::VOBJ);
error.push_back(Pair("code", code)); error.pushKV("code", code);
error.push_back(Pair("message", message)); error.pushKV("message", message);
return error; return error;
} }

View file

@ -41,46 +41,46 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fInclud
vector<CTxDestination> addresses; vector<CTxDestination> addresses;
int nRequired; int nRequired;
out.push_back(Pair("asm", ScriptToAsmStr(scriptPubKey))); out.pushKV("asm", ScriptToAsmStr(scriptPubKey));
if (fIncludeHex) if (fIncludeHex)
out.push_back(Pair("hex", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); out.pushKV("hex", HexStr(scriptPubKey.begin(), scriptPubKey.end()));
if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired)) { if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired)) {
out.push_back(Pair("type", GetTxnOutputType(type))); out.pushKV("type", GetTxnOutputType(type));
return; return;
} }
out.push_back(Pair("reqSigs", nRequired)); out.pushKV("reqSigs", nRequired);
out.push_back(Pair("type", GetTxnOutputType(type))); out.pushKV("type", GetTxnOutputType(type));
UniValue a(UniValue::VARR); UniValue a(UniValue::VARR);
BOOST_FOREACH(const CTxDestination& addr, addresses) BOOST_FOREACH(const CTxDestination& addr, addresses)
a.push_back(CBitcoinAddress(addr).ToString()); a.push_back(CBitcoinAddress(addr).ToString());
out.push_back(Pair("addresses", a)); out.pushKV("addresses", a);
} }
void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
{ {
entry.push_back(Pair("txid", tx.GetHash().GetHex())); entry.pushKV("txid", tx.GetHash().GetHex());
entry.push_back(Pair("hash", tx.GetWitnessHash().GetHex())); entry.pushKV("hash", tx.GetWitnessHash().GetHex());
entry.push_back(Pair("size", (int)::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION))); entry.pushKV("size", (int)::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION));
entry.push_back(Pair("vsize", (int)::GetVirtualTransactionSize(tx))); entry.pushKV("vsize", (int)::GetVirtualTransactionSize(tx));
entry.push_back(Pair("version", tx.nVersion)); entry.pushKV("version", tx.nVersion);
entry.push_back(Pair("locktime", (int64_t)tx.nLockTime)); entry.pushKV("locktime", (int64_t)tx.nLockTime);
UniValue vin(UniValue::VARR); UniValue vin(UniValue::VARR);
for (unsigned int i = 0; i < tx.vin.size(); i++) { for (unsigned int i = 0; i < tx.vin.size(); i++) {
const CTxIn& txin = tx.vin[i]; const CTxIn& txin = tx.vin[i];
UniValue in(UniValue::VOBJ); UniValue in(UniValue::VOBJ);
if (tx.IsCoinBase()) if (tx.IsCoinBase())
in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); in.pushKV("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()));
else { else {
in.push_back(Pair("txid", txin.prevout.hash.GetHex())); in.pushKV("txid", txin.prevout.hash.GetHex());
in.push_back(Pair("vout", (int64_t)txin.prevout.n)); in.pushKV("vout", (int64_t)txin.prevout.n);
UniValue o(UniValue::VOBJ); UniValue o(UniValue::VOBJ);
o.push_back(Pair("asm", ScriptToAsmStr(txin.scriptSig, true))); o.pushKV("asm", ScriptToAsmStr(txin.scriptSig, true));
o.push_back(Pair("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); o.pushKV("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()));
in.push_back(Pair("scriptSig", o)); in.pushKV("scriptSig", o);
} }
if (tx.HasWitness()) { if (tx.HasWitness()) {
UniValue txinwitness(UniValue::VARR); UniValue txinwitness(UniValue::VARR);
@ -88,37 +88,37 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
std::vector<unsigned char> item = tx.vin[i].scriptWitness.stack[j]; std::vector<unsigned char> item = tx.vin[i].scriptWitness.stack[j];
txinwitness.push_back(HexStr(item.begin(), item.end())); txinwitness.push_back(HexStr(item.begin(), item.end()));
} }
in.push_back(Pair("txinwitness", txinwitness)); in.pushKV("txinwitness", txinwitness);
} }
in.push_back(Pair("sequence", (int64_t)txin.nSequence)); in.pushKV("sequence", (int64_t)txin.nSequence);
vin.push_back(in); vin.push_back(in);
} }
entry.push_back(Pair("vin", vin)); entry.pushKV("vin", vin);
UniValue vout(UniValue::VARR); UniValue vout(UniValue::VARR);
for (unsigned int i = 0; i < tx.vout.size(); i++) { for (unsigned int i = 0; i < tx.vout.size(); i++) {
const CTxOut& txout = tx.vout[i]; const CTxOut& txout = tx.vout[i];
UniValue out(UniValue::VOBJ); UniValue out(UniValue::VOBJ);
out.push_back(Pair("value", ValueFromAmount(txout.nValue))); out.pushKV("value", ValueFromAmount(txout.nValue));
out.push_back(Pair("n", (int64_t)i)); out.pushKV("n", (int64_t)i);
UniValue o(UniValue::VOBJ); UniValue o(UniValue::VOBJ);
ScriptPubKeyToJSON(txout.scriptPubKey, o, true); ScriptPubKeyToJSON(txout.scriptPubKey, o, true);
out.push_back(Pair("scriptPubKey", o)); out.pushKV("scriptPubKey", o);
vout.push_back(out); vout.push_back(out);
} }
entry.push_back(Pair("vout", vout)); entry.pushKV("vout", vout);
if (!hashBlock.IsNull()) { if (!hashBlock.IsNull()) {
entry.push_back(Pair("blockhash", hashBlock.GetHex())); entry.pushKV("blockhash", hashBlock.GetHex());
BlockMap::iterator mi = mapBlockIndex.find(hashBlock); BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
if (mi != mapBlockIndex.end() && (*mi).second) { if (mi != mapBlockIndex.end() && (*mi).second) {
CBlockIndex* pindex = (*mi).second; CBlockIndex* pindex = (*mi).second;
if (chainActive.Contains(pindex)) { if (chainActive.Contains(pindex)) {
entry.push_back(Pair("confirmations", 1 + chainActive.Height() - pindex->nHeight)); entry.pushKV("confirmations", 1 + chainActive.Height() - pindex->nHeight);
entry.push_back(Pair("time", pindex->GetBlockTime())); entry.pushKV("time", pindex->GetBlockTime());
entry.push_back(Pair("blocktime", pindex->GetBlockTime())); entry.pushKV("blocktime", pindex->GetBlockTime());
} }
else else
entry.push_back(Pair("confirmations", 0)); entry.pushKV("confirmations", 0);
} }
} }
} }
@ -231,7 +231,7 @@ UniValue getrawtransaction(const JSONRPCRequest& request)
return strHex; return strHex;
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
result.push_back(Pair("hex", strHex)); result.pushKV("hex", strHex);
TxToJSON(*tx, hashBlock, result); TxToJSON(*tx, hashBlock, result);
return result; return result;
} }
@ -575,7 +575,7 @@ UniValue decodescript(const JSONRPCRequest& request)
if (type.isStr() && type.get_str() != "scripthash") { if (type.isStr() && type.get_str() != "scripthash") {
// P2SH cannot be wrapped in a P2SH. If this script is already a P2SH, // 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. // don't return the address for a P2SH of the P2SH.
r.push_back(Pair("p2sh", CBitcoinAddress(CScriptID(script)).ToString())); r.pushKV("p2sh", CBitcoinAddress(CScriptID(script)).ToString());
} }
return r; return r;
@ -585,11 +585,11 @@ UniValue decodescript(const JSONRPCRequest& request)
static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::string& strMessage) static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::string& strMessage)
{ {
UniValue entry(UniValue::VOBJ); UniValue entry(UniValue::VOBJ);
entry.push_back(Pair("txid", txin.prevout.hash.ToString())); entry.pushKV("txid", txin.prevout.hash.ToString());
entry.push_back(Pair("vout", (uint64_t)txin.prevout.n)); entry.pushKV("vout", (uint64_t)txin.prevout.n);
entry.push_back(Pair("scriptSig", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); entry.pushKV("scriptSig", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()));
entry.push_back(Pair("sequence", (uint64_t)txin.nSequence)); entry.pushKV("sequence", (uint64_t)txin.nSequence);
entry.push_back(Pair("error", strMessage)); entry.pushKV("error", strMessage);
vErrorsRet.push_back(entry); vErrorsRet.push_back(entry);
} }
@ -850,10 +850,10 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
bool fComplete = vErrors.empty(); bool fComplete = vErrors.empty();
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
result.push_back(Pair("hex", EncodeHexTx(mergedTx))); result.pushKV("hex", EncodeHexTx(mergedTx));
result.push_back(Pair("complete", fComplete)); result.pushKV("complete", fComplete);
if (!vErrors.empty()) { if (!vErrors.empty()) {
result.push_back(Pair("errors", vErrors)); result.pushKV("errors", vErrors);
} }
return result; return result;

View file

@ -60,25 +60,25 @@ void EnsureWalletIsUnlocked()
void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
{ {
int confirms = wtx.GetDepthInMainChain(); int confirms = wtx.GetDepthInMainChain();
entry.push_back(Pair("confirmations", confirms)); entry.pushKV("confirmations", confirms);
if (wtx.IsCoinBase()) if (wtx.IsCoinBase())
entry.push_back(Pair("generated", true)); entry.pushKV("generated", true);
if (confirms > 0) if (confirms > 0)
{ {
entry.push_back(Pair("blockhash", wtx.hashBlock.GetHex())); entry.pushKV("blockhash", wtx.hashBlock.GetHex());
entry.push_back(Pair("blockindex", wtx.nIndex)); entry.pushKV("blockindex", wtx.nIndex);
entry.push_back(Pair("blocktime", mapBlockIndex[wtx.hashBlock]->GetBlockTime())); entry.pushKV("blocktime", mapBlockIndex[wtx.hashBlock]->GetBlockTime());
} else { } else {
entry.push_back(Pair("trusted", wtx.IsTrusted())); entry.pushKV("trusted", wtx.IsTrusted());
} }
uint256 hash = wtx.GetHash(); uint256 hash = wtx.GetHash();
entry.push_back(Pair("txid", hash.GetHex())); entry.pushKV("txid", hash.GetHex());
UniValue conflicts(UniValue::VARR); UniValue conflicts(UniValue::VARR);
BOOST_FOREACH(const uint256& conflict, wtx.GetConflicts()) BOOST_FOREACH(const uint256& conflict, wtx.GetConflicts())
conflicts.push_back(conflict.GetHex()); conflicts.push_back(conflict.GetHex());
entry.push_back(Pair("walletconflicts", conflicts)); entry.pushKV("walletconflicts", conflicts);
entry.push_back(Pair("time", wtx.GetTxTime())); entry.pushKV("time", wtx.GetTxTime());
entry.push_back(Pair("timereceived", (int64_t)wtx.nTimeReceived)); entry.pushKV("timereceived", (int64_t)wtx.nTimeReceived);
// Add opt-in RBF status // Add opt-in RBF status
std::string rbfStatus = "no"; std::string rbfStatus = "no";
@ -90,10 +90,10 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
else if (rbfState == RBF_TRANSACTIONSTATE_REPLACEABLE_BIP125) else if (rbfState == RBF_TRANSACTIONSTATE_REPLACEABLE_BIP125)
rbfStatus = "yes"; rbfStatus = "yes";
} }
entry.push_back(Pair("bip125-replaceable", rbfStatus)); entry.pushKV("bip125-replaceable", rbfStatus);
BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue) BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue)
entry.push_back(Pair(item.first, item.second)); entry.pushKV(item.first, item.second);
} }
string AccountFromValue(const UniValue& value) string AccountFromValue(const UniValue& value)
@ -1226,13 +1226,13 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts)
{ {
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
if(fIsWatchonly) if(fIsWatchonly)
obj.push_back(Pair("involvesWatchonly", true)); obj.pushKV("involvesWatchonly", true);
obj.push_back(Pair("address", address.ToString())); obj.pushKV("address", address.ToString());
obj.push_back(Pair("account", strAccount)); obj.pushKV("account", strAccount);
obj.push_back(Pair("amount", ValueFromAmount(nAmount))); obj.pushKV("amount", ValueFromAmount(nAmount));
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf))); obj.pushKV("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
if (!fByAccounts) if (!fByAccounts)
obj.push_back(Pair("label", strAccount)); obj.pushKV("label", strAccount);
UniValue transactions(UniValue::VARR); UniValue transactions(UniValue::VARR);
if (it != mapTally.end()) if (it != mapTally.end())
{ {
@ -1241,7 +1241,7 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts)
transactions.push_back(_item.GetHex()); transactions.push_back(_item.GetHex());
} }
} }
obj.push_back(Pair("txids", transactions)); obj.pushKV("txids", transactions);
ret.push_back(obj); ret.push_back(obj);
} }
} }
@ -1254,10 +1254,10 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts)
int nConf = (*it).second.nConf; int nConf = (*it).second.nConf;
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
if((*it).second.fIsWatchonly) if((*it).second.fIsWatchonly)
obj.push_back(Pair("involvesWatchonly", true)); obj.pushKV("involvesWatchonly", true);
obj.push_back(Pair("account", (*it).first)); obj.pushKV("account", (*it).first);
obj.push_back(Pair("amount", ValueFromAmount(nAmount))); obj.pushKV("amount", ValueFromAmount(nAmount));
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf))); obj.pushKV("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
ret.push_back(obj); ret.push_back(obj);
} }
} }
@ -1348,7 +1348,7 @@ static void MaybePushAddress(UniValue & entry, const CTxDestination &dest)
{ {
CBitcoinAddress addr; CBitcoinAddress addr;
if (addr.Set(dest)) if (addr.Set(dest))
entry.push_back(Pair("address", addr.ToString())); entry.pushKV("address", addr.ToString());
} }
void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter) void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter)
@ -1370,18 +1370,18 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
{ {
UniValue entry(UniValue::VOBJ); UniValue entry(UniValue::VOBJ);
if(involvesWatchonly || (::IsMine(*pwalletMain, s.destination) & ISMINE_WATCH_ONLY)) if(involvesWatchonly || (::IsMine(*pwalletMain, 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); MaybePushAddress(entry, s.destination);
entry.push_back(Pair("category", "send")); entry.pushKV("category", "send");
entry.push_back(Pair("amount", ValueFromAmount(-s.amount))); entry.pushKV("amount", ValueFromAmount(-s.amount));
if (pwalletMain->mapAddressBook.count(s.destination)) if (pwalletMain->mapAddressBook.count(s.destination))
entry.push_back(Pair("label", pwalletMain->mapAddressBook[s.destination].name)); entry.pushKV("label", pwalletMain->mapAddressBook[s.destination].name);
entry.push_back(Pair("vout", s.vout)); entry.pushKV("vout", s.vout);
entry.push_back(Pair("fee", ValueFromAmount(-nFee))); entry.pushKV("fee", ValueFromAmount(-nFee));
if (fLong) if (fLong)
WalletTxToJSON(wtx, entry); WalletTxToJSON(wtx, entry);
entry.push_back(Pair("abandoned", wtx.isAbandoned())); entry.pushKV("abandoned", wtx.isAbandoned());
ret.push_back(entry); ret.push_back(entry);
} }
} }
@ -1398,26 +1398,26 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
{ {
UniValue entry(UniValue::VOBJ); UniValue entry(UniValue::VOBJ);
if(involvesWatchonly || (::IsMine(*pwalletMain, r.destination) & ISMINE_WATCH_ONLY)) if(involvesWatchonly || (::IsMine(*pwalletMain, 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); MaybePushAddress(entry, r.destination);
if (wtx.IsCoinBase()) if (wtx.IsCoinBase())
{ {
if (wtx.GetDepthInMainChain() < 1) if (wtx.GetDepthInMainChain() < 1)
entry.push_back(Pair("category", "orphan")); entry.pushKV("category", "orphan");
else if (wtx.GetBlocksToMaturity() > 0) else if (wtx.GetBlocksToMaturity() > 0)
entry.push_back(Pair("category", "immature")); entry.pushKV("category", "immature");
else else
entry.push_back(Pair("category", "generate")); entry.pushKV("category", "generate");
} }
else 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 (pwalletMain->mapAddressBook.count(r.destination)) if (pwalletMain->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) if (fLong)
WalletTxToJSON(wtx, entry); WalletTxToJSON(wtx, entry);
ret.push_back(entry); ret.push_back(entry);
@ -1433,12 +1433,12 @@ void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, Un
if (fAllAccounts || acentry.strAccount == strAccount) if (fAllAccounts || acentry.strAccount == strAccount)
{ {
UniValue entry(UniValue::VOBJ); UniValue entry(UniValue::VOBJ);
entry.push_back(Pair("account", acentry.strAccount)); entry.pushKV("account", acentry.strAccount);
entry.push_back(Pair("category", "move")); entry.pushKV("category", "move");
entry.push_back(Pair("time", acentry.nTime)); entry.pushKV("time", acentry.nTime);
entry.push_back(Pair("amount", ValueFromAmount(acentry.nCreditDebit))); entry.pushKV("amount", ValueFromAmount(acentry.nCreditDebit));
entry.push_back(Pair("otheraccount", acentry.strOtherAccount)); entry.pushKV("otheraccount", acentry.strOtherAccount);
entry.push_back(Pair("comment", acentry.strComment)); entry.pushKV("comment", acentry.strComment);
ret.push_back(entry); ret.push_back(entry);
} }
} }
@ -1645,7 +1645,7 @@ UniValue listaccounts(const JSONRPCRequest& request)
UniValue ret(UniValue::VOBJ); UniValue ret(UniValue::VOBJ);
BOOST_FOREACH(const PAIRTYPE(string, CAmount)& accountBalance, mapAccountBalances) { BOOST_FOREACH(const PAIRTYPE(string, CAmount)& accountBalance, mapAccountBalances) {
ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second))); ret.pushKV(accountBalance.first, ValueFromAmount(accountBalance.second));
} }
return ret; return ret;
} }
@ -1750,8 +1750,8 @@ UniValue listsinceblock(const JSONRPCRequest& request)
uint256 lastblock = pblockLast ? pblockLast->GetBlockHash() : uint256(); uint256 lastblock = pblockLast ? pblockLast->GetBlockHash() : uint256();
UniValue ret(UniValue::VOBJ); UniValue ret(UniValue::VOBJ);
ret.push_back(Pair("transactions", transactions)); ret.pushKV("transactions", transactions);
ret.push_back(Pair("lastblock", lastblock.GetHex())); ret.pushKV("lastblock", lastblock.GetHex());
return ret; return ret;
} }
@ -1826,18 +1826,18 @@ UniValue gettransaction(const JSONRPCRequest& request)
CAmount nNet = nCredit - nDebit; CAmount nNet = nCredit - nDebit;
CAmount nFee = (wtx.IsFromMe(filter) ? wtx.tx->GetValueOut() - nDebit : 0); 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)) if (wtx.IsFromMe(filter))
entry.push_back(Pair("fee", ValueFromAmount(nFee))); entry.pushKV("fee", ValueFromAmount(nFee));
WalletTxToJSON(wtx, entry); WalletTxToJSON(wtx, entry);
UniValue details(UniValue::VARR); UniValue details(UniValue::VARR);
ListTransactions(wtx, "*", 0, false, details, filter); ListTransactions(wtx, "*", 0, false, details, filter);
entry.push_back(Pair("details", details)); entry.pushKV("details", details);
string strHex = EncodeHexTx(static_cast<CTransaction>(wtx), RPCSerializationFlags()); string strHex = EncodeHexTx(static_cast<CTransaction>(wtx), RPCSerializationFlags());
entry.push_back(Pair("hex", strHex)); entry.pushKV("hex", strHex);
return entry; return entry;
} }
@ -2279,8 +2279,8 @@ UniValue listlockunspent(const JSONRPCRequest& request)
BOOST_FOREACH(COutPoint &outpt, vOutpts) { BOOST_FOREACH(COutPoint &outpt, vOutpts) {
UniValue o(UniValue::VOBJ); UniValue o(UniValue::VOBJ);
o.push_back(Pair("txid", outpt.hash.GetHex())); o.pushKV("txid", outpt.hash.GetHex());
o.push_back(Pair("vout", (int)outpt.n)); o.pushKV("vout", (int)outpt.n);
ret.push_back(o); ret.push_back(o);
} }
@ -2344,19 +2344,19 @@ UniValue getwalletinfo(const JSONRPCRequest& request)
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); obj.pushKV("walletversion", pwalletMain->GetVersion());
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); obj.pushKV("balance", ValueFromAmount(pwalletMain->GetBalance()));
obj.push_back(Pair("unconfirmed_balance", ValueFromAmount(pwalletMain->GetUnconfirmedBalance()))); obj.pushKV("unconfirmed_balance", ValueFromAmount(pwalletMain->GetUnconfirmedBalance()));
obj.push_back(Pair("immature_balance", ValueFromAmount(pwalletMain->GetImmatureBalance()))); obj.pushKV("immature_balance", ValueFromAmount(pwalletMain->GetImmatureBalance()));
obj.push_back(Pair("txcount", (int)pwalletMain->mapWallet.size())); obj.pushKV("txcount", (int)pwalletMain->mapWallet.size());
obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime())); obj.pushKV("keypoololdest", pwalletMain->GetOldestKeyPoolTime());
obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); obj.pushKV("keypoolsize", (int)pwalletMain->GetKeyPoolSize());
if (pwalletMain->IsCrypted()) if (pwalletMain->IsCrypted())
obj.push_back(Pair("unlocked_until", nWalletUnlockTime)); obj.pushKV("unlocked_until", nWalletUnlockTime);
obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); obj.pushKV("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()));
CKeyID masterKeyID = pwalletMain->GetHDChain().masterKeyID; CKeyID masterKeyID = pwalletMain->GetHDChain().masterKeyID;
if (!masterKeyID.IsNull()) if (!masterKeyID.IsNull())
obj.push_back(Pair("hdmasterkeyid", masterKeyID.GetHex())); obj.pushKV("hdmasterkeyid", masterKeyID.GetHex());
return obj; return obj;
} }
@ -2512,28 +2512,28 @@ UniValue listunspent(const JSONRPCRequest& request)
continue; continue;
UniValue entry(UniValue::VOBJ); UniValue entry(UniValue::VOBJ);
entry.push_back(Pair("txid", out.tx->GetHash().GetHex())); entry.pushKV("txid", out.tx->GetHash().GetHex());
entry.push_back(Pair("vout", out.i)); entry.pushKV("vout", out.i);
if (fValidAddress) { if (fValidAddress) {
entry.push_back(Pair("address", CBitcoinAddress(address).ToString())); entry.pushKV("address", CBitcoinAddress(address).ToString());
if (pwalletMain->mapAddressBook.count(address)) if (pwalletMain->mapAddressBook.count(address))
entry.push_back(Pair("account", pwalletMain->mapAddressBook[address].name)); entry.pushKV("account", pwalletMain->mapAddressBook[address].name);
if (scriptPubKey.IsPayToScriptHash()) { if (scriptPubKey.IsPayToScriptHash()) {
const CScriptID& hash = boost::get<CScriptID>(address); const CScriptID& hash = boost::get<CScriptID>(address);
CScript redeemScript; CScript redeemScript;
if (pwalletMain->GetCScript(hash, redeemScript)) if (pwalletMain->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.pushKV("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()));
entry.push_back(Pair("amount", ValueFromAmount(out.tx->tx->vout[out.i].nValue))); entry.pushKV("amount", ValueFromAmount(out.tx->tx->vout[out.i].nValue));
entry.push_back(Pair("confirmations", out.nDepth)); entry.pushKV("confirmations", out.nDepth);
entry.push_back(Pair("spendable", out.fSpendable)); entry.pushKV("spendable", out.fSpendable);
entry.push_back(Pair("solvable", out.fSolvable)); entry.pushKV("solvable", out.fSolvable);
results.push_back(entry); results.push_back(entry);
} }
@ -2688,9 +2688,9 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
throw JSONRPCError(RPC_WALLET_ERROR, strFailReason); throw JSONRPCError(RPC_WALLET_ERROR, strFailReason);
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
result.push_back(Pair("hex", EncodeHexTx(tx))); result.pushKV("hex", EncodeHexTx(tx));
result.push_back(Pair("changepos", changePosition)); result.pushKV("changepos", changePosition);
result.push_back(Pair("fee", ValueFromAmount(nFeeOut))); result.pushKV("fee", ValueFromAmount(nFeeOut));
return result; return result;
} }
@ -3008,10 +3008,10 @@ UniValue bumpfee(const JSONRPCRequest& request)
} }
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
result.push_back(Pair("txid", wtxBumped.GetHash().GetHex())); result.pushKV("txid", wtxBumped.GetHash().GetHex());
result.push_back(Pair("origfee", ValueFromAmount(nOldFee))); result.pushKV("origfee", ValueFromAmount(nOldFee));
result.push_back(Pair("fee", ValueFromAmount(nNewFee))); result.pushKV("fee", ValueFromAmount(nNewFee));
result.push_back(Pair("errors", vErrors)); result.pushKV("errors", vErrors);
return result; return result;
} }