wallet2_api: add ring api

This commit is contained in:
moneromooo-monero 2018-03-05 15:04:59 +00:00
parent d32ef7b0f2
commit b057a21d56
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
3 changed files with 46 additions and 0 deletions

View file

@ -1952,6 +1952,44 @@ bool WalletImpl::unblackballOutput(const std::string &pubkey)
return true; return true;
} }
bool WalletImpl::getRing(const std::string &key_image, std::vector<uint64_t> &ring) const
{
crypto::key_image raw_key_image;
if (!epee::string_tools::hex_to_pod(key_image, raw_key_image))
{
m_status = Status_Error;
m_errorString = tr("Failed to parse key image");
return false;
}
bool ret = m_wallet->get_ring(raw_key_image, ring);
if (!ret)
{
m_status = Status_Error;
m_errorString = tr("Failed to get ring");
return false;
}
return true;
}
bool WalletImpl::setRing(const std::string &key_image, const std::vector<uint64_t> &ring, bool relative)
{
crypto::key_image raw_key_image;
if (!epee::string_tools::hex_to_pod(key_image, raw_key_image))
{
m_status = Status_Error;
m_errorString = tr("Failed to parse key image");
return false;
}
bool ret = m_wallet->set_ring(raw_key_image, ring, relative);
if (!ret)
{
m_status = Status_Error;
m_errorString = tr("Failed to set ring");
return false;
}
return true;
}
} // namespace } // namespace
namespace Bitmonero = Monero; namespace Bitmonero = Monero;

View file

@ -165,6 +165,8 @@ public:
virtual bool lightWalletImportWalletRequest(std::string &payment_id, uint64_t &fee, bool &new_request, bool &request_fulfilled, std::string &payment_address, std::string &status); virtual bool lightWalletImportWalletRequest(std::string &payment_id, uint64_t &fee, bool &new_request, bool &request_fulfilled, std::string &payment_address, std::string &status);
virtual bool blackballOutputs(const std::vector<std::string> &pubkeys, bool add); virtual bool blackballOutputs(const std::vector<std::string> &pubkeys, bool add);
virtual bool unblackballOutput(const std::string &pubkey); virtual bool unblackballOutput(const std::string &pubkey);
virtual bool getRing(const std::string &key_image, std::vector<uint64_t> &ring) const;
virtual bool setRing(const std::string &key_image, const std::vector<uint64_t> &ring, bool relative);
private: private:
void clearStatus() const; void clearStatus() const;

View file

@ -763,6 +763,12 @@ struct Wallet
//! unblackballs an output //! unblackballs an output
virtual bool unblackballOutput(const std::string &pubkey) = 0; virtual bool unblackballOutput(const std::string &pubkey) = 0;
//! gets the ring used for a key image, if any
virtual bool getRing(const std::string &key_image, std::vector<uint64_t> &ring) const = 0;
//! sets the ring used for a key image
virtual bool setRing(const std::string &key_image, const std::vector<uint64_t> &ring, bool relative) = 0;
//! Light wallet authenticate and login //! Light wallet authenticate and login
virtual bool lightWalletLogin(bool &isNewWallet) const = 0; virtual bool lightWalletLogin(bool &isNewWallet) const = 0;