expose set/get walletcache attribute functionality in wallet api

This commit is contained in:
dsc 2019-05-10 17:45:44 +02:00 committed by selsta
parent 2bf855e3cd
commit 4c666141e3
3 changed files with 28 additions and 0 deletions

View file

@ -1697,6 +1697,17 @@ void WalletImpl::setDefaultMixin(uint32_t arg)
m_wallet->default_mixin(arg); m_wallet->default_mixin(arg);
} }
bool WalletImpl::setCacheAttribute(const std::string &key, const std::string &val)
{
m_wallet->set_attribute(key, val);
return true;
}
std::string WalletImpl::getCacheAttribute(const std::string &key) const
{
return m_wallet->get_attribute(key);
}
bool WalletImpl::setUserNote(const std::string &txid, const std::string &note) bool WalletImpl::setUserNote(const std::string &txid, const std::string &note)
{ {
cryptonote::blobdata txid_data; cryptonote::blobdata txid_data;

View file

@ -168,6 +168,10 @@ public:
virtual void setListener(WalletListener * l) override; virtual void setListener(WalletListener * l) override;
virtual uint32_t defaultMixin() const override; virtual uint32_t defaultMixin() const override;
virtual void setDefaultMixin(uint32_t arg) override; virtual void setDefaultMixin(uint32_t arg) override;
virtual bool setCacheAttribute(const std::string &key, const std::string &val) override;
virtual std::string getCacheAttribute(const std::string &key) const override;
virtual bool setUserNote(const std::string &txid, const std::string &note) override; virtual bool setUserNote(const std::string &txid, const std::string &note) override;
virtual std::string getUserNote(const std::string &txid) const override; virtual std::string getUserNote(const std::string &txid) const override;
virtual std::string getTxKey(const std::string &txid) const override; virtual std::string getTxKey(const std::string &txid) const override;

View file

@ -890,6 +890,19 @@ struct Wallet
*/ */
virtual void setDefaultMixin(uint32_t arg) = 0; virtual void setDefaultMixin(uint32_t arg) = 0;
/*!
* \brief setCacheAttribute - attach an arbitrary string to a wallet cache attribute
* \param key - the key
* \param val - the value
* \return true if successful, false otherwise
*/
virtual bool setCacheAttribute(const std::string &key, const std::string &val) = 0;
/*!
* \brief getCacheAttribute - return an arbitrary string attached to a wallet cache attribute
* \param key - the key
* \return the attached string, or empty string if there is none
*/
virtual std::string getCacheAttribute(const std::string &key) const = 0;
/*! /*!
* \brief setUserNote - attach an arbitrary string note to a txid * \brief setUserNote - attach an arbitrary string note to a txid
* \param txid - the transaction id to attach the note to * \param txid - the transaction id to attach the note to