expicit set UniValue type to avoid empty values

This commit is contained in:
Jonas Schnelli
2015-05-10 14:48:35 +02:00
parent 53b4671a9d
commit 6c7bee0624
10 changed files with 93 additions and 92 deletions

View File

@@ -265,7 +265,7 @@ static bool rest_chaininfo(AcceptedConnection* conn,
switch (rf) {
case RF_JSON: {
Array rpcParams;
UniValue rpcParams(UniValue::VARR);
Value chainInfoObject = getblockchaininfo(rpcParams, false);
string strJSON = chainInfoObject.write() + "\n";
conn->stream() << HTTPReply(HTTP_OK, strJSON, fRun) << std::flush;
@@ -316,7 +316,7 @@ static bool rest_tx(AcceptedConnection* conn,
}
case RF_JSON: {
Object objTx;
UniValue objTx(UniValue::VOBJ);
TxToJSON(tx, hashBlock, objTx);
string strJSON = objTx.write() + "\n";
conn->stream() << HTTPReply(HTTP_OK, strJSON, fRun) << std::flush;
@@ -491,7 +491,7 @@ static bool rest_getutxos(AcceptedConnection* conn,
}
case RF_JSON: {
Object objGetUTXOResponse;
UniValue objGetUTXOResponse(UniValue::VOBJ);
// pack in some essentials
// use more or less the same output as mentioned in Bip64
@@ -499,15 +499,15 @@ static bool rest_getutxos(AcceptedConnection* conn,
objGetUTXOResponse.push_back(Pair("chaintipHash", chainActive.Tip()->GetBlockHash().GetHex()));
objGetUTXOResponse.push_back(Pair("bitmap", bitmapStringRepresentation));
Array utxos;
UniValue utxos(UniValue::VARR);
BOOST_FOREACH (const CCoin& coin, outs) {
Object utxo;
UniValue utxo(UniValue::VOBJ);
utxo.push_back(Pair("txvers", (int32_t)coin.nTxVer));
utxo.push_back(Pair("height", (int32_t)coin.nHeight));
utxo.push_back(Pair("value", ValueFromAmount(coin.out.nValue)));
// include the script in a json output
Object o;
UniValue o(UniValue::VOBJ);
ScriptPubKeyToJSON(coin.out.scriptPubKey, o, true);
utxo.push_back(Pair("scriptPubKey", o));
utxos.push_back(utxo);