From cfd7928365849af9e343cf644c16009319cb3fcd Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 6 Apr 2018 20:34:28 +0100 Subject: [PATCH] wallet2: fix misc issues when the ringdb can't be initialized --- src/wallet/wallet2.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 113f546ce..a7aa42dce 100755 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -5506,7 +5506,8 @@ bool wallet2::add_rings(const crypto::chacha_key &key, const cryptonote::transac { if (!m_ringdb) return false; - return m_ringdb->add_rings(key, tx); + try { return m_ringdb->add_rings(key, tx); } + catch (const std::exception &e) { return false; } } bool wallet2::add_rings(const cryptonote::transaction_prefix &tx) @@ -5529,7 +5530,8 @@ bool wallet2::get_ring(const crypto::chacha_key &key, const crypto::key_image &k { if (!m_ringdb) return false; - return m_ringdb->get_ring(key, key_image, outs); + try { return m_ringdb->get_ring(key, key_image, outs); } + catch (const std::exception &e) { return false; } } bool wallet2::get_rings(const crypto::hash &txid, std::vector>> &outs) @@ -5650,33 +5652,40 @@ bool wallet2::blackball_output(const crypto::public_key &output) { if (!m_ringdb) return false; - return m_ringdb->blackball(output); + try { return m_ringdb->blackball(output); } + catch (const std::exception &e) { return false; } } bool wallet2::set_blackballed_outputs(const std::vector &outputs, bool add) { if (!m_ringdb) return false; - bool ret = true; - if (!add) - ret &= m_ringdb->clear_blackballs(); - for (const auto &output: outputs) - ret &= m_ringdb->blackball(output); - return ret; + try + { + bool ret = true; + if (!add) + ret &= m_ringdb->clear_blackballs(); + for (const auto &output: outputs) + ret &= m_ringdb->blackball(output); + return ret; + } + catch (const std::exception &e) { return false; } } bool wallet2::unblackball_output(const crypto::public_key &output) { if (!m_ringdb) return false; - return m_ringdb->unblackball(output); + try { return m_ringdb->unblackball(output); } + catch (const std::exception &e) { return false; } } bool wallet2::is_output_blackballed(const crypto::public_key &output) const { if (!m_ringdb) return false; - return m_ringdb->blackballed(output); + try { return m_ringdb->blackballed(output); } + catch (const std::exception &e) { return false; } } bool wallet2::tx_add_fake_output(std::vector> &outs, uint64_t global_index, const crypto::public_key& output_public_key, const rct::key& mask, uint64_t real_index, bool unlocked) const