aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet2.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2019-04-11 13:05:42 +0200
committerRiccardo Spagni <ric@spagni.net>2019-04-11 13:05:43 +0200
commit5db72d12b428e21ad1cd292df4d13aee5c273b95 (patch)
tree517e7df6a38e956ba9e31395ec8c7025d2c42469 /src/wallet/wallet2.cpp
parentMerge pull request #5382 (diff)
parentsimplewallet: new unset_ring command (diff)
downloadmonero-5db72d12b428e21ad1cd292df4d13aee5c273b95.tar.xz
Merge pull request #5388
0be5b2ee simplewallet: new unset_ring command (moneromooo-monero)
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 39fe4608c..dfcc61426 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -7094,6 +7094,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)