Changeset View
Changeset View
Standalone View
Standalone View
src/script/interpreter.cpp
Show First 20 Lines • Show All 1,022 Lines • ▼ Show 20 Lines | try { | ||||
// Remove signature for pre-fork scripts | // Remove signature for pre-fork scripts | ||||
for (int k = 0; k < nSigsCount; k++) { | for (int k = 0; k < nSigsCount; k++) { | ||||
valtype &vchSig = stacktop(-idxTopSig - k); | valtype &vchSig = stacktop(-idxTopSig - k); | ||||
CleanupScriptCode(scriptCode, vchSig, flags); | CleanupScriptCode(scriptCode, vchSig, flags); | ||||
} | } | ||||
bool fSuccess = true; | bool fSuccess = true; | ||||
size_t ikey = idxTopKey; | |||||
size_t isig = idxTopSig; | |||||
int nSigsRemaining = nSigsCount; | int nSigsRemaining = nSigsCount; | ||||
int nKeysRemaining = nKeysCount; | int nKeysRemaining = nKeysCount; | ||||
while (fSuccess && nSigsRemaining > 0) { | while (fSuccess && nSigsRemaining > 0) { | ||||
valtype &vchSig = stacktop(-isig); | valtype &vchSig = stacktop( | ||||
valtype &vchPubKey = stacktop(-ikey); | -idxTopSig - (nSigsCount - nSigsRemaining)); | ||||
valtype &vchPubKey = stacktop( | |||||
-idxTopKey - (nKeysCount - nKeysRemaining)); | |||||
// Note how this makes the exact order of | // Note how this makes the exact order of | ||||
// pubkey/signature evaluation distinguishable by | // pubkey/signature evaluation distinguishable by | ||||
// CHECKMULTISIG NOT if the STRICTENC flag is set. | // CHECKMULTISIG NOT if the STRICTENC flag is set. | ||||
// See the script_(in)valid tests for details. | // See the script_(in)valid tests for details. | ||||
if (!CheckTransactionECDSASignatureEncoding( | if (!CheckTransactionECDSASignatureEncoding( | ||||
vchSig, flags, serror) || | vchSig, flags, serror) || | ||||
!CheckPubKeyEncoding(vchPubKey, flags, | !CheckPubKeyEncoding(vchPubKey, flags, | ||||
serror)) { | serror)) { | ||||
// serror is set | // serror is set | ||||
return false; | return false; | ||||
} | } | ||||
// Check signature | // Check signature | ||||
bool fOk = checker.CheckSig(vchSig, vchPubKey, | bool fOk = checker.CheckSig(vchSig, vchPubKey, | ||||
scriptCode, flags); | scriptCode, flags); | ||||
if (fOk) { | if (fOk) { | ||||
isig++; | |||||
nSigsRemaining--; | nSigsRemaining--; | ||||
} | } | ||||
ikey++; | |||||
nKeysRemaining--; | nKeysRemaining--; | ||||
// If there are more signatures left than keys left, | // If there are more signatures left than keys left, | ||||
// then too many signatures have failed. Exit early, | // then too many signatures have failed. Exit early, | ||||
// without checking any further signatures. | // without checking any further signatures. | ||||
if (nSigsRemaining > nKeysRemaining) { | if (nSigsRemaining > nKeysRemaining) { | ||||
fSuccess = false; | fSuccess = false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 605 Lines • Show Last 20 Lines |