diff options
| author | Riccardo Spagni <ric@spagni.net> | 2017-01-08 16:42:08 -0800 |
|---|---|---|
| committer | Riccardo Spagni <ric@spagni.net> | 2017-01-08 16:42:08 -0800 |
| commit | 6cbfe0f849d6e3e96f82ce314b85ce0f8c1ef32e (patch) | |
| tree | 33a162a4e7eb93aac62e90572357039720f52702 /src/wallet/api/address_book.cpp | |
| parent | ba9744d4000268dedb08a00125776ccf526064f7 (diff) | |
| parent | 21c5af5a8a20a58cb913ac0a417ba3d508b2ef91 (diff) | |
| download | monzero-core-6cbfe0f849d6e3e96f82ce314b85ce0f8c1ef32e.tar.gz monzero-core-6cbfe0f849d6e3e96f82ce314b85ce0f8c1ef32e.tar.xz monzero-core-6cbfe0f849d6e3e96f82ce314b85ce0f8c1ef32e.zip | |
Merge pull request #1521
21c5af5a wallet2_api: add an address book payment id lookup API (moneromooo-monero)
Diffstat (limited to 'src/wallet/api/address_book.cpp')
| -rw-r--r-- | src/wallet/api/address_book.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/wallet/api/address_book.cpp b/src/wallet/api/address_book.cpp index bbf96c81a..b878491ce 100644 --- a/src/wallet/api/address_book.cpp +++ b/src/wallet/api/address_book.cpp @@ -103,6 +103,28 @@ bool AddressBookImpl::deleteRow(std::size_t rowId) return r; } +int AddressBookImpl::lookupPaymentID(const std::string &payment_id) const +{ + // turn short ones into long ones for comparison + const std::string long_payment_id = payment_id + std::string(64 - payment_id.size(), '0'); + + int idx = -1; + for (const auto &row: m_rows) { + ++idx; + // this does short/short and long/long + if (payment_id == row->getPaymentId()) + return idx; + // short/long + if (long_payment_id == row->getPaymentId()) + return idx; + // one case left: payment_id was long, row's is short + const std::string long_row_payment_id = row->getPaymentId() + std::string(64 - row->getPaymentId().size(), '0'); + if (payment_id == long_row_payment_id) + return idx; + } + return -1; +} + void AddressBookImpl::clearRows() { for (auto r : m_rows) { delete r; |
