31#include <boost/range/adaptor/transformed.hpp>
32#include <boost/variant/apply_visitor.hpp>
45 template<
typename Source,
typename Destination>
46 constexpr bool precision_loss()
49 std::numeric_limits<Destination>::is_signed != std::numeric_limits<Source>::is_signed ||
50 std::numeric_limits<Destination>::min() > std::numeric_limits<Source>::min() ||
51 std::numeric_limits<Destination>::max() < std::numeric_limits<Source>::max();
54 template<
typename Source,
typename Type>
58 (std::is_same<Type, char>() && std::is_same<Source, int>()) ||
59 std::numeric_limits<Source>::is_signed == std::numeric_limits<Type>::is_signed,
60 "comparisons below may have undefined behavior"
62 if (
source < std::numeric_limits<Type>::min())
66 if (std::numeric_limits<Type>::max() <
source)
73 template<
typename Type>
74 void to_int(
const rapidjson::Value& val,
Type& i)
80 convert_numeric(val.GetInt(), i);
82 template<
typename Type>
83 void to_int64(
const rapidjson::Value& val,
Type& i)
89 convert_numeric(val.GetInt64(), i);
92 template<
typename Type>
93 void to_uint(
const rapidjson::Value& val,
Type& i)
99 convert_numeric(val.GetUint(), i);
101 template<
typename Type>
102 void to_uint64(
const rapidjson::Value& val,
Type& i)
108 convert_numeric(val.GetUint64(), i);
112void toJsonValue(rapidjson::Document& doc,
const std::string& i, rapidjson::Value& val)
114 val = rapidjson::Value(i.c_str(), doc.GetAllocator());
124 str = val.GetString();
127void toJsonValue(rapidjson::Document& doc,
bool i, rapidjson::Value& val)
166void toJsonValue(rapidjson::Document& doc,
const unsigned int i, rapidjson::Value& val)
168 val = rapidjson::Value(i);
176void toJsonValue(rapidjson::Document& doc,
const int i, rapidjson::Value& val)
178 val = rapidjson::Value(i);
186void toJsonValue(rapidjson::Document& doc,
const unsigned long long i, rapidjson::Value& val)
188 static_assert(!precision_loss<unsigned long long, std::uint64_t>(),
"precision loss");
189 val = rapidjson::Value(std::uint64_t(i));
197void toJsonValue(rapidjson::Document& doc,
const long long i, rapidjson::Value& val)
199 static_assert(!precision_loss<long long, std::int64_t>(),
"precision loss");
200 val = rapidjson::Value(std::int64_t(i));
284 using result_type = void;
286 rapidjson::Document& doc;
287 rapidjson::Value& val;
310 boost::apply_visitor(add_input{doc, val}, txin);
321 if (val.MemberCount() != 1)
326 for (
auto const& elem : val.GetObject())
328 if (elem.name ==
"to_key")
332 txin = std::move(tmpVal);
334 else if (elem.name ==
"gen")
338 txin = std::move(tmpVal);
340 else if (elem.name ==
"to_script")
344 txin = std::move(tmpVal);
346 else if (elem.name ==
"to_scripthash")
350 txin = std::move(tmpVal);
543 using result_type = void;
545 rapidjson::Document& doc;
546 rapidjson::Value& val;
565 boost::apply_visitor(add_output{doc, val}, txout.
target);
575 if (val.MemberCount() != 2)
580 for (
auto const& elem : val.GetObject())
582 if (elem.name ==
"amount")
587 if (elem.name ==
"to_key")
591 txout.
target = std::move(tmpVal);
593 else if (elem.name ==
"to_key_public")
597 txout.
target = std::move(tmpVal);
599 else if (elem.name ==
"to_script")
603 txout.
target = std::move(tmpVal);
605 else if (elem.name ==
"to_scripthash")
609 txout.
target = std::move(tmpVal);
1012 using boost::adaptors::transform;
1028 rapidjson::Value prunable;
1029 prunable.SetObject();
1036 val.AddMember(
"prunable", prunable, doc.GetAllocator());
1042 using boost::adaptors::transform;
1044 if (!val.IsObject())
1049 std::vector<rct::key> commitments;
1059 const auto& prunable = val[
"prunable"];
1071 sig.
outPk.reserve(commitments.size());
1072 for (
rct::key const& commitment : commitments)
1074 sig.
outPk.push_back({{}, commitment});
1088 if (!val.IsObject())
1103 std::vector<rct::key> keyVector(sig.
Ci, std::end(sig.
Ci));
1109 if (!val.IsObject())
1114 const auto ci = val.FindMember(
"Ci");
1115 if (ci == val.MemberEnd())
1122 std::vector<rct::key> keyVector;
1124 if (!(keyVector.size() == 64))
1128 for (
size_t i=0; i < 64; i++)
1130 sig.
Ci[i] = keyVector[i];
1154 if (!val.IsObject())
1177 std::vector<rct::key> keyVector(sig.
s0, std::end(sig.
s0));
1180 keyVector.assign(sig.
s1, std::end(sig.
s1));
1188 if (!val.IsObject())
1194 std::vector<rct::key> keyVector;
1196 if (!(keyVector.size() == 64))
1200 for (
size_t i=0; i < 64; i++)
1202 sig.
s0[i] = keyVector[i];
1208 if (!(keyVector.size() == 64))
1212 for (
size_t i=0; i < 64; i++)
1214 sig.
s1[i] = keyVector[i];
1230 if (!val.IsObject())
1269 if (!val.IsObject())
1310 if (!val.IsObject())
std::vector< uint8_t > extra
std::vector< txin_v > vin
std::vector< tx_out > vout
rct::rctSig rct_signatures
std::vector< std::vector< crypto::signature > > signatures
std::string message("Message requiring signing")
#define GET_FROM_JSON_OBJECT(source, dst, key)
#define OBJECT_HAS_MEMBER_OR_THROW(val, key)
#define INSERT_INTO_JSON_OBJECT(jsonVal, doc, key, source)
void toJsonValue(rapidjson::Document &doc, const std::string &i, rapidjson::Value &val)
void fromJsonValue(const rapidjson::Value &val, std::string &str)
Holds cryptonote related classes and helpers.
boost::variant< txin_gen, txin_to_script, txin_to_scripthash, txin_to_key, txin_to_key_public > txin_v
const CharType(& source)[N]
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
std::vector< blobdata > txs
std::vector< crypto::hash > tx_hashes
std::vector< cryptonote::transaction > transactions
std::uint64_t start_height
std::vector< std::uint64_t > distribution
output_distribution_data data
crypto::hash last_failed_block_hash
cryptonote::transaction tx
uint64_t last_relayed_time
bool nonexistent_utxo_seen
uint64_t last_failed_block_height
uint64_t max_used_block_height
crypto::hash max_used_block_hash
crypto::key_image k_image
std::vector< uint64_t > key_offsets
std::vector< uint8_t > sigset
std::vector< uint8_t > sigset
uint64_t m_address_prefix
cryptonote::account_public_address address
std::vector< crypto::public_key > keys
std::vector< uint8_t > script
std::vector< ecdhTuple > ecdhInfo
std::vector< rangeSig > rangeSigs
std::vector< Bulletproof > bulletproofs