46 : m_wallet(wallet), m_errorCode(Status_Ok) {}
54 m_errorString =
tr(
"Invalid destination address");
63 if(payment_id_str.length() == 16) {
64 m_errorString =
tr(
"Invalid payment ID. Short payment ID should only be used in an integrated address");
70 if(!payment_id_str.empty() && !has_long_pid) {
71 m_errorString =
tr(
"Invalid payment ID");
77 if(has_long_pid &&
info.has_payment_id) {
78 m_errorString =
tr(
"Integrated address and long payment ID can't be used at the same time");
84 if (
info.has_payment_id)
86 memcpy(payment_id.data,
info.payment_id.data, 8);
89 bool r = m_wallet->m_wallet->add_address_book_row(
info.address,payment_id,description,
info.is_subaddress);
104 std::vector<tools::wallet2::address_book_row>
rows = m_wallet->m_wallet->get_address_book();
105 for (
size_t i = 0; i <
rows.size(); ++i) {
111 if (!row->
m_is_subaddress && payment_id.length() > 16 && payment_id.substr(16).find_first_not_of(
'0') == std::string::npos) {
112 payment_id = payment_id.substr(0,16);
121 m_rows.push_back(abr);
129 bool r = m_wallet->m_wallet->delete_address_book_row(rowId);
141 for (
const auto &row: m_rows) {
144 if (payment_id == row->getPaymentId())
147 if (long_payment_id == row->getPaymentId())
150 const std::string long_row_payment_id = row->getPaymentId() +
std::string(64 - row->getPaymentId().size(),
'0');
151 if (payment_id == long_row_payment_id)
157 void AddressBookImpl::clearRows() {
158 for (
auto r : m_rows) {
164 void AddressBookImpl::clearStatus(){
std::string get_account_address_as_str(network_type nettype, bool subaddress, account_public_address const &adr)
bool addRow(const std::string &dst_addr, const std::string &payment_id, const std::string &description) override
std::vector< AddressBookRow * > getAll() const override
std::string get_account_integrated_address_as_str(network_type nettype, account_public_address const &adr, crypto::hash8 const &payment_id)
bool deleteRow(std::size_t rowId) override
AddressBookImpl(WalletImpl *wallet)
AddressBookRow - provides functions to manage address book.
void * memcpy(void *a, const void *b, size_t c)
bool get_account_address_from_str(address_parse_info &info, network_type nettype, std::string const &str)
int lookupPaymentID(const std::string &payment_id) const override