Skip to content

Commit 3df0411

Browse files
committed
remove JSON Spirit UniValue wrapper
1 parent 1f263c8 commit 3df0411

23 files changed

+239
-258
lines changed

src/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ BITCOIN_CORE_H = \
9898
ecwrapper.h \
9999
hash.h \
100100
init.h \
101-
json_spirit_wrapper.h \
102101
key.h \
103102
keystore.h \
104103
leveldbwrapper.h \

src/bitcoin-cli.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static bool AppInitRPC(int argc, char* argv[])
9494
return true;
9595
}
9696

97-
Object CallRPC(const string& strMethod, const Array& params)
97+
UniValue CallRPC(const string& strMethod, const Array& params)
9898
{
9999
if (mapArgs["-rpcuser"] == "" && mapArgs["-rpcpassword"] == "")
100100
throw runtime_error(strprintf(
@@ -142,7 +142,7 @@ Object CallRPC(const string& strMethod, const Array& params)
142142
throw runtime_error("no response from server");
143143

144144
// Parse reply
145-
Value valReply(UniValue::VSTR);
145+
UniValue valReply(UniValue::VSTR);
146146
if (!valReply.read(strReply))
147147
throw runtime_error("couldn't parse reply from server");
148148
const Object& reply = valReply.get_obj();
@@ -170,14 +170,13 @@ int CommandLineRPC(int argc, char *argv[])
170170

171171
// Parameters default to strings
172172
std::vector<std::string> strParams(&argv[2], &argv[argc]);
173-
Array params = RPCConvertValues(strMethod, strParams);
173+
UniValue params = RPCConvertValues(strMethod, strParams);
174174

175175
// Execute and handle connection failures with -rpcwait
176176
const bool fWait = GetBoolArg("-rpcwait", false);
177177
do {
178178
try {
179-
// Execute
180-
Object reply = CallRPC(strMethod, params);
179+
const UniValue reply = CallRPC(strMethod, params);
181180

182181
// Parse reply
183182
const Value& result = find_value(reply, "result");

src/json_spirit_wrapper.h

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/rest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class RestErr
6262
};
6363

6464
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry);
65-
extern Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false);
65+
extern UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false);
6666
extern void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeHex);
6767

6868
static RestErr RESTERR(enum HTTPStatusCode status, string message)
@@ -221,7 +221,7 @@ static bool rest_block(AcceptedConnection* conn,
221221
}
222222

223223
case RF_JSON: {
224-
Object objBlock = blockToJSON(block, pblockindex, showTxDetails);
224+
UniValue objBlock = blockToJSON(block, pblockindex, showTxDetails);
225225
string strJSON = objBlock.write() + "\n";
226226
conn->stream() << HTTPReply(HTTP_OK, strJSON, fRun) << std::flush;
227227
return true;
@@ -266,7 +266,7 @@ static bool rest_chaininfo(AcceptedConnection* conn,
266266
switch (rf) {
267267
case RF_JSON: {
268268
UniValue rpcParams(UniValue::VARR);
269-
Value chainInfoObject = getblockchaininfo(rpcParams, false);
269+
UniValue chainInfoObject = getblockchaininfo(rpcParams, false);
270270
string strJSON = chainInfoObject.write() + "\n";
271271
conn->stream() << HTTPReply(HTTP_OK, strJSON, fRun) << std::flush;
272272
return true;

src/rpcblockchain.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ double GetDifficulty(const CBlockIndex* blockindex)
5353
}
5454

5555

56-
Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false)
56+
UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false)
5757
{
5858
UniValue result(UniValue::VOBJ);
5959
result.push_back(Pair("hash", block.GetHash().GetHex()));
@@ -94,7 +94,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDe
9494
}
9595

9696

97-
Value getblockcount(const Array& params, bool fHelp)
97+
UniValue getblockcount(const Array& params, bool fHelp)
9898
{
9999
if (fHelp || params.size() != 0)
100100
throw runtime_error(
@@ -111,7 +111,7 @@ Value getblockcount(const Array& params, bool fHelp)
111111
return chainActive.Height();
112112
}
113113

114-
Value getbestblockhash(const Array& params, bool fHelp)
114+
UniValue getbestblockhash(const Array& params, bool fHelp)
115115
{
116116
if (fHelp || params.size() != 0)
117117
throw runtime_error(
@@ -128,7 +128,7 @@ Value getbestblockhash(const Array& params, bool fHelp)
128128
return chainActive.Tip()->GetBlockHash().GetHex();
129129
}
130130

131-
Value getdifficulty(const Array& params, bool fHelp)
131+
UniValue getdifficulty(const Array& params, bool fHelp)
132132
{
133133
if (fHelp || params.size() != 0)
134134
throw runtime_error(
@@ -146,7 +146,7 @@ Value getdifficulty(const Array& params, bool fHelp)
146146
}
147147

148148

149-
Value getrawmempool(const Array& params, bool fHelp)
149+
UniValue getrawmempool(const Array& params, bool fHelp)
150150
{
151151
if (fHelp || params.size() > 1)
152152
throw runtime_error(
@@ -231,7 +231,7 @@ Value getrawmempool(const Array& params, bool fHelp)
231231
}
232232
}
233233

234-
Value getblockhash(const Array& params, bool fHelp)
234+
UniValue getblockhash(const Array& params, bool fHelp)
235235
{
236236
if (fHelp || params.size() != 1)
237237
throw runtime_error(
@@ -256,7 +256,7 @@ Value getblockhash(const Array& params, bool fHelp)
256256
return pblockindex->GetBlockHash().GetHex();
257257
}
258258

259-
Value getblock(const Array& params, bool fHelp)
259+
UniValue getblock(const Array& params, bool fHelp)
260260
{
261261
if (fHelp || params.size() < 1 || params.size() > 2)
262262
throw runtime_error(
@@ -324,7 +324,7 @@ Value getblock(const Array& params, bool fHelp)
324324
return blockToJSON(block, pblockindex);
325325
}
326326

327-
Value gettxoutsetinfo(const Array& params, bool fHelp)
327+
UniValue gettxoutsetinfo(const Array& params, bool fHelp)
328328
{
329329
if (fHelp || params.size() != 0)
330330
throw runtime_error(
@@ -364,7 +364,7 @@ Value gettxoutsetinfo(const Array& params, bool fHelp)
364364
return ret;
365365
}
366366

367-
Value gettxout(const Array& params, bool fHelp)
367+
UniValue gettxout(const Array& params, bool fHelp)
368368
{
369369
if (fHelp || params.size() < 2 || params.size() > 3)
370370
throw runtime_error(
@@ -444,7 +444,7 @@ Value gettxout(const Array& params, bool fHelp)
444444
return ret;
445445
}
446446

447-
Value verifychain(const Array& params, bool fHelp)
447+
UniValue verifychain(const Array& params, bool fHelp)
448448
{
449449
if (fHelp || params.size() > 2)
450450
throw runtime_error(
@@ -472,7 +472,7 @@ Value verifychain(const Array& params, bool fHelp)
472472
return CVerifyDB().VerifyDB(pcoinsTip, nCheckLevel, nCheckDepth);
473473
}
474474

475-
Value getblockchaininfo(const Array& params, bool fHelp)
475+
UniValue getblockchaininfo(const Array& params, bool fHelp)
476476
{
477477
if (fHelp || params.size() != 0)
478478
throw runtime_error(
@@ -530,7 +530,7 @@ struct CompareBlocksByHeight
530530
}
531531
};
532532

533-
Value getchaintips(const Array& params, bool fHelp)
533+
UniValue getchaintips(const Array& params, bool fHelp)
534534
{
535535
if (fHelp || params.size() != 0)
536536
throw runtime_error(
@@ -620,7 +620,7 @@ Value getchaintips(const Array& params, bool fHelp)
620620
return res;
621621
}
622622

623-
Value getmempoolinfo(const Array& params, bool fHelp)
623+
UniValue getmempoolinfo(const Array& params, bool fHelp)
624624
{
625625
if (fHelp || params.size() != 0)
626626
throw runtime_error(
@@ -643,7 +643,7 @@ Value getmempoolinfo(const Array& params, bool fHelp)
643643
return ret;
644644
}
645645

646-
Value invalidateblock(const Array& params, bool fHelp)
646+
UniValue invalidateblock(const Array& params, bool fHelp)
647647
{
648648
if (fHelp || params.size() != 1)
649649
throw runtime_error(
@@ -681,7 +681,7 @@ Value invalidateblock(const Array& params, bool fHelp)
681681
return NullUniValue;
682682
}
683683

684-
Value reconsiderblock(const Array& params, bool fHelp)
684+
UniValue reconsiderblock(const Array& params, bool fHelp)
685685
{
686686
if (fHelp || params.size() != 1)
687687
throw runtime_error(

src/rpcclient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ CRPCConvertTable::CRPCConvertTable()
122122
static CRPCConvertTable rpcCvtTable;
123123

124124
/** Convert strings to command-specific RPC representation */
125-
Array RPCConvertValues(const std::string &strMethod, const std::vector<std::string> &strParams)
125+
UniValue RPCConvertValues(const std::string &strMethod, const std::vector<std::string> &strParams)
126126
{
127127
UniValue params(UniValue::VARR);
128128

src/rpcclient.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#ifndef BITCOIN_RPCCLIENT_H
77
#define BITCOIN_RPCCLIENT_H
88

9-
#include "json_spirit_wrapper.h"
9+
#include "univalue/univalue.h"
1010

11-
json_spirit::Array RPCConvertValues(const std::string& strMethod, const std::vector<std::string>& strParams);
11+
UniValue RPCConvertValues(const std::string& strMethod, const std::vector<std::string>& strParams);
1212

1313
#endif // BITCOIN_RPCCLIENT_H

src/rpcmining.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ using namespace std;
3434
* or from the last difficulty change if 'lookup' is nonpositive.
3535
* If 'height' is nonnegative, compute the estimate at the time when a given block was found.
3636
*/
37-
Value GetNetworkHashPS(int lookup, int height) {
37+
UniValue GetNetworkHashPS(int lookup, int height) {
3838
CBlockIndex *pb = chainActive.Tip();
3939

4040
if (height >= 0 && height < chainActive.Height())
@@ -71,7 +71,7 @@ Value GetNetworkHashPS(int lookup, int height) {
7171
return (int64_t)(workDiff.getdouble() / timeDiff);
7272
}
7373

74-
Value getnetworkhashps(const Array& params, bool fHelp)
74+
UniValue getnetworkhashps(const Array& params, bool fHelp)
7575
{
7676
if (fHelp || params.size() > 2)
7777
throw runtime_error(
@@ -94,7 +94,7 @@ Value getnetworkhashps(const Array& params, bool fHelp)
9494
}
9595

9696
#ifdef ENABLE_WALLET
97-
Value getgenerate(const Array& params, bool fHelp)
97+
UniValue getgenerate(const Array& params, bool fHelp)
9898
{
9999
if (fHelp || params.size() != 0)
100100
throw runtime_error(
@@ -113,7 +113,7 @@ Value getgenerate(const Array& params, bool fHelp)
113113
return GetBoolArg("-gen", false);
114114
}
115115

116-
Value generate(const Array& params, bool fHelp)
116+
UniValue generate(const Array& params, bool fHelp)
117117
{
118118
if (fHelp || params.size() < 1 || params.size() > 1)
119119
throw runtime_error(
@@ -172,7 +172,7 @@ Value generate(const Array& params, bool fHelp)
172172
}
173173

174174

175-
Value setgenerate(const Array& params, bool fHelp)
175+
UniValue setgenerate(const Array& params, bool fHelp)
176176
{
177177
if (fHelp || params.size() < 1 || params.size() > 2)
178178
throw runtime_error(
@@ -220,7 +220,7 @@ Value setgenerate(const Array& params, bool fHelp)
220220
#endif
221221

222222

223-
Value getmininginfo(const Array& params, bool fHelp)
223+
UniValue getmininginfo(const Array& params, bool fHelp)
224224
{
225225
if (fHelp || params.size() != 0)
226226
throw runtime_error(
@@ -266,7 +266,7 @@ Value getmininginfo(const Array& params, bool fHelp)
266266

267267

268268
// NOTE: Unlike wallet RPC (which use BTC values), mining RPCs follow GBT (BIP 22) in using satoshi amounts
269-
Value prioritisetransaction(const Array& params, bool fHelp)
269+
UniValue prioritisetransaction(const Array& params, bool fHelp)
270270
{
271271
if (fHelp || params.size() != 3)
272272
throw runtime_error(
@@ -298,7 +298,7 @@ Value prioritisetransaction(const Array& params, bool fHelp)
298298

299299

300300
// NOTE: Assumes a conclusive result; if result is inconclusive, it must be handled by caller
301-
static Value BIP22ValidationResult(const CValidationState& state)
301+
static UniValue BIP22ValidationResult(const CValidationState& state)
302302
{
303303
if (state.IsValid())
304304
return Value::null;
@@ -316,7 +316,7 @@ static Value BIP22ValidationResult(const CValidationState& state)
316316
return "valid?";
317317
}
318318

319-
Value getblocktemplate(const Array& params, bool fHelp)
319+
UniValue getblocktemplate(const Array& params, bool fHelp)
320320
{
321321
if (fHelp || params.size() > 1)
322322
throw runtime_error(
@@ -381,7 +381,7 @@ Value getblocktemplate(const Array& params, bool fHelp)
381381
LOCK(cs_main);
382382

383383
std::string strMode = "template";
384-
Value lpval = NullUniValue;
384+
UniValue lpval = NullUniValue;
385385
if (params.size() > 0)
386386
{
387387
const Object& oparam = params[0].get_obj();
@@ -605,7 +605,7 @@ class submitblock_StateCatcher : public CValidationInterface
605605
};
606606
};
607607

608-
Value submitblock(const Array& params, bool fHelp)
608+
UniValue submitblock(const Array& params, bool fHelp)
609609
{
610610
if (fHelp || params.size() < 1 || params.size() > 2)
611611
throw runtime_error(
@@ -666,7 +666,7 @@ Value submitblock(const Array& params, bool fHelp)
666666
return BIP22ValidationResult(state);
667667
}
668668

669-
Value estimatefee(const Array& params, bool fHelp)
669+
UniValue estimatefee(const Array& params, bool fHelp)
670670
{
671671
if (fHelp || params.size() != 1)
672672
throw runtime_error(
@@ -698,7 +698,7 @@ Value estimatefee(const Array& params, bool fHelp)
698698
return ValueFromAmount(feeRate.GetFeePerK());
699699
}
700700

701-
Value estimatepriority(const Array& params, bool fHelp)
701+
UniValue estimatepriority(const Array& params, bool fHelp)
702702
{
703703
if (fHelp || params.size() != 1)
704704
throw runtime_error(

0 commit comments

Comments
 (0)