mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-18 07:41:32 +02:00
implement close(bool save);
cleanup
This commit is contained in:
@@ -2664,14 +2664,14 @@ namespace monero {
|
||||
return send_request;
|
||||
}
|
||||
|
||||
void monero_wallet::set_attribute(const string& key, const string& val) {
|
||||
m_w2->set_attribute(key, val);
|
||||
}
|
||||
|
||||
string monero_wallet::get_attribute(const string& key) const {
|
||||
return m_w2->get_attribute(key);
|
||||
}
|
||||
|
||||
void monero_wallet::set_attribute(const string& key, const string& val) {
|
||||
m_w2->set_attribute(key, val);
|
||||
}
|
||||
|
||||
void monero_wallet::start_mining(boost::optional<uint64_t> num_threads, boost::optional<bool> background_mining, boost::optional<bool> ignore_battery) {
|
||||
MTRACE("start_mining()");
|
||||
|
||||
@@ -2712,11 +2712,6 @@ namespace monero {
|
||||
}
|
||||
}
|
||||
|
||||
void monero_wallet::save() {
|
||||
MTRACE("save()");
|
||||
m_w2->store();
|
||||
}
|
||||
|
||||
uint64_t monero_wallet::wait_for_next_block() {
|
||||
|
||||
// use mutex and condition variable to wait for block
|
||||
@@ -2749,25 +2744,6 @@ namespace monero {
|
||||
return block_listener.last_height;
|
||||
}
|
||||
|
||||
void monero_wallet::move_to(string path, string password) {
|
||||
MTRACE("move_to(" << path << ", " << password << ")");
|
||||
m_w2->store_to(path, password);
|
||||
}
|
||||
|
||||
void monero_wallet::close() {
|
||||
MTRACE("close()");
|
||||
m_w2->callback(NULL);
|
||||
stop_syncing(); // prevent sync thread from starting again
|
||||
m_w2->stop();
|
||||
m_w2->deinit();
|
||||
if (!m_syncing_thread_done) {
|
||||
m_syncing_enabled = false;
|
||||
m_syncing_thread_done = true;
|
||||
m_sync_cv.notify_one();
|
||||
m_syncing_thread.join();
|
||||
}
|
||||
}
|
||||
|
||||
bool monero_wallet::is_multisig_import_needed() const {
|
||||
return m_w2->multisig() && m_w2->has_multisig_partial_key_images();
|
||||
}
|
||||
@@ -2955,6 +2931,31 @@ namespace monero {
|
||||
return tx_ids;
|
||||
}
|
||||
|
||||
void monero_wallet::save() {
|
||||
MTRACE("save()");
|
||||
m_w2->store();
|
||||
}
|
||||
|
||||
void monero_wallet::move_to(string path, string password) {
|
||||
MTRACE("move_to(" << path << ", " << password << ")");
|
||||
m_w2->store_to(path, password);
|
||||
}
|
||||
|
||||
void monero_wallet::close(bool save) {
|
||||
MTRACE("close()");
|
||||
if (save) save();
|
||||
m_w2->callback(NULL);
|
||||
stop_syncing(); // prevent sync thread from starting again
|
||||
m_w2->stop();
|
||||
m_w2->deinit();
|
||||
if (!m_syncing_thread_done) {
|
||||
m_syncing_enabled = false;
|
||||
m_syncing_thread_done = true;
|
||||
m_sync_cv.notify_one();
|
||||
m_syncing_thread.join();
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------- PRIVATE HELPERS ----------------------------
|
||||
|
||||
void monero_wallet::init_common() {
|
||||
|
||||
+28
-26
@@ -1239,14 +1239,6 @@ namespace monero {
|
||||
*/
|
||||
shared_ptr<monero_send_request> parse_payment_uri(const string& uri) const;
|
||||
|
||||
/**
|
||||
* Set an arbitrary attribute.
|
||||
*
|
||||
* @param key is the attribute key
|
||||
* @param val is the attribute value
|
||||
*/
|
||||
void set_attribute(const string& key, const string& val);
|
||||
|
||||
/**
|
||||
* Get an attribute.
|
||||
*
|
||||
@@ -1255,6 +1247,14 @@ namespace monero {
|
||||
*/
|
||||
string get_attribute(const string& key) const;
|
||||
|
||||
/**
|
||||
* Set an arbitrary attribute.
|
||||
*
|
||||
* @param key is the attribute key
|
||||
* @param val is the attribute value
|
||||
*/
|
||||
void set_attribute(const string& key, const string& val);
|
||||
|
||||
/**
|
||||
* Start mining.
|
||||
*
|
||||
@@ -1276,24 +1276,6 @@ namespace monero {
|
||||
*/
|
||||
uint64_t wait_for_next_block();
|
||||
|
||||
/**
|
||||
* Save the wallet at its current path.
|
||||
*/
|
||||
void save();
|
||||
|
||||
/**
|
||||
* Move the wallet from its current path to the given path.
|
||||
*
|
||||
* @param path is the new wallet's path
|
||||
* @param password is the new wallet's password
|
||||
*/
|
||||
void move_to(string path, string password);
|
||||
|
||||
/**
|
||||
* Close the wallet.
|
||||
*/
|
||||
void close();
|
||||
|
||||
/**
|
||||
* Indicates if importing multisig data is needed for returning a correct balance.
|
||||
*
|
||||
@@ -1385,6 +1367,26 @@ namespace monero {
|
||||
*/
|
||||
vector<string> submit_multisig_tx_hex(const string& signed_multisig_tx_hex);
|
||||
|
||||
/**
|
||||
* Save the wallet at its current path.
|
||||
*/
|
||||
void save();
|
||||
|
||||
/**
|
||||
* Move the wallet from its current path to the given path.
|
||||
*
|
||||
* @param path is the new wallet's path
|
||||
* @param password is the new wallet's password
|
||||
*/
|
||||
void move_to(string path, string password);
|
||||
|
||||
/**
|
||||
* Optionally save then close the wallet.
|
||||
*
|
||||
* @param save specifies if the wallet should be saved before being closed (default true)
|
||||
*/
|
||||
void close(bool save = true);
|
||||
|
||||
// --------------------------------- PRIVATE --------------------------------
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user