mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Merge #12193: RPC: Consistently use UniValue.pushKV instead of push_back(Pair()) (karel-3d)
91986ed206scripted-diff: Use UniValue.pushKV instead of push_back(Pair()) (Karel Bilek)a570098021Squashed 'src/univalue/' changes from 07947ff2da..51d3ab34ba (MarcoFalke) Pull request description: Rebased version of #11386 by karel-3d. Closes: #11386 Tree-SHA512: f3a81447e573c17e75813f4d41ceb34b9980eac81efdd98ddb149d7c51f792be7e2b32239b6ea7e6da68af23897afa6b4ce3f4e8070f9c4adf5105bf6075f2a0
This commit is contained in:
@@ -47,17 +47,17 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
|
||||
TxToUniv(tx, uint256(), entry, true, RPCSerializationFlags());
|
||||
|
||||
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("confirmations", 1 + chainActive.Height() - pindex->nHeight));
|
||||
entry.push_back(Pair("time", pindex->GetBlockTime()));
|
||||
entry.push_back(Pair("blocktime", pindex->GetBlockTime()));
|
||||
entry.pushKV("confirmations", 1 + chainActive.Height() - pindex->nHeight);
|
||||
entry.pushKV("time", pindex->GetBlockTime());
|
||||
entry.pushKV("blocktime", pindex->GetBlockTime());
|
||||
}
|
||||
else
|
||||
entry.push_back(Pair("confirmations", 0));
|
||||
entry.pushKV("confirmations", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,7 +190,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;
|
||||
}
|
||||
@@ -562,7 +562,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;
|
||||
@@ -572,16 +572,16 @@ 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.pushKV("txid", txin.prevout.hash.ToString());
|
||||
entry.pushKV("vout", (uint64_t)txin.prevout.n);
|
||||
UniValue witness(UniValue::VARR);
|
||||
for (unsigned int i = 0; i < txin.scriptWitness.stack.size(); i++) {
|
||||
witness.push_back(HexStr(txin.scriptWitness.stack[i].begin(), txin.scriptWitness.stack[i].end()));
|
||||
}
|
||||
entry.push_back(Pair("witness", witness));
|
||||
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("witness", witness);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -916,10 +916,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;
|
||||
|
||||
Reference in New Issue
Block a user