aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/api
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-11-19 16:30:19 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-01-26 00:03:53 +0000
commitdd8c6b170386b64ae1d4344c7abd93d7b814a43b (patch)
treedbba8d82ef4bfc7a14fcbf9de9066c8914ebbd12 /src/wallet/api
parentMerge pull request #6093 (diff)
downloadmonero-dd8c6b170386b64ae1d4344c7abd93d7b814a43b.tar.xz
wallet: do not split integrated addresses in address book api
Diffstat (limited to 'src/wallet/api')
-rw-r--r--src/wallet/api/address_book.cpp50
1 files changed, 10 insertions, 40 deletions
diff --git a/src/wallet/api/address_book.cpp b/src/wallet/api/address_book.cpp
index 7be78bba7..005ddf7ee 100644
--- a/src/wallet/api/address_book.cpp
+++ b/src/wallet/api/address_book.cpp
@@ -55,37 +55,14 @@ bool AddressBookImpl::addRow(const std::string &dst_addr , const std::string &pa
return false;
}
- crypto::hash payment_id = crypto::null_hash;
- bool has_long_pid = (payment_id_str.empty())? false : tools::wallet2::parse_long_payment_id(payment_id_str, payment_id);
-
- // Short payment id provided
- if(payment_id_str.length() == 16) {
- m_errorString = tr("Invalid payment ID. Short payment ID should only be used in an integrated address");
- m_errorCode = Invalid_Payment_Id;
- return false;
- }
-
- // long payment id provided but not valid
- if(!payment_id_str.empty() && !has_long_pid) {
- m_errorString = tr("Invalid payment ID");
- m_errorCode = Invalid_Payment_Id;
- return false;
- }
-
- // integrated + long payment id provided
- if(has_long_pid && info.has_payment_id) {
- m_errorString = tr("Integrated address and long payment ID can't be used at the same time");
+ if (!payment_id_str.empty())
+ {
+ m_errorString = tr("Payment ID supplied: this is obsolete");
m_errorCode = Invalid_Payment_Id;
return false;
}
- // Pad short pid with zeros
- if (info.has_payment_id)
- {
- memcpy(payment_id.data, info.payment_id.data, 8);
- }
-
- bool r = m_wallet->m_wallet->add_address_book_row(info.address,payment_id,description,info.is_subaddress);
+ bool r = m_wallet->m_wallet->add_address_book_row(info.address, info.has_payment_id ? &info.payment_id : NULL,description,info.is_subaddress);
if (r)
refresh();
else
@@ -104,19 +81,12 @@ void AddressBookImpl::refresh()
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 == crypto::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->nettype(), row->m_is_subaddress, row->m_address);
- // convert the zero padded short payment id to integrated address
- if (!row->m_is_subaddress && payment_id.length() > 16 && payment_id.substr(16).find_first_not_of('0') == std::string::npos) {
- payment_id = payment_id.substr(0,16);
- crypto::hash8 payment_id_short;
- if(tools::wallet2::parse_short_payment_id(payment_id, payment_id_short)) {
- address = cryptonote::get_account_integrated_address_as_str(m_wallet->m_wallet->nettype(), row->m_address, payment_id_short);
- // Don't show payment id when integrated address is used
- payment_id = "";
- }
- }
- AddressBookRow * abr = new AddressBookRow(i, address, payment_id, row->m_description);
+ std::string address;
+ if (row->m_has_payment_id)
+ address = cryptonote::get_account_integrated_address_as_str(m_wallet->m_wallet->nettype(), row->m_address, row->m_payment_id);
+ else
+ address = get_account_address_as_str(m_wallet->m_wallet->nettype(), row->m_is_subaddress, row->m_address);
+ AddressBookRow * abr = new AddressBookRow(i, address, "", row->m_description);
m_rows.push_back(abr);
}