mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-17 15:21:30 +02:00
implement get_address_book_entries() and delete_address_book_entry()
This commit is contained in:
@@ -2791,19 +2791,43 @@ namespace monero {
|
||||
}
|
||||
|
||||
vector<monero_address_book_entry> monero_wallet::get_address_book_entries(const vector<uint32_t>& indices) const {
|
||||
throw runtime_error("get_address_book_entries() not implemented");
|
||||
MTRACE("monero_wallet::get_address_book_entries()");
|
||||
|
||||
// get wallet2 address book entries
|
||||
const auto w2_entries = m_w2->get_address_book();
|
||||
|
||||
// build entries from wallet2 types
|
||||
vector<monero_address_book_entry> entries;
|
||||
if (indices.empty()) {
|
||||
uint64_t idx = 0;
|
||||
for (const auto &w2_entry: w2_entries) {
|
||||
monero_address_book_entry entry(idx++, cryptonote::get_account_address_as_str(m_w2->nettype(), w2_entry.m_is_subaddress, w2_entry.m_address), w2_entry.m_description, epee::string_tools::pod_to_hex(w2_entry.m_payment_id));
|
||||
entries.push_back(entry);
|
||||
}
|
||||
} else {
|
||||
for (uint64_t idx : indices) {
|
||||
if (idx >= w2_entries.size()) throw runtime_error("Index out of range: " + std::to_string(idx));
|
||||
const auto &w2_entry = w2_entries[idx];
|
||||
monero_address_book_entry entry(idx++, cryptonote::get_account_address_as_str(m_w2->nettype(), w2_entry.m_is_subaddress, w2_entry.m_address), w2_entry.m_description, epee::string_tools::pod_to_hex(w2_entry.m_payment_id));
|
||||
entries.push_back(entry);
|
||||
}
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
uint32_t monero_wallet::add_address_book_entry(const string& address, boost::optional<string> description, boost::optional<string> payment_id) {
|
||||
throw runtime_error("add_address_book_entry() not implemented");
|
||||
}
|
||||
|
||||
void monero_wallet::edit_address_book_entry(uint32_t index, bool set_address, boost::optional<string> address, bool set_description, boost::optional<string> description, bool set_payment_id, boost::optional<string> payment_id) {
|
||||
void monero_wallet::edit_address_book_entry(uint64_t index, bool set_address, boost::optional<string> address, bool set_description, boost::optional<string> description, bool set_payment_id, boost::optional<string> payment_id) {
|
||||
throw runtime_error("edit_address_book_entry() not implemented");
|
||||
}
|
||||
|
||||
void monero_wallet::delete_address_book_entry(uint32_t index) {
|
||||
throw runtime_error("delete_address_book_entry() not implemented");
|
||||
void monero_wallet::delete_address_book_entry(uint64_t index) {
|
||||
const auto w2_entries = m_w2->get_address_book();
|
||||
if (index >= w2_entries.size()) throw runtime_error("Index out of range: " + std::to_string(index));
|
||||
if (!m_w2->delete_address_book_row(index)) throw runtime_error("Failed to delete address book entry");
|
||||
}
|
||||
|
||||
string monero_wallet::create_payment_uri(const monero_send_request& request) const {
|
||||
|
||||
@@ -1195,14 +1195,14 @@ namespace monero {
|
||||
* @param set_payment_id specifies if the payment id should be updated
|
||||
* @param payment_id is the updated payment id
|
||||
*/
|
||||
void edit_address_book_entry(uint32_t index, bool set_address, boost::optional<string> address, bool set_description, boost::optional<string> description, bool set_payment_id, boost::optional<string> payment_id);
|
||||
void edit_address_book_entry(uint64_t index, bool set_address, boost::optional<string> address, bool set_description, boost::optional<string> description, bool set_payment_id, boost::optional<string> payment_id);
|
||||
|
||||
/**
|
||||
* Delete an address book entry.
|
||||
*
|
||||
* @param index is the index of the entry to delete
|
||||
*/
|
||||
void delete_address_book_entry(uint32_t index);
|
||||
void delete_address_book_entry(uint64_t index);
|
||||
|
||||
// /**
|
||||
// * Tag accounts.
|
||||
|
||||
@@ -448,11 +448,13 @@ namespace monero {
|
||||
* Monero address book entry model.
|
||||
*/
|
||||
struct monero_address_book_entry : serializable_struct {
|
||||
boost::optional<uint32_t> m_index;
|
||||
boost::optional<uint64_t> m_index; // TODO: not boost::optional
|
||||
boost::optional<string> m_address;
|
||||
boost::optional<string> m_description;
|
||||
boost::optional<string> m_payment_id;
|
||||
|
||||
monero_address_book_entry() {}
|
||||
monero_address_book_entry(uint64_t index, const string& address, const string& description, const string& payment_id) : m_index(index), m_address(address), m_description(description), m_payment_id(payment_id) {}
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user