aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-06-10 09:42:42 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-06-12 15:28:41 +0200
commit18116b06c177acb97ad1051a0d5da92251adf2dc (patch)
treeaa649517b36605d746f669962022f57d4d2f8901 /src/wallet.cpp
parente5ee8f016ebb1db1bac3c4d0dd895249a4a17a1d (diff)
downloadbitcoin-18116b06c177acb97ad1051a0d5da92251adf2dc.tar.xz
Ignore too-long redeemScripts while loading wallet
This avoids that long redeemScripts that were grandfathered in prevent the wallet from loading. Fixes #4313.
Diffstat (limited to 'src/wallet.cpp')
-rw-r--r--src/wallet.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index ef0b442e1a..400c966a95 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -128,6 +128,22 @@ bool CWallet::AddCScript(const CScript& redeemScript)
return CWalletDB(strWalletFile).WriteCScript(Hash160(redeemScript), redeemScript);
}
+bool CWallet::LoadCScript(const CScript& redeemScript)
+{
+ /* A sanity check was added in pull #3843 to avoid adding redeemScripts
+ * that never can be redeemed. However, old wallets may still contain
+ * these. Do not add them to the wallet and warn. */
+ if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE)
+ {
+ std::string strAddr = CBitcoinAddress(redeemScript.GetID()).ToString();
+ LogPrintf("%s: Warning: This wallet contains a redeemScript of size %i which exceeds maximum size %i thus can never be redeemed. Do not use address %s.\n",
+ __func__, redeemScript.size(), MAX_SCRIPT_ELEMENT_SIZE, strAddr);
+ return true;
+ }
+
+ return CCryptoKeyStore::AddCScript(redeemScript);
+}
+
bool CWallet::Unlock(const SecureString& strWalletPassphrase)
{
CCrypter crypter;