aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/api/address_book.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2016-12-12 23:46:47 +0200
committerRiccardo Spagni <ric@spagni.net>2016-12-12 23:46:47 +0200
commit1a286061ff294f8fd8910492e1725b08d0942377 (patch)
tree8b340ead05c950767ba6f8776a864eff2afced39 /src/wallet/api/address_book.cpp
parentMerge pull request #1424 (diff)
parentaddressbook updates (diff)
downloadmonero-1a286061ff294f8fd8910492e1725b08d0942377.tar.xz
Merge pull request #1436
3b4539ee addressbook updates (Jaquee)
Diffstat (limited to 'src/wallet/api/address_book.cpp')
-rw-r--r--src/wallet/api/address_book.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/wallet/api/address_book.cpp b/src/wallet/api/address_book.cpp
index 198ce17cd..edeb5bb46 100644
--- a/src/wallet/api/address_book.cpp
+++ b/src/wallet/api/address_book.cpp
@@ -79,16 +79,16 @@ void AddressBookImpl::refresh()
LOG_PRINT_L2("Refreshing addressbook");
clearRows();
-
- // Fetch from Wallet2 and create vector
- for (auto const &a : m_wallet->m_wallet->get_address_book() ) {
- auto row = a.second;
- int rowId = a.first;
-
- 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);
-
- AddressBookRow * abr = new AddressBookRow(rowId, address, payment_id, row.m_description);
+
+ // Fetch from Wallet2 and create vector of AddressBookRow objects
+ std::vector<tools::wallet2::address_book_row> rows = m_wallet->m_wallet->get_address_book();
+ for (size_t i = 0; i < rows.size(); ++i) {
+ 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 address = cryptonote::get_account_address_as_str(m_wallet->m_wallet->testnet(),row->m_address);
+
+ AddressBookRow * abr = new AddressBookRow(i, address, payment_id, row->m_description);
m_rows.push_back(abr);
}
@@ -98,7 +98,8 @@ bool AddressBookImpl::deleteRow(int rowId)
{
LOG_PRINT_L2("Deleting address book row " << rowId);
bool r = m_wallet->m_wallet->delete_address_book_row(rowId);
- refresh();
+ if (r)
+ refresh();
return r;
}