Skip to content
Permalink
Browse files

Merge pull request #6121

44c7474 univalue: add type check unit tests (Jonas Schnelli)
c023092 univalue: add strict type checking (Wladimir J. van der Laan)
7e98a3c util: Add ParseInt64 and ParseDouble functions (Wladimir J. van der Laan)
043df2b Simplify RPCclient, adapt json_parse_error test (Wladimir J. van der Laan)
519eede fix univalue json parse tests (Jonas Schnelli)
c7fbbc7 fix missing univalue types during constructing (Jonas Schnelli)
8f7e4ab fix rpc batching univalue issue (Jonas Schnelli)
9a8897f Remove JSON Spirit wrapper, remove JSON Spirit leftovers (Jonas Schnelli)
3df0411 remove JSON Spirit UniValue wrapper (Jonas Schnelli)
1f263c8 fix rpc unit test, plain numbers are not JSON compatible object (Jonas Schnelli)
e04d9c2 univalue: correct bool support (Jonas Schnelli)
0c5b2cf univalue: add support for real, fix percision and make it json_spirit compatible (Jonas Schnelli)
21c10de special threatment for null,true,false because they are non valid json (Jonas Schnelli)
6c7bee0 expicit set UniValue type to avoid empty values (Jonas Schnelli)
53b4671 extend conversion to UniValue (Jonas Schnelli)
15982a8 Convert tree to using univalue. Eliminate all json_spirit uses. (Jeff Garzik)
5e3060c UniValue: export NullUniValue global constant (Jeff Garzik)
efc7883 UniValue: prefer .size() to .count(), to harmonize w/ existing tree (Jeff Garzik)
  • Loading branch information
laanwj committed Jun 4, 2015
2 parents dbd8550 + 44c7474 commit 466f0ea0e66b88285c7797ab36ba777725324e83
Showing with 1,129 additions and 2,742 deletions.
  1. +1 −12 src/Makefile.am
  2. +16 −16 src/bitcoin-cli.cpp
  3. +2 −2 src/bitcoin-tx.cpp
  4. +0 −24 src/json/LICENSE.txt
  5. +0 −18 src/json/json_spirit.h
  6. +0 −54 src/json/json_spirit_error_position.h
  7. +0 −137 src/json/json_spirit_reader.cpp
  8. +0 −62 src/json/json_spirit_reader.h
  9. +0 −612 src/json/json_spirit_reader_template.h
  10. +0 −70 src/json/json_spirit_stream_reader.h
  11. +0 −61 src/json/json_spirit_utils.h
  12. +0 −8 src/json/json_spirit_value.cpp
  13. +0 −534 src/json/json_spirit_value.h
  14. +0 −95 src/json/json_spirit_writer.cpp
  15. +0 −50 src/json/json_spirit_writer.h
  16. +0 −249 src/json/json_spirit_writer_template.h
  17. +8 −8 src/qt/rpcconsole.cpp
  18. +17 −17 src/rest.cpp
  19. +43 −38 src/rpcblockchain.cpp
  20. +21 −12 src/rpcclient.cpp
  21. +6 −4 src/rpcclient.h
  22. +35 −37 src/rpcmining.cpp
  23. +23 −24 src/rpcmisc.cpp
  24. +28 −29 src/rpcnet.cpp
  25. +14 −14 src/rpcprotocol.cpp
  26. +5 −7 src/rpcprotocol.h
  27. +63 −59 src/rpcrawtransaction.cpp
  28. +60 −60 src/rpcserver.cpp
  29. +111 −110 src/rpcserver.h
  30. +26 −32 src/test/base58_tests.cpp
  31. +32 −31 src/test/rpc_tests.cpp
  32. +8 −7 src/test/rpc_wallet_tests.cpp
  33. +27 −29 src/test/script_tests.cpp
  34. +7 −10 src/test/sighash_tests.cpp
  35. +26 −27 src/test/transaction_tests.cpp
  36. +55 −13 src/test/univalue_tests.cpp
  37. +65 −0 src/test/util_tests.cpp
  38. +100 −7 src/univalue/univalue.cpp
  39. +98 −3 src/univalue/univalue.h
  40. +9 −0 src/univalue/univalue_write.cpp
  41. +42 −1 src/utilstrencodings.cpp
  42. +14 −0 src/utilstrencodings.h
  43. +17 −18 src/wallet/rpcdump.cpp
  44. +150 −141 src/wallet/rpcwallet.cpp
@@ -154,17 +154,6 @@ BITCOIN_CORE_H = \
wallet/wallet_ismine.h \
wallet/walletdb.h

JSON_H = \
json/json_spirit.h \
json/json_spirit_error_position.h \
json/json_spirit_reader.h \
json/json_spirit_reader_template.h \
json/json_spirit_stream_reader.h \
json/json_spirit_utils.h \
json/json_spirit_value.h \
json/json_spirit_writer.h \
json/json_spirit_writer_template.h

obj/build.h: FORCE
@$(MKDIR_P) $(builddir)/obj
@$(top_srcdir)/share/genbuild.sh $(abs_top_builddir)/src/obj/build.h \
@@ -200,7 +189,6 @@ libbitcoin_server_a_SOURCES = \
txdb.cpp \
txmempool.cpp \
validationinterface.cpp \
$(JSON_H) \
$(BITCOIN_CORE_H)

# wallet: shared between bitcoind and bitcoin-qt, but only linked
@@ -342,6 +330,7 @@ endif

bitcoin_cli_LDADD = \
$(LIBBITCOIN_CLI) \
$(LIBBITCOIN_UNIVALUE) \
$(LIBBITCOIN_UTIL) \
$(LIBSECP256K1)

@@ -12,8 +12,9 @@

#include <boost/filesystem/operations.hpp>

#include "univalue/univalue.h"

using namespace std;
using namespace json_spirit;

std::string HelpMessageCli()
{
@@ -94,7 +95,7 @@ static bool AppInitRPC(int argc, char* argv[])
return true;
}

Object CallRPC(const string& strMethod, const Array& params)
UniValue CallRPC(const string& strMethod, const UniValue& params)
{
if (mapArgs["-rpcuser"] == "" && mapArgs["-rpcpassword"] == "")
throw runtime_error(strprintf(
@@ -142,10 +143,10 @@ Object CallRPC(const string& strMethod, const Array& params)
throw runtime_error("no response from server");

// Parse reply
Value valReply;
if (!read_string(strReply, valReply))
UniValue valReply(UniValue::VSTR);
if (!valReply.read(strReply))
throw runtime_error("couldn't parse reply from server");
const Object& reply = valReply.get_obj();
const UniValue& reply = valReply.get_obj();
if (reply.empty())
throw runtime_error("expected reply to have result, error and id properties");

@@ -170,35 +171,34 @@ int CommandLineRPC(int argc, char *argv[])

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

// Execute and handle connection failures with -rpcwait
const bool fWait = GetBoolArg("-rpcwait", false);
do {
try {
const Object reply = CallRPC(strMethod, params);
const UniValue reply = CallRPC(strMethod, params);

// Parse reply
const Value& result = find_value(reply, "result");
const Value& error = find_value(reply, "error");
const UniValue& result = find_value(reply, "result");
const UniValue& error = find_value(reply, "error");

if (error.type() != null_type) {
if (!error.isNull()) {
// Error
const int code = find_value(error.get_obj(), "code").get_int();
int code = error["code"].get_int();
if (fWait && code == RPC_IN_WARMUP)
throw CConnectionFailed("server in warmup");
strPrint = "error: " + write_string(error, false);
strPrint = "error: " + error.write();
nRet = abs(code);
} else {
// Result
if (result.type() == null_type)
if (result.isNull())
strPrint = "";
else if (result.type() == str_type)
else if (result.isStr())
strPrint = result.get_str();
else
strPrint = write_string(result, true);
strPrint = result.write(2);
}

// Connection succeeded, no need to retry.
break;
}
@@ -346,7 +346,7 @@ static void MutateTxSign(CMutableTransaction& tx, const string& flagStr)
UniValue keysObj = registers["privatekeys"];
fGivenKeys = true;

for (unsigned int kidx = 0; kidx < keysObj.count(); kidx++) {
for (unsigned int kidx = 0; kidx < keysObj.size(); kidx++) {
if (!keysObj[kidx].isStr())
throw runtime_error("privatekey not a string");
CBitcoinSecret vchSecret;
@@ -363,7 +363,7 @@ static void MutateTxSign(CMutableTransaction& tx, const string& flagStr)
throw runtime_error("prevtxs register variable must be set.");
UniValue prevtxsObj = registers["prevtxs"];
{
for (unsigned int previdx = 0; previdx < prevtxsObj.count(); previdx++) {
for (unsigned int previdx = 0; previdx < prevtxsObj.size(); previdx++) {
UniValue prevOut = prevtxsObj[previdx];
if (!prevOut.isObject())
throw runtime_error("expected prevtxs internal object");

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 466f0ea

Please sign in to comment.
You can’t perform that action at this time.