mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-26 21:03:28 +01:00
commit
1a286061ff
@ -80,15 +80,15 @@ void AddressBookImpl::refresh()
|
|||||||
|
|
||||||
clearRows();
|
clearRows();
|
||||||
|
|
||||||
// Fetch from Wallet2 and create vector
|
// Fetch from Wallet2 and create vector of AddressBookRow objects
|
||||||
for (auto const &a : m_wallet->m_wallet->get_address_book() ) {
|
std::vector<tools::wallet2::address_book_row> rows = m_wallet->m_wallet->get_address_book();
|
||||||
auto row = a.second;
|
for (size_t i = 0; i < rows.size(); ++i) {
|
||||||
int rowId = a.first;
|
tools::wallet2::address_book_row * row = &rows.at(i);
|
||||||
|
|
||||||
std::string payment_id = (row.m_payment_id == cryptonote::null_hash)? "" : epee::string_tools::pod_to_hex(row.m_payment_id);
|
std::string payment_id = (row->m_payment_id == cryptonote::null_hash)? "" : epee::string_tools::pod_to_hex(row->m_payment_id);
|
||||||
std::string address = cryptonote::get_account_address_as_str(m_wallet->m_wallet->testnet(),row.m_address);
|
std::string address = cryptonote::get_account_address_as_str(m_wallet->m_wallet->testnet(),row->m_address);
|
||||||
|
|
||||||
AddressBookRow * abr = new AddressBookRow(rowId, address, payment_id, row.m_description);
|
AddressBookRow * abr = new AddressBookRow(i, address, payment_id, row->m_description);
|
||||||
m_rows.push_back(abr);
|
m_rows.push_back(abr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,6 +98,7 @@ bool AddressBookImpl::deleteRow(int rowId)
|
|||||||
{
|
{
|
||||||
LOG_PRINT_L2("Deleting address book row " << rowId);
|
LOG_PRINT_L2("Deleting address book row " << rowId);
|
||||||
bool r = m_wallet->m_wallet->delete_address_book_row(rowId);
|
bool r = m_wallet->m_wallet->delete_address_book_row(rowId);
|
||||||
|
if (r)
|
||||||
refresh();
|
refresh();
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ bool WalletImpl::create(const std::string &path, const std::string &password, co
|
|||||||
if (keys_file_exists || wallet_file_exists) {
|
if (keys_file_exists || wallet_file_exists) {
|
||||||
m_errorString = "attempting to generate or restore wallet, but specified file(s) exist. Exiting to not risk overwriting.";
|
m_errorString = "attempting to generate or restore wallet, but specified file(s) exist. Exiting to not risk overwriting.";
|
||||||
LOG_ERROR(m_errorString);
|
LOG_ERROR(m_errorString);
|
||||||
m_status = Status_Error;
|
m_status = Status_Critical;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// TODO: validate language
|
// TODO: validate language
|
||||||
@ -260,7 +260,7 @@ bool WalletImpl::create(const std::string &path, const std::string &password, co
|
|||||||
m_status = Status_Ok;
|
m_status = Status_Ok;
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
LOG_ERROR("Error creating wallet: " << e.what());
|
LOG_ERROR("Error creating wallet: " << e.what());
|
||||||
m_status = Status_Error;
|
m_status = Status_Critical;
|
||||||
m_errorString = e.what();
|
m_errorString = e.what();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -287,7 +287,7 @@ bool WalletImpl::open(const std::string &path, const std::string &password)
|
|||||||
m_password = password;
|
m_password = password;
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
LOG_ERROR("Error opening wallet: " << e.what());
|
LOG_ERROR("Error opening wallet: " << e.what());
|
||||||
m_status = Status_Error;
|
m_status = Status_Critical;
|
||||||
m_errorString = e.what();
|
m_errorString = e.what();
|
||||||
}
|
}
|
||||||
return m_status == Status_Ok;
|
return m_status == Status_Ok;
|
||||||
@ -319,7 +319,7 @@ bool WalletImpl::recover(const std::string &path, const std::string &seed)
|
|||||||
// TODO: wallet->init(daemon_address);
|
// TODO: wallet->init(daemon_address);
|
||||||
|
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
m_status = Status_Error;
|
m_status = Status_Critical;
|
||||||
m_errorString = e.what();
|
m_errorString = e.what();
|
||||||
}
|
}
|
||||||
return m_status == Status_Ok;
|
return m_status == Status_Ok;
|
||||||
@ -331,7 +331,12 @@ bool WalletImpl::close()
|
|||||||
bool result = false;
|
bool result = false;
|
||||||
LOG_PRINT_L3("closing wallet...");
|
LOG_PRINT_L3("closing wallet...");
|
||||||
try {
|
try {
|
||||||
|
// Do not store wallet with invalid status
|
||||||
|
// Status Critical refers to errors on opening or creating wallets.
|
||||||
|
if (status() != Status_Critical)
|
||||||
m_wallet->store();
|
m_wallet->store();
|
||||||
|
else
|
||||||
|
LOG_PRINT_L3("Status_Critical - not storing wallet");
|
||||||
LOG_PRINT_L3("wallet::store done");
|
LOG_PRINT_L3("wallet::store done");
|
||||||
LOG_PRINT_L3("Calling wallet::stop...");
|
LOG_PRINT_L3("Calling wallet::stop...");
|
||||||
m_wallet->stop();
|
m_wallet->stop();
|
||||||
@ -339,7 +344,7 @@ bool WalletImpl::close()
|
|||||||
result = true;
|
result = true;
|
||||||
clearStatus();
|
clearStatus();
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
m_status = Status_Error;
|
m_status = Status_Critical;
|
||||||
m_errorString = e.what();
|
m_errorString = e.what();
|
||||||
LOG_ERROR("Error closing wallet: " << e.what());
|
LOG_ERROR("Error closing wallet: " << e.what());
|
||||||
}
|
}
|
||||||
|
@ -1569,13 +1569,20 @@ bool wallet2::add_address_book_row(const cryptonote::account_public_address &add
|
|||||||
a.m_payment_id = payment_id;
|
a.m_payment_id = payment_id;
|
||||||
a.m_description = description;
|
a.m_description = description;
|
||||||
|
|
||||||
int key = (m_address_book.empty())? 0 : m_address_book.rbegin()->first;
|
int old_size = m_address_book.size();
|
||||||
bool r = m_address_book.emplace(++key,a).second;
|
m_address_book.push_back(a);
|
||||||
return r;
|
if(m_address_book.size() == old_size+1)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wallet2::delete_address_book_row(int row_id) {
|
bool wallet2::delete_address_book_row(int row_id) {
|
||||||
return (m_address_book.erase(row_id) > 0);
|
if(m_address_book.size() <= row_id)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_address_book.erase(m_address_book.begin()+row_id);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
@ -523,7 +523,7 @@ namespace tools
|
|||||||
/*!
|
/*!
|
||||||
* \brief GUI Address book get/store
|
* \brief GUI Address book get/store
|
||||||
*/
|
*/
|
||||||
std::map<int, address_book_row> get_address_book() const { return m_address_book; }
|
std::vector<address_book_row> get_address_book() const { return m_address_book; }
|
||||||
bool add_address_book_row(const cryptonote::account_public_address &address, const crypto::hash &payment_id, const std::string &description);
|
bool add_address_book_row(const cryptonote::account_public_address &address, const crypto::hash &payment_id, const std::string &description);
|
||||||
bool delete_address_book_row(int row_id);
|
bool delete_address_book_row(int row_id);
|
||||||
|
|
||||||
@ -641,7 +641,7 @@ namespace tools
|
|||||||
std::unordered_map<crypto::public_key, size_t> m_pub_keys;
|
std::unordered_map<crypto::public_key, size_t> m_pub_keys;
|
||||||
cryptonote::account_public_address m_account_public_address;
|
cryptonote::account_public_address m_account_public_address;
|
||||||
std::unordered_map<crypto::hash, std::string> m_tx_notes;
|
std::unordered_map<crypto::hash, std::string> m_tx_notes;
|
||||||
std::map<int, tools::wallet2::address_book_row> m_address_book;
|
std::vector<tools::wallet2::address_book_row> m_address_book;
|
||||||
uint64_t m_upper_transaction_size_limit; //TODO: auto-calc this value or request from daemon, now use some fixed value
|
uint64_t m_upper_transaction_size_limit; //TODO: auto-calc this value or request from daemon, now use some fixed value
|
||||||
|
|
||||||
std::atomic<bool> m_run;
|
std::atomic<bool> m_run;
|
||||||
|
@ -63,7 +63,8 @@ struct PendingTransaction
|
|||||||
{
|
{
|
||||||
enum Status {
|
enum Status {
|
||||||
Status_Ok,
|
Status_Ok,
|
||||||
Status_Error
|
Status_Error,
|
||||||
|
Status_Critical
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Priority {
|
enum Priority {
|
||||||
@ -221,7 +222,8 @@ struct Wallet
|
|||||||
|
|
||||||
enum Status {
|
enum Status {
|
||||||
Status_Ok,
|
Status_Ok,
|
||||||
Status_Error
|
Status_Error,
|
||||||
|
Status_Critical
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ConnectionStatus {
|
enum ConnectionStatus {
|
||||||
|
Loading…
Reference in New Issue
Block a user