aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/api
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-03-14 19:13:55 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-03-16 12:07:45 +0000
commiteac3a11ed330faefa01685e98cf91e9ac1e31135 (patch)
tree0ab820cc329d2cf61fbe257df9ee62a254e85d9d /src/wallet/api
parentwallet2_api: add key reuse mitigations API (diff)
downloadmonero-eac3a11ed330faefa01685e98cf91e9ac1e31135.tar.xz
wallet: more user friendly print_ring
It can now take a txid (to display rings for all its inputs), and will print rings in a format that set_ring understands
Diffstat (limited to 'src/wallet/api')
-rw-r--r--src/wallet/api/wallet.cpp24
-rw-r--r--src/wallet/api/wallet.h1
-rw-r--r--src/wallet/api/wallet2_api.h3
3 files changed, 28 insertions, 0 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 4838395cd..b02884f67 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -1971,6 +1971,30 @@ bool WalletImpl::getRing(const std::string &key_image, std::vector<uint64_t> &ri
return true;
}
+bool WalletImpl::getRings(const std::string &txid, std::vector<std::pair<std::string, std::vector<uint64_t>>> &rings) const
+{
+ crypto::hash raw_txid;
+ if (!epee::string_tools::hex_to_pod(txid, raw_txid))
+ {
+ m_status = Status_Error;
+ m_errorString = tr("Failed to parse txid");
+ return false;
+ }
+ std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> raw_rings;
+ bool ret = m_wallet->get_rings(raw_txid, raw_rings);
+ if (!ret)
+ {
+ m_status = Status_Error;
+ m_errorString = tr("Failed to get rings");
+ return false;
+ }
+ for (const auto &r: raw_rings)
+ {
+ rings.push_back(std::make_pair(epee::string_tools::pod_to_hex(r.first), r.second));
+ }
+ return true;
+}
+
bool WalletImpl::setRing(const std::string &key_image, const std::vector<uint64_t> &ring, bool relative)
{
crypto::key_image raw_key_image;
diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h
index 4bde20959..4929c9673 100644
--- a/src/wallet/api/wallet.h
+++ b/src/wallet/api/wallet.h
@@ -166,6 +166,7 @@ public:
virtual bool blackballOutputs(const std::vector<std::string> &pubkeys, bool add);
virtual bool unblackballOutput(const std::string &pubkey);
virtual bool getRing(const std::string &key_image, std::vector<uint64_t> &ring) const;
+ virtual bool getRings(const std::string &txid, std::vector<std::pair<std::string, std::vector<uint64_t>>> &rings) const;
virtual bool setRing(const std::string &key_image, const std::vector<uint64_t> &ring, bool relative);
virtual void segregatePreForkOutputs(bool segregate);
virtual void segregationHeight(uint64_t height);
diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h
index c77e495a2..d4e41c5aa 100644
--- a/src/wallet/api/wallet2_api.h
+++ b/src/wallet/api/wallet2_api.h
@@ -766,6 +766,9 @@ struct Wallet
//! 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;
+ //! gets the rings used for a txid, if any
+ virtual bool getRings(const std::string &txid, std::vector<std::pair<std::string, std::vector<uint64_t>>> &rings) 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;