mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-17 15:21:30 +02:00
support changing wallet password
This commit is contained in:
@@ -1328,10 +1328,13 @@ namespace monero {
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the wallet at its current path.
|
||||
* Change the wallet password.
|
||||
*
|
||||
* @param old_password is the wallet's old password
|
||||
* @param new_password is the wallet's new password
|
||||
*/
|
||||
virtual void save() {
|
||||
throw std::runtime_error("save() not supported");
|
||||
virtual void change_password(const std::string& old_password, const std::string& new_password) {
|
||||
throw std::runtime_error("change_password() not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1340,10 +1343,17 @@ namespace monero {
|
||||
* @param path is the new wallet's path
|
||||
* @param password is the new wallet's password
|
||||
*/
|
||||
virtual void move_to(std::string path, std::string password) {
|
||||
virtual void move_to(const std::string& path, const std::string& password) {
|
||||
throw std::runtime_error("move_to() not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the wallet at its current path.
|
||||
*/
|
||||
virtual void save() {
|
||||
throw std::runtime_error("save() not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally save then close the wallet.
|
||||
*
|
||||
|
||||
@@ -3312,16 +3312,24 @@ namespace monero {
|
||||
return tx_hashes;
|
||||
}
|
||||
|
||||
void monero_wallet_full::change_password(const std::string& old_password, const std::string& new_password) {
|
||||
MTRACE("change_password(" << "***" << ", ***)");
|
||||
#if !defined(__EMSCRIPTEN__) // TODO: wallet2 verify_password loads from disk so password is verified in js for wasm
|
||||
if (!m_w2->verify_password(old_password)) throw std::runtime_error("Invalid original password.");
|
||||
#endif
|
||||
m_w2->change_password(m_w2->get_wallet_file(), old_password, new_password);
|
||||
}
|
||||
|
||||
void monero_wallet_full::move_to(const std::string& path, const std::string& password) {
|
||||
MTRACE("move_to(" << path << ", ***)");
|
||||
m_w2->store_to(path, password);
|
||||
}
|
||||
|
||||
void monero_wallet_full::save() {
|
||||
MTRACE("save()");
|
||||
m_w2->store();
|
||||
}
|
||||
|
||||
void monero_wallet_full::move_to(std::string path, std::string password) {
|
||||
MTRACE("move_to(" << path << ", ***)");
|
||||
m_w2->store_to(path, password);
|
||||
}
|
||||
|
||||
std::string monero_wallet_full::get_keys_file_buffer(const epee::wipeable_string& password, bool view_only) const {
|
||||
boost::optional<wallet2::keys_file_data> keys_file_data = m_w2->get_keys_file_data(password, view_only);
|
||||
std::string buf;
|
||||
|
||||
@@ -274,8 +274,9 @@ namespace monero {
|
||||
int import_multisig_hex(const std::vector<std::string>& multisig_hexes) override;
|
||||
monero_multisig_sign_result sign_multisig_tx_hex(const std::string& multisig_tx_hex) override;
|
||||
std::vector<std::string> submit_multisig_tx_hex(const std::string& signed_multisig_tx_hex) override;
|
||||
void change_password(const std::string& old_password, const std::string& new_password) override;
|
||||
void move_to(const std::string& path, const std::string& password) override;
|
||||
void save() override;
|
||||
void move_to(std::string path, std::string password) override;
|
||||
void close(bool save = false) override;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user