diff options
| author | Wladimir J. van der Laan <[email protected]> | 2014-06-14 11:31:52 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2014-06-14 11:32:03 +0200 |
| commit | 8615bfb486d9b9fa24ca038fa078b8ccb1f2f180 (patch) | |
| tree | b26fd0da1dbde085bdb983617b7ab74a39ec4a56 /src/wallet.cpp | |
| parent | Merge pull request #4193 (diff) | |
| parent | Ignore too-long redeemScripts while loading wallet (diff) | |
| download | discoin-8615bfb486d9b9fa24ca038fa078b8ccb1f2f180.tar.xz discoin-8615bfb486d9b9fa24ca038fa078b8ccb1f2f180.zip | |
Merge pull request #4316
18116b0 Ignore too-long redeemScripts while loading wallet (Wladimir J. van der Laan)
Diffstat (limited to 'src/wallet.cpp')
| -rw-r--r-- | src/wallet.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp index ef0b442e1..400c966a9 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; |