diff options
author | Riccardo Spagni <ric@spagni.net> | 2018-02-20 17:46:29 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2018-02-20 17:46:29 +0200 |
commit | 6920fdaf4f6c9b47dcc1678c9e3185271942070d (patch) | |
tree | 049f3dd003d6c70ef048335062ce02fcbae97d9c /src/wallet | |
parent | Merge pull request #3243 (diff) | |
parent | wallet2: don't store invalid key image when watch-only (diff) | |
download | monero-6920fdaf4f6c9b47dcc1678c9e3185271942070d.tar.xz |
Merge pull request #3246
3c33e131 wallet2: don't store invalid key image when watch-only (stoffu)
0133b348 wallet2: don't throw when spent amount is inconsistent (stoffu)
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/wallet2.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index d97e53011..4bcc0b24a 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1218,7 +1218,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote td.m_rct = false; } set_unspent(m_transfers.size()-1); - if (!m_multisig) + if (!m_multisig && !m_watch_only) m_key_images[td.m_key_image] = m_transfers.size()-1; m_pub_keys[tx_scan_info[o].in_ephemeral.pub] = m_transfers.size()-1; if (m_multisig) @@ -1312,11 +1312,21 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote uint64_t amount = boost::get<cryptonote::txin_to_key>(in).amount; if (amount > 0) { - THROW_WALLET_EXCEPTION_IF(amount != td.amount(), error::wallet_internal_error, - std::string("Inconsistent amount in tx input: got ") + print_money(amount) + - std::string(", expected ") + print_money(td.amount())); + if(amount != td.amount()) + { + MERROR("Inconsistent amount in tx input: got " << print_money(amount) << + ", expected " << print_money(td.amount())); + // this means: + // 1) the same output pub key was used as destination multiple times, + // 2) the wallet set the highest amount among them to transfer_details::m_amount, and + // 3) the wallet somehow spent that output with an amount smaller than the above amount, causing inconsistency + td.m_amount = amount; + } + } + else + { + amount = td.amount(); } - amount = td.amount(); tx_money_spent_in_ins += amount; if (subaddr_account && *subaddr_account != td.m_subaddr_index.major) LOG_ERROR("spent funds are from different subaddress accounts; count of incoming/outgoing payments will be incorrect"); |