diff options
author | Riccardo Spagni <ric@spagni.net> | 2016-11-08 22:45:54 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2016-11-08 22:45:54 +0200 |
commit | af2ceb29fa5c569714b12d97a206759d5184ee78 (patch) | |
tree | 42589e81c1e9422a8fd4a069ee22e7458407ecf0 /src/wallet/api | |
parent | Merge pull request #1297 (diff) | |
parent | wallet2_api: add API for tx notes (diff) | |
download | monero-af2ceb29fa5c569714b12d97a206759d5184ee78.tar.xz |
Merge pull request #1298
97288a5 wallet2_api: add API for tx notes (moneromooo-monero)
Diffstat (limited to 'src/wallet/api')
-rw-r--r-- | src/wallet/api/pending_transaction.cpp | 8 | ||||
-rw-r--r-- | src/wallet/api/pending_transaction.h | 1 | ||||
-rw-r--r-- | src/wallet/api/wallet.cpp | 20 | ||||
-rw-r--r-- | src/wallet/api/wallet.h | 2 |
4 files changed, 31 insertions, 0 deletions
diff --git a/src/wallet/api/pending_transaction.cpp b/src/wallet/api/pending_transaction.cpp index 26ce9fc7e..e1a5e7674 100644 --- a/src/wallet/api/pending_transaction.cpp +++ b/src/wallet/api/pending_transaction.cpp @@ -69,6 +69,14 @@ string PendingTransactionImpl::errorString() const return m_errorString; } +std::vector<std::string> PendingTransactionImpl::txid() const +{ + std::vector<std::string> txid; + for (const auto &pt: m_pending_tx) + txid.push_back(epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(pt.tx))); + return txid; +} + bool PendingTransactionImpl::commit() { diff --git a/src/wallet/api/pending_transaction.h b/src/wallet/api/pending_transaction.h index 8e09bec91..2f06d2f6e 100644 --- a/src/wallet/api/pending_transaction.h +++ b/src/wallet/api/pending_transaction.h @@ -49,6 +49,7 @@ public: uint64_t amount() const; uint64_t dust() const; uint64_t fee() const; + std::vector<std::string> txid() const; // TODO: continue with interface; private: diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index 9a9638b40..7227b6b4d 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -707,6 +707,26 @@ void WalletImpl::setDefaultMixin(uint32_t arg) m_wallet->default_mixin(arg); } +bool WalletImpl::setUserNote(const std::string &txid, const std::string ¬e) +{ + cryptonote::blobdata txid_data; + if(!epee::string_tools::parse_hexstr_to_binbuff(txid, txid_data)) + return false; + const crypto::hash htxid = *reinterpret_cast<const crypto::hash*>(txid_data.data()); + + m_wallet->set_tx_note(htxid, note); + return true; +} + +std::string WalletImpl::getUserNote(const std::string &txid) const +{ + cryptonote::blobdata txid_data; + if(!epee::string_tools::parse_hexstr_to_binbuff(txid, txid_data)) + return ""; + const crypto::hash htxid = *reinterpret_cast<const crypto::hash*>(txid_data.data()); + + return m_wallet->get_tx_note(htxid); +} bool WalletImpl::connectToDaemon() { diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h index c8a59f7c3..69c27b035 100644 --- a/src/wallet/api/wallet.h +++ b/src/wallet/api/wallet.h @@ -97,6 +97,8 @@ public: virtual void setListener(WalletListener * l); virtual uint32_t defaultMixin() const; virtual void setDefaultMixin(uint32_t arg); + virtual bool setUserNote(const std::string &txid, const std::string ¬e); + virtual std::string getUserNote(const std::string &txid) const; private: void clearStatus(); |