This commit is contained in:
woodser
2019-06-04 18:32:29 -04:00
parent 9564393f95
commit 5751a1bf52
4 changed files with 143 additions and 64 deletions
+33
View File
@@ -132,3 +132,36 @@ namespace monero {
shared_ptr<string> 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 <class Archive>
// inline void serialize(Archive &a, monero::MoneroTx& x, const boost::serialization::version_type ver)
// {
//// a & x.m_L;
//// a & x.m_R;
// }
//
// template <class Archive>
// 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 <class Archive>
// 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
+39 -33
View File
@@ -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 <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
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");
//}
+28 -21
View File
@@ -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 <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
/**
* 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 <class T> string serialize(const vector<T> 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 <class T> string serialize(const vector<T> types) {
// cout << "serialize(types)" << endl;
// throw runtime_error("Not implemented");
// }
//
// void addNode(boost::property_tree::ptree root, const string& key, shared_ptr<void> 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.
+43 -10
View File
@@ -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<tools::wallet2> wallet2; // internal wallet implementation
unique_ptr<Wallet2Listener> wallet2Listener; // listener for internal wallet implementation
MoneroWalletListener* listener; // wallet's external listener
private:
friend struct Wallet2Listener;
shared_ptr<tools::wallet2> wallet2; // internal wallet implementation
unique_ptr<Wallet2Listener> wallet2Listener; // listener for internal wallet implementation
MoneroWalletListener* listener; // wallet's external listener
MoneroSyncResult syncAux(uint64_t* startHeight, uint64_t* endHeight, MoneroSyncListener* listener);
vector<MoneroSubaddress> getSubaddressesAux(uint32_t accountIdx, vector<uint32_t> subaddressIndices, vector<tools::wallet2::transfer_details> transfers) const;
};
MoneroSyncResult syncAux(uint64_t* startHeight, uint64_t* endHeight, MoneroSyncListener* listener);
vector<MoneroSubaddress> getSubaddressesAux(uint32_t accountIdx, vector<uint32_t> subaddressIndices, vector<tools::wallet2::transfer_details> 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 <class Archive>
// inline void serialize(Archive &a, monero::MoneroWallet& x, const boost::serialization::version_type ver)
// {
//// a & x.m_L;
//// a & x.m_R;
// }
//
// template <class Archive>
// 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 <class Archive>
// 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