From d71ad76e5085e0c083c6c82a8c4613deca4de7eb Mon Sep 17 00:00:00 2001 From: woodser Date: Mon, 27 May 2019 13:08:15 -0400 Subject: [PATCH] use redefined MoneroNetworkType; implement getMnemonic() --- src/daemon/MoneroDaemon.h | 4 ++-- src/wallet/MoneroWallet.cpp | 19 +++++++++++-------- src/wallet/MoneroWallet.h | 19 ++++++++----------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/daemon/MoneroDaemon.h b/src/daemon/MoneroDaemon.h index 9bc4ecb..aa1b35f 100644 --- a/src/daemon/MoneroDaemon.h +++ b/src/daemon/MoneroDaemon.h @@ -23,8 +23,8 @@ namespace monero { 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 string& uri; + const string& username; const epee::wipeable_string& password; }; } diff --git a/src/wallet/MoneroWallet.cpp b/src/wallet/MoneroWallet.cpp index ef35fb5..eb404ca 100644 --- a/src/wallet/MoneroWallet.cpp +++ b/src/wallet/MoneroWallet.cpp @@ -1,6 +1,9 @@ +#include "MoneroWallet.h" + #include #include -#include "MoneroWallet.h" + +using namespace cryptonote; bool MoneroWallet::walletExists(const string& path) { cout << "walletExists(" << path << ")" << endl; @@ -14,24 +17,24 @@ MoneroWallet::MoneroWallet() { cout << "MoneroWallet()" << endl; } -MoneroWallet::MoneroWallet(network_type networkType, const MoneroRpcConnection& daemonConnection, const string& language) { - wallet2 = new tools::wallet2(networkType, 1, true); +MoneroWallet::MoneroWallet(const MoneroNetworkType networkType, const MoneroRpcConnection& daemonConnection, const string& language) { + wallet2 = new tools::wallet2(static_cast(networkType), 1, true); 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); } -MoneroWallet::MoneroWallet(const string& mnemonic, network_type networkType, const string& daemonConnection, uint64_t restoreHeight) { +MoneroWallet::MoneroWallet(const string& mnemonic, const MoneroNetworkType networkType, const string& daemonConnection, uint64_t restoreHeight) { cout << "MoneroWallet(4)" << endl; } -MoneroWallet::MoneroWallet(const string& address, const string& viewKey, const string& spendKey, network_type networkType, const string& daemonConnection, uint64_t restoreHeight, const string& language) { +MoneroWallet::MoneroWallet(const string& address, const string& viewKey, const string& spendKey, const MoneroNetworkType networkType, const string& daemonConnection, uint64_t restoreHeight, const string& language) { cout << "MoneroWallet(7)" << endl; } -MoneroWallet::MoneroWallet(const string& path, const epee::wipeable_string& password, network_type networkType) { - wallet2 = new tools::wallet2(networkType, 1, true); +MoneroWallet::MoneroWallet(const string& path, const epee::wipeable_string& password, const MoneroNetworkType networkType) { + wallet2 = new tools::wallet2(static_cast(networkType), 1, true); wallet2->load(path, password); } @@ -40,7 +43,7 @@ MoneroWallet::~MoneroWallet() { } void MoneroWallet::getMnemonic(epee::wipeable_string& mnemonic) const { - throw runtime_error("Not implemented"); + wallet2->get_seed(mnemonic); } void MoneroWallet::setDaemonConnection(const string& uri, const string& username, const epee::wipeable_string& password) { diff --git a/src/wallet/MoneroWallet.h b/src/wallet/MoneroWallet.h index 77fd6ad..0cd0e31 100644 --- a/src/wallet/MoneroWallet.h +++ b/src/wallet/MoneroWallet.h @@ -4,12 +4,9 @@ using namespace std; using namespace monero; using namespace crypto; -using namespace cryptonote; /** * Monero wallet interface. - * - * TODO: daemonConnection is object with uri, username, and password */ class MoneroWallet { @@ -37,7 +34,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 MoneroRpcConnection& daemonConnection, const string& language); + MoneroWallet(const MoneroNetworkType networkType, const MoneroRpcConnection& daemonConnection, const string& language); /** * Construct a wallet from a mnemonic phrase. @@ -47,7 +44,7 @@ using namespace cryptonote; * @param daemonConnection is connection information to a daemon (default = an unconnected wallet) * @param restoreHeight is the block height to restore (i.e. scan the chain) from (default = 0) */ - MoneroWallet(const string& mnemonic, network_type networkType, const string& daemonConnection, uint64_t restoreHeight); + MoneroWallet(const string& mnemonic, const MoneroNetworkType networkType, const string& daemonConnection, uint64_t restoreHeight); /** * Construct a wallet from an address, view key, and spend key. @@ -60,7 +57,7 @@ using namespace cryptonote; * @param restoreHeight is the block height to restore (i.e. scan the chain) from (default = 0) * @param language is the wallet and mnemonic's language (default = "English") */ - MoneroWallet(const string& address, const string& viewKey, const string& spendKey, network_type networkType, const string& daemonConnection, uint64_t restoreHeight, const string& language); + MoneroWallet(const string& address, const string& viewKey, const string& spendKey, const MoneroNetworkType networkType, const string& daemonConnection, uint64_t restoreHeight, const string& language); /** * Construct a wallet by opening a wallet file on disk. @@ -69,7 +66,7 @@ using namespace cryptonote; * @param password is the password of the wallet file to open * @param networkType is the wallet's network type */ - MoneroWallet(const string& path, const epee::wipeable_string& password, network_type networkType); + MoneroWallet(const string& path, const epee::wipeable_string& password, const MoneroNetworkType networkType); /** * Deconstructs the wallet. @@ -79,11 +76,11 @@ using namespace cryptonote; /** * Set the wallet's daemon connection. * - * @param daemonUri is the daemon's URI - * @param daemonUsername is the daemon's username - * @param daemonPassword is the daemon's password + * @param uri is the daemon's URI + * @param username is the daemon's username + * @param password is the daemon's password */ - void setDaemonConnection(const string& daemonUri, const string& daemonUsername, const epee::wipeable_string& daemonPassword); + void setDaemonConnection(const string& uri, const string& username, const epee::wipeable_string& password); // /** // * Get the wallet's seed.