From 712886a345c2e34dc091db6c483ba2ad76fd8f57 Mon Sep 17 00:00:00 2001 From: Jerzy Kozera Date: Wed, 16 Dec 2015 19:51:54 +0100 Subject: [PATCH] Fixed errors after receiving a tx with wrong scanning key After someone sent a transaction using a wrong scanning key to an alphad wallet, "CWallet::GetCredit() : value out of range" errors were returned on attempts to get balance or create new outgoing transactions. This change causes such outputs to be ignored, thus preventing wallet from being locked down this way. --- src/wallet.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wallet.h b/src/wallet.h index 7a4c0217cb..a8f12e292d 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -737,6 +737,10 @@ public: CAmount amount = 0; if (pwallet->IsMine(vout[nTxOut]) & filter) amount = GetValueOut(nTxOut); + // Can be -1 if someone sent us a transaction using a wrong scanning key: + if (amount == -1) { + return 0; + } if (!MoneyRange(amount)) throw std::runtime_error("CWallet::GetCredit() : value out of range"); return amount;