aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet2.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-04-02 14:03:25 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-04-02 14:18:07 +0000
commit0be5b2ee78efaa242757ca8f998a091f8930788d (patch)
treed8a02f45e707087a2c8872979cfc1425f6475c04 /src/wallet/wallet2.cpp
parentMerge pull request #5387 (diff)
downloadmonero-0be5b2ee78efaa242757ca8f998a091f8930788d.tar.xz
simplewallet: new unset_ring command
Useful when debugging, though not much for users
Diffstat (limited to 'src/wallet/wallet2.cpp')
-rw-r--r--src/wallet/wallet2.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 0e82f1a91..f066c9c14 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -7040,6 +7040,43 @@ bool wallet2::set_ring(const crypto::key_image &key_image, const std::vector<uin
catch (const std::exception &e) { return false; }
}
+bool wallet2::unset_ring(const std::vector<crypto::key_image> &key_images)
+{
+ if (!m_ringdb)
+ return false;
+
+ try { return m_ringdb->remove_rings(get_ringdb_key(), key_images); }
+ catch (const std::exception &e) { return false; }
+}
+
+bool wallet2::unset_ring(const crypto::hash &txid)
+{
+ if (!m_ringdb)
+ return false;
+
+ COMMAND_RPC_GET_TRANSACTIONS::request req;
+ COMMAND_RPC_GET_TRANSACTIONS::response res;
+ req.txs_hashes.push_back(epee::string_tools::pod_to_hex(txid));
+ req.decode_as_json = false;
+ req.prune = true;
+ m_daemon_rpc_mutex.lock();
+ bool ok = epee::net_utils::invoke_http_json("/gettransactions", req, res, m_http_client);
+ m_daemon_rpc_mutex.unlock();
+ THROW_WALLET_EXCEPTION_IF(!ok, error::wallet_internal_error, "Failed to get transaction from daemon");
+ if (res.txs.empty())
+ return false;
+ THROW_WALLET_EXCEPTION_IF(res.txs.size(), error::wallet_internal_error, "Failed to get transaction from daemon");
+
+ cryptonote::transaction tx;
+ crypto::hash tx_hash;
+ if (!get_pruned_tx(res.txs.front(), tx, tx_hash))
+ return false;
+ THROW_WALLET_EXCEPTION_IF(tx_hash != txid, error::wallet_internal_error, "Failed to get the right transaction from daemon");
+
+ try { return m_ringdb->remove_rings(get_ringdb_key(), tx); }
+ catch (const std::exception &e) { return false; }
+}
+
bool wallet2::find_and_save_rings(bool force)
{
if (!force && m_ring_history_saved)