expicit set UniValue type to avoid empty values
This commit is contained in:
parent
53b4671a9d
commit
6c7bee0624
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);
|
||||
|
@ -55,7 +55,7 @@ double GetDifficulty(const CBlockIndex* blockindex)
|
||||
|
||||
Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false)
|
||||
{
|
||||
Object result;
|
||||
UniValue result(UniValue::VOBJ);
|
||||
result.push_back(Pair("hash", block.GetHash().GetHex()));
|
||||
int confirmations = -1;
|
||||
// Only report confirmations if the block is on the main chain
|
||||
@ -66,12 +66,12 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDe
|
||||
result.push_back(Pair("height", blockindex->nHeight));
|
||||
result.push_back(Pair("version", block.nVersion));
|
||||
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
|
||||
Array txs;
|
||||
UniValue txs(UniValue::VARR);
|
||||
BOOST_FOREACH(const CTransaction&tx, block.vtx)
|
||||
{
|
||||
if(txDetails)
|
||||
{
|
||||
Object objTx;
|
||||
UniValue objTx(UniValue::VOBJ);
|
||||
TxToJSON(tx, uint256(), objTx);
|
||||
txs.push_back(objTx);
|
||||
}
|
||||
@ -187,12 +187,12 @@ Value getrawmempool(const Array& params, bool fHelp)
|
||||
if (fVerbose)
|
||||
{
|
||||
LOCK(mempool.cs);
|
||||
Object o;
|
||||
UniValue o(UniValue::VOBJ);
|
||||
BOOST_FOREACH(const PAIRTYPE(uint256, CTxMemPoolEntry)& entry, mempool.mapTx)
|
||||
{
|
||||
const uint256& hash = entry.first;
|
||||
const CTxMemPoolEntry& e = entry.second;
|
||||
Object info;
|
||||
UniValue info(UniValue::VOBJ);
|
||||
info.push_back(Pair("size", (int)e.GetTxSize()));
|
||||
info.push_back(Pair("fee", ValueFromAmount(e.GetFee())));
|
||||
info.push_back(Pair("time", e.GetTime()));
|
||||
@ -223,7 +223,7 @@ Value getrawmempool(const Array& params, bool fHelp)
|
||||
vector<uint256> vtxid;
|
||||
mempool.queryHashes(vtxid);
|
||||
|
||||
Array a;
|
||||
UniValue a(UniValue::VARR);
|
||||
BOOST_FOREACH(const uint256& hash, vtxid)
|
||||
a.push_back(hash.ToString());
|
||||
|
||||
@ -348,7 +348,7 @@ Value gettxoutsetinfo(const Array& params, bool fHelp)
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
Object ret;
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
|
||||
CCoinsStats stats;
|
||||
FlushStateToDisk();
|
||||
@ -404,7 +404,7 @@ Value gettxout(const Array& params, bool fHelp)
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
Object ret;
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
|
||||
std::string strHash = params[0].get_str();
|
||||
uint256 hash(uint256S(strHash));
|
||||
@ -435,7 +435,7 @@ Value gettxout(const Array& params, bool fHelp)
|
||||
else
|
||||
ret.push_back(Pair("confirmations", pindex->nHeight - coins.nHeight + 1));
|
||||
ret.push_back(Pair("value", ValueFromAmount(coins.vout[n].nValue)));
|
||||
Object o;
|
||||
UniValue o(UniValue::VOBJ);
|
||||
ScriptPubKeyToJSON(coins.vout[n].scriptPubKey, o, true);
|
||||
ret.push_back(Pair("scriptPubKey", o));
|
||||
ret.push_back(Pair("version", coins.nVersion));
|
||||
@ -495,7 +495,7 @@ Value getblockchaininfo(const Array& params, bool fHelp)
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("chain", Params().NetworkIDString()));
|
||||
obj.push_back(Pair("blocks", (int)chainActive.Height()));
|
||||
obj.push_back(Pair("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1));
|
||||
@ -582,10 +582,10 @@ Value getchaintips(const Array& params, bool fHelp)
|
||||
setTips.insert(chainActive.Tip());
|
||||
|
||||
/* Construct the output array. */
|
||||
Array res;
|
||||
UniValue res(UniValue::VARR);
|
||||
BOOST_FOREACH(const CBlockIndex* block, setTips)
|
||||
{
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("height", block->nHeight));
|
||||
obj.push_back(Pair("hash", block->phashBlock->GetHex()));
|
||||
|
||||
@ -636,7 +636,7 @@ Value getmempoolinfo(const Array& params, bool fHelp)
|
||||
+ HelpExampleRpc("getmempoolinfo", "")
|
||||
);
|
||||
|
||||
Object ret;
|
||||
UniValue ret;
|
||||
ret.push_back(Pair("size", (int64_t) mempool.size()));
|
||||
ret.push_back(Pair("bytes", (int64_t) mempool.GetTotalTxSize()));
|
||||
|
||||
|
@ -146,7 +146,7 @@ Value generate(const Array& params, bool fHelp)
|
||||
nHeightEnd = nHeightStart+nGenerate;
|
||||
}
|
||||
unsigned int nExtraNonce = 0;
|
||||
Array blockHashes;
|
||||
UniValue blockHashes(UniValue::VARR);
|
||||
while (nHeight < nHeightEnd)
|
||||
{
|
||||
auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey));
|
||||
@ -247,7 +247,7 @@ Value getmininginfo(const Array& params, bool fHelp)
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("blocks", (int)chainActive.Height()));
|
||||
obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize));
|
||||
obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx));
|
||||
@ -519,9 +519,9 @@ Value getblocktemplate(const Array& params, bool fHelp)
|
||||
UpdateTime(pblock, Params().GetConsensus(), pindexPrev);
|
||||
pblock->nNonce = 0;
|
||||
|
||||
Array aCaps; aCaps.push_back("proposal");
|
||||
UniValue aCaps(UniValue::VARR); aCaps.push_back("proposal");
|
||||
|
||||
Array transactions;
|
||||
UniValue transactions(UniValue::VARR);
|
||||
map<uint256, int64_t> setTxIndex;
|
||||
int i = 0;
|
||||
BOOST_FOREACH (CTransaction& tx, pblock->vtx)
|
||||
@ -532,13 +532,13 @@ Value getblocktemplate(const Array& params, bool fHelp)
|
||||
if (tx.IsCoinBase())
|
||||
continue;
|
||||
|
||||
Object entry;
|
||||
UniValue entry(UniValue::VOBJ);
|
||||
|
||||
entry.push_back(Pair("data", EncodeHexTx(tx)));
|
||||
|
||||
entry.push_back(Pair("hash", txHash.GetHex()));
|
||||
|
||||
Array deps;
|
||||
UniValue deps(UniValue::VARR);
|
||||
BOOST_FOREACH (const CTxIn &in, tx.vin)
|
||||
{
|
||||
if (setTxIndex.count(in.prevout.hash))
|
||||
@ -553,12 +553,12 @@ Value getblocktemplate(const Array& params, bool fHelp)
|
||||
transactions.push_back(entry);
|
||||
}
|
||||
|
||||
Object aux;
|
||||
UniValue aux(UniValue::VOBJ);
|
||||
aux.push_back(Pair("flags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end())));
|
||||
|
||||
arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits);
|
||||
|
||||
static Array aMutable;
|
||||
static UniValue aMutable(UniValue::VARR);
|
||||
if (aMutable.empty())
|
||||
{
|
||||
aMutable.push_back("time");
|
||||
@ -566,7 +566,7 @@ Value getblocktemplate(const Array& params, bool fHelp)
|
||||
aMutable.push_back("prevblock");
|
||||
}
|
||||
|
||||
Object result;
|
||||
UniValue result(UniValue::VOBJ);
|
||||
result.push_back(Pair("capabilities", aCaps));
|
||||
result.push_back(Pair("version", pblock->nVersion));
|
||||
result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex()));
|
||||
|
@ -77,7 +77,7 @@ Value getinfo(const Array& params, bool fHelp)
|
||||
proxyType proxy;
|
||||
GetProxy(NET_IPV4, proxy);
|
||||
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("version", CLIENT_VERSION));
|
||||
obj.push_back(Pair("protocolversion", PROTOCOL_VERSION));
|
||||
#ifdef ENABLE_WALLET
|
||||
@ -118,7 +118,7 @@ public:
|
||||
Object operator()(const CNoDestination &dest) const { return Object(); }
|
||||
|
||||
Object operator()(const CKeyID &keyID) const {
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
CPubKey vchPubKey;
|
||||
obj.push_back(Pair("isscript", false));
|
||||
if (mine == ISMINE_SPENDABLE) {
|
||||
@ -130,7 +130,7 @@ public:
|
||||
}
|
||||
|
||||
Object operator()(const CScriptID &scriptID) const {
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("isscript", true));
|
||||
if (mine != ISMINE_NO) {
|
||||
CScript subscript;
|
||||
@ -141,7 +141,7 @@ public:
|
||||
ExtractDestinations(subscript, whichType, addresses, nRequired);
|
||||
obj.push_back(Pair("script", GetTxnOutputType(whichType)));
|
||||
obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end())));
|
||||
Array a;
|
||||
UniValue a(UniValue::VARR);
|
||||
BOOST_FOREACH(const CTxDestination& addr, addresses)
|
||||
a.push_back(CBitcoinAddress(addr).ToString());
|
||||
obj.push_back(Pair("addresses", a));
|
||||
@ -186,7 +186,7 @@ Value validateaddress(const Array& params, bool fHelp)
|
||||
CBitcoinAddress address(params[0].get_str());
|
||||
bool isValid = address.IsValid();
|
||||
|
||||
Object ret;
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
ret.push_back(Pair("isvalid", isValid));
|
||||
if (isValid)
|
||||
{
|
||||
@ -312,7 +312,7 @@ Value createmultisig(const Array& params, bool fHelp)
|
||||
CScriptID innerID(inner);
|
||||
CBitcoinAddress address(innerID);
|
||||
|
||||
Object result;
|
||||
UniValue result;
|
||||
result.push_back(Pair("address", address.ToString()));
|
||||
result.push_back(Pair("redeemScript", HexStr(inner.begin(), inner.end())));
|
||||
|
||||
|
@ -120,10 +120,10 @@ Value getpeerinfo(const Array& params, bool fHelp)
|
||||
vector<CNodeStats> vstats;
|
||||
CopyNodeStats(vstats);
|
||||
|
||||
Array ret;
|
||||
UniValue ret(UniValue::VARR);
|
||||
|
||||
BOOST_FOREACH(const CNodeStats& stats, vstats) {
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
CNodeStateStats statestats;
|
||||
bool fStateStats = GetNodeStateStats(stats.nodeid, statestats);
|
||||
obj.push_back(Pair("id", stats.nodeid));
|
||||
@ -151,7 +151,7 @@ Value getpeerinfo(const Array& params, bool fHelp)
|
||||
obj.push_back(Pair("banscore", statestats.nMisbehavior));
|
||||
obj.push_back(Pair("synced_headers", statestats.nSyncHeight));
|
||||
obj.push_back(Pair("synced_blocks", statestats.nCommonHeight));
|
||||
Array heights;
|
||||
UniValue heights(UniValue::VARR);
|
||||
BOOST_FOREACH(int height, statestats.vHeightInFlight) {
|
||||
heights.push_back(height);
|
||||
}
|
||||
@ -271,12 +271,12 @@ Value getaddednodeinfo(const Array& params, bool fHelp)
|
||||
throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Node has not been added.");
|
||||
}
|
||||
|
||||
Array ret;
|
||||
UniValue ret(UniValue::VARR);
|
||||
if (!fDns)
|
||||
{
|
||||
BOOST_FOREACH(string& strAddNode, laddedNodes)
|
||||
{
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("addednode", strAddNode));
|
||||
ret.push_back(obj);
|
||||
}
|
||||
@ -291,10 +291,10 @@ Value getaddednodeinfo(const Array& params, bool fHelp)
|
||||
laddedAddreses.push_back(make_pair(strAddNode, vservNode));
|
||||
else
|
||||
{
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("addednode", strAddNode));
|
||||
obj.push_back(Pair("connected", false));
|
||||
Array addresses;
|
||||
UniValue addresses(UniValue::VARR);
|
||||
obj.push_back(Pair("addresses", addresses));
|
||||
}
|
||||
}
|
||||
@ -302,15 +302,15 @@ Value getaddednodeinfo(const Array& params, bool fHelp)
|
||||
LOCK(cs_vNodes);
|
||||
for (list<pair<string, vector<CService> > >::iterator it = laddedAddreses.begin(); it != laddedAddreses.end(); it++)
|
||||
{
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("addednode", it->first));
|
||||
|
||||
Array addresses;
|
||||
UniValue addresses(UniValue::VARR);
|
||||
bool fConnected = false;
|
||||
BOOST_FOREACH(CService& addrNode, it->second)
|
||||
{
|
||||
bool fFound = false;
|
||||
Object node;
|
||||
UniValue node(UniValue::VOBJ);
|
||||
node.push_back(Pair("address", addrNode.ToString()));
|
||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
||||
if (pnode->addr == addrNode)
|
||||
@ -350,7 +350,7 @@ Value getnettotals(const Array& params, bool fHelp)
|
||||
+ HelpExampleRpc("getnettotals", "")
|
||||
);
|
||||
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("totalbytesrecv", CNode::GetTotalBytesRecv()));
|
||||
obj.push_back(Pair("totalbytessent", CNode::GetTotalBytesSent()));
|
||||
obj.push_back(Pair("timemillis", GetTimeMillis()));
|
||||
@ -359,14 +359,14 @@ Value getnettotals(const Array& params, bool fHelp)
|
||||
|
||||
static Array GetNetworksInfo()
|
||||
{
|
||||
Array networks;
|
||||
UniValue networks(UniValue::VARR);
|
||||
for(int n=0; n<NET_MAX; ++n)
|
||||
{
|
||||
enum Network network = static_cast<enum Network>(n);
|
||||
if(network == NET_UNROUTABLE)
|
||||
continue;
|
||||
proxyType proxy;
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
GetProxy(network, proxy);
|
||||
obj.push_back(Pair("name", GetNetworkName(network)));
|
||||
obj.push_back(Pair("limited", IsLimited(network)));
|
||||
@ -418,7 +418,7 @@ Value getnetworkinfo(const Array& params, bool fHelp)
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("version", CLIENT_VERSION));
|
||||
obj.push_back(Pair("subversion",
|
||||
FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>())));
|
||||
@ -428,12 +428,12 @@ Value getnetworkinfo(const Array& params, bool fHelp)
|
||||
obj.push_back(Pair("connections", (int)vNodes.size()));
|
||||
obj.push_back(Pair("networks", GetNetworksInfo()));
|
||||
obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())));
|
||||
Array localAddresses;
|
||||
UniValue localAddresses(UniValue::VARR);
|
||||
{
|
||||
LOCK(cs_mapLocalHost);
|
||||
BOOST_FOREACH(const PAIRTYPE(CNetAddr, LocalServiceInfo) &item, mapLocalHost)
|
||||
{
|
||||
Object rec;
|
||||
UniValue rec(UniValue::VOBJ);
|
||||
rec.push_back(Pair("address", item.first.ToString()));
|
||||
rec.push_back(Pair("port", item.second.nPort));
|
||||
rec.push_back(Pair("score", item.second.nScore));
|
||||
|
@ -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()) {
|
||||
|
@ -866,7 +866,7 @@ void JSONRequest::parse(const Value& valRequest)
|
||||
|
||||
static Object JSONRPCExecOne(const Value& req)
|
||||
{
|
||||
Object rpc_result;
|
||||
UniValue rpc_result(UniValue::VOBJ);
|
||||
|
||||
JSONRequest jreq;
|
||||
try {
|
||||
|
@ -19,9 +19,9 @@ using namespace json_spirit;
|
||||
Array
|
||||
createArgs(int nRequired, const char* address1=NULL, const char* address2=NULL)
|
||||
{
|
||||
Array result;
|
||||
UniValue result(UniValue::VARR);
|
||||
result.push_back(nRequired);
|
||||
Array addresses;
|
||||
UniValue addresses(UniValue::VARR);
|
||||
if (address1) addresses.push_back(address1);
|
||||
if (address2) addresses.push_back(address2);
|
||||
result.push_back(addresses);
|
||||
|
@ -296,7 +296,7 @@ public:
|
||||
Array GetJSON()
|
||||
{
|
||||
DoPush();
|
||||
Array array;
|
||||
UniValue array(UniValue::VARR);
|
||||
array.push_back(FormatScript(spendTx.vin[0].scriptSig));
|
||||
array.push_back(FormatScript(creditTx.vout[0].scriptPubKey));
|
||||
array.push_back(FormatScriptFlags(flags));
|
||||
|
@ -68,7 +68,7 @@ void WalletTxToJSON(const CWalletTx& wtx, Object& entry)
|
||||
}
|
||||
uint256 hash = wtx.GetHash();
|
||||
entry.push_back(Pair("txid", hash.GetHex()));
|
||||
Array conflicts;
|
||||
UniValue conflicts(UniValue::VARR);
|
||||
BOOST_FOREACH(const uint256& conflict, wtx.GetConflicts())
|
||||
conflicts.push_back(conflict.GetHex());
|
||||
entry.push_back(Pair("walletconflicts", conflicts));
|
||||
@ -336,7 +336,7 @@ Value getaddressesbyaccount(const Array& params, bool fHelp)
|
||||
string strAccount = AccountFromValue(params[0]);
|
||||
|
||||
// Find all addresses that have the given account
|
||||
Array ret;
|
||||
UniValue ret(UniValue::VARR);
|
||||
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, CAddressBookData)& item, pwalletMain->mapAddressBook)
|
||||
{
|
||||
const CBitcoinAddress& address = item.first;
|
||||
@ -464,14 +464,14 @@ Value listaddressgroupings(const Array& params, bool fHelp)
|
||||
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
Array jsonGroupings;
|
||||
UniValue jsonGroupings(UniValue::VARR);
|
||||
map<CTxDestination, CAmount> balances = pwalletMain->GetAddressBalances();
|
||||
BOOST_FOREACH(set<CTxDestination> grouping, pwalletMain->GetAddressGroupings())
|
||||
{
|
||||
Array jsonGrouping;
|
||||
UniValue jsonGrouping(UniValue::VARR);
|
||||
BOOST_FOREACH(CTxDestination address, grouping)
|
||||
{
|
||||
Array addressInfo;
|
||||
UniValue addressInfo(UniValue::VARR);
|
||||
addressInfo.push_back(CBitcoinAddress(address).ToString());
|
||||
addressInfo.push_back(ValueFromAmount(balances[address]));
|
||||
{
|
||||
@ -967,7 +967,7 @@ Value sendmany(const Array& params, bool fHelp)
|
||||
if (params.size() > 3 && !params[3].isNull() && !params[3].get_str().empty())
|
||||
wtx.mapValue["comment"] = params[3].get_str();
|
||||
|
||||
Array subtractFeeFromAmount;
|
||||
UniValue subtractFeeFromAmount(UniValue::VARR);
|
||||
if (params.size() > 4)
|
||||
subtractFeeFromAmount = params[4].get_array();
|
||||
|
||||
@ -1138,7 +1138,7 @@ Value ListReceived(const Array& params, bool fByAccounts)
|
||||
}
|
||||
|
||||
// Reply
|
||||
Array ret;
|
||||
UniValue ret(UniValue::VARR);
|
||||
map<string, tallyitem> mapAccountTally;
|
||||
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, CAddressBookData)& item, pwalletMain->mapAddressBook)
|
||||
{
|
||||
@ -1167,14 +1167,14 @@ Value ListReceived(const Array& params, bool fByAccounts)
|
||||
}
|
||||
else
|
||||
{
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
if(fIsWatchonly)
|
||||
obj.push_back(Pair("involvesWatchonly", true));
|
||||
obj.push_back(Pair("address", address.ToString()));
|
||||
obj.push_back(Pair("account", strAccount));
|
||||
obj.push_back(Pair("amount", ValueFromAmount(nAmount)));
|
||||
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf)));
|
||||
Array transactions;
|
||||
UniValue transactions(UniValue::VARR);
|
||||
if (it != mapTally.end())
|
||||
{
|
||||
BOOST_FOREACH(const uint256& item, (*it).second.txids)
|
||||
@ -1193,7 +1193,7 @@ Value ListReceived(const Array& params, bool fByAccounts)
|
||||
{
|
||||
CAmount nAmount = (*it).second.nAmount;
|
||||
int nConf = (*it).second.nConf;
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
if((*it).second.fIsWatchonly)
|
||||
obj.push_back(Pair("involvesWatchonly", true));
|
||||
obj.push_back(Pair("account", (*it).first));
|
||||
@ -1303,7 +1303,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
|
||||
{
|
||||
BOOST_FOREACH(const COutputEntry& s, listSent)
|
||||
{
|
||||
Object entry;
|
||||
UniValue entry(UniValue::VOBJ);
|
||||
if(involvesWatchonly || (::IsMine(*pwalletMain, s.destination) & ISMINE_WATCH_ONLY))
|
||||
entry.push_back(Pair("involvesWatchonly", true));
|
||||
entry.push_back(Pair("account", strSentAccount));
|
||||
@ -1328,7 +1328,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
|
||||
account = pwalletMain->mapAddressBook[r.destination].name;
|
||||
if (fAllAccounts || (account == strAccount))
|
||||
{
|
||||
Object entry;
|
||||
UniValue entry(UniValue::VOBJ);
|
||||
if(involvesWatchonly || (::IsMine(*pwalletMain, r.destination) & ISMINE_WATCH_ONLY))
|
||||
entry.push_back(Pair("involvesWatchonly", true));
|
||||
entry.push_back(Pair("account", account));
|
||||
@ -1362,7 +1362,7 @@ void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, Ar
|
||||
|
||||
if (fAllAccounts || acentry.strAccount == strAccount)
|
||||
{
|
||||
Object entry;
|
||||
UniValue entry(UniValue::VOBJ);
|
||||
entry.push_back(Pair("account", acentry.strAccount));
|
||||
entry.push_back(Pair("category", "move"));
|
||||
entry.push_back(Pair("time", acentry.nTime));
|
||||
@ -1451,7 +1451,7 @@ Value listtransactions(const Array& params, bool fHelp)
|
||||
if (nFrom < 0)
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative from");
|
||||
|
||||
Array ret;
|
||||
UniValue ret(UniValue::VARR);
|
||||
|
||||
std::list<CAccountingEntry> acentries;
|
||||
CWallet::TxItems txOrdered = pwalletMain->OrderedTxItems(acentries, strAccount);
|
||||
@ -1488,6 +1488,7 @@ Value listtransactions(const Array& params, bool fHelp)
|
||||
std::reverse(arrTmp.begin(), arrTmp.end()); // Return oldest to newest
|
||||
|
||||
ret.clear();
|
||||
ret.setArray();
|
||||
ret.push_backV(arrTmp);
|
||||
|
||||
return ret;
|
||||
@ -1566,7 +1567,7 @@ Value listaccounts(const Array& params, bool fHelp)
|
||||
BOOST_FOREACH(const CAccountingEntry& entry, acentries)
|
||||
mapAccountBalances[entry.strAccount] += entry.nCreditDebit;
|
||||
|
||||
Object ret;
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
BOOST_FOREACH(const PAIRTYPE(string, CAmount)& accountBalance, mapAccountBalances) {
|
||||
ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second)));
|
||||
}
|
||||
@ -1644,7 +1645,7 @@ Value listsinceblock(const Array& params, bool fHelp)
|
||||
|
||||
int depth = pindex ? (1 + chainActive.Height() - pindex->nHeight) : -1;
|
||||
|
||||
Array transactions;
|
||||
UniValue transactions(UniValue::VARR);
|
||||
|
||||
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); it++)
|
||||
{
|
||||
@ -1657,7 +1658,7 @@ Value listsinceblock(const Array& params, bool fHelp)
|
||||
CBlockIndex *pblockLast = chainActive[chainActive.Height() + 1 - target_confirms];
|
||||
uint256 lastblock = pblockLast ? pblockLast->GetBlockHash() : uint256();
|
||||
|
||||
Object ret;
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
ret.push_back(Pair("transactions", transactions));
|
||||
ret.push_back(Pair("lastblock", lastblock.GetHex()));
|
||||
|
||||
@ -1715,7 +1716,7 @@ Value gettransaction(const Array& params, bool fHelp)
|
||||
if(params[1].get_bool())
|
||||
filter = filter | ISMINE_WATCH_ONLY;
|
||||
|
||||
Object entry;
|
||||
UniValue entry(UniValue::VOBJ);
|
||||
if (!pwalletMain->mapWallet.count(hash))
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id");
|
||||
const CWalletTx& wtx = pwalletMain->mapWallet[hash];
|
||||
@ -1731,7 +1732,7 @@ Value gettransaction(const Array& params, bool fHelp)
|
||||
|
||||
WalletTxToJSON(wtx, entry);
|
||||
|
||||
Array details;
|
||||
UniValue details(UniValue::VARR);
|
||||
ListTransactions(wtx, "*", 0, false, details, filter);
|
||||
entry.push_back(Pair("details", details));
|
||||
|
||||
@ -2134,10 +2135,10 @@ Value listlockunspent(const Array& params, bool fHelp)
|
||||
vector<COutPoint> vOutpts;
|
||||
pwalletMain->ListLockedCoins(vOutpts);
|
||||
|
||||
Array ret;
|
||||
UniValue ret(UniValue::VARR);
|
||||
|
||||
BOOST_FOREACH(COutPoint &outpt, vOutpts) {
|
||||
Object o;
|
||||
UniValue o(UniValue::VOBJ);
|
||||
|
||||
o.push_back(Pair("txid", outpt.hash.GetHex()));
|
||||
o.push_back(Pair("vout", (int)outpt.n));
|
||||
@ -2203,7 +2204,7 @@ Value getwalletinfo(const Array& params, bool fHelp)
|
||||
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
Object obj;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("walletversion", pwalletMain->GetVersion()));
|
||||
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance())));
|
||||
obj.push_back(Pair("unconfirmed_balance", ValueFromAmount(pwalletMain->GetUnconfirmedBalance())));
|
||||
@ -2233,7 +2234,7 @@ Value resendwallettransactions(const Array& params, bool fHelp)
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
std::vector<uint256> txids = pwalletMain->ResendWalletTransactionsBefore(GetTime());
|
||||
Array result;
|
||||
UniValue result(UniValue::VARR);
|
||||
BOOST_FOREACH(const uint256& txid, txids)
|
||||
{
|
||||
result.push_back(txid.ToString());
|
||||
@ -2306,7 +2307,7 @@ Value listunspent(const Array& params, bool fHelp)
|
||||
}
|
||||
}
|
||||
|
||||
Array results;
|
||||
UniValue results(UniValue::VARR);
|
||||
vector<COutput> vecOutputs;
|
||||
assert(pwalletMain != NULL);
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
@ -2326,7 +2327,7 @@ Value listunspent(const Array& params, bool fHelp)
|
||||
|
||||
CAmount nValue = out.tx->vout[out.i].nValue;
|
||||
const CScript& pk = out.tx->vout[out.i].scriptPubKey;
|
||||
Object entry;
|
||||
UniValue entry(UniValue::VOBJ);
|
||||
entry.push_back(Pair("txid", out.tx->GetHash().GetHex()));
|
||||
entry.push_back(Pair("vout", out.i));
|
||||
CTxDestination address;
|
||||
|
Loading…
Reference in New Issue
Block a user