Permalink
Browse files

Ignore too-long redeemScripts while loading wallet

  • Loading branch information...
Tranz5 committed Aug 20, 2014
1 parent 6703b69 commit 61580e3b358c5d7e61c54b10724ec136b9c33050
Showing with 17 additions and 1 deletion.
  1. +16 −0 src/wallet.cpp
  2. +1 −1 src/wallet.h
View
@@ -116,6 +116,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();
printf("%s: Warning: This wallet contains a redeemScript of size %"PRIszu" which exceeds maximum size %i thus can never be redeemed. Do not use address %s.\n",
__func__, redeemScript.size(), MAX_SCRIPT_ELEMENT_SIZE, strAddr.c_str());
return true;
}
return CCryptoKeyStore::AddCScript(redeemScript);
}
bool CWallet::Unlock(const SecureString& strWalletPassphrase)
{
View
@@ -203,7 +203,7 @@ class CWallet : public CCryptoKeyStore
// Adds an encrypted key to the store, without saving it to disk (used by LoadWallet)
bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
bool AddCScript(const CScript& redeemScript);
bool LoadCScript(const CScript& redeemScript) { return CCryptoKeyStore::AddCScript(redeemScript); }
bool LoadCScript(const CScript& redeemScript);
bool Unlock(const SecureString& strWalletPassphrase);
bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);

0 comments on commit 61580e3

Please sign in to comment.