diff --git a/src/daemon/MoneroDaemon.h b/src/daemon/MoneroDaemon.h new file mode 100644 index 0000000..9bc4ecb --- /dev/null +++ b/src/daemon/MoneroDaemon.h @@ -0,0 +1,30 @@ +#include "include_base_utils.h" +#include "common/util.h" + +using namespace std; + +/** + * Public interface for libmonero library. + */ +namespace monero { + + /** + * Enumerates Monero network types. + */ + enum MoneroNetworkType : uint8_t { + MAINNET = 0, + TESTNET, + STAGENET + }; + + /** + * Models a connection to a daemon. + */ + struct MoneroRpcConnection { + //MoneroRpcConnection() : uri(""), username(""), password("")) {} + MoneroRpcConnection(const string& uri = "", const string& username = "", const epee::wipeable_string& password = epee::wipeable_string()) : uri(uri), username(username), password(password) {} + const string uri; + const string username; + const epee::wipeable_string& password; + }; +} diff --git a/src/wallet/MoneroWallet.cpp b/src/wallet/MoneroWallet.cpp index dde1f24..ef35fb5 100644 --- a/src/wallet/MoneroWallet.cpp +++ b/src/wallet/MoneroWallet.cpp @@ -2,9 +2,6 @@ #include #include "MoneroWallet.h" -using namespace std; -using namespace epee; - bool MoneroWallet::walletExists(const string& path) { cout << "walletExists(" << path << ")" << endl; bool keyFileExists; @@ -17,13 +14,12 @@ MoneroWallet::MoneroWallet() { cout << "MoneroWallet()" << endl; } -MoneroWallet::MoneroWallet(network_type networkType, const string& daemonConnection, const string& language) { +MoneroWallet::MoneroWallet(network_type networkType, const MoneroRpcConnection& daemonConnection, const string& language) { wallet2 = new tools::wallet2(networkType, 1, true); - MoneroWallet::setDaemonConnection(daemonConnection, nullptr, nullptr); + MoneroWallet::setDaemonConnection(daemonConnection.uri, daemonConnection.username, daemonConnection.password); wallet2->set_seed_language(language); crypto::secret_key recovery_val, secret_key; wallet2->generate(string(""), string(""), secret_key, false, false); - cout << "MoneroWallet(3)" << endl; } MoneroWallet::MoneroWallet(const string& mnemonic, network_type networkType, const string& daemonConnection, uint64_t restoreHeight) { diff --git a/src/wallet/MoneroWallet.h b/src/wallet/MoneroWallet.h index ea8aaa7..77fd6ad 100644 --- a/src/wallet/MoneroWallet.h +++ b/src/wallet/MoneroWallet.h @@ -1,6 +1,8 @@ +#include "daemon/MoneroDaemon.h" #include "wallet/wallet2.h" using namespace std; +using namespace monero; using namespace crypto; using namespace cryptonote; @@ -35,7 +37,7 @@ using namespace cryptonote; * @param daemonConnection is connection information to a daemon (default = an unconnected wallet) * @param language is the wallet and mnemonic's language (default = "English") */ - MoneroWallet(network_type networkType, const string& daemonConnection, const string& language); + MoneroWallet(network_type networkType, const MoneroRpcConnection& daemonConnection, const string& language); /** * Construct a wallet from a mnemonic phrase.