aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet2.cpp7
-rw-r--r--src/wallet/wallet2.h3
-rw-r--r--src/wallet/wallet_errors.h11
3 files changed, 18 insertions, 3 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index fb1e5575b..a63eb4be7 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -38,6 +38,7 @@ void do_prepare_file_names(const std::string& file_path, std::string& keys_file,
keys_file += ".keys";
}
}
+
} //namespace
namespace tools
@@ -435,7 +436,7 @@ void wallet2::load_keys(const std::string& keys_file_name, const std::string& pa
THROW_WALLET_EXCEPTION_IF(!r, error::invalid_password);
}
//----------------------------------------------------------------------------------------------------
-void wallet2::generate(const std::string& wallet_, const std::string& password)
+crypto::secret_key wallet2::generate(const std::string& wallet_, const std::string& password, const crypto::secret_key& recovery_param, bool recover, bool two_random)
{
clear();
prepare_file_names(wallet_);
@@ -444,7 +445,8 @@ void wallet2::generate(const std::string& wallet_, const std::string& password)
THROW_WALLET_EXCEPTION_IF(boost::filesystem::exists(m_wallet_file, ignored_ec), error::file_exists, m_wallet_file);
THROW_WALLET_EXCEPTION_IF(boost::filesystem::exists(m_keys_file, ignored_ec), error::file_exists, m_keys_file);
- m_account.generate();
+ crypto::secret_key retval = m_account.generate(recovery_param, recover, two_random);
+
m_account_public_address = m_account.get_keys().m_account_address;
bool r = store_keys(m_keys_file, password);
@@ -454,6 +456,7 @@ void wallet2::generate(const std::string& wallet_, const std::string& password)
if(!r) LOG_PRINT_RED_L0("String with address text not saved");
store();
+ return retval;
}
//----------------------------------------------------------------------------------------------------
void wallet2::wallet_exists(const std::string& file_path, bool& keys_file_exists, bool& wallet_file_exists)
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index 9ca586425..534a0517b 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -97,7 +97,7 @@ namespace tools
END_SERIALIZE()
};
- void generate(const std::string& wallet, const std::string& password);
+ crypto::secret_key generate(const std::string& wallet, const std::string& password, const crypto::secret_key& recovery_param = crypto::secret_key(), bool recover = false, bool two_random = false);
void load(const std::string& wallet, const std::string& password);
void store();
cryptonote::account_base& get_account(){return m_account;}
@@ -227,6 +227,7 @@ namespace boost
namespace tools
{
+
namespace detail
{
//----------------------------------------------------------------------------------------------------
diff --git a/src/wallet/wallet_errors.h b/src/wallet/wallet_errors.h
index 0d42dbaf4..71c946545 100644
--- a/src/wallet/wallet_errors.h
+++ b/src/wallet/wallet_errors.h
@@ -188,6 +188,17 @@ namespace tools
std::string to_string() const { return wallet_logic_error::to_string(); }
};
+
+ //----------------------------------------------------------------------------------------------------
+ struct invalid_pregenerated_random : public wallet_logic_error
+ {
+ explicit invalid_pregenerated_random (std::string&& loc)
+ : wallet_logic_error(std::move(loc), "invalid pregenerated random for wallet creation/recovery")
+ {
+ }
+
+ std::string to_string() const { return wallet_logic_error::to_string(); }
+ };
//----------------------------------------------------------------------------------------------------
struct refresh_error : public wallet_logic_error
{