diff --git a/src/daemon/MoneroDaemon.h b/src/daemon/MoneroDaemon.h index 8391013..7719db5 100644 --- a/src/daemon/MoneroDaemon.h +++ b/src/daemon/MoneroDaemon.h @@ -132,3 +132,36 @@ namespace monero { shared_ptr stealthPublicKey; }; } + +//// --------------------------- MODEL SERIALIZATION ---------------------------- +// +//BOOST_CLASS_VERSION(monero::MoneroTx, 0) +//BOOST_CLASS_VERSION(monero::MoneroOutput, 0) +//BOOST_CLASS_VERSION(monero::MoneroKeyImage, 0) +// +//namespace boost { +// namespace serialization { +// template +// inline void serialize(Archive &a, monero::MoneroTx& x, const boost::serialization::version_type ver) +// { +//// a & x.m_L; +//// a & x.m_R; +// } +// +// template +// inline void serialize(Archive &a, monero::MoneroOutput& x, const boost::serialization::version_type ver) +// { +//// a & x.m_signer; +//// a & x.m_LR; +//// a & x.m_partial_key_images; +// } +// +// template +// inline void serialize(Archive &a, monero::MoneroKeyImage& x, const boost::serialization::version_type ver) +// { +//// a & x.m_signer; +//// a & x.m_LR; +//// a & x.m_partial_key_images; +// } +// } // namepsace serialization +//} // namespace boost diff --git a/src/utils/MoneroUtils.cpp b/src/utils/MoneroUtils.cpp index 48c4c6c..fb54fdd 100644 --- a/src/utils/MoneroUtils.cpp +++ b/src/utils/MoneroUtils.cpp @@ -2,8 +2,6 @@ #include "rpc/core_rpc_server_commands_defs.h" #include "storages/portable_storage_template_helper.h" #include "cryptonote_basic/cryptonote_format_utils.h" -#include -#include using namespace std; using namespace boost; @@ -74,34 +72,42 @@ void MoneroUtils::binaryBlocksToJson(const std::string &bin, std::string &json) json = ss.str(); } -string MoneroUtils::serialize(const MoneroAccount& account) { - throw runtime_error("serialize(account) not implemented"); -} - -string MoneroUtils::serialize(const MoneroSubaddress& subaddress) { - throw runtime_error("serialize(subaddress) not implemented"); -} - -string MoneroUtils::serialize(const MoneroBlock& block) { - throw runtime_error("serialize(block) not implemented"); -} - -void MoneroUtils::deserializeTx(const string& txStr, MoneroTx& tx) { - throw runtime_error("deserializeTx(txStr) not implemented"); -} - -void MoneroUtils::deserializeTxWallet(const string& txStr, MoneroTxWallet& tx) { - throw runtime_error("deserializeTxWallet(txStr) not implemented"); -} - -void MoneroUtils::deserializeTxRequest(const string& txRequestStr, MoneroTxRequest& request) { - throw runtime_error("deserializeTxRequest(txRequestStr) not implemented"); -} - -void MoneroUtils::deserializeOutput(const string& outputStr, MoneroOutput& output) { - throw runtime_error("deserializeOutput(outputStr) not implemented"); -} - -void MoneroUtils::deserializeOutputWallet(const string& outputStr, MoneroOutputWallet& output) { - throw runtime_error("deserializeOutputWallet(outputStr) not implemented"); -} +//string MoneroUtils::serialize(const MoneroAccount& account) { +// +// // build property tree from account +// boost::property_tree::ptree accountNode; +// addNode(accountNode, string("index"), account.index); +// +// // convert root to string +// std::stringstream ss; +// boost::property_tree::write_json(ss, accountNode, false); +// return ss.str(); +//} +// +//string MoneroUtils::serialize(const MoneroSubaddress& subaddress) { +// throw runtime_error("serialize(subaddress) not implemented"); +//} +// +//string MoneroUtils::serialize(const MoneroBlock& block) { +// throw runtime_error("serialize(block) not implemented"); +//} +// +//void MoneroUtils::deserializeTx(const string& txStr, MoneroTx& tx) { +// throw runtime_error("deserializeTx(txStr) not implemented"); +//} +// +//void MoneroUtils::deserializeTxWallet(const string& txStr, MoneroTxWallet& tx) { +// throw runtime_error("deserializeTxWallet(txStr) not implemented"); +//} +// +//void MoneroUtils::deserializeTxRequest(const string& txRequestStr, MoneroTxRequest& request) { +// throw runtime_error("deserializeTxRequest(txRequestStr) not implemented"); +//} +// +//void MoneroUtils::deserializeOutput(const string& outputStr, MoneroOutput& output) { +// throw runtime_error("deserializeOutput(outputStr) not implemented"); +//} +// +//void MoneroUtils::deserializeOutputWallet(const string& outputStr, MoneroOutputWallet& output) { +// throw runtime_error("deserializeOutputWallet(outputStr) not implemented"); +//} diff --git a/src/utils/MoneroUtils.h b/src/utils/MoneroUtils.h index 42faedd..93bb121 100644 --- a/src/utils/MoneroUtils.h +++ b/src/utils/MoneroUtils.h @@ -5,6 +5,8 @@ #include "cryptonote_basic/cryptonote_basic.h" #include "serialization/keyvalue_serialization.h" // TODO: consolidate with other binary deps? #include "storages/portable_storage.h" +#include +#include /** * Collection of utilities for working with Monero's binary portable storage format. @@ -21,27 +23,32 @@ namespace MoneroUtils void binaryBlocksToJson(const std::string &bin, std::string &json); - // TODO: template implementation here, could move to MoneroUtils.hpp per https://stackoverflow.com/questions/3040480/c-template-function-compiles-in-header-but-not-implementation - template string serialize(const vector types) { - cout << "serialize(types)" << endl; - throw runtime_error("Not implemented"); - } - - string serialize(const MoneroAccount& account); - - string serialize(const MoneroSubaddress& subaddress); - - string serialize(const MoneroBlock& block); - - void deserializeTx(const string& txStr, MoneroTx& tx); - - void deserializeTxWallet(const string& txStr, MoneroTxWallet& tx); - - void deserializeTxRequest(const string& txRequestStr, MoneroTxRequest& request); - - void deserializeOutput(const string& outputStr, MoneroOutput& output); - - void deserializeOutputWallet(const string& outputStr, MoneroOutputWallet& output); +// // TODO: template implementation here, could move to MoneroUtils.hpp per https://stackoverflow.com/questions/3040480/c-template-function-compiles-in-header-but-not-implementation +// template string serialize(const vector types) { +// cout << "serialize(types)" << endl; +// throw runtime_error("Not implemented"); +// } +// +// void addNode(boost::property_tree::ptree root, const string& key, shared_ptr ptr) { +// cout << "addNode(...)" << endl; +// throw runtime_error("Not implemented"); +// } +// +// string serialize(const MoneroAccount& account); +// +// string serialize(const MoneroSubaddress& subaddress); +// +// string serialize(const MoneroBlock& block); +// +// void deserializeTx(const string& txStr, MoneroTx& tx); +// +// void deserializeTxWallet(const string& txStr, MoneroTxWallet& tx); +// +// void deserializeTxRequest(const string& txRequestStr, MoneroTxRequest& request); +// +// void deserializeOutput(const string& outputStr, MoneroOutput& output); +// +// void deserializeOutputWallet(const string& outputStr, MoneroOutputWallet& output); /** * Modified from core_rpc_server.cpp to return a string. diff --git a/src/wallet/MoneroWallet.h b/src/wallet/MoneroWallet.h index c120fc6..0aa2fc4 100644 --- a/src/wallet/MoneroWallet.h +++ b/src/wallet/MoneroWallet.h @@ -212,9 +212,9 @@ namespace monero { /** * Monero wallet interface. */ - class MoneroWallet { + class MoneroWallet { - public: + public: /** * Indicates if a wallet exists at the given path. @@ -1190,13 +1190,46 @@ namespace monero { // --------------------------------- PRIVATE -------------------------------- - private: - friend struct Wallet2Listener; - shared_ptr wallet2; // internal wallet implementation - unique_ptr wallet2Listener; // listener for internal wallet implementation - MoneroWalletListener* listener; // wallet's external listener + private: + friend struct Wallet2Listener; + shared_ptr wallet2; // internal wallet implementation + unique_ptr wallet2Listener; // listener for internal wallet implementation + MoneroWalletListener* listener; // wallet's external listener - MoneroSyncResult syncAux(uint64_t* startHeight, uint64_t* endHeight, MoneroSyncListener* listener); - vector getSubaddressesAux(uint32_t accountIdx, vector subaddressIndices, vector transfers) const; - }; + MoneroSyncResult syncAux(uint64_t* startHeight, uint64_t* endHeight, MoneroSyncListener* listener); + vector getSubaddressesAux(uint32_t accountIdx, vector subaddressIndices, vector transfers) const; + }; } + +//// --------------------------- MODEL SERIALIZATION ---------------------------- +// +//BOOST_CLASS_VERSION(monero::MoneroWallet, 0) +//BOOST_CLASS_VERSION(monero::MoneroAccount, 0) +//BOOST_CLASS_VERSION(monero::MoneroSubaddress, 0) +// +//namespace boost { +// namespace serialization { +// template +// inline void serialize(Archive &a, monero::MoneroWallet& x, const boost::serialization::version_type ver) +// { +//// a & x.m_L; +//// a & x.m_R; +// } +// +// template +// inline void serialize(Archive &a, monero::MoneroAccount& x, const boost::serialization::version_type ver) +// { +//// a & x.m_signer; +//// a & x.m_LR; +//// a & x.m_partial_key_images; +// } +// +// template +// inline void serialize(Archive &a, monero::MoneroSubaddress& x, const boost::serialization::version_type ver) +// { +//// a & x.m_signer; +//// a & x.m_LR; +//// a & x.m_partial_key_images; +// } +// } // namepsace serialization +//} // namespace boost