aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2020-10-13 10:39:05 -0500
committerluigi1111 <luigi1111w@gmail.com>2020-10-13 10:39:05 -0500
commite503688a6bf5ccc46057098c2aa790f2c520df39 (patch)
tree37c0a66e25e58a35211db703367a6e7c34200450 /src/wallet
parentMerge pull request #6822 (diff)
parentAllow AddressBook description edits via wallet/api interface (diff)
downloadmonero-e503688a6bf5ccc46057098c2aa790f2c520df39.tar.xz
Merge pull request #6828
1b3f220 Allow AddressBook description edits via wallet/api interface (xmrdsc)
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/api/address_book.cpp19
-rw-r--r--src/wallet/api/address_book.h1
-rw-r--r--src/wallet/api/wallet2_api.h1
3 files changed, 21 insertions, 0 deletions
diff --git a/src/wallet/api/address_book.cpp b/src/wallet/api/address_book.cpp
index f69a69ca3..96090d9f5 100644
--- a/src/wallet/api/address_book.cpp
+++ b/src/wallet/api/address_book.cpp
@@ -70,6 +70,25 @@ bool AddressBookImpl::addRow(const std::string &dst_addr , const std::string &pa
return r;
}
+bool AddressBookImpl::setDescription(std::size_t index, const std::string &description)
+{
+ clearStatus();
+
+ const auto ab = m_wallet->m_wallet->get_address_book();
+ if (index >= ab.size()){
+ return false;
+ }
+
+ tools::wallet2::address_book_row entry = ab[index];
+ entry.m_description = description;
+ bool r = m_wallet->m_wallet->set_address_book_row(index, entry.m_address, NULL, entry.m_description, entry.m_is_subaddress);
+ if (r)
+ refresh();
+ else
+ m_errorCode = General_Error;
+ return r;
+}
+
void AddressBookImpl::refresh()
{
LOG_PRINT_L2("Refreshing addressbook");
diff --git a/src/wallet/api/address_book.h b/src/wallet/api/address_book.h
index f287969f3..e22f474fb 100644
--- a/src/wallet/api/address_book.h
+++ b/src/wallet/api/address_book.h
@@ -45,6 +45,7 @@ public:
void refresh() override;
std::vector<AddressBookRow*> getAll() const override;
bool addRow(const std::string &dst_addr , const std::string &payment_id, const std::string &description) override;
+ bool setDescription(std::size_t index, const std::string &description) override;
bool deleteRow(std::size_t rowId) override;
// Error codes. See AddressBook:ErrorCode enum in wallet2_api.h
diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h
index 50df7e5dd..c2559d1df 100644
--- a/src/wallet/api/wallet2_api.h
+++ b/src/wallet/api/wallet2_api.h
@@ -250,6 +250,7 @@ struct AddressBook
virtual std::vector<AddressBookRow*> getAll() const = 0;
virtual bool addRow(const std::string &dst_addr , const std::string &payment_id, const std::string &description) = 0;
virtual bool deleteRow(std::size_t rowId) = 0;
+ virtual bool setDescription(std::size_t index, const std::string &description) = 0;
virtual void refresh() = 0;
virtual std::string errorString() const = 0;
virtual int errorCode() const = 0;