53 #ifndef monero_utils_h 54 #define monero_utils_h 56 #include "wallet/monero_wallet_model.h" 57 #include "cryptonote_basic/cryptonote_basic.h" 58 #include "serialization/keyvalue_serialization.h" 59 #include "storages/portable_storage.h" 67 using namespace cryptonote;
71 static const int RING_SIZE = 12;
75 void json_to_binary(
const std::string &json, std::string &bin);
76 void binary_to_json(
const std::string &bin, std::string &json);
77 void binary_blocks_to_json(
const std::string &bin, std::string &json);
81 string serialize(
const rapidjson::Document& doc);
83 void addJsonMember(
string key, uint8_t val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field);
84 void addJsonMember(
string key, uint32_t val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field);
85 void addJsonMember(
string key, uint64_t val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field);
86 void addJsonMember(
string key,
string val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field);
87 void addJsonMember(
string key,
bool val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root);
90 template <
class T> rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator,
const vector<shared_ptr<T>>& vals) {
91 rapidjson::Value value_arr(rapidjson::kArrayType);
92 for (
const auto& val : vals) {
93 value_arr.PushBack(val->to_rapidjson_val(allocator), allocator);
99 template <
class T> rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator,
const vector<T>& vals) {
100 rapidjson::Value value_arr(rapidjson::kArrayType);
101 for (
const auto& val : vals) {
102 value_arr.PushBack(val.to_rapidjson_val(allocator), allocator);
107 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator,
const vector<string>& strs);
108 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator,
const vector<uint8_t>& nums);
109 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator,
const vector<uint32_t>& nums);
110 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator,
const vector<uint64_t>& nums);
116 string serialize(
const boost::property_tree::ptree& node);
117 void deserialize(
const string& json, boost::property_tree::ptree& root);
121 void deserialize(
const string& json, boost::property_tree::ptree& root);
138 shared_ptr<monero_tx>
cn_tx_to_tx(
const cryptonote::transaction& cn_tx,
bool init_as_tx_wallet =
false);
145 static std::string get_pruned_tx_json(cryptonote::transaction &tx)
147 std::stringstream ss;
148 json_archive<true> ar(ss);
149 bool r = tx.serialize_base(ar);
150 CHECK_AND_ASSERT_MES(r, std::string(),
"Failed to serialize rct signatures base");
shared_ptr< monero_block > cn_block_to_block(const cryptonote::block &cn_block)
Definition: monero_utils.cpp:236
shared_ptr< monero_tx > cn_tx_to_tx(const cryptonote::transaction &cn_tx, bool init_as_tx_wallet=false)
Definition: monero_utils.cpp:252
Definition: monero_utils.h:64