all wallet constructors require path and password

This commit is contained in:
woodser
2019-06-02 13:19:54 -04:00
parent 66e01660b5
commit 45b900f66e
2 changed files with 19 additions and 10 deletions
+6 -6
View File
@@ -109,22 +109,22 @@ namespace monero {
return walletFileExists;
}
MoneroWallet::MoneroWallet() {
MoneroWallet::MoneroWallet(const string& path, const string&password) {
cout << "MoneroWallet()" << endl;
throw runtime_error("Not implemented");
}
MoneroWallet::MoneroWallet(const MoneroNetworkType networkType, const MoneroRpcConnection& daemonConnection, const string& language) {
MoneroWallet::MoneroWallet(const string& path, const string&password, const MoneroNetworkType networkType, const MoneroRpcConnection& daemonConnection, const string& language) {
cout << "MoneroWallet(3)" << endl;
wallet2 = shared_ptr<tools::wallet2>(new tools::wallet2(static_cast<network_type>(networkType), 1, true));
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);
wallet2->generate(path, password, secret_key, false, false);
wallet2Listener = unique_ptr<Wallet2Listener>(new Wallet2Listener(this, wallet2));
}
MoneroWallet::MoneroWallet(const string& mnemonic, const MoneroNetworkType networkType, const MoneroRpcConnection& daemonConnection, uint64_t restoreHeight) {
MoneroWallet::MoneroWallet(const string& path, const string& password, const string& mnemonic, const MoneroNetworkType networkType, const MoneroRpcConnection& daemonConnection, uint64_t restoreHeight) {
// validate mnemonic and get recovery key and language
crypto::secret_key recoveryKey;
@@ -136,7 +136,7 @@ namespace monero {
// initialize wallet
wallet2 = shared_ptr<tools::wallet2>(new tools::wallet2(static_cast<cryptonote::network_type>(networkType), 1, true));
wallet2->set_seed_language(language);
wallet2->generate(string(""), string(""), recoveryKey, true, false);
wallet2->generate(path, password, recoveryKey, true, false);
wallet2->set_refresh_from_block_height(restoreHeight);
wallet2Listener = unique_ptr<Wallet2Listener>(new Wallet2Listener(this, wallet2));
@@ -146,7 +146,7 @@ namespace monero {
cout << "Mnemonic: " << string(fetchedMnemonic.data(), fetchedMnemonic.size()) << endl;
}
MoneroWallet::MoneroWallet(const string& address, const string& viewKey, const string& spendKey, const MoneroNetworkType networkType, const string& daemonConnection, uint64_t restoreHeight, const string& language) {
MoneroWallet::MoneroWallet(const string& path, const string& password, 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;
throw runtime_error("Not implemented");
}
+13 -4
View File
@@ -169,31 +169,40 @@ namespace monero {
/**
* Construct an unconnected English wallet with a randomly generated seed on mainnet.
*
* @param path is the path to create the wallet
* @param password is the password encrypt the wallet
*/
MoneroWallet();
MoneroWallet(const string& path, const string& password);
/**
* Construct a wallet with a randomly generated seed.
*
* @param path is the path to create the wallet
* @param password is the password encrypt the wallet
* @param networkType is the wallet's network type (default = MoneroNetworkType.MAINNET)
* @param daemonConnection is connection information to a daemon (default = an unconnected wallet)
* @param language is the wallet and mnemonic's language (default = "English")
*/
MoneroWallet(const MoneroNetworkType networkType, const MoneroRpcConnection& daemonConnection, const string& language);
MoneroWallet(const string& path, const string& password, const MoneroNetworkType networkType, const MoneroRpcConnection& daemonConnection, const string& language);
/**
* Construct a wallet from a mnemonic phrase.
*
* @param path is the path to create the wallet
* @param password is the password encrypt the wallet
* @param mnemonic is the mnemonic of the wallet to construct
* @param networkType is the wallet's network type
* @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, const MoneroNetworkType networkType, const MoneroRpcConnection& daemonConnection, uint64_t restoreHeight);
MoneroWallet(const string& path, const string& password, const string& mnemonic, const MoneroNetworkType networkType, const MoneroRpcConnection& daemonConnection, uint64_t restoreHeight);
/**
* Construct a wallet from an address, view key, and spend key.
*
* @param path is the path to create the wallet
* @param password is the password encrypt the wallet
* @param address is the address of the wallet to construct
* @param viewKey is the view key of the wallet to construct
* @param spendKey is the spend key of the wallet to construct
@@ -202,7 +211,7 @@ namespace monero {
* @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, const MoneroNetworkType networkType, const string& daemonConnection, uint64_t restoreHeight, const string& language);
MoneroWallet(const string& path, const string& password, 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.