aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-12-01 22:30:06 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2013-01-08 01:49:15 +0100
commit2800ce7367760a9bb8fd5209feddf71e574a592d (patch)
tree03a3551000b10db481b48a87a041f7b266729358 /src/main.cpp
parentf1136200a67fc1df894d45fba51b40f748e0b889 (diff)
Add CScriptCheck: a closure representing a script check
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp
index c0446370ae..4441c65fd4 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1348,15 +1348,16 @@ bool CTransaction::HaveInputs(CCoinsViewCache &inputs) const
return true;
}
+bool CScriptCheck::operator()() const {
+ const CScript &scriptSig = ptxTo->vin[nIn].scriptSig;
+ if (!VerifyScript(scriptSig, scriptPubKey, *ptxTo, nIn, nFlags, nHashType))
+ return error("CScriptCheck() : %s VerifySignature failed", ptxTo->GetHash().ToString().substr(0,10).c_str());
+ return true;
+}
+
bool VerifySignature(const CCoins& txFrom, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType)
{
- assert(nIn < txTo.vin.size());
- const CTxIn& txin = txTo.vin[nIn];
- if (txin.prevout.n >= txFrom.vout.size())
- return false;
- const CTxOut& txout = txFrom.vout[txin.prevout.n];
-
- return VerifyScript(txin.scriptSig, txout.scriptPubKey, txTo, nIn, flags, nHashType);
+ return CScriptCheck(txFrom, txTo, nIn, flags, nHashType)();
}
bool CTransaction::CheckInputs(CCoinsViewCache &inputs, enum CheckSig_mode csmode, unsigned int flags) const