\r
CBigNum& operator>>=(unsigned int shift)\r
{\r
- // Note: BN_rshift segfaults on 64-bit ubuntu 9.10 if 2^shift is greater than the number,\r
- // tested OK on 64-bit ubuntu 10.4\r
+ // Note: BN_rshift segfaults on 64-bit if 2^shift is greater than the number\r
+ // if built on ubuntu 9.04 or 9.10, probably depends on version of openssl\r
+ CBigNum a = 1;\r
+ a <<= shift;\r
+ if (BN_cmp(&a, this) > 0)\r
+ {\r
+ *this = 0;\r
+ return *this;\r
+ }\r
+\r
if (!BN_rshift(this, this, shift))\r
throw bignum_error("CBigNum:operator>>= : BN_rshift failed");\r
return *this;\r
\r
inline const CBigNum operator>>(const CBigNum& a, unsigned int shift)\r
{\r
- CBigNum r;\r
- // Note: BN_rshift segfaults on 64-bit ubuntu 9.10 if 2^shift is greater than the number\r
- if (!BN_rshift(&r, &a, shift))\r
- throw bignum_error("CBigNum:operator>> : BN_rshift failed");\r
+ CBigNum r = a;\r
+ r >>= shift;\r
return r;\r
}\r
\r
foreach(CWalletTx* pcoin, setCoins)\r
for (int nOut = 0; nOut < pcoin->vout.size(); nOut++)\r
if (pcoin->vout[nOut].IsMine())\r
- SignSignature(*pcoin, wtxNew, nIn++);\r
+ if (!SignSignature(*pcoin, wtxNew, nIn++))\r
+ return false;\r
\r
// Check that enough fee is included\r
if (nFee < wtxNew.GetMinFee())\r
#define stacktop(i) (stack.at(stack.size()+(i)))\r
#define altstacktop(i) (altstack.at(altstack.size()+(i)))\r
\r
-bool EvalScript(const CScript& script, const CTransaction& txTo, unsigned int nIn, int nHashType,\r
- vector<vector<unsigned char> >* pvStackRet)\r
+bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, int nHashType)\r
{\r
CAutoBN_CTX pctx;\r
CScript::const_iterator pc = script.begin();\r
CScript::const_iterator pend = script.end();\r
CScript::const_iterator pbegincodehash = script.begin();\r
vector<bool> vfExec;\r
- vector<valtype> stack;\r
vector<valtype> altstack;\r
- if (pvStackRet)\r
- pvStackRet->clear();\r
- if (script.size() > 20000)\r
+ if (script.size() > 10000)\r
return false;\r
+ int nOpCount = 0;\r
\r
\r
try\r
return false;\r
if (vchPushValue.size() > 5000)\r
return false;\r
+ if (opcode > OP_16 && nOpCount++ > 200)\r
+ return false;\r
\r
if (fExec && opcode <= OP_PUSHDATA4)\r
stack.push_back(vchPushValue);\r
if (!vfExec.empty())\r
return false;\r
\r
- if (pvStackRet)\r
- *pvStackRet = stack;\r
- return (stack.empty() ? false : CastToBool(stack.back()));\r
+ return true;\r
}\r
\r
#undef top\r
}\r
\r
\r
+bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, int nHashType)\r
+{\r
+ vector<vector<unsigned char> > stack;\r
+ if (!EvalScript(stack, scriptSig, txTo, nIn, nHashType))\r
+ return false;\r
+ if (!EvalScript(stack, scriptPubKey, txTo, nIn, nHashType))\r
+ return false;\r
+ if (stack.empty())\r
+ return false;\r
+ return CastToBool(stack.back());\r
+}\r
+\r
+\r
bool SignSignature(const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType, CScript scriptPrereq)\r
{\r
assert(nIn < txTo.vin.size());\r
\r
// Test solution\r
if (scriptPrereq.empty())\r
- if (!EvalScript(txin.scriptSig + CScript(OP_CODESEPARATOR) + txout.scriptPubKey, txTo, nIn))\r
+ if (!VerifyScript(txin.scriptSig, txout.scriptPubKey, txTo, nIn, 0))\r
return false;\r
\r
return true;\r
if (txin.prevout.hash != txFrom.GetHash())\r
return false;\r
\r
- if (!EvalScript(txin.scriptSig + CScript(OP_CODESEPARATOR) + txout.scriptPubKey, txTo, nIn, nHashType))\r
+ if (!VerifyScript(txin.scriptSig, txout.scriptPubKey, txTo, nIn, nHashType))\r
return false;\r
\r
// Anytime a signature is successfully verified, it's proof the outpoint is spent,\r
\r
\r
\r
-bool EvalScript(const CScript& script, const CTransaction& txTo, unsigned int nIn, int nHashType=0,\r
- vector<vector<unsigned char> >* pvStackRet=NULL);\r
uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);\r
bool IsMine(const CScript& scriptPubKey);\r
bool ExtractPubKey(const CScript& scriptPubKey, bool fMineOnly, vector<unsigned char>& vchPubKeyRet);\r
\r
# General Symbol Definitions\r
!define REGKEY "SOFTWARE\$(^Name)"\r
-!define VERSION 0.3.6\r
+!define VERSION 0.3.7\r
!define COMPANY "Bitcoin project"\r
!define URL http://www.bitcoin.org/\r
\r
!insertmacro MUI_LANGUAGE English\r
\r
# Installer attributes\r
-OutFile bitcoin-0.3.6-win32-setup.exe\r
+OutFile bitcoin-0.3.7-win32-setup.exe\r
InstallDir $PROGRAMFILES\Bitcoin\r
CRCCheck on\r
XPStyle on\r
ShowInstDetails show\r
-VIProductVersion 0.3.6.0\r
+VIProductVersion 0.3.7.0\r
VIAddVersionKey ProductName Bitcoin\r
VIAddVersionKey ProductVersion "${VERSION}"\r
VIAddVersionKey CompanyName "${COMPANY}"\r