Remove FindAndDelete. refs #1386
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
80259d4b4f
commit
05e2db116d
|
@ -247,7 +247,6 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, un
|
||||||
|
|
||||||
CScript::const_iterator pc = script.begin();
|
CScript::const_iterator pc = script.begin();
|
||||||
CScript::const_iterator pend = script.end();
|
CScript::const_iterator pend = script.end();
|
||||||
CScript::const_iterator pbegincodehash = script.begin();
|
|
||||||
opcodetype opcode;
|
opcodetype opcode;
|
||||||
valtype vchPushValue;
|
valtype vchPushValue;
|
||||||
vector<bool> vfExec;
|
vector<bool> vfExec;
|
||||||
|
@ -834,17 +833,11 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, un
|
||||||
valtype& vchSig = stacktop(-2);
|
valtype& vchSig = stacktop(-2);
|
||||||
valtype& vchPubKey = stacktop(-1);
|
valtype& vchPubKey = stacktop(-1);
|
||||||
|
|
||||||
// Subset of script starting at the most recent codeseparator
|
|
||||||
CScript scriptCode(pbegincodehash, pend);
|
|
||||||
|
|
||||||
// Drop the signature, since there's no way for a signature to sign itself
|
|
||||||
scriptCode.FindAndDelete(CScript(vchSig));
|
|
||||||
|
|
||||||
if (!CheckSignatureEncoding(vchSig, flags, serror) || !CheckPubKeyEncoding(vchPubKey, flags, serror)) {
|
if (!CheckSignatureEncoding(vchSig, flags, serror) || !CheckPubKeyEncoding(vchPubKey, flags, serror)) {
|
||||||
//serror is set
|
//serror is set
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool fSuccess = checker.CheckSig(vchSig, vchPubKey, scriptCode);
|
bool fSuccess = checker.CheckSig(vchSig, vchPubKey, script);
|
||||||
|
|
||||||
popstack(stack);
|
popstack(stack);
|
||||||
popstack(stack);
|
popstack(stack);
|
||||||
|
@ -887,16 +880,6 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, un
|
||||||
if ((int)stack.size() < i)
|
if ((int)stack.size() < i)
|
||||||
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
|
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
|
||||||
|
|
||||||
// Subset of script starting at the most recent codeseparator
|
|
||||||
CScript scriptCode(pbegincodehash, pend);
|
|
||||||
|
|
||||||
// Drop the signatures, since there's no way for a signature to sign itself
|
|
||||||
for (int k = 0; k < nSigsCount; k++)
|
|
||||||
{
|
|
||||||
valtype& vchSig = stacktop(-isig-k);
|
|
||||||
scriptCode.FindAndDelete(CScript(vchSig));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool fSuccess = true;
|
bool fSuccess = true;
|
||||||
while (fSuccess && nSigsCount > 0)
|
while (fSuccess && nSigsCount > 0)
|
||||||
{
|
{
|
||||||
|
@ -912,7 +895,7 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, un
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check signature
|
// Check signature
|
||||||
bool fOk = checker.CheckSig(vchSig, vchPubKey, scriptCode);
|
bool fOk = checker.CheckSig(vchSig, vchPubKey, script);
|
||||||
|
|
||||||
if (fOk) {
|
if (fOk) {
|
||||||
isig++;
|
isig++;
|
||||||
|
|
|
@ -543,34 +543,6 @@ public:
|
||||||
return (opcodetype)(OP_1+n-1);
|
return (opcodetype)(OP_1+n-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FindAndDelete(const CScript& b)
|
|
||||||
{
|
|
||||||
int nFound = 0;
|
|
||||||
if (b.empty())
|
|
||||||
return nFound;
|
|
||||||
iterator pc = begin();
|
|
||||||
opcodetype opcode;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
while (end() - pc >= (long)b.size() && memcmp(&pc[0], &b[0], b.size()) == 0)
|
|
||||||
{
|
|
||||||
pc = erase(pc, pc + b.size());
|
|
||||||
++nFound;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (GetOp(pc, opcode));
|
|
||||||
return nFound;
|
|
||||||
}
|
|
||||||
int Find(opcodetype op) const
|
|
||||||
{
|
|
||||||
int nFound = 0;
|
|
||||||
opcodetype opcode;
|
|
||||||
for (const_iterator pc = begin(); pc != end() && GetOp(pc, opcode);)
|
|
||||||
if (opcode == op)
|
|
||||||
++nFound;
|
|
||||||
return nFound;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs
|
* Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs
|
||||||
* as 20 sigops. With pay-to-script-hash, that changed:
|
* as 20 sigops. With pay-to-script-hash, that changed:
|
||||||
|
|
|
@ -129,12 +129,6 @@
|
||||||
|
|
||||||
["OP_CODESEPARATOR tests"],
|
["OP_CODESEPARATOR tests"],
|
||||||
|
|
||||||
["Test that SignatureHash() removes OP_CODESEPARATOR with FindAndDelete()"],
|
|
||||||
[[["bc7fd132fcf817918334822ee6d9bd95c889099c96e07ca2c1eb2cc70db63224", 0, "CODESEPARATOR 0x21 0x038479a0fa998cd35259a2ef0a7a5c68662c1474f88ccb6d08a7677bbec7f22041 CHECKSIG"]],
|
|
||||||
"01000000012432b60dc72cebc1a27ce0969c0989c895bdd9e62e8234839117f8fc32d17fbc000000004a493046022100a576b52051962c25e642c0fd3d77ee6c92487048e5d90818bcf5b51abaccd7900221008204f8fb121be4ec3b24483b1f92d89b1b0548513a134e345c5442e86e8617a501ffffffff010000000000000000016a00000000", "P2SH"],
|
|
||||||
[[["83e194f90b6ef21fa2e3a365b63794fb5daa844bdc9b25de30899fcfe7b01047", 0, "CODESEPARATOR CODESEPARATOR 0x21 0x038479a0fa998cd35259a2ef0a7a5c68662c1474f88ccb6d08a7677bbec7f22041 CHECKSIG"]],
|
|
||||||
"01000000014710b0e7cf9f8930de259bdc4b84aa5dfb9437b665a3e3a21ff26e0bf994e183000000004a493046022100a166121a61b4eeb19d8f922b978ff6ab58ead8a5a5552bf9be73dc9c156873ea02210092ad9bc43ee647da4f6652c320800debcf08ec20a094a0aaf085f63ecb37a17201ffffffff010000000000000000016a00000000", "P2SH"],
|
|
||||||
|
|
||||||
["Hashed data starts at the CODESEPARATOR"],
|
["Hashed data starts at the CODESEPARATOR"],
|
||||||
[[["326882a7f22b5191f1a0cc9962ca4b878cd969cf3b3a70887aece4d801a0ba5e", 0, "0x21 0x038479a0fa998cd35259a2ef0a7a5c68662c1474f88ccb6d08a7677bbec7f22041 CODESEPARATOR CHECKSIG"]],
|
[[["326882a7f22b5191f1a0cc9962ca4b878cd969cf3b3a70887aece4d801a0ba5e", 0, "0x21 0x038479a0fa998cd35259a2ef0a7a5c68662c1474f88ccb6d08a7677bbec7f22041 CODESEPARATOR CHECKSIG"]],
|
||||||
"01000000015ebaa001d8e4ec7a88703a3bcf69d98c874bca6299cca0f191512bf2a7826832000000004948304502203bf754d1c6732fbf87c5dcd81258aefd30f2060d7bd8ac4a5696f7927091dad1022100f5bcb726c4cf5ed0ed34cc13dadeedf628ae1045b7cb34421bc60b89f4cecae701ffffffff010000000000000000016a00000000", "P2SH"],
|
"01000000015ebaa001d8e4ec7a88703a3bcf69d98c874bca6299cca0f191512bf2a7826832000000004948304502203bf754d1c6732fbf87c5dcd81258aefd30f2060d7bd8ac4a5696f7927091dad1022100f5bcb726c4cf5ed0ed34cc13dadeedf628ae1045b7cb34421bc60b89f4cecae701ffffffff010000000000000000016a00000000", "P2SH"],
|
||||||
|
|
|
@ -35,10 +35,6 @@ uint256 static SignatureHashOld(CScript scriptCode, const CTransaction& txTo, un
|
||||||
}
|
}
|
||||||
CMutableTransaction txTmp(txTo);
|
CMutableTransaction txTmp(txTo);
|
||||||
|
|
||||||
// In case concatenating two scripts ends up with two codeseparators,
|
|
||||||
// or an extra one at the end, this prevents all those possible incompatibilities.
|
|
||||||
scriptCode.FindAndDelete(CScript(OP_CODESEPARATOR));
|
|
||||||
|
|
||||||
// Blank out other inputs' signatures
|
// Blank out other inputs' signatures
|
||||||
for (unsigned int i = 0; i < txTmp.vin.size(); i++)
|
for (unsigned int i = 0; i < txTmp.vin.size(); i++)
|
||||||
txTmp.vin[i].scriptSig = CScript();
|
txTmp.vin[i].scriptSig = CScript();
|
||||||
|
|
Loading…
Reference in New Issue