mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
expicit set UniValue type to avoid empty values
This commit is contained in:
@@ -48,7 +48,7 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeH
|
||||
out.push_back(Pair("reqSigs", nRequired));
|
||||
out.push_back(Pair("type", GetTxnOutputType(type)));
|
||||
|
||||
Array a;
|
||||
UniValue a(UniValue::VARR);
|
||||
BOOST_FOREACH(const CTxDestination& addr, addresses)
|
||||
a.push_back(CBitcoinAddress(addr).ToString());
|
||||
out.push_back(Pair("addresses", a));
|
||||
@@ -59,15 +59,15 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
|
||||
entry.push_back(Pair("txid", tx.GetHash().GetHex()));
|
||||
entry.push_back(Pair("version", tx.nVersion));
|
||||
entry.push_back(Pair("locktime", (int64_t)tx.nLockTime));
|
||||
Array vin;
|
||||
UniValue vin(UniValue::VARR);
|
||||
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
|
||||
Object in;
|
||||
UniValue in(UniValue::VOBJ);
|
||||
if (tx.IsCoinBase())
|
||||
in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
|
||||
else {
|
||||
in.push_back(Pair("txid", txin.prevout.hash.GetHex()));
|
||||
in.push_back(Pair("vout", (int64_t)txin.prevout.n));
|
||||
Object o;
|
||||
UniValue o(UniValue::VOBJ);
|
||||
o.push_back(Pair("asm", txin.scriptSig.ToString()));
|
||||
o.push_back(Pair("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
|
||||
in.push_back(Pair("scriptSig", o));
|
||||
@@ -76,13 +76,13 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
|
||||
vin.push_back(in);
|
||||
}
|
||||
entry.push_back(Pair("vin", vin));
|
||||
Array vout;
|
||||
UniValue vout(UniValue::VARR);
|
||||
for (unsigned int i = 0; i < tx.vout.size(); i++) {
|
||||
const CTxOut& txout = tx.vout[i];
|
||||
Object out;
|
||||
UniValue out(UniValue::VOBJ);
|
||||
out.push_back(Pair("value", ValueFromAmount(txout.nValue)));
|
||||
out.push_back(Pair("n", (int64_t)i));
|
||||
Object o;
|
||||
UniValue o(UniValue::VOBJ);
|
||||
ScriptPubKeyToJSON(txout.scriptPubKey, o, true);
|
||||
out.push_back(Pair("scriptPubKey", o));
|
||||
vout.push_back(out);
|
||||
@@ -189,7 +189,7 @@ Value getrawtransaction(const Array& params, bool fHelp)
|
||||
if (!fVerbose)
|
||||
return strHex;
|
||||
|
||||
Object result;
|
||||
UniValue result(UniValue::VOBJ);
|
||||
result.push_back(Pair("hex", strHex));
|
||||
TxToJSON(tx, hashBlock, result);
|
||||
return result;
|
||||
@@ -293,7 +293,7 @@ Value verifytxoutproof(const Array& params, bool fHelp)
|
||||
CMerkleBlock merkleBlock;
|
||||
ssMB >> merkleBlock;
|
||||
|
||||
Array res;
|
||||
UniValue res(UniValue::VARR);
|
||||
|
||||
vector<uint256> vMatch;
|
||||
if (merkleBlock.txn.ExtractMatches(vMatch) != merkleBlock.header.hashMerkleRoot)
|
||||
@@ -481,7 +481,7 @@ Value decodescript(const Array& params, bool fHelp)
|
||||
LOCK(cs_main);
|
||||
RPCTypeCheck(params, boost::assign::list_of(UniValue::VSTR));
|
||||
|
||||
Object r;
|
||||
UniValue r(UniValue::VOBJ);
|
||||
CScript script;
|
||||
if (params[0].get_str().size() > 0){
|
||||
vector<unsigned char> scriptData(ParseHexV(params[0], "argument"));
|
||||
@@ -498,7 +498,7 @@ Value decodescript(const Array& params, bool fHelp)
|
||||
/** Pushes a JSON object for script verification or signing errors to vErrorsRet. */
|
||||
static void TxInErrorToJSON(const CTxIn& txin, Array& vErrorsRet, const std::string& strMessage)
|
||||
{
|
||||
Object entry;
|
||||
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())));
|
||||
@@ -711,7 +711,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
|
||||
bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE);
|
||||
|
||||
// Script verification errors
|
||||
Array vErrors;
|
||||
UniValue vErrors(UniValue::VARR);
|
||||
|
||||
// Sign what we can:
|
||||
for (unsigned int i = 0; i < mergedTx.vin.size(); i++) {
|
||||
@@ -739,7 +739,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
|
||||
}
|
||||
bool fComplete = vErrors.empty();
|
||||
|
||||
Object result;
|
||||
UniValue result(UniValue::VOBJ);
|
||||
result.push_back(Pair("hex", EncodeHexTx(mergedTx)));
|
||||
result.push_back(Pair("complete", fComplete));
|
||||
if (!vErrors.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user