aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am12
-rw-r--r--src/bitcoin-cli.cpp15
-rw-r--r--src/json/LICENSE.txt24
-rw-r--r--src/json/json_spirit.h18
-rw-r--r--src/json/json_spirit_error_position.h54
-rw-r--r--src/json/json_spirit_reader.cpp137
-rw-r--r--src/json/json_spirit_reader.h62
-rw-r--r--src/json/json_spirit_reader_template.h612
-rw-r--r--src/json/json_spirit_stream_reader.h70
-rw-r--r--src/json/json_spirit_utils.h61
-rw-r--r--src/json/json_spirit_value.cpp8
-rw-r--r--src/json/json_spirit_value.h534
-rw-r--r--src/json/json_spirit_writer.cpp95
-rw-r--r--src/json/json_spirit_writer.h50
-rw-r--r--src/json/json_spirit_writer_template.h249
-rw-r--r--src/qt/rpcconsole.cpp4
-rw-r--r--src/rest.cpp7
-rw-r--r--src/rpcblockchain.cpp35
-rw-r--r--src/rpcclient.cpp4
-rw-r--r--src/rpcmining.cpp31
-rw-r--r--src/rpcmisc.cpp22
-rw-r--r--src/rpcnet.cpp17
-rw-r--r--src/rpcprotocol.cpp10
-rw-r--r--src/rpcprotocol.h2
-rw-r--r--src/rpcrawtransaction.cpp36
-rw-r--r--src/rpcserver.cpp47
-rw-r--r--src/rpcserver.h3
-rw-r--r--src/test/base58_tests.cpp4
-rw-r--r--src/test/rpc_tests.cpp17
-rw-r--r--src/test/rpc_wallet_tests.cpp11
-rw-r--r--src/test/script_tests.cpp14
-rw-r--r--src/test/sighash_tests.cpp4
-rw-r--r--src/test/transaction_tests.cpp23
-rw-r--r--src/univalue/univalue.cpp12
-rw-r--r--src/univalue/univalue.h4
-rw-r--r--src/wallet/rpcdump.cpp13
-rw-r--r--src/wallet/rpcwallet.cpp93
37 files changed, 212 insertions, 2202 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 63332f9acd..59618c4940 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index 0cafd2b0b4..d451720141 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -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;
}
-UniValue CallRPC(const string& strMethod, const Array& params)
+UniValue CallRPC(const string& strMethod, const UniValue& params)
{
if (mapArgs["-rpcuser"] == "" && mapArgs["-rpcpassword"] == "")
throw runtime_error(strprintf(
@@ -145,7 +146,7 @@ UniValue CallRPC(const string& strMethod, const Array& params)
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");
@@ -179,13 +180,15 @@ int CommandLineRPC(int argc, char *argv[])
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.isNull()) {
// Error
- strPrint = "error: " + error.write();
int code = error["code"].get_int();
+ if (fWait && code == RPC_IN_WARMUP)
+ throw CConnectionFailed("server in warmup");
+ strPrint = "error: " + error.write();
nRet = abs(code);
} else {
// Result
diff --git a/src/json/LICENSE.txt b/src/json/LICENSE.txt
deleted file mode 100644
index 797d5363b3..0000000000
--- a/src/json/LICENSE.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-The MIT License
-
-Copyright (c) 2007 - 2009 John W. Wilkinson
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
diff --git a/src/json/json_spirit.h b/src/json/json_spirit.h
deleted file mode 100644
index ac1879d5b3..0000000000
--- a/src/json/json_spirit.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef JSON_SPIRIT
-#define JSON_SPIRIT
-
-// Copyright John W. Wilkinson 2007 - 2009.
-// Distributed under the MIT License, see accompanying file LICENSE.txt
-
-// json spirit version 4.03
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-#include "json_spirit_value.h"
-#include "json_spirit_reader.h"
-#include "json_spirit_writer.h"
-#include "json_spirit_utils.h"
-
-#endif
diff --git a/src/json/json_spirit_error_position.h b/src/json/json_spirit_error_position.h
deleted file mode 100644
index 17208507df..0000000000
--- a/src/json/json_spirit_error_position.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef JSON_SPIRIT_ERROR_POSITION
-#define JSON_SPIRIT_ERROR_POSITION
-
-// Copyright John W. Wilkinson 2007 - 2009.
-// Distributed under the MIT License, see accompanying file LICENSE.txt
-
-// json spirit version 4.03
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-#include <string>
-
-namespace json_spirit
-{
- // An Error_position exception is thrown by the "read_or_throw" functions below on finding an error.
- // Note the "read_or_throw" functions are around 3 times slower than the standard functions "read"
- // functions that return a bool.
- //
- struct Error_position
- {
- Error_position();
- Error_position( unsigned int line, unsigned int column, const std::string& reason );
- bool operator==( const Error_position& lhs ) const;
- unsigned int line_;
- unsigned int column_;
- std::string reason_;
- };
-
- inline Error_position::Error_position()
- : line_( 0 )
- , column_( 0 )
- {
- }
-
- inline Error_position::Error_position( unsigned int line, unsigned int column, const std::string& reason )
- : line_( line )
- , column_( column )
- , reason_( reason )
- {
- }
-
- inline bool Error_position::operator==( const Error_position& lhs ) const
- {
- if( this == &lhs ) return true;
-
- return ( reason_ == lhs.reason_ ) &&
- ( line_ == lhs.line_ ) &&
- ( column_ == lhs.column_ );
-}
-}
-
-#endif
diff --git a/src/json/json_spirit_reader.cpp b/src/json/json_spirit_reader.cpp
deleted file mode 100644
index aa4f637226..0000000000
--- a/src/json/json_spirit_reader.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright John W. Wilkinson 2007 - 2009.
-// Distributed under the MIT License, see accompanying file LICENSE.txt
-
-// json spirit version 4.03
-
-#include "json_spirit_reader.h"
-#include "json_spirit_reader_template.h"
-
-using namespace json_spirit;
-
-bool json_spirit::read( const std::string& s, Value& value )
-{
- return read_string( s, value );
-}
-
-void json_spirit::read_or_throw( const std::string& s, Value& value )
-{
- read_string_or_throw( s, value );
-}
-
-bool json_spirit::read( std::istream& is, Value& value )
-{
- return read_stream( is, value );
-}
-
-void json_spirit::read_or_throw( std::istream& is, Value& value )
-{
- read_stream_or_throw( is, value );
-}
-
-bool json_spirit::read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value )
-{
- return read_range( begin, end, value );
-}
-
-void json_spirit::read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value )
-{
- begin = read_range_or_throw( begin, end, value );
-}
-
-#ifndef BOOST_NO_STD_WSTRING
-
-bool json_spirit::read( const std::wstring& s, wValue& value )
-{
- return read_string( s, value );
-}
-
-void json_spirit::read_or_throw( const std::wstring& s, wValue& value )
-{
- read_string_or_throw( s, value );
-}
-
-bool json_spirit::read( std::wistream& is, wValue& value )
-{
- return read_stream( is, value );
-}
-
-void json_spirit::read_or_throw( std::wistream& is, wValue& value )
-{
- read_stream_or_throw( is, value );
-}
-
-bool json_spirit::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value )
-{
- return read_range( begin, end, value );
-}
-
-void json_spirit::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value )
-{
- begin = read_range_or_throw( begin, end, value );
-}
-
-#endif
-
-bool json_spirit::read( const std::string& s, mValue& value )
-{
- return read_string( s, value );
-}
-
-void json_spirit::read_or_throw( const std::string& s, mValue& value )
-{
- read_string_or_throw( s, value );
-}
-
-bool json_spirit::read( std::istream& is, mValue& value )
-{
- return read_stream( is, value );
-}
-
-void json_spirit::read_or_throw( std::istream& is, mValue& value )
-{
- read_stream_or_throw( is, value );
-}
-
-bool json_spirit::read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value )
-{
- return read_range( begin, end, value );
-}
-
-void json_spirit::read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value )
-{
- begin = read_range_or_throw( begin, end, value );
-}
-
-#ifndef BOOST_NO_STD_WSTRING
-
-bool json_spirit::read( const std::wstring& s, wmValue& value )
-{
- return read_string( s, value );
-}
-
-void json_spirit::read_or_throw( const std::wstring& s, wmValue& value )
-{
- read_string_or_throw( s, value );
-}
-
-bool json_spirit::read( std::wistream& is, wmValue& value )
-{
- return read_stream( is, value );
-}
-
-void json_spirit::read_or_throw( std::wistream& is, wmValue& value )
-{
- read_stream_or_throw( is, value );
-}
-
-bool json_spirit::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value )
-{
- return read_range( begin, end, value );
-}
-
-void json_spirit::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value )
-{
- begin = read_range_or_throw( begin, end, value );
-}
-
-#endif
diff --git a/src/json/json_spirit_reader.h b/src/json/json_spirit_reader.h
deleted file mode 100644
index 96494a9789..0000000000
--- a/src/json/json_spirit_reader.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef JSON_SPIRIT_READER
-#define JSON_SPIRIT_READER
-
-// Copyright John W. Wilkinson 2007 - 2009.
-// Distributed under the MIT License, see accompanying file LICENSE.txt
-
-// json spirit version 4.03
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-#include "json_spirit_value.h"
-#include "json_spirit_error_position.h"
-#include <iostream>
-
-namespace json_spirit
-{
- // functions to reads a JSON values
-
- bool read( const std::string& s, Value& value );
- bool read( std::istream& is, Value& value );
- bool read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value );
-
- void read_or_throw( const std::string& s, Value& value );
- void read_or_throw( std::istream& is, Value& value );
- void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value );
-
-#ifndef BOOST_NO_STD_WSTRING
-
- bool read( const std::wstring& s, wValue& value );
- bool read( std::wistream& is, wValue& value );
- bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value );
-
- void read_or_throw( const std::wstring& s, wValue& value );
- void read_or_throw( std::wistream& is, wValue& value );
- void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value );
-
-#endif
-
- bool read( const std::string& s, mValue& value );
- bool read( std::istream& is, mValue& value );
- bool read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value );
-
- void read_or_throw( const std::string& s, mValue& value );
- void read_or_throw( std::istream& is, mValue& value );
- void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value );
-
-#ifndef BOOST_NO_STD_WSTRING
-
- bool read( const std::wstring& s, wmValue& value );
- bool read( std::wistream& is, wmValue& value );
- bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value );
-
- void read_or_throw( const std::wstring& s, wmValue& value );
- void read_or_throw( std::wistream& is, wmValue& value );
- void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value );
-
-#endif
-}
-
-#endif
diff --git a/src/json/json_spirit_reader_template.h b/src/json/json_spirit_reader_template.h
deleted file mode 100644
index 47e3c1ca84..0000000000
--- a/src/json/json_spirit_reader_template.h
+++ /dev/null
@@ -1,612 +0,0 @@
-#ifndef JSON_SPIRIT_READER_TEMPLATE
-#define JSON_SPIRIT_READER_TEMPLATE
-
-// Copyright John W. Wilkinson 2007 - 2009.
-// Distributed under the MIT License, see accompanying file LICENSE.txt
-
-// json spirit version 4.03
-
-#include "json_spirit_value.h"
-#include "json_spirit_error_position.h"
-
-//#define BOOST_SPIRIT_THREADSAFE // uncomment for multithreaded use, requires linking to boost.thread
-
-#include <boost/bind.hpp>
-#include <boost/function.hpp>
-#include <boost/version.hpp>
-
-#if BOOST_VERSION >= 103800
- #include <boost/spirit/include/classic_core.hpp>
- #include <boost/spirit/include/classic_confix.hpp>
- #include <boost/spirit/include/classic_escape_char.hpp>
- #include <boost/spirit/include/classic_multi_pass.hpp>
- #include <boost/spirit/include/classic_position_iterator.hpp>
- #define spirit_namespace boost::spirit::classic
-#else
- #include <boost/spirit/core.hpp>
- #include <boost/spirit/utility/confix.hpp>
- #include <boost/spirit/utility/escape_char.hpp>
- #include <boost/spirit/iterator/multi_pass.hpp>
- #include <boost/spirit/iterator/position_iterator.hpp>
- #define spirit_namespace boost::spirit
-#endif
-
-namespace json_spirit
-{
- const spirit_namespace::int_parser < int64_t > int64_p = spirit_namespace::int_parser < int64_t >();
- const spirit_namespace::uint_parser< uint64_t > uint64_p = spirit_namespace::uint_parser< uint64_t >();
-
- template< class Iter_type >
- bool is_eq( Iter_type first, Iter_type last, const char* c_str )
- {
- for( Iter_type i = first; i != last; ++i, ++c_str )
- {
- if( *c_str == 0 ) return false;
-
- if( *i != *c_str ) return false;
- }
-
- return true;
- }
-
- template< class Char_type >
- Char_type hex_to_num( const Char_type c )
- {
- if( ( c >= '0' ) && ( c <= '9' ) ) return c - '0';
- if( ( c >= 'a' ) && ( c <= 'f' ) ) return c - 'a' + 10;
- if( ( c >= 'A' ) && ( c <= 'F' ) ) return c - 'A' + 10;
- return 0;
- }
-
- template< class Char_type, class Iter_type >
- Char_type hex_str_to_char( Iter_type& begin )
- {
- const Char_type c1( *( ++begin ) );
- const Char_type c2( *( ++begin ) );
-
- return ( hex_to_num( c1 ) << 4 ) + hex_to_num( c2 );
- }
-
- template< class Char_type, class Iter_type >
- Char_type unicode_str_to_char( Iter_type& begin )
- {
- const Char_type c1( *( ++begin ) );
- const Char_type c2( *( ++begin ) );
- const Char_type c3( *( ++begin ) );
- const Char_type c4( *( ++begin ) );
-
- return ( hex_to_num( c1 ) << 12 ) +
- ( hex_to_num( c2 ) << 8 ) +
- ( hex_to_num( c3 ) << 4 ) +
- hex_to_num( c4 );
- }
-
- template< class String_type >
- void append_esc_char_and_incr_iter( String_type& s,
- typename String_type::const_iterator& begin,
- typename String_type::const_iterator end )
- {
- typedef typename String_type::value_type Char_type;
-
- const Char_type c2( *begin );
-
- switch( c2 )
- {
- case 't': s += '\t'; break;
- case 'b': s += '\b'; break;
- case 'f': s += '\f'; break;
- case 'n': s += '\n'; break;
- case 'r': s += '\r'; break;
- case '\\': s += '\\'; break;
- case '/': s += '/'; break;
- case '"': s += '"'; break;
- case 'x':
- {
- if( end - begin >= 3 ) // expecting "xHH..."
- {
- s += hex_str_to_char< Char_type >( begin );
- }
- break;
- }
- case 'u':
- {
- if( end - begin >= 5 ) // expecting "uHHHH..."
- {
- s += unicode_str_to_char< Char_type >( begin );
- }
- break;
- }
- }
- }
-
- template< class String_type >
- String_type substitute_esc_chars( typename String_type::const_iterator begin,
- typename String_type::const_iterator end )
- {
- typedef typename String_type::const_iterator Iter_type;
-
- if( end - begin < 2 ) return String_type( begin, end );
-
- String_type result;
-
- result.reserve( end - begin );
-
- const Iter_type end_minus_1( end - 1 );
-
- Iter_type substr_start = begin;
- Iter_type i = begin;
-
- for( ; i < end_minus_1; ++i )
- {
- if( *i == '\\' )
- {
- result.append( substr_start, i );
-
- ++i; // skip the '\'
-
- append_esc_char_and_incr_iter( result, i, end );
-
- substr_start = i + 1;
- }
- }
-
- result.append( substr_start, end );
-
- return result;
- }
-
- template< class String_type >
- String_type get_str_( typename String_type::const_iterator begin,
- typename String_type::const_iterator end )
- {
- assert( end - begin >= 2 );
-
- typedef typename String_type::const_iterator Iter_type;
-
- Iter_type str_without_quotes( ++begin );
- Iter_type end_without_quotes( --end );
-
- return substitute_esc_chars< String_type >( str_without_quotes, end_without_quotes );
- }
-
- inline std::string get_str( std::string::const_iterator begin, std::string::const_iterator end )
- {
- return get_str_< std::string >( begin, end );
- }
-
- inline std::wstring get_str( std::wstring::const_iterator begin, std::wstring::const_iterator end )
- {
- return get_str_< std::wstring >( begin, end );
- }
-
- template< class String_type, class Iter_type >
- String_type get_str( Iter_type begin, Iter_type end )
- {
- const String_type tmp( begin, end ); // convert multipass iterators to string iterators
-
- return get_str( tmp.begin(), tmp.end() );
- }
-
- // this class's methods get called by the spirit parse resulting
- // in the creation of a JSON object or array
- //
- // NB Iter_type could be a std::string iterator, wstring iterator, a position iterator or a multipass iterator
- //
- template< class Value_type, class Iter_type >
- class Semantic_actions
- {
- public:
-
- typedef typename Value_type::Config_type Config_type;
- typedef typename Config_type::String_type String_type;
- typedef typename Config_type::Object_type Object_type;
- typedef typename Config_type::Array_type Array_type;
- typedef typename String_type::value_type Char_type;
-
- Semantic_actions( Value_type& value )
- : value_( value )
- , current_p_( 0 )
- {
- }
-
- void begin_obj( Char_type c )
- {
- assert( c == '{' );
-
- begin_compound< Object_type >();
- }
-
- void end_obj( Char_type c )
- {
- assert( c == '}' );
-
- end_compound();
- }
-
- void begin_array( Char_type c )
- {
- assert( c == '[' );
-
- begin_compound< Array_type >();
- }
-
- void end_array( Char_type c )
- {
- assert( c == ']' );
-
- end_compound();
- }
-
- void new_name( Iter_type begin, Iter_type end )
- {
- assert( current_p_->type() == obj_type );
-
- name_ = get_str< String_type >( begin, end );
- }
-
- void new_str( Iter_type begin, Iter_type end )
- {
- add_to_current( get_str< String_type >( begin, end ) );
- }
-
- void new_true( Iter_type begin, Iter_type end )
- {
- assert( is_eq( begin, end, "true" ) );
-
- add_to_current( true );
- }
-
- void new_false( Iter_type begin, Iter_type end )
- {
- assert( is_eq( begin, end, "false" ) );
-
- add_to_current( false );
- }
-
- void new_null( Iter_type begin, Iter_type end )
- {
- assert( is_eq( begin, end, "null" ) );
-
- add_to_current( Value_type() );
- }
-
- void new_int( int64_t i )
- {
- add_to_current( i );
- }
-
- void new_uint64( uint64_t ui )
- {
- add_to_current( ui );
- }
-
- void new_real( double d )
- {
- add_to_current( d );
- }
-
- private:
-
- Semantic_actions& operator=( const Semantic_actions& );
- // to prevent "assignment operator could not be generated" warning
-
- Value_type* add_first( const Value_type& value )
- {
- assert( current_p_ == 0 );
-
- value_ = value;
- current_p_ = &value_;
- return current_p_;
- }
-
- template< class Array_or_obj >
- void begin_compound()
- {
- if( current_p_ == 0 )
- {
- add_first( Array_or_obj() );
- }
- else
- {
- stack_.push_back( current_p_ );
-
- Array_or_obj new_array_or_obj; // avoid copy by building new array or object in place
-
- current_p_ = add_to_current( new_array_or_obj );
- }
- }
-
- void end_compound()
- {
- if( current_p_ != &value_ )
- {
- current_p_ = stack_.back();
-
- stack_.pop_back();
- }
- }
-
- Value_type* add_to_current( const Value_type& value )
- {
- if( current_p_ == 0 )
- {
- return add_first( value );
- }
- else if( current_p_->type() == array_type )
- {
- current_p_->get_array().push_back( value );
-
- return &current_p_->get_array().back();
- }
-
- assert( current_p_->type() == obj_type );
-
- return &Config_type::add( current_p_->get_obj(), name_, value );
- }
-
- Value_type& value_; // this is the object or array that is being created
- Value_type* current_p_; // the child object or array that is currently being constructed
-
- std::vector< Value_type* > stack_; // previous child objects and arrays
-
- String_type name_; // of current name/value pair
- };
-
- template< typename Iter_type >
- void throw_error( spirit_namespace::position_iterator< Iter_type > i, const std::string& reason )
- {
- throw Error_position( i.get_position().line, i.get_position().column, reason );
- }
-
- template< typename Iter_type >
- void throw_error( Iter_type i, const std::string& reason )
- {
- throw reason;
- }
-
- // the spirit grammer
- //
- template< class Value_type, class Iter_type >
- class Json_grammer : public spirit_namespace::grammar< Json_grammer< Value_type, Iter_type > >
- {
- public:
-
- typedef Semantic_actions< Value_type, Iter_type > Semantic_actions_t;
-
- Json_grammer( Semantic_actions_t& semantic_actions )
- : actions_( semantic_actions )
- {
- }
-
- static void throw_not_value( Iter_type begin, Iter_type end )
- {
- throw_error( begin, "not a value" );
- }
-
- static void throw_not_array( Iter_type begin, Iter_type end )
- {
- throw_error( begin, "not an array" );
- }
-
- static void throw_not_object( Iter_type begin, Iter_type end )
- {
- throw_error( begin, "not an object" );
- }
-
- static void throw_not_pair( Iter_type begin, Iter_type end )
- {
- throw_error( begin, "not a pair" );
- }
-
- static void throw_not_colon( Iter_type begin, Iter_type end )
- {
- throw_error( begin, "no colon in pair" );
- }
-
- static void throw_not_string( Iter_type begin, Iter_type end )
- {
- throw_error( begin, "not a string" );
- }
-
- template< typename ScannerT >
- class definition
- {
- public:
-
- definition( const Json_grammer& self )
- {
- using namespace spirit_namespace;
-
- typedef typename Value_type::String_type::value_type Char_type;
-
- // first we convert the semantic action class methods to functors with the
- // parameter signature expected by spirit
-
- typedef boost::function< void( Char_type ) > Char_action;
- typedef boost::function< void( Iter_type, Iter_type ) > Str_action;
- typedef boost::function< void( double ) > Real_action;
- typedef boost::function< void( int64_t ) > Int_action;
- typedef boost::function< void( uint64_t ) > Uint64_action;
-
- Char_action begin_obj ( boost::bind( &Semantic_actions_t::begin_obj, &self.actions_, _1 ) );
- Char_action end_obj ( boost::bind( &Semantic_actions_t::end_obj, &self.actions_, _1 ) );
- Char_action begin_array( boost::bind( &Semantic_actions_t::begin_array, &self.actions_, _1 ) );
- Char_action end_array ( boost::bind( &Semantic_actions_t::end_array, &self.actions_, _1 ) );
- Str_action new_name ( boost::bind( &Semantic_actions_t::new_name, &self.actions_, _1, _2 ) );
- Str_action new_str ( boost::bind( &Semantic_actions_t::new_str, &self.actions_, _1, _2 ) );
- Str_action new_true ( boost::bind( &Semantic_actions_t::new_true, &self.actions_, _1, _2 ) );
- Str_action new_false ( boost::bind( &Semantic_actions_t::new_false, &self.actions_, _1, _2 ) );
- Str_action new_null ( boost::bind( &Semantic_actions_t::new_null, &self.actions_, _1, _2 ) );
- Real_action new_real ( boost::bind( &Semantic_actions_t::new_real, &self.actions_, _1 ) );
- Int_action new_int ( boost::bind( &Semantic_actions_t::new_int, &self.actions_, _1 ) );
- Uint64_action new_uint64 ( boost::bind( &Semantic_actions_t::new_uint64, &self.actions_, _1 ) );
-
- // actual grammer
-
- json_
- = value_ | eps_p[ &throw_not_value ]
- ;
-
- value_
- = string_[ new_str ]
- | number_
- | object_
- | array_
- | str_p( "true" ) [ new_true ]
- | str_p( "false" )[ new_false ]
- | str_p( "null" ) [ new_null ]
- ;
-
- object_
- = ch_p('{')[ begin_obj ]
- >> !members_
- >> ( ch_p('}')[ end_obj ] | eps_p[ &throw_not_object ] )
- ;
-
- members_
- = pair_ >> *( ',' >> pair_ )
- ;
-
- pair_
- = string_[ new_name ]
- >> ( ':' | eps_p[ &throw_not_colon ] )
- >> ( value_ | eps_p[ &throw_not_value ] )
- ;
-
- array_
- = ch_p('[')[ begin_array ]
- >> !elements_
- >> ( ch_p(']')[ end_array ] | eps_p[ &throw_not_array ] )
- ;
-
- elements_
- = value_ >> *( ',' >> value_ )
- ;
-
- string_
- = lexeme_d // this causes white space inside a string to be retained
- [
- confix_p
- (
- '"',
- *lex_escape_ch_p,
- '"'
- )
- ]
- ;
-
- number_
- = strict_real_p[ new_real ]
- | int64_p [ new_int ]
- | uint64_p [ new_uint64 ]
- ;
- }
-
- spirit_namespace::rule< ScannerT > json_, object_, members_, pair_, array_, elements_, value_, string_, number_;
-
- const spirit_namespace::rule< ScannerT >& start() const { return json_; }
- };
-
- private:
-
- Json_grammer& operator=( const Json_grammer& ); // to prevent "assignment operator could not be generated" warning
-
- Semantic_actions_t& actions_;
- };
-
- template< class Iter_type, class Value_type >
- Iter_type read_range_or_throw( Iter_type begin, Iter_type end, Value_type& value )
- {
- Semantic_actions< Value_type, Iter_type > semantic_actions( value );
-
- const spirit_namespace::parse_info< Iter_type > info =
- spirit_namespace::parse( begin, end,
- Json_grammer< Value_type, Iter_type >( semantic_actions ) >> spirit_namespace::end_p,
- spirit_namespace::space_p );
-
- if( !info.hit )
- {
- throw_error( info.stop, "error" );
- }
-
- return info.stop;
- }
-
- template< class Iter_type, class Value_type >
- void add_posn_iter_and_read_range_or_throw( Iter_type begin, Iter_type end, Value_type& value )
- {
- typedef spirit_namespace::position_iterator< Iter_type > Posn_iter_t;
-
- const Posn_iter_t posn_begin( begin, end );
- const Posn_iter_t posn_end( end, end );
-
- read_range_or_throw( posn_begin, posn_end, value );
- }
-
- template< class Iter_type, class Value_type >
- bool read_range( Iter_type& begin, Iter_type end, Value_type& value )
- {
- try
- {
- begin = read_range_or_throw( begin, end, value );
-
- return true;
- }
- catch( ... )
- {
- return false;
- }
- }
-
- template< class String_type, class Value_type >
- void read_string_or_throw( const String_type& s, Value_type& value )
- {
- add_posn_iter_and_read_range_or_throw( s.begin(), s.end(), value );
- }
-
- template< class String_type, class Value_type >
- bool read_string( const String_type& s, Value_type& value )
- {
- typename String_type::const_iterator begin = s.begin();
-
- bool success = read_range( begin, s.end(), value );
- return success && begin == s.end();
- }
-
- template< class Istream_type >
- struct Multi_pass_iters
- {
- typedef typename Istream_type::char_type Char_type;
- typedef std::istream_iterator< Char_type, Char_type > istream_iter;
- typedef spirit_namespace::multi_pass< istream_iter > Mp_iter;
-
- Multi_pass_iters( Istream_type& is )
- {
- is.unsetf( std::ios::skipws );
-
- begin_ = spirit_namespace::make_multi_pass( istream_iter( is ) );
- end_ = spirit_namespace::make_multi_pass( istream_iter() );
- }
-
- Mp_iter begin_;
- Mp_iter end_;
- };
-
- template< class Istream_type, class Value_type >
- bool read_stream( Istream_type& is, Value_type& value )
- {
- Multi_pass_iters< Istream_type > mp_iters( is );
-
- return read_range( mp_iters.begin_, mp_iters.end_, value );
- }
-
- template< class Istream_type, class Value_type >
- void read_stream_or_throw( Istream_type& is, Value_type& value )
- {
- const Multi_pass_iters< Istream_type > mp_iters( is );
-
- add_posn_iter_and_read_range_or_throw( mp_iters.begin_, mp_iters.end_, value );
- }
-}
-
-#endif
diff --git a/src/json/json_spirit_stream_reader.h b/src/json/json_spirit_stream_reader.h
deleted file mode 100644
index 7e59c9adc2..0000000000
--- a/src/json/json_spirit_stream_reader.h
+++ /dev/null
@@ -1,70 +0,0 @@
-#ifndef JSON_SPIRIT_READ_STREAM
-#define JSON_SPIRIT_READ_STREAM
-
-// Copyright John W. Wilkinson 2007 - 2009.
-// Distributed under the MIT License, see accompanying file LICENSE.txt
-
-// json spirit version 4.03
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-#include "json_spirit_reader_template.h"
-
-namespace json_spirit
-{
- // these classes allows you to read multiple top level contiguous values from a stream,
- // the normal stream read functions have a bug that prevent multiple top level values
- // from being read unless they are separated by spaces
-
- template< class Istream_type, class Value_type >
- class Stream_reader
- {
- public:
-
- Stream_reader( Istream_type& is )
- : iters_( is )
- {
- }
-
- bool read_next( Value_type& value )
- {
- return read_range( iters_.begin_, iters_.end_, value );
- }
-
- private:
-
- typedef Multi_pass_iters< Istream_type > Mp_iters;
-
- Mp_iters iters_;
- };
-
- template< class Istream_type, class Value_type >
- class Stream_reader_thrower
- {
- public:
-
- Stream_reader_thrower( Istream_type& is )
- : iters_( is )
- , posn_begin_( iters_.begin_, iters_.end_ )
- , posn_end_( iters_.end_, iters_.end_ )
- {
- }
-
- void read_next( Value_type& value )
- {
- posn_begin_ = read_range_or_throw( posn_begin_, posn_end_, value );
- }
-
- private:
-
- typedef Multi_pass_iters< Istream_type > Mp_iters;
- typedef spirit_namespace::position_iterator< typename Mp_iters::Mp_iter > Posn_iter_t;
-
- Mp_iters iters_;
- Posn_iter_t posn_begin_, posn_end_;
- };
-}
-
-#endif
diff --git a/src/json/json_spirit_utils.h b/src/json/json_spirit_utils.h
deleted file mode 100644
index 553e3b96a4..0000000000
--- a/src/json/json_spirit_utils.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef JSON_SPIRIT_UTILS
-#define JSON_SPIRIT_UTILS
-
-// Copyright John W. Wilkinson 2007 - 2009.
-// Distributed under the MIT License, see accompanying file LICENSE.txt
-
-// json spirit version 4.03
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-#include "json_spirit_value.h"
-#include <map>
-
-namespace json_spirit
-{
- template< class Obj_t, class Map_t >
- void obj_to_map( const Obj_t& obj, Map_t& mp_obj )
- {
- mp_obj.clear();
-
- for( typename Obj_t::const_iterator i = obj.begin(); i != obj.end(); ++i )
- {
- mp_obj[ i->name_ ] = i->value_;
- }
- }
-
- template< class Obj_t, class Map_t >
- void map_to_obj( const Map_t& mp_obj, Obj_t& obj )
- {
- obj.clear();
-
- for( typename Map_t::const_iterator i = mp_obj.begin(); i != mp_obj.end(); ++i )
- {
- obj.push_back( typename Obj_t::value_type( i->first, i->second ) );
- }
- }
-
- typedef std::map< std::string, Value > Mapped_obj;
-
-#ifndef BOOST_NO_STD_WSTRING
- typedef std::map< std::wstring, wValue > wMapped_obj;
-#endif
-
- template< class Object_type, class String_type >
- const typename Object_type::value_type::Value_type& find_value( const Object_type& obj, const String_type& name )
- {
- for( typename Object_type::const_iterator i = obj.begin(); i != obj.end(); ++i )
- {
- if( i->name_ == name )
- {
- return i->value_;
- }
- }
-
- return Object_type::value_type::Value_type::null;
- }
-}
-
-#endif
diff --git a/src/json/json_spirit_value.cpp b/src/json/json_spirit_value.cpp
deleted file mode 100644
index 44d2f06a01..0000000000
--- a/src/json/json_spirit_value.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-/* Copyright (c) 2007 John W Wilkinson
-
- This source code can be used for any purpose as long as
- this comment is retained. */
-
-// json spirit version 2.00
-
-#include "json_spirit_value.h"
diff --git a/src/json/json_spirit_value.h b/src/json/json_spirit_value.h
deleted file mode 100644
index 13cc89210c..0000000000
--- a/src/json/json_spirit_value.h
+++ /dev/null
@@ -1,534 +0,0 @@
-#ifndef JSON_SPIRIT_VALUE
-#define JSON_SPIRIT_VALUE
-
-// Copyright John W. Wilkinson 2007 - 2009.
-// Distributed under the MIT License, see accompanying file LICENSE.txt
-
-// json spirit version 4.03
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-#include <vector>
-#include <map>
-#include <string>
-#include <cassert>
-#include <sstream>
-#include <stdexcept>
-#include <stdint.h>
-#include <boost/config.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/variant.hpp>
-
-namespace json_spirit
-{
- enum Value_type{ obj_type, array_type, str_type, bool_type, int_type, real_type, null_type };
- static const char* Value_type_name[]={"obj", "array", "str", "bool", "int", "real", "null"};
-
- template< class Config > // Config determines whether the value uses std::string or std::wstring and
- // whether JSON Objects are represented as vectors or maps
- class Value_impl
- {
- public:
-
- typedef Config Config_type;
- typedef typename Config::String_type String_type;
- typedef typename Config::Object_type Object;
- typedef typename Config::Array_type Array;
- typedef typename String_type::const_pointer Const_str_ptr; // eg const char*
-
- Value_impl(); // creates null value
- Value_impl( Const_str_ptr value );
- Value_impl( const String_type& value );
- Value_impl( const Object& value );
- Value_impl( const Array& value );
- Value_impl( bool value );
- Value_impl( int value );
- Value_impl( int64_t value );
- Value_impl( uint64_t value );
- Value_impl( double value );
-
- Value_impl( const Value_impl& other );
-
- bool operator==( const Value_impl& lhs ) const;
-
- Value_impl& operator=( const Value_impl& lhs );
-
- Value_type type() const;
-
- bool is_uint64() const;
- bool is_null() const;
-
- const String_type& get_str() const;
- const Object& get_obj() const;
- const Array& get_array() const;
- bool get_bool() const;
- int get_int() const;
- int64_t get_int64() const;
- uint64_t get_uint64() const;
- double get_real() const;
-
- Object& get_obj();
- Array& get_array();
-
- template< typename T > T get_value() const; // example usage: int i = value.get_value< int >();
- // or double d = value.get_value< double >();
-
- static const Value_impl null;
-
- private:
-
- void check_type( const Value_type vtype ) const;
-
- typedef boost::variant< String_type,
- boost::recursive_wrapper< Object >, boost::recursive_wrapper< Array >,
- bool, int64_t, double > Variant;
-
- Value_type type_;
- Variant v_;
- bool is_uint64_;
- };
-
- // vector objects
-
- template< class Config >
- struct Pair_impl
- {
- typedef typename Config::String_type String_type;
- typedef typename Config::Value_type Value_type;
-
- Pair_impl( const String_type& name, const Value_type& value );
-
- bool operator==( const Pair_impl& lhs ) const;
-
- String_type name_;
- Value_type value_;
- };
-
- template< class String >
- struct Config_vector
- {
- typedef String String_type;
- typedef Value_impl< Config_vector > Value_type;
- typedef Pair_impl < Config_vector > Pair_type;
- typedef std::vector< Value_type > Array_type;
- typedef std::vector< Pair_type > Object_type;
-
- static Value_type& add( Object_type& obj, const String_type& name, const Value_type& value )
- {
- obj.push_back( Pair_type( name , value ) );
-
- return obj.back().value_;
- }
-
- static String_type get_name( const Pair_type& pair )
- {
- return pair.name_;
- }
-
- static Value_type get_value( const Pair_type& pair )
- {
- return pair.value_;
- }
- };
-
- // typedefs for ASCII
-
- typedef Config_vector< std::string > Config;
-
- typedef Config::Value_type Value;
- typedef Config::Pair_type Pair;
- typedef Config::Object_type Object;
- typedef Config::Array_type Array;
-
- // typedefs for Unicode
-
-#ifndef BOOST_NO_STD_WSTRING
-
- typedef Config_vector< std::wstring > wConfig;
-
- typedef wConfig::Value_type wValue;
- typedef wConfig::Pair_type wPair;
- typedef wConfig::Object_type wObject;
- typedef wConfig::Array_type wArray;
-#endif
-
- // map objects
-
- template< class String >
- struct Config_map
- {
- typedef String String_type;
- typedef Value_impl< Config_map > Value_type;
- typedef std::vector< Value_type > Array_type;
- typedef std::map< String_type, Value_type > Object_type;
- typedef typename Object_type::value_type Pair_type;
-
- static Value_type& add( Object_type& obj, const String_type& name, const Value_type& value )
- {
- return obj[ name ] = value;
- }
-
- static String_type get_name( const Pair_type& pair )
- {
- return pair.first;
- }
-
- static Value_type get_value( const Pair_type& pair )
- {
- return pair.second;
- }
- };
-
- // typedefs for ASCII
-
- typedef Config_map< std::string > mConfig;
-
- typedef mConfig::Value_type mValue;
- typedef mConfig::Object_type mObject;
- typedef mConfig::Array_type mArray;
-
- // typedefs for Unicode
-
-#ifndef BOOST_NO_STD_WSTRING
-
- typedef Config_map< std::wstring > wmConfig;
-
- typedef wmConfig::Value_type wmValue;
- typedef wmConfig::Object_type wmObject;
- typedef wmConfig::Array_type wmArray;
-
-#endif
-
- ///////////////////////////////////////////////////////////////////////////////////////////////
- //
- // implementation
-
- template< class Config >
- const Value_impl< Config > Value_impl< Config >::null;
-
- template< class Config >
- Value_impl< Config >::Value_impl()
- : type_( null_type )
- , is_uint64_( false )
- {
- }
-
- template< class Config >
- Value_impl< Config >::Value_impl( const Const_str_ptr value )
- : type_( str_type )
- , v_( String_type( value ) )
- , is_uint64_( false )
- {
- }
-
- template< class Config >
- Value_impl< Config >::Value_impl( const String_type& value )
- : type_( str_type )
- , v_( value )
- , is_uint64_( false )
- {
- }
-
- template< class Config >
- Value_impl< Config >::Value_impl( const Object& value )
- : type_( obj_type )
- , v_( value )
- , is_uint64_( false )
- {
- }
-
- template< class Config >
- Value_impl< Config >::Value_impl( const Array& value )
- : type_( array_type )
- , v_( value )
- , is_uint64_( false )
- {
- }
-
- template< class Config >
- Value_impl< Config >::Value_impl( bool value )
- : type_( bool_type )
- , v_( value )
- , is_uint64_( false )
- {
- }
-
- template< class Config >
- Value_impl< Config >::Value_impl( int value )
- : type_( int_type )
- , v_( static_cast< int64_t >( value ) )
- , is_uint64_( false )
- {
- }
-
- template< class Config >
- Value_impl< Config >::Value_impl( int64_t value )
- : type_( int_type )
- , v_( value )
- , is_uint64_( false )
- {
- }
-
- template< class Config >
- Value_impl< Config >::Value_impl( uint64_t value )
- : type_( int_type )
- , v_( static_cast< int64_t >( value ) )
- , is_uint64_( true )
- {
- }
-
- template< class Config >
- Value_impl< Config >::Value_impl( double value )
- : type_( real_type )
- , v_( value )
- , is_uint64_( false )
- {
- }
-
- template< class Config >
- Value_impl< Config >::Value_impl( const Value_impl< Config >& other )
- : type_( other.type() )
- , v_( other.v_ )
- , is_uint64_( other.is_uint64_ )
- {
- }
-
- template< class Config >
- Value_impl< Config >& Value_impl< Config >::operator=( const Value_impl& lhs )
- {
- Value_impl tmp( lhs );
-
- std::swap( type_, tmp.type_ );
- std::swap( v_, tmp.v_ );
- std::swap( is_uint64_, tmp.is_uint64_ );
-
- return *this;
- }
-
- template< class Config >
- bool Value_impl< Config >::operator==( const Value_impl& lhs ) const
- {
- if( this == &lhs ) return true;
-
- if( type() != lhs.type() ) return false;
-
- return v_ == lhs.v_;
- }
-
- template< class Config >
- Value_type Value_impl< Config >::type() const
- {
- return type_;
- }
-
- template< class Config >
- bool Value_impl< Config >::is_uint64() const
- {
- return is_uint64_;
- }
-
- template< class Config >
- bool Value_impl< Config >::is_null() const
- {
- return type() == null_type;
- }
-
- template< class Config >
- void Value_impl< Config >::check_type( const Value_type vtype ) const
- {
- if( type() != vtype )
- {
- std::ostringstream os;
-
- ///// Bitcoin: Tell the types by name instead of by number
- os << "value is type " << Value_type_name[type()] << ", expected " << Value_type_name[vtype];
-
- throw std::runtime_error( os.str() );
- }
- }
-
- template< class Config >
- const typename Config::String_type& Value_impl< Config >::get_str() const
- {
- check_type( str_type );
-
- return *boost::get< String_type >( &v_ );
- }
-
- template< class Config >
- const typename Value_impl< Config >::Object& Value_impl< Config >::get_obj() const
- {
- check_type( obj_type );
-
- return *boost::get< Object >( &v_ );
- }
-
- template< class Config >
- const typename Value_impl< Config >::Array& Value_impl< Config >::get_array() const
- {
- check_type( array_type );
-
- return *boost::get< Array >( &v_ );
- }
-
- template< class Config >
- bool Value_impl< Config >::get_bool() const
- {
- check_type( bool_type );
-
- return boost::get< bool >( v_ );
- }
-
- template< class Config >
- int Value_impl< Config >::get_int() const
- {
- check_type( int_type );
-
- return static_cast< int >( get_int64() );
- }
-
- template< class Config >
- int64_t Value_impl< Config >::get_int64() const
- {
- check_type( int_type );
-
- return boost::get< int64_t >( v_ );
- }
-
- template< class Config >
- uint64_t Value_impl< Config >::get_uint64() const
- {
- check_type( int_type );
-
- return static_cast< uint64_t >( get_int64() );
- }
-
- template< class Config >
- double Value_impl< Config >::get_real() const
- {
- if( type() == int_type )
- {
- return is_uint64() ? static_cast< double >( get_uint64() )
- : static_cast< double >( get_int64() );
- }
-
- check_type( real_type );
-
- return boost::get< double >( v_ );
- }
-
- template< class Config >
- typename Value_impl< Config >::Object& Value_impl< Config >::get_obj()
- {
- check_type( obj_type );
-
- return *boost::get< Object >( &v_ );
- }
-
- template< class Config >
- typename Value_impl< Config >::Array& Value_impl< Config >::get_array()
- {
- check_type( array_type );
-
- return *boost::get< Array >( &v_ );
- }
-
- template< class Config >
- Pair_impl< Config >::Pair_impl( const String_type& name, const Value_type& value )
- : name_( name )
- , value_( value )
- {
- }
-
- template< class Config >
- bool Pair_impl< Config >::operator==( const Pair_impl< Config >& lhs ) const
- {
- if( this == &lhs ) return true;
-
- return ( name_ == lhs.name_ ) && ( value_ == lhs.value_ );
- }
-
- // converts a C string, ie. 8 bit char array, to a string object
- //
- template < class String_type >
- String_type to_str( const char* c_str )
- {
- String_type result;
-
- for( const char* p = c_str; *p != 0; ++p )
- {
- result += *p;
- }
-
- return result;
- }
-
- //
-
- namespace internal_
- {
- template< typename T >
- struct Type_to_type
- {
- };
-
- template< class Value >
- int get_value( const Value& value, Type_to_type< int > )
- {
- return value.get_int();
- }
-
- template< class Value >
- int64_t get_value( const Value& value, Type_to_type< int64_t > )
- {
- return value.get_int64();
- }
-
- template< class Value >
- uint64_t get_value( const Value& value, Type_to_type< uint64_t > )
- {
- return value.get_uint64();
- }
-
- template< class Value >
- double get_value( const Value& value, Type_to_type< double > )
- {
- return value.get_real();
- }
-
- template< class Value >
- typename Value::String_type get_value( const Value& value, Type_to_type< typename Value::String_type > )
- {
- return value.get_str();
- }
-
- template< class Value >
- typename Value::Array get_value( const Value& value, Type_to_type< typename Value::Array > )
- {
- return value.get_array();
- }
-
- template< class Value >
- typename Value::Object get_value( const Value& value, Type_to_type< typename Value::Object > )
- {
- return value.get_obj();
- }
-
- template< class Value >
- bool get_value( const Value& value, Type_to_type< bool > )
- {
- return value.get_bool();
- }
- }
-
- template< class Config >
- template< typename T >
- T Value_impl< Config >::get_value() const
- {
- return internal_::get_value( *this, internal_::Type_to_type< T >() );
- }
-}
-
-#endif
diff --git a/src/json/json_spirit_writer.cpp b/src/json/json_spirit_writer.cpp
deleted file mode 100644
index d24a632cf3..0000000000
--- a/src/json/json_spirit_writer.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright John W. Wilkinson 2007 - 2009.
-// Distributed under the MIT License, see accompanying file LICENSE.txt
-
-// json spirit version 4.03
-
-#include "json_spirit_writer.h"
-#include "json_spirit_writer_template.h"
-
-void json_spirit::write( const Value& value, std::ostream& os )
-{
- write_stream( value, os, false );
-}
-
-void json_spirit::write_formatted( const Value& value, std::ostream& os )
-{
- write_stream( value, os, true );
-}
-
-std::string json_spirit::write( const Value& value )
-{
- return write_string( value, false );
-}
-
-std::string json_spirit::write_formatted( const Value& value )
-{
- return write_string( value, true );
-}
-
-#ifndef BOOST_NO_STD_WSTRING
-
-void json_spirit::write( const wValue& value, std::wostream& os )
-{
- write_stream( value, os, false );
-}
-
-void json_spirit::write_formatted( const wValue& value, std::wostream& os )
-{
- write_stream( value, os, true );
-}
-
-std::wstring json_spirit::write( const wValue& value )
-{
- return write_string( value, false );
-}
-
-std::wstring json_spirit::write_formatted( const wValue& value )
-{
- return write_string( value, true );
-}
-
-#endif
-
-void json_spirit::write( const mValue& value, std::ostream& os )
-{
- write_stream( value, os, false );
-}
-
-void json_spirit::write_formatted( const mValue& value, std::ostream& os )
-{
- write_stream( value, os, true );
-}
-
-std::string json_spirit::write( const mValue& value )
-{
- return write_string( value, false );
-}
-
-std::string json_spirit::write_formatted( const mValue& value )
-{
- return write_string( value, true );
-}
-
-#ifndef BOOST_NO_STD_WSTRING
-
-void json_spirit::write( const wmValue& value, std::wostream& os )
-{
- write_stream( value, os, false );
-}
-
-void json_spirit::write_formatted( const wmValue& value, std::wostream& os )
-{
- write_stream( value, os, true );
-}
-
-std::wstring json_spirit::write( const wmValue& value )
-{
- return write_string( value, false );
-}
-
-std::wstring json_spirit::write_formatted( const wmValue& value )
-{
- return write_string( value, true );
-}
-
-#endif
diff --git a/src/json/json_spirit_writer.h b/src/json/json_spirit_writer.h
deleted file mode 100644
index 52e14068e7..0000000000
--- a/src/json/json_spirit_writer.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef JSON_SPIRIT_WRITER
-#define JSON_SPIRIT_WRITER
-
-// Copyright John W. Wilkinson 2007 - 2009.
-// Distributed under the MIT License, see accompanying file LICENSE.txt
-
-// json spirit version 4.03
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-#include "json_spirit_value.h"
-#include <iostream>
-
-namespace json_spirit
-{
- // functions to convert JSON Values to text,
- // the "formatted" versions add whitespace to format the output nicely
-
- void write ( const Value& value, std::ostream& os );
- void write_formatted( const Value& value, std::ostream& os );
- std::string write ( const Value& value );
- std::string write_formatted( const Value& value );
-
-#ifndef BOOST_NO_STD_WSTRING
-
- void write ( const wValue& value, std::wostream& os );
- void write_formatted( const wValue& value, std::wostream& os );
- std::wstring write ( const wValue& value );
- std::wstring write_formatted( const wValue& value );
-
-#endif
-
- void write ( const mValue& value, std::ostream& os );
- void write_formatted( const mValue& value, std::ostream& os );
- std::string write ( const mValue& value );
- std::string write_formatted( const mValue& value );
-
-#ifndef BOOST_NO_STD_WSTRING
-
- void write ( const wmValue& value, std::wostream& os );
- void write_formatted( const wmValue& value, std::wostream& os );
- std::wstring write ( const wmValue& value );
- std::wstring write_formatted( const wmValue& value );
-
-#endif
-}
-
-#endif
diff --git a/src/json/json_spirit_writer_template.h b/src/json/json_spirit_writer_template.h
deleted file mode 100644
index 6b4978a1ff..0000000000
--- a/src/json/json_spirit_writer_template.h
+++ /dev/null
@@ -1,249 +0,0 @@
-#ifndef JSON_SPIRIT_WRITER_TEMPLATE
-#define JSON_SPIRIT_WRITER_TEMPLATE
-
-// Copyright John W. Wilkinson 2007 - 2009.
-// Distributed under the MIT License, see accompanying file LICENSE.txt
-
-// json spirit version 4.03
-
-#include "json_spirit_value.h"
-
-#include <cassert>
-#include <sstream>
-#include <iomanip>
-
-namespace json_spirit
-{
- inline char to_hex_char( unsigned int c )
- {
- assert( c <= 0xF );
-
- const char ch = static_cast< char >( c );
-
- if( ch < 10 ) return '0' + ch;
-
- return 'A' - 10 + ch;
- }
-
- template< class String_type >
- String_type non_printable_to_string( unsigned int c )
- {
- // Silence the warning: typedef ‘Char_type’ locally defined but not used [-Wunused-local-typedefs]
- // typedef typename String_type::value_type Char_type;
-
- String_type result( 6, '\\' );
-
- result[1] = 'u';
-
- result[ 5 ] = to_hex_char( c & 0x000F ); c >>= 4;
- result[ 4 ] = to_hex_char( c & 0x000F ); c >>= 4;
- result[ 3 ] = to_hex_char( c & 0x000F ); c >>= 4;
- result[ 2 ] = to_hex_char( c & 0x000F );
-
- return result;
- }
-
- template< typename Char_type, class String_type >
- bool add_esc_char( Char_type c, String_type& s )
- {
- switch( c )
- {
- case '"': s += to_str< String_type >( "\\\"" ); return true;
- case '\\': s += to_str< String_type >( "\\\\" ); return true;
- case '\b': s += to_str< String_type >( "\\b" ); return true;
- case '\f': s += to_str< String_type >( "\\f" ); return true;
- case '\n': s += to_str< String_type >( "\\n" ); return true;
- case '\r': s += to_str< String_type >( "\\r" ); return true;
- case '\t': s += to_str< String_type >( "\\t" ); return true;
- }
-
- return false;
- }
-
- template< class String_type >
- String_type add_esc_chars( const String_type& s )
- {
- typedef typename String_type::const_iterator Iter_type;
- typedef typename String_type::value_type Char_type;
-
- String_type result;
-
- const Iter_type end( s.end() );
-
- for( Iter_type i = s.begin(); i != end; ++i )
- {
- const Char_type c( *i );
-
- if( add_esc_char( c, result ) ) continue;
-
- const wint_t unsigned_c( ( c >= 0 ) ? c : 256 + c );
-
- if( iswprint( unsigned_c ) )
- {
- result += c;
- }
- else
- {
- result += non_printable_to_string< String_type >( unsigned_c );
- }
- }
-
- return result;
- }
-
- // this class generates the JSON text,
- // it keeps track of the indentation level etc.
- //
- template< class Value_type, class Ostream_type >
- class Generator
- {
- typedef typename Value_type::Config_type Config_type;
- typedef typename Config_type::String_type String_type;
- typedef typename Config_type::Object_type Object_type;
- typedef typename Config_type::Array_type Array_type;
- typedef typename String_type::value_type Char_type;
- typedef typename Object_type::value_type Obj_member_type;
-
- public:
-
- Generator( const Value_type& value, Ostream_type& os, bool pretty )
- : os_( os )
- , indentation_level_( 0 )
- , pretty_( pretty )
- {
- output( value );
- }
-
- private:
-
- void output( const Value_type& value )
- {
- switch( value.type() )
- {
- case obj_type: output( value.get_obj() ); break;
- case array_type: output( value.get_array() ); break;
- case str_type: output( value.get_str() ); break;
- case bool_type: output( value.get_bool() ); break;
- case int_type: output_int( value ); break;
-
- /// Bitcoin: Added std::fixed and changed precision from 16 to 8
- case real_type: os_ << std::showpoint << std::fixed << std::setprecision(8)
- << value.get_real(); break;
-
- case null_type: os_ << "null"; break;
- default: assert( false );
- }
- }
-
- void output( const Object_type& obj )
- {
- output_array_or_obj( obj, '{', '}' );
- }
-
- void output( const Array_type& arr )
- {
- output_array_or_obj( arr, '[', ']' );
- }
-
- void output( const Obj_member_type& member )
- {
- output( Config_type::get_name( member ) ); space();
- os_ << ':'; space();
- output( Config_type::get_value( member ) );
- }
-
- void output_int( const Value_type& value )
- {
- if( value.is_uint64() )
- {
- os_ << value.get_uint64();
- }
- else
- {
- os_ << value.get_int64();
- }
- }
-
- void output( const String_type& s )
- {
- os_ << '"' << add_esc_chars( s ) << '"';
- }
-
- void output( bool b )
- {
- os_ << to_str< String_type >( b ? "true" : "false" );
- }
-
- template< class T >
- void output_array_or_obj( const T& t, Char_type start_char, Char_type end_char )
- {
- os_ << start_char; new_line();
-
- ++indentation_level_;
-
- for( typename T::const_iterator i = t.begin(); i != t.end(); ++i )
- {
- indent(); output( *i );
-
- typename T::const_iterator next = i;
-
- if( ++next != t.end())
- {
- os_ << ',';
- }
-
- new_line();
- }
-
- --indentation_level_;
-
- indent(); os_ << end_char;
- }
-
- void indent()
- {
- if( !pretty_ ) return;
-
- for( int i = 0; i < indentation_level_; ++i )
- {
- os_ << " ";
- }
- }
-
- void space()
- {
- if( pretty_ ) os_ << ' ';
- }
-
- void new_line()
- {
- if( pretty_ ) os_ << '\n';
- }
-
- Generator& operator=( const Generator& ); // to prevent "assignment operator could not be generated" warning
-
- Ostream_type& os_;
- int indentation_level_;
- bool pretty_;
- };
-
- template< class Value_type, class Ostream_type >
- void write_stream( const Value_type& value, Ostream_type& os, bool pretty )
- {
- Generator< Value_type, Ostream_type >( value, os, pretty );
- }
-
- template< class Value_type >
- typename Value_type::String_type write_string( const Value_type& value, bool pretty )
- {
- typedef typename Value_type::String_type::value_type Char_type;
-
- std::basic_ostringstream< Char_type > os;
-
- write_stream( value, os, pretty );
-
- return os.str();
- }
-}
-
-#endif
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 29b1e8f262..d7be531b2d 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -181,11 +181,7 @@ void RPCExecutor::request(const QString &command)
emit reply(RPCConsole::CMD_REPLY, QString::fromStdString(strPrint));
}
-<<<<<<< HEAD
- catch (const json_spirit::Object& objError)
-=======
catch (UniValue& objError)
->>>>>>> Convert tree to using univalue. Eliminate all json_spirit uses.
{
try // Nice formatting for standard-format error
{
diff --git a/src/rest.cpp b/src/rest.cpp
index 3142b25036..1fce7dfc9c 100644
--- a/src/rest.cpp
+++ b/src/rest.cpp
@@ -16,8 +16,9 @@
#include <boost/algorithm/string.hpp>
#include <boost/dynamic_bitset.hpp>
+#include "univalue/univalue.h"
+
using namespace std;
-using namespace json_spirit;
static const int MAX_GETUTXOS_OUTPOINTS = 15; //allow a max of 15 outpoints to be queried at once
@@ -61,9 +62,9 @@ public:
string message;
};
-extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry);
+extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry);
extern UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false);
-extern void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeHex);
+extern void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
static RestErr RESTERR(enum HTTPStatusCode status, string message)
{
diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
index f20f9f994d..e3f17b4ae7 100644
--- a/src/rpcblockchain.cpp
+++ b/src/rpcblockchain.cpp
@@ -13,13 +13,12 @@
#include <stdint.h>
-#include "json_spirit_wrapper.h"
+#include "univalue/univalue.h"
-using namespace json_spirit;
using namespace std;
-extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry);
-void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeHex);
+extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry);
+void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
double GetDifficulty(const CBlockIndex* blockindex)
{
@@ -94,7 +93,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
}
-UniValue getblockcount(const Array& params, bool fHelp)
+UniValue getblockcount(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
@@ -111,7 +110,7 @@ UniValue getblockcount(const Array& params, bool fHelp)
return chainActive.Height();
}
-UniValue getbestblockhash(const Array& params, bool fHelp)
+UniValue getbestblockhash(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
@@ -128,7 +127,7 @@ UniValue getbestblockhash(const Array& params, bool fHelp)
return chainActive.Tip()->GetBlockHash().GetHex();
}
-UniValue getdifficulty(const Array& params, bool fHelp)
+UniValue getdifficulty(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
@@ -146,7 +145,7 @@ UniValue getdifficulty(const Array& params, bool fHelp)
}
-UniValue getrawmempool(const Array& params, bool fHelp)
+UniValue getrawmempool(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
@@ -231,7 +230,7 @@ UniValue getrawmempool(const Array& params, bool fHelp)
}
}
-UniValue getblockhash(const Array& params, bool fHelp)
+UniValue getblockhash(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
@@ -256,7 +255,7 @@ UniValue getblockhash(const Array& params, bool fHelp)
return pblockindex->GetBlockHash().GetHex();
}
-UniValue getblock(const Array& params, bool fHelp)
+UniValue getblock(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
@@ -324,7 +323,7 @@ UniValue getblock(const Array& params, bool fHelp)
return blockToJSON(block, pblockindex);
}
-UniValue gettxoutsetinfo(const Array& params, bool fHelp)
+UniValue gettxoutsetinfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
@@ -364,7 +363,7 @@ UniValue gettxoutsetinfo(const Array& params, bool fHelp)
return ret;
}
-UniValue gettxout(const Array& params, bool fHelp)
+UniValue gettxout(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 2 || params.size() > 3)
throw runtime_error(
@@ -444,7 +443,7 @@ UniValue gettxout(const Array& params, bool fHelp)
return ret;
}
-UniValue verifychain(const Array& params, bool fHelp)
+UniValue verifychain(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 2)
throw runtime_error(
@@ -472,7 +471,7 @@ UniValue verifychain(const Array& params, bool fHelp)
return CVerifyDB().VerifyDB(pcoinsTip, nCheckLevel, nCheckDepth);
}
-UniValue getblockchaininfo(const Array& params, bool fHelp)
+UniValue getblockchaininfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
@@ -530,7 +529,7 @@ struct CompareBlocksByHeight
}
};
-UniValue getchaintips(const Array& params, bool fHelp)
+UniValue getchaintips(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
@@ -620,7 +619,7 @@ UniValue getchaintips(const Array& params, bool fHelp)
return res;
}
-UniValue getmempoolinfo(const Array& params, bool fHelp)
+UniValue getmempoolinfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
@@ -643,7 +642,7 @@ UniValue getmempoolinfo(const Array& params, bool fHelp)
return ret;
}
-UniValue invalidateblock(const Array& params, bool fHelp)
+UniValue invalidateblock(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
@@ -681,7 +680,7 @@ UniValue invalidateblock(const Array& params, bool fHelp)
return NullUniValue;
}
-UniValue reconsiderblock(const Array& params, bool fHelp)
+UniValue reconsiderblock(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp
index ec098a17a7..d175db09ee 100644
--- a/src/rpcclient.cpp
+++ b/src/rpcclient.cpp
@@ -12,9 +12,9 @@
#include <stdint.h>
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
+#include "univalue/univalue.h"
using namespace std;
-using namespace json_spirit;
class CRPCConvertParam
{
@@ -137,7 +137,7 @@ UniValue RPCConvertValues(const std::string &strMethod, const std::vector<std::s
// parse string as JSON, insert bool/number/object/etc. value
else {
//according to rfc4627 null, true, false are not valid json strings
- Value jVal;
+ UniValue jVal;
if(strVal == "null")
jVal.setNull();
else if(strVal == "true")
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index 89e20526ed..76d90a3f7e 100644
--- a/src/rpcmining.cpp
+++ b/src/rpcmining.cpp
@@ -24,9 +24,8 @@
#include <boost/assign/list_of.hpp>
-#include "json_spirit_wrapper.h"
+#include "univalue/univalue.h"
-using namespace json_spirit;
using namespace std;
/**
@@ -71,7 +70,7 @@ UniValue GetNetworkHashPS(int lookup, int height) {
return (int64_t)(workDiff.getdouble() / timeDiff);
}
-UniValue getnetworkhashps(const Array& params, bool fHelp)
+UniValue getnetworkhashps(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 2)
throw runtime_error(
@@ -94,7 +93,7 @@ UniValue getnetworkhashps(const Array& params, bool fHelp)
}
#ifdef ENABLE_WALLET
-UniValue getgenerate(const Array& params, bool fHelp)
+UniValue getgenerate(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
@@ -113,7 +112,7 @@ UniValue getgenerate(const Array& params, bool fHelp)
return GetBoolArg("-gen", false);
}
-UniValue generate(const Array& params, bool fHelp)
+UniValue generate(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 1)
throw runtime_error(
@@ -172,7 +171,7 @@ UniValue generate(const Array& params, bool fHelp)
}
-UniValue setgenerate(const Array& params, bool fHelp)
+UniValue setgenerate(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
@@ -220,7 +219,7 @@ UniValue setgenerate(const Array& params, bool fHelp)
#endif
-UniValue getmininginfo(const Array& params, bool fHelp)
+UniValue getmininginfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
@@ -266,7 +265,7 @@ UniValue getmininginfo(const Array& params, bool fHelp)
// NOTE: Unlike wallet RPC (which use BTC values), mining RPCs follow GBT (BIP 22) in using satoshi amounts
-UniValue prioritisetransaction(const Array& params, bool fHelp)
+UniValue prioritisetransaction(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 3)
throw runtime_error(
@@ -301,7 +300,7 @@ UniValue prioritisetransaction(const Array& params, bool fHelp)
static UniValue BIP22ValidationResult(const CValidationState& state)
{
if (state.IsValid())
- return Value::null;
+ return NullUniValue;
std::string strRejectReason = state.GetRejectReason();
if (state.IsError())
@@ -316,7 +315,7 @@ static UniValue BIP22ValidationResult(const CValidationState& state)
return "valid?";
}
-UniValue getblocktemplate(const Array& params, bool fHelp)
+UniValue getblocktemplate(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
@@ -384,8 +383,8 @@ UniValue getblocktemplate(const Array& params, bool fHelp)
UniValue lpval = NullUniValue;
if (params.size() > 0)
{
- const Object& oparam = params[0].get_obj();
- const Value& modeval = find_value(oparam, "mode");
+ const UniValue& oparam = params[0].get_obj();
+ const UniValue& modeval = find_value(oparam, "mode");
if (modeval.isStr())
strMode = modeval.get_str();
else if (modeval.isNull())
@@ -398,7 +397,7 @@ UniValue getblocktemplate(const Array& params, bool fHelp)
if (strMode == "proposal")
{
- const Value& dataval = find_value(oparam, "data");
+ const UniValue& dataval = find_value(oparam, "data");
if (dataval.isStr())
throw JSONRPCError(RPC_TYPE_ERROR, "Missing data String key for proposal");
@@ -605,7 +604,7 @@ protected:
};
};
-UniValue submitblock(const Array& params, bool fHelp)
+UniValue submitblock(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
@@ -666,7 +665,7 @@ UniValue submitblock(const Array& params, bool fHelp)
return BIP22ValidationResult(state);
}
-UniValue estimatefee(const Array& params, bool fHelp)
+UniValue estimatefee(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
@@ -698,7 +697,7 @@ UniValue estimatefee(const Array& params, bool fHelp)
return ValueFromAmount(feeRate.GetFeePerK());
}
-UniValue estimatepriority(const Array& params, bool fHelp)
+UniValue estimatepriority(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp
index 15bbe90bc7..f5fc22aff1 100644
--- a/src/rpcmisc.cpp
+++ b/src/rpcmisc.cpp
@@ -20,9 +20,9 @@
#include <stdint.h>
#include <boost/assign/list_of.hpp>
-#include "json_spirit_wrapper.h"
-using namespace json_spirit;
+#include "univalue/univalue.h"
+
using namespace std;
/**
@@ -38,7 +38,7 @@ using namespace std;
*
* Or alternatively, create a specific query method for the information.
**/
-UniValue getinfo(const Array& params, bool fHelp)
+UniValue getinfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
@@ -107,7 +107,7 @@ UniValue getinfo(const Array& params, bool fHelp)
}
#ifdef ENABLE_WALLET
-class DescribeAddressVisitor : public boost::static_visitor<Object>
+class DescribeAddressVisitor : public boost::static_visitor<UniValue>
{
private:
isminetype mine;
@@ -115,7 +115,7 @@ private:
public:
DescribeAddressVisitor(isminetype mineIn) : mine(mineIn) {}
- UniValue operator()(const CNoDestination &dest) const { return Object(); }
+ UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); }
UniValue operator()(const CKeyID &keyID) const {
UniValue obj(UniValue::VOBJ);
@@ -153,7 +153,7 @@ public:
};
#endif
-UniValue validateaddress(const Array& params, bool fHelp)
+UniValue validateaddress(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
@@ -215,10 +215,10 @@ UniValue validateaddress(const Array& params, bool fHelp)
/**
* Used by addmultisigaddress / createmultisig:
*/
-CScript _createmultisig_redeemScript(const Array& params)
+CScript _createmultisig_redeemScript(const UniValue& params)
{
int nRequired = params[0].get_int();
- const Array& keys = params[1].get_array();
+ const UniValue& keys = params[1].get_array();
// Gather public keys
if (nRequired < 1)
@@ -276,7 +276,7 @@ CScript _createmultisig_redeemScript(const Array& params)
return result;
}
-UniValue createmultisig(const Array& params, bool fHelp)
+UniValue createmultisig(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 2 || params.size() > 2)
{
@@ -319,7 +319,7 @@ UniValue createmultisig(const Array& params, bool fHelp)
return result;
}
-UniValue verifymessage(const Array& params, bool fHelp)
+UniValue verifymessage(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 3)
throw runtime_error(
@@ -373,7 +373,7 @@ UniValue verifymessage(const Array& params, bool fHelp)
return (pubkey.GetID() == keyID);
}
-UniValue setmocktime(const Array& params, bool fHelp)
+UniValue setmocktime(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp
index 17eda22451..59253e72af 100644
--- a/src/rpcnet.cpp
+++ b/src/rpcnet.cpp
@@ -16,12 +16,11 @@
#include <boost/foreach.hpp>
-#include "json_spirit_wrapper.h"
+#include "univalue/univalue.h"
-using namespace json_spirit;
using namespace std;
-UniValue getconnectioncount(const Array& params, bool fHelp)
+UniValue getconnectioncount(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
@@ -39,7 +38,7 @@ UniValue getconnectioncount(const Array& params, bool fHelp)
return (int)vNodes.size();
}
-UniValue ping(const Array& params, bool fHelp)
+UniValue ping(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
@@ -75,7 +74,7 @@ static void CopyNodeStats(std::vector<CNodeStats>& vstats)
}
}
-UniValue getpeerinfo(const Array& params, bool fHelp)
+UniValue getpeerinfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
@@ -165,7 +164,7 @@ UniValue getpeerinfo(const Array& params, bool fHelp)
return ret;
}
-UniValue addnode(const Array& params, bool fHelp)
+UniValue addnode(const UniValue& params, bool fHelp)
{
string strCommand;
if (params.size() == 2)
@@ -215,7 +214,7 @@ UniValue addnode(const Array& params, bool fHelp)
return NullUniValue;
}
-UniValue getaddednodeinfo(const Array& params, bool fHelp)
+UniValue getaddednodeinfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
@@ -332,7 +331,7 @@ UniValue getaddednodeinfo(const Array& params, bool fHelp)
return ret;
}
-UniValue getnettotals(const Array& params, bool fHelp)
+UniValue getnettotals(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 0)
throw runtime_error(
@@ -378,7 +377,7 @@ static UniValue GetNetworksInfo()
return networks;
}
-UniValue getnetworkinfo(const Array& params, bool fHelp)
+UniValue getnetworkinfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
diff --git a/src/rpcprotocol.cpp b/src/rpcprotocol.cpp
index 953e476022..090e5ea7f4 100644
--- a/src/rpcprotocol.cpp
+++ b/src/rpcprotocol.cpp
@@ -23,10 +23,10 @@
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/shared_ptr.hpp>
-#include "json_spirit_wrapper.h"
+
+#include "univalue/univalue.h"
using namespace std;
-using namespace json_spirit;
//! Number of bytes to allocate and read at most at once in post data
const size_t POST_READ_SIZE = 256 * 1024;
@@ -254,7 +254,7 @@ int ReadHTTPMessage(std::basic_istream<char>& stream, map<string,
* http://www.codeproject.com/KB/recipes/JSON_Spirit.aspx
*/
-string JSONRPCRequest(const string& strMethod, const Array& params, const Value& id)
+string JSONRPCRequest(const string& strMethod, const UniValue& params, const UniValue& id)
{
UniValue request(UniValue::VOBJ);
request.push_back(Pair("method", strMethod));
@@ -263,7 +263,7 @@ string JSONRPCRequest(const string& strMethod, const Array& params, const Value&
return request.write() + "\n";
}
-Object JSONRPCReplyObj(const Value& result, const Value& error, const Value& id)
+UniValue JSONRPCReplyObj(const UniValue& result, const UniValue& error, const UniValue& id)
{
UniValue reply(UniValue::VOBJ);
if (!error.isNull())
@@ -275,7 +275,7 @@ Object JSONRPCReplyObj(const Value& result, const Value& error, const Value& id)
return reply;
}
-string JSONRPCReply(const Value& result, const Value& error, const Value& id)
+string JSONRPCReply(const UniValue& result, const UniValue& error, const UniValue& id)
{
UniValue reply = JSONRPCReplyObj(result, error, id);
return reply.write() + "\n";
diff --git a/src/rpcprotocol.h b/src/rpcprotocol.h
index 83d6123c56..b9fa091955 100644
--- a/src/rpcprotocol.h
+++ b/src/rpcprotocol.h
@@ -15,7 +15,7 @@
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
-#include "json_spirit_wrapper.h"
+#include "univalue/univalue.h"
//! HTTP status codes
enum HTTPStatusCode
diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp
index b4ddbfebf3..20394fc2c1 100644
--- a/src/rpcrawtransaction.cpp
+++ b/src/rpcrawtransaction.cpp
@@ -25,12 +25,12 @@
#include <stdint.h>
#include <boost/assign/list_of.hpp>
-#include "json_spirit_wrapper.h"
-using namespace json_spirit;
+#include "univalue/univalue.h"
+
using namespace std;
-void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeHex)
+void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex)
{
txnouttype type;
vector<CTxDestination> addresses;
@@ -54,7 +54,7 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeH
out.push_back(Pair("addresses", a));
}
-void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
+void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
{
entry.push_back(Pair("txid", tx.GetHash().GetHex()));
entry.push_back(Pair("version", tx.nVersion));
@@ -105,7 +105,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
}
}
-UniValue getrawtransaction(const Array& params, bool fHelp)
+UniValue getrawtransaction(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
@@ -195,7 +195,7 @@ UniValue getrawtransaction(const Array& params, bool fHelp)
return result;
}
-UniValue gettxoutproof(const Array& params, bool fHelp)
+UniValue gettxoutproof(const UniValue& params, bool fHelp)
{
if (fHelp || (params.size() != 1 && params.size() != 2))
throw runtime_error(
@@ -221,7 +221,7 @@ UniValue gettxoutproof(const Array& params, bool fHelp)
uint256 oneTxid;
UniValue txids = params[0].get_array();
for (unsigned int idx = 0; idx < txids.size(); idx++) {
- const Value& txid = txids[idx];
+ const UniValue& txid = txids[idx];
if (txid.get_str().length() != 64 || !IsHex(txid.get_str()))
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid txid ")+txid.get_str());
uint256 hash(uint256S(txid.get_str()));
@@ -276,7 +276,7 @@ UniValue gettxoutproof(const Array& params, bool fHelp)
return strHex;
}
-UniValue verifytxoutproof(const Array& params, bool fHelp)
+UniValue verifytxoutproof(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
@@ -309,7 +309,7 @@ UniValue verifytxoutproof(const Array& params, bool fHelp)
return res;
}
-UniValue createrawtransaction(const Array& params, bool fHelp)
+UniValue createrawtransaction(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 2)
throw runtime_error(
@@ -351,12 +351,12 @@ UniValue createrawtransaction(const Array& params, bool fHelp)
CMutableTransaction rawTx;
for (unsigned int idx = 0; idx < inputs.size(); idx++) {
- const Value& input = inputs[idx];
- const Object& o = input.get_obj();
+ const UniValue& input = inputs[idx];
+ const UniValue& o = input.get_obj();
uint256 txid = ParseHashO(o, "txid");
- const Value& vout_v = find_value(o, "vout");
+ const UniValue& vout_v = find_value(o, "vout");
if (!vout_v.isNum())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing vout key");
int nOutput = vout_v.get_int();
@@ -388,7 +388,7 @@ UniValue createrawtransaction(const Array& params, bool fHelp)
return EncodeHexTx(rawTx);
}
-UniValue decoderawtransaction(const Array& params, bool fHelp)
+UniValue decoderawtransaction(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
@@ -453,7 +453,7 @@ UniValue decoderawtransaction(const Array& params, bool fHelp)
return result;
}
-UniValue decodescript(const Array& params, bool fHelp)
+UniValue decodescript(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
@@ -496,7 +496,7 @@ UniValue 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)
+static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::string& strMessage)
{
UniValue entry(UniValue::VOBJ);
entry.push_back(Pair("txid", txin.prevout.hash.ToString()));
@@ -507,7 +507,7 @@ static void TxInErrorToJSON(const CTxIn& txin, Array& vErrorsRet, const std::str
vErrorsRet.push_back(entry);
}
-UniValue signrawtransaction(const Array& params, bool fHelp)
+UniValue signrawtransaction(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 4)
throw runtime_error(
@@ -639,7 +639,7 @@ UniValue signrawtransaction(const Array& params, bool fHelp)
if (params.size() > 1 && !params[1].isNull()) {
UniValue prevTxs = params[1].get_array();
for (unsigned int idx = 0; idx < prevTxs.size(); idx++) {
- const Value& p = prevTxs[idx];
+ const UniValue& p = prevTxs[idx];
if (!p.isObject())
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "expected object with {\"txid'\",\"vout\",\"scriptPubKey\"}");
@@ -749,7 +749,7 @@ UniValue signrawtransaction(const Array& params, bool fHelp)
return result;
}
-UniValue sendrawtransaction(const Array& params, bool fHelp)
+UniValue sendrawtransaction(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp
index cb746508b1..18e74e03cf 100644
--- a/src/rpcserver.cpp
+++ b/src/rpcserver.cpp
@@ -28,10 +28,9 @@
#include <boost/signals2/signal.hpp>
#include <boost/thread.hpp>
-#include "json_spirit_wrapper.h"
+#include "univalue/univalue.h"
using namespace boost::asio;
-using namespace json_spirit;
using namespace RPCServer;
using namespace std;
@@ -79,17 +78,17 @@ void RPCServer::OnPostCommand(boost::function<void (const CRPCCommand&)> slot)
g_rpcSignals.PostCommand.connect(boost::bind(slot, _1));
}
-void RPCTypeCheck(const Array& params,
- const list<Value_type>& typesExpected,
+void RPCTypeCheck(const UniValue& params,
+ const list<UniValue::VType>& typesExpected,
bool fAllowNull)
{
unsigned int i = 0;
- BOOST_FOREACH(Value_type t, typesExpected)
+ BOOST_FOREACH(UniValue::VType t, typesExpected)
{
if (params.size() <= i)
break;
- const Value& v = params[i];
+ const UniValue& v = params[i];
if (!((v.type() == t) || (fAllowNull && (v.isNull()))))
{
string err = strprintf("Expected type %s, got %s",
@@ -104,9 +103,9 @@ void RPCTypeCheckObj(const UniValue& o,
const map<string, UniValue::VType>& typesExpected,
bool fAllowNull)
{
- BOOST_FOREACH(const PAIRTYPE(string, Value_type)& t, typesExpected)
+ BOOST_FOREACH(const PAIRTYPE(string, UniValue::VType)& t, typesExpected)
{
- const Value& v = find_value(o, t.first);
+ const UniValue& v = find_value(o, t.first);
if (!fAllowNull && v.isNull())
throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing %s", t.first));
@@ -124,7 +123,7 @@ static inline int64_t roundint64(double d)
return (int64_t)(d > 0 ? d + 0.5 : d - 0.5);
}
-CAmount AmountFromValue(const Value& value)
+CAmount AmountFromValue(const UniValue& value)
{
double dAmount = value.get_real();
if (dAmount <= 0.0 || dAmount > 21000000.0)
@@ -140,7 +139,7 @@ UniValue ValueFromAmount(const CAmount& amount)
return (double)amount / (double)COIN;
}
-uint256 ParseHashV(const Value& v, string strName)
+uint256 ParseHashV(const UniValue& v, string strName)
{
string strHex;
if (v.isStr())
@@ -151,11 +150,11 @@ uint256 ParseHashV(const Value& v, string strName)
result.SetHex(strHex);
return result;
}
-uint256 ParseHashO(const Object& o, string strKey)
+uint256 ParseHashO(const UniValue& o, string strKey)
{
return ParseHashV(find_value(o, strKey), strKey);
}
-vector<unsigned char> ParseHexV(const Value& v, string strName)
+vector<unsigned char> ParseHexV(const UniValue& v, string strName)
{
string strHex;
if (v.isStr())
@@ -164,7 +163,7 @@ vector<unsigned char> ParseHexV(const Value& v, string strName)
throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be hexadecimal string (not '"+strHex+"')");
return ParseHex(strHex);
}
-vector<unsigned char> ParseHexO(const Object& o, string strKey)
+vector<unsigned char> ParseHexO(const UniValue& o, string strKey)
{
return ParseHexV(find_value(o, strKey), strKey);
}
@@ -229,7 +228,7 @@ string CRPCTable::help(string strCommand) const
return strRet;
}
-UniValue help(const Array& params, bool fHelp)
+UniValue help(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
@@ -249,7 +248,7 @@ UniValue help(const Array& params, bool fHelp)
}
-UniValue stop(const Array& params, bool fHelp)
+UniValue stop(const UniValue& params, bool fHelp)
{
// Accept the deprecated and ignored 'detach' boolean argument
if (fHelp || params.size() > 1)
@@ -411,7 +410,7 @@ bool HTTPAuthorized(map<string, string>& mapHeaders)
return TimingResistantEqual(strUserPass, strRPCUserColonPass);
}
-void ErrorReply(std::ostream& stream, const Object& objError, const Value& id)
+void ErrorReply(std::ostream& stream, const UniValue& objError, const UniValue& id)
{
// Send error reply from json-rpc error object
int nStatus = HTTP_INTERNAL_SERVER_ERROR;
@@ -830,15 +829,15 @@ public:
UniValue params;
JSONRequest() { id = NullUniValue; }
- void parse(const Value& valRequest);
+ void parse(const UniValue& valRequest);
};
-void JSONRequest::parse(const Value& valRequest)
+void JSONRequest::parse(const UniValue& valRequest)
{
// Parse request
if (!valRequest.isObject())
throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object");
- const Object& request = valRequest.get_obj();
+ const UniValue& request = valRequest.get_obj();
// Parse id now so errors from here on will have the id
id = find_value(request, "id");
@@ -858,13 +857,13 @@ void JSONRequest::parse(const Value& valRequest)
if (valParams.isArray())
params = valParams.get_array();
else if (valParams.isNull())
- params = Array();
+ params = UniValue(UniValue::VARR);
else
throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array");
}
-static UniValue JSONRPCExecOne(const Value& req)
+static UniValue JSONRPCExecOne(const UniValue& req)
{
UniValue rpc_result(UniValue::VOBJ);
@@ -875,7 +874,7 @@ static UniValue JSONRPCExecOne(const Value& req)
UniValue result = tableRPC.execute(jreq.strMethod, jreq.params);
rpc_result = JSONRPCReplyObj(result, NullUniValue, jreq.id);
}
- catch (const Object& objError)
+ catch (const UniValue& objError)
{
rpc_result = JSONRPCReplyObj(NullUniValue, objError, jreq.id);
}
@@ -888,7 +887,7 @@ static UniValue JSONRPCExecOne(const Value& req)
return rpc_result;
}
-static string JSONRPCExecBatch(const Array& vReq)
+static string JSONRPCExecBatch(const UniValue& vReq)
{
UniValue ret;
for (unsigned int reqIdx = 0; reqIdx < vReq.size(); reqIdx++)
@@ -955,7 +954,7 @@ static bool HTTPReq_JSONRPC(AcceptedConnection *conn,
conn->stream() << HTTPReplyHeader(HTTP_OK, fRun, strReply.size()) << strReply << std::flush;
}
- catch (const Object& objError)
+ catch (const UniValue& objError)
{
ErrorReply(conn->stream(), objError, jreq.id);
return false;
diff --git a/src/rpcserver.h b/src/rpcserver.h
index e2bc8c0955..3f623651cc 100644
--- a/src/rpcserver.h
+++ b/src/rpcserver.h
@@ -16,7 +16,8 @@
#include <string>
#include <boost/function.hpp>
-#include "json_spirit_wrapper.h"
+
+#include "univalue/univalue.h"
class CRPCCommand;
diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp
index 114bd79ea9..9e74f5f427 100644
--- a/src/test/base58_tests.cpp
+++ b/src/test/base58_tests.cpp
@@ -17,9 +17,9 @@
#include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp>
-#include "json_spirit_wrapper.h"
-using namespace json_spirit;
+#include "univalue/univalue.h"
+
extern UniValue read_json(const std::string& jsondata);
BOOST_FIXTURE_TEST_SUITE(base58_tests, BasicTestingSetup)
diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp
index a97c96be72..8dbe377626 100644
--- a/src/test/rpc_tests.cpp
+++ b/src/test/rpc_tests.cpp
@@ -13,10 +13,11 @@
#include <boost/algorithm/string.hpp>
#include <boost/test/unit_test.hpp>
+#include "univalue/univalue.h"
+
using namespace std;
-using namespace json_spirit;
-Array
+UniValue
createArgs(int nRequired, const char* address1=NULL, const char* address2=NULL)
{
UniValue result(UniValue::VARR);
@@ -28,7 +29,7 @@ createArgs(int nRequired, const char* address1=NULL, const char* address2=NULL)
return result;
}
-Value CallRPC(string args)
+UniValue CallRPC(string args)
{
vector<string> vArgs;
boost::split(vArgs, args, boost::is_any_of(" \t"));
@@ -38,10 +39,10 @@ Value CallRPC(string args)
rpcfn_type method = tableRPC[strMethod]->actor;
try {
- Value result = (*method)(params, false);
+ UniValue result = (*method)(params, false);
return result;
}
- catch (const Object& objError) {
+ catch (const UniValue& objError) {
throw runtime_error(find_value(objError, "message").get_str());
}
}
@@ -52,7 +53,7 @@ BOOST_FIXTURE_TEST_SUITE(rpc_tests, TestingSetup)
BOOST_AUTO_TEST_CASE(rpc_rawparams)
{
// Test raw transaction API argument handling
- Value r;
+ UniValue r;
BOOST_CHECK_THROW(CallRPC("getrawtransaction"), runtime_error);
BOOST_CHECK_THROW(CallRPC("getrawtransaction not_hex"), runtime_error);
@@ -92,7 +93,7 @@ BOOST_AUTO_TEST_CASE(rpc_rawparams)
BOOST_AUTO_TEST_CASE(rpc_rawsign)
{
- Value r;
+ UniValue r;
// input is a 1-of-2 multisig (so is output):
string prevout =
"[{\"txid\":\"b4cc287e58f87cdae59417329f710f3ecd75a4ee1d2872b7248f50977c8493f3\","
@@ -121,7 +122,7 @@ BOOST_AUTO_TEST_CASE(rpc_format_monetary_values)
BOOST_CHECK(ValueFromAmount(2099999999999999LL).write() == "20999999.99999999");
}
-static Value ValueFromString(const std::string &str)
+static UniValue ValueFromString(const std::string &str)
{
UniValue value;
BOOST_CHECK(value.setNumStr(str));
diff --git a/src/test/rpc_wallet_tests.cpp b/src/test/rpc_wallet_tests.cpp
index 1a897fcd54..a72b656100 100644
--- a/src/test/rpc_wallet_tests.cpp
+++ b/src/test/rpc_wallet_tests.cpp
@@ -14,11 +14,12 @@
#include <boost/algorithm/string.hpp>
#include <boost/test/unit_test.hpp>
+#include "univalue/univalue.h"
+
using namespace std;
-using namespace json_spirit;
extern UniValue createArgs(int nRequired, const char* address1 = NULL, const char* address2 = NULL);
-extern Value CallRPC(string args);
+extern UniValue CallRPC(string args);
extern CWallet* pwalletMain;
@@ -35,7 +36,7 @@ BOOST_AUTO_TEST_CASE(rpc_addmultisig)
// new, compressed:
const char address2Hex[] = "0388c2037017c62240b6b72ac1a2a5f94da790596ebd06177c8572752922165cb4";
- Value v;
+ UniValue v;
CBitcoinAddress address;
BOOST_CHECK_NO_THROW(v = addmultisig(createArgs(1, address1Hex), false));
address.SetString(v.get_str());
@@ -66,13 +67,13 @@ BOOST_AUTO_TEST_CASE(rpc_addmultisig)
BOOST_AUTO_TEST_CASE(rpc_wallet)
{
// Test RPC calls for various wallet statistics
- Value r;
+ UniValue r;
LOCK2(cs_main, pwalletMain->cs_wallet);
CPubKey demoPubkey = pwalletMain->GenerateNewKey();
CBitcoinAddress demoAddress = CBitcoinAddress(CTxDestination(demoPubkey.GetID()));
- Value retValue;
+ UniValue retValue;
string strAccount = "walletDemoAccount";
string strPurpose = "receive";
BOOST_CHECK_NO_THROW({ /*Initialize Wallet with an account */
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index af11c0c9d9..3733425699 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -26,10 +26,10 @@
#include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp>
-#include "json_spirit_wrapper.h"
+
+#include "univalue/univalue.h"
using namespace std;
-using namespace json_spirit;
// Uncomment if you want to output updated JSON tests.
// #define UPDATE_JSON_TESTS
@@ -39,15 +39,15 @@ static const unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC;
unsigned int ParseScriptFlags(string strFlags);
string FormatScriptFlags(unsigned int flags);
-Array
+UniValue
read_json(const std::string& jsondata)
{
- Value v;
+ UniValue v;
if (!v.read(jsondata) || !v.isArray())
{
BOOST_ERROR("Parse error.");
- return Array();
+ return UniValue(UniValue::VARR);
}
return v.get_array();
}
@@ -584,11 +584,11 @@ BOOST_AUTO_TEST_CASE(script_build)
UniValue json_bad = read_json(std::string(json_tests::script_invalid, json_tests::script_invalid + sizeof(json_tests::script_invalid)));
for (unsigned int idx = 0; idx < json_good.size(); idx++) {
- const Value& tv = json_good[idx];
+ const UniValue& tv = json_good[idx];
tests_good.insert(tv.get_array().write());
}
for (unsigned int idx = 0; idx < json_bad.size(); idx++) {
- const Value& tv = json_bad[idx];
+ const UniValue& tv = json_bad[idx];
tests_bad.insert(tv.get_array().write());
}
}
diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp
index efdb4e8043..a0797d5f3f 100644
--- a/src/test/sighash_tests.cpp
+++ b/src/test/sighash_tests.cpp
@@ -16,9 +16,9 @@
#include <iostream>
#include <boost/test/unit_test.hpp>
-#include "json_spirit_wrapper.h"
-using namespace json_spirit;
+#include "univalue/univalue.h"
+
extern UniValue read_json(const std::string& jsondata);
// Old script.cpp SignatureHash function
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp
index afd2d74013..4cfdec1267 100644
--- a/src/test/transaction_tests.cpp
+++ b/src/test/transaction_tests.cpp
@@ -24,10 +24,9 @@
#include <boost/test/unit_test.hpp>
#include <boost/assign/list_of.hpp>
-#include "json_spirit_wrapper.h"
+#include "univalue/univalue.h"
using namespace std;
-using namespace json_spirit;
// In script_tests.cpp
extern UniValue read_json(const std::string& jsondata);
@@ -92,19 +91,11 @@ BOOST_AUTO_TEST_CASE(tx_valid)
// verifyFlags is a comma separated list of script verification flags to apply, or "NONE"
UniValue tests = read_json(std::string(json_tests::tx_valid, json_tests::tx_valid + sizeof(json_tests::tx_valid)));
-<<<<<<< HEAD
ScriptError err;
- BOOST_FOREACH(Value& tv, tests)
- {
- Array test = tv.get_array();
- string strTest = write_string(tv, false);
- if (test[0].type() == array_type)
-=======
for (unsigned int idx = 0; idx < tests.size(); idx++) {
UniValue test = tests[idx];
string strTest = test.write();
if (test[0].isArray())
->>>>>>> Convert tree to using univalue. Eliminate all json_spirit uses.
{
if (test.size() != 3 || !test[1].isStr() || !test[2].isStr())
{
@@ -116,7 +107,7 @@ BOOST_AUTO_TEST_CASE(tx_valid)
UniValue inputs = test[0].get_array();
bool fValid = true;
for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) {
- const Value& input = inputs[inpIdx];
+ const UniValue& input = inputs[inpIdx];
if (!input.isArray())
{
fValid = false;
@@ -175,19 +166,11 @@ BOOST_AUTO_TEST_CASE(tx_invalid)
// verifyFlags is a comma separated list of script verification flags to apply, or "NONE"
UniValue tests = read_json(std::string(json_tests::tx_invalid, json_tests::tx_invalid + sizeof(json_tests::tx_invalid)));
-<<<<<<< HEAD
ScriptError err;
- BOOST_FOREACH(Value& tv, tests)
- {
- Array test = tv.get_array();
- string strTest = write_string(tv, false);
- if (test[0].type() == array_type)
-=======
for (unsigned int idx = 0; idx < tests.size(); idx++) {
UniValue test = tests[idx];
string strTest = test.write();
if (test[0].isArray())
->>>>>>> Convert tree to using univalue. Eliminate all json_spirit uses.
{
if (test.size() != 3 || !test[1].isStr() || !test[2].isStr())
{
@@ -199,7 +182,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid)
UniValue inputs = test[0].get_array();
bool fValid = true;
for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) {
- const Value& input = inputs[inpIdx];
+ const UniValue& input = inputs[inpIdx];
if (!input.isArray())
{
fValid = false;
diff --git a/src/univalue/univalue.cpp b/src/univalue/univalue.cpp
index 994d93113a..e8fc513433 100644
--- a/src/univalue/univalue.cpp
+++ b/src/univalue/univalue.cpp
@@ -213,3 +213,15 @@ const char *uvTypeName(UniValue::VType t)
return NULL;
}
+const UniValue& find_value( const UniValue& obj, const std::string& name)
+{
+ for (unsigned int i = 0; i < obj.keys.size(); i++)
+ {
+ if( obj.keys[i] == name )
+ {
+ return obj.values[i];
+ }
+ }
+
+ return NullUniValue;
+} \ No newline at end of file
diff --git a/src/univalue/univalue.h b/src/univalue/univalue.h
index c37a3829fc..57a96abe26 100644
--- a/src/univalue/univalue.h
+++ b/src/univalue/univalue.h
@@ -161,6 +161,7 @@ public:
std::istringstream(getValStr()) >> ret;
return ret;
}
+ friend const UniValue& find_value( const UniValue& obj, const std::string& name);
};
//
@@ -248,5 +249,8 @@ extern enum jtokentype getJsonToken(std::string& tokenVal,
extern const char *uvTypeName(UniValue::VType t);
extern const UniValue NullUniValue;
+
+const UniValue& find_value( const UniValue& obj, const std::string& name);
+
#endif // BITCOIN_UNIVALUE_UNIVALUE_H
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp
index 9d72c45bae..b682a42e23 100644
--- a/src/wallet/rpcdump.cpp
+++ b/src/wallet/rpcdump.cpp
@@ -19,9 +19,8 @@
#include <boost/algorithm/string.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
-#include "json_spirit_wrapper.h"
+#include "univalue/univalue.h"
-using namespace json_spirit;
using namespace std;
void EnsureWalletIsUnlocked();
@@ -70,7 +69,7 @@ std::string DecodeDumpString(const std::string &str) {
return ret.str();
}
-UniValue importprivkey(const Array& params, bool fHelp)
+UniValue importprivkey(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -144,7 +143,7 @@ UniValue importprivkey(const Array& params, bool fHelp)
return NullUniValue;
}
-UniValue importaddress(const Array& params, bool fHelp)
+UniValue importaddress(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -217,7 +216,7 @@ UniValue importaddress(const Array& params, bool fHelp)
return NullUniValue;
}
-UniValue importwallet(const Array& params, bool fHelp)
+UniValue importwallet(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -321,7 +320,7 @@ UniValue importwallet(const Array& params, bool fHelp)
return NullUniValue;
}
-UniValue dumpprivkey(const Array& params, bool fHelp)
+UniValue dumpprivkey(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -359,7 +358,7 @@ UniValue dumpprivkey(const Array& params, bool fHelp)
}
-UniValue dumpwallet(const Array& params, bool fHelp)
+UniValue dumpwallet(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index d5d97604f4..e44940993e 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -21,10 +21,9 @@
#include <boost/assign/list_of.hpp>
-#include "json_spirit_wrapper.h"
+#include "univalue/univalue.h"
using namespace std;
-using namespace json_spirit;
int64_t nWalletUnlockTime;
static CCriticalSection cs_nWalletUnlockTime;
@@ -54,7 +53,7 @@ void EnsureWalletIsUnlocked()
throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");
}
-void WalletTxToJSON(const CWalletTx& wtx, Object& entry)
+void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
{
int confirms = wtx.GetDepthInMainChain();
entry.push_back(Pair("confirmations", confirms));
@@ -78,7 +77,7 @@ void WalletTxToJSON(const CWalletTx& wtx, Object& entry)
entry.push_back(Pair(item.first, item.second));
}
-string AccountFromValue(const Value& value)
+string AccountFromValue(const UniValue& value)
{
string strAccount = value.get_str();
if (strAccount == "*")
@@ -86,7 +85,7 @@ string AccountFromValue(const Value& value)
return strAccount;
}
-Value getnewaddress(const Array& params, bool fHelp)
+UniValue getnewaddress(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -165,7 +164,7 @@ CBitcoinAddress GetAccountAddress(string strAccount, bool bForceNew=false)
return CBitcoinAddress(account.vchPubKey.GetID());
}
-Value getaccountaddress(const Array& params, bool fHelp)
+UniValue getaccountaddress(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -190,14 +189,14 @@ Value getaccountaddress(const Array& params, bool fHelp)
// Parse the account first so we don't generate a key if there's an error
string strAccount = AccountFromValue(params[0]);
- Value ret;
+ UniValue ret(UniValue::VSTR);
ret = GetAccountAddress(strAccount).ToString();
return ret;
}
-Value getrawchangeaddress(const Array& params, bool fHelp)
+UniValue getrawchangeaddress(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -232,7 +231,7 @@ Value getrawchangeaddress(const Array& params, bool fHelp)
}
-Value setaccount(const Array& params, bool fHelp)
+UniValue setaccount(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -278,7 +277,7 @@ Value setaccount(const Array& params, bool fHelp)
}
-Value getaccount(const Array& params, bool fHelp)
+UniValue getaccount(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -310,7 +309,7 @@ Value getaccount(const Array& params, bool fHelp)
}
-Value getaddressesbyaccount(const Array& params, bool fHelp)
+UniValue getaddressesbyaccount(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -378,7 +377,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr
throw JSONRPCError(RPC_WALLET_ERROR, "Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.");
}
-Value sendtoaddress(const Array& params, bool fHelp)
+UniValue sendtoaddress(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -434,7 +433,7 @@ Value sendtoaddress(const Array& params, bool fHelp)
return wtx.GetHash().GetHex();
}
-Value listaddressgroupings(const Array& params, bool fHelp)
+UniValue listaddressgroupings(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -486,7 +485,7 @@ Value listaddressgroupings(const Array& params, bool fHelp)
return jsonGroupings;
}
-Value signmessage(const Array& params, bool fHelp)
+UniValue signmessage(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -542,7 +541,7 @@ Value signmessage(const Array& params, bool fHelp)
return EncodeBase64(&vchSig[0], vchSig.size());
}
-Value getreceivedbyaddress(const Array& params, bool fHelp)
+UniValue getreceivedbyaddress(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -600,7 +599,7 @@ Value getreceivedbyaddress(const Array& params, bool fHelp)
}
-Value getreceivedbyaccount(const Array& params, bool fHelp)
+UniValue getreceivedbyaccount(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -689,7 +688,7 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef
}
-Value getbalance(const Array& params, bool fHelp)
+UniValue getbalance(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -764,7 +763,7 @@ Value getbalance(const Array& params, bool fHelp)
return ValueFromAmount(nBalance);
}
-Value getunconfirmedbalance(const UniValue &params, bool fHelp)
+UniValue getunconfirmedbalance(const UniValue &params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -780,7 +779,7 @@ Value getunconfirmedbalance(const UniValue &params, bool fHelp)
}
-Value movecmd(const Array& params, bool fHelp)
+UniValue movecmd(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -850,7 +849,7 @@ Value movecmd(const Array& params, bool fHelp)
}
-Value sendfrom(const Array& params, bool fHelp)
+UniValue sendfrom(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -913,7 +912,7 @@ Value sendfrom(const Array& params, bool fHelp)
}
-Value sendmany(const Array& params, bool fHelp)
+UniValue sendmany(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -992,7 +991,7 @@ Value sendmany(const Array& params, bool fHelp)
bool fSubtractFeeFromAmount = false;
for (unsigned int idx = 0; idx < subtractFeeFromAmount.size(); idx++) {
- const Value& addr = subtractFeeFromAmount[idx];
+ const UniValue& addr = subtractFeeFromAmount[idx];
if (addr.get_str() == name_)
fSubtractFeeFromAmount = true;
}
@@ -1023,9 +1022,9 @@ Value sendmany(const Array& params, bool fHelp)
}
// Defined in rpcmisc.cpp
-extern CScript _createmultisig_redeemScript(const Array& params);
+extern CScript _createmultisig_redeemScript(const UniValue& params);
-Value addmultisigaddress(const Array& params, bool fHelp)
+UniValue addmultisigaddress(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -1088,7 +1087,7 @@ struct tallyitem
}
};
-Value ListReceived(const Array& params, bool fByAccounts)
+UniValue ListReceived(const UniValue& params, bool fByAccounts)
{
// Minimum confirmations
int nMinDepth = 1;
@@ -1206,7 +1205,7 @@ Value ListReceived(const Array& params, bool fByAccounts)
return ret;
}
-Value listreceivedbyaddress(const Array& params, bool fHelp)
+UniValue listreceivedbyaddress(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -1243,7 +1242,7 @@ Value listreceivedbyaddress(const Array& params, bool fHelp)
return ListReceived(params, false);
}
-Value listreceivedbyaccount(const Array& params, bool fHelp)
+UniValue listreceivedbyaccount(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -1286,7 +1285,7 @@ static void MaybePushAddress(UniValue & entry, const CTxDestination &dest)
entry.push_back(Pair("address", addr.ToString()));
}
-void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret, const isminefilter& filter)
+void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter)
{
CAmount nFee;
string strSentAccount;
@@ -1356,7 +1355,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
}
}
-void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, Array& ret)
+void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, UniValue& ret)
{
bool fAllAccounts = (strAccount == string("*"));
@@ -1373,7 +1372,7 @@ void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, Ar
}
}
-Value listtransactions(const Array& params, bool fHelp)
+UniValue listtransactions(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -1494,7 +1493,7 @@ Value listtransactions(const Array& params, bool fHelp)
return ret;
}
-Value listaccounts(const Array& params, bool fHelp)
+UniValue listaccounts(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -1574,7 +1573,7 @@ Value listaccounts(const Array& params, bool fHelp)
return ret;
}
-Value listsinceblock(const Array& params, bool fHelp)
+UniValue listsinceblock(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -1665,7 +1664,7 @@ Value listsinceblock(const Array& params, bool fHelp)
return ret;
}
-Value gettransaction(const Array& params, bool fHelp)
+UniValue gettransaction(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -1743,7 +1742,7 @@ Value gettransaction(const Array& params, bool fHelp)
}
-Value backupwallet(const Array& params, bool fHelp)
+UniValue backupwallet(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -1769,7 +1768,7 @@ Value backupwallet(const Array& params, bool fHelp)
}
-Value keypoolrefill(const Array& params, bool fHelp)
+UniValue keypoolrefill(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -1813,7 +1812,7 @@ static void LockWallet(CWallet* pWallet)
pWallet->Lock();
}
-Value walletpassphrase(const Array& params, bool fHelp)
+UniValue walletpassphrase(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -1873,7 +1872,7 @@ Value walletpassphrase(const Array& params, bool fHelp)
}
-Value walletpassphrasechange(const Array& params, bool fHelp)
+UniValue walletpassphrasechange(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -1919,7 +1918,7 @@ Value walletpassphrasechange(const Array& params, bool fHelp)
}
-Value walletlock(const Array& params, bool fHelp)
+UniValue walletlock(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -1958,7 +1957,7 @@ Value walletlock(const Array& params, bool fHelp)
}
-Value encryptwallet(const Array& params, bool fHelp)
+UniValue encryptwallet(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -2015,7 +2014,7 @@ Value encryptwallet(const Array& params, bool fHelp)
return "wallet encrypted; Bitcoin server stopping, restart to run with encrypted wallet. The keypool has been flushed, you need to make a new backup.";
}
-Value lockunspent(const Array& params, bool fHelp)
+UniValue lockunspent(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -2076,7 +2075,7 @@ Value lockunspent(const Array& params, bool fHelp)
const UniValue& output = outputs[idx];
if (!output.isObject())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected object");
- const Object& o = output.get_obj();
+ const UniValue& o = output.get_obj();
RPCTypeCheckObj(o, boost::assign::map_list_of("txid", UniValue::VSTR)("vout", UniValue::VNUM));
@@ -2099,7 +2098,7 @@ Value lockunspent(const Array& params, bool fHelp)
return true;
}
-Value listlockunspent(const Array& params, bool fHelp)
+UniValue listlockunspent(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -2148,7 +2147,7 @@ Value listlockunspent(const Array& params, bool fHelp)
return ret;
}
-Value settxfee(const Array& params, bool fHelp)
+UniValue settxfee(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -2177,7 +2176,7 @@ Value settxfee(const Array& params, bool fHelp)
return true;
}
-Value getwalletinfo(const Array& params, bool fHelp)
+UniValue getwalletinfo(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -2217,7 +2216,7 @@ Value getwalletinfo(const Array& params, bool fHelp)
return obj;
}
-Value resendwallettransactions(const Array& params, bool fHelp)
+UniValue resendwallettransactions(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -2242,7 +2241,7 @@ Value resendwallettransactions(const Array& params, bool fHelp)
return result;
}
-Value listunspent(const Array& params, bool fHelp)
+UniValue listunspent(const UniValue& params, bool fHelp)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
@@ -2297,7 +2296,7 @@ Value listunspent(const Array& params, bool fHelp)
if (params.size() > 2) {
UniValue inputs = params[2].get_array();
for (unsigned int idx = 0; idx < inputs.size(); idx++) {
- const Value& input = inputs[idx];
+ const UniValue& input = inputs[idx];
CBitcoinAddress address(input.get_str());
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Bitcoin address: ")+input.get_str());