mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-18 15:51:34 +02:00
remove standalone payment id from add/edit_address_book_entry
This commit is contained in:
@@ -2794,10 +2794,9 @@ namespace monero {
|
||||
return entries;
|
||||
}
|
||||
|
||||
uint64_t monero_wallet_core::add_address_book_entry(const string& address, const string& description, const string& payment_id) {
|
||||
uint64_t monero_wallet_core::add_address_book_entry(const string& address, const string& description) {
|
||||
MTRACE("add_address_book_entry()");
|
||||
cryptonote::address_parse_info info;
|
||||
crypto::hash payment_id_hash = crypto::null_hash;
|
||||
epee::json_rpc::error er;
|
||||
if(!get_account_address_from_str_or_url(info, m_w2->nettype(), address,
|
||||
[&er](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid)->std::string {
|
||||
@@ -2808,23 +2807,11 @@ namespace monero {
|
||||
{
|
||||
throw runtime_error(std::string("WALLET_RPC_ERROR_CODE_WRONG_ADDRESS: ") + address);
|
||||
}
|
||||
if (info.has_payment_id) {
|
||||
memcpy(payment_id_hash.data, info.payment_id.data, 8);
|
||||
memset(payment_id_hash.data + 8, 0, 24);
|
||||
}
|
||||
if (!payment_id.empty()) {
|
||||
if (info.has_payment_id) throw runtime_error("Separate payment ID given with integrated address");
|
||||
crypto::hash long_payment_id;
|
||||
if (!wallet2::parse_long_payment_id(payment_id, payment_id_hash)) {
|
||||
if (!wallet2::parse_short_payment_id(payment_id, info.payment_id)) throw runtime_error("Payment id has invalid format: \"" + payment_id + "\", expected 64 character string");
|
||||
else throw runtime_error("Payment id has invalid format: standalone short payment IDs are forbidden, they must be part of an integrated address");
|
||||
}
|
||||
}
|
||||
if (!m_w2->add_address_book_row(info.address, payment_id_hash, description, info.is_subaddress)) throw runtime_error("Failed to add address book entry");
|
||||
if (!m_w2->add_address_book_row(info.address, info.has_payment_id ? &info.payment_id : NULL, description, info.is_subaddress)) throw runtime_error("Failed to add address book entry");
|
||||
return m_w2->get_address_book().size() - 1;
|
||||
}
|
||||
|
||||
void monero_wallet_core::edit_address_book_entry(uint64_t index, bool set_address, const string& address, bool set_description, const string& description, bool set_payment_id, const string& payment_id) {
|
||||
void monero_wallet_core::edit_address_book_entry(uint64_t index, bool set_address, const string& address, bool set_description, const string& description) {
|
||||
MTRACE("edit_address_book_entry()");
|
||||
|
||||
const auto ab = m_w2->get_address_book();
|
||||
@@ -2833,7 +2820,6 @@ namespace monero {
|
||||
tools::wallet2::address_book_row entry = ab[index];
|
||||
|
||||
cryptonote::address_parse_info info;
|
||||
crypto::hash payment_id_hash = crypto::null_hash;
|
||||
epee::json_rpc::error er;
|
||||
if (set_address) {
|
||||
er.message = "";
|
||||
@@ -2848,29 +2834,12 @@ namespace monero {
|
||||
}
|
||||
entry.m_address = info.address;
|
||||
entry.m_is_subaddress = info.is_subaddress;
|
||||
if (info.has_payment_id) {
|
||||
memcpy(entry.m_payment_id.data, info.payment_id.data, 8);
|
||||
memset(entry.m_payment_id.data + 8, 0, 24);
|
||||
}
|
||||
}
|
||||
|
||||
if (set_payment_id) {
|
||||
if (payment_id.empty()) {
|
||||
payment_id_hash = crypto::null_hash;
|
||||
} else {
|
||||
if (set_address && info.has_payment_id) throw runtime_error("Separate payment ID given with integrated address");
|
||||
if (!wallet2::parse_long_payment_id(payment_id, payment_id_hash)) {
|
||||
crypto::hash8 spid;
|
||||
if (!wallet2::parse_short_payment_id(payment_id, spid)) throw runtime_error("Payment id has invalid format: \"" + payment_id + "\", expected 64 character string");
|
||||
else throw runtime_error("Payment id has invalid format: standalone short payment IDs are forbidden, they must be part of an integrated address");
|
||||
}
|
||||
}
|
||||
entry.m_payment_id = payment_id_hash;
|
||||
if (info.has_payment_id) entry.m_payment_id = info.payment_id;
|
||||
}
|
||||
|
||||
if (set_description) entry.m_description = description;
|
||||
|
||||
if (!m_w2->set_address_book_row(index, entry.m_address, entry.m_payment_id, entry.m_description, entry.m_is_subaddress)) {
|
||||
if (!m_w2->set_address_book_row(index, entry.m_address, set_address && entry.m_has_payment_id ? &entry.m_payment_id : NULL, entry.m_description, entry.m_is_subaddress)) {
|
||||
throw runtime_error("Failed to edit address book entry");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,8 +263,8 @@ namespace monero {
|
||||
void set_tx_note(const string& tx_hash, const string& note);
|
||||
void set_tx_notes(const vector<string>& tx_hashes, const vector<string>& notes);
|
||||
vector<monero_address_book_entry> get_address_book_entries(const vector<uint64_t>& indices) const;
|
||||
uint64_t add_address_book_entry(const string& address, const string& description, const string& payment_id = "");
|
||||
void edit_address_book_entry(uint64_t index, bool set_address, const string& address, bool set_description, const string& description, bool set_payment_id = false, const string& payment_id = "");
|
||||
uint64_t add_address_book_entry(const string& address, const string& description);
|
||||
void edit_address_book_entry(uint64_t index, bool set_address, const string& address, bool set_description, const string& description);
|
||||
void delete_address_book_entry(uint64_t index);
|
||||
string create_payment_uri(const monero_send_request& request) const;
|
||||
shared_ptr<monero_send_request> parse_payment_uri(const string& uri) const;
|
||||
|
||||
Reference in New Issue
Block a user