mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
expicit set UniValue type to avoid empty values
This commit is contained in:
12
src/rest.cpp
12
src/rest.cpp
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user