Changeset View
Changeset View
Standalone View
Standalone View
src/script/sign.cpp
Show First 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | if (solved && whichType == TX_SCRIPTHASH) { | ||||
whichType != TX_SCRIPTHASH; | whichType != TX_SCRIPTHASH; | ||||
result.push_back( | result.push_back( | ||||
std::vector<uint8_t>(subscript.begin(), subscript.end())); | std::vector<uint8_t>(subscript.begin(), subscript.end())); | ||||
} | } | ||||
sigdata.scriptSig = PushAll(result); | sigdata.scriptSig = PushAll(result); | ||||
// Test solution | // Test solution | ||||
return solved && VerifyScript(sigdata.scriptSig, fromPubKey, | return solved && | ||||
STANDARD_SCRIPT_VERIFY_FLAGS | | VerifyScript(sigdata.scriptSig, fromPubKey, | ||||
SCRIPT_ENABLE_SIGHASH_FORKID, | STANDARD_SCRIPT_VERIFY_FLAGS, creator.Checker()); | ||||
creator.Checker()); | |||||
} | } | ||||
SignatureData DataFromTransaction(const CMutableTransaction &tx, | SignatureData DataFromTransaction(const CMutableTransaction &tx, | ||||
unsigned int nIn) { | unsigned int nIn) { | ||||
SignatureData data; | SignatureData data; | ||||
assert(tx.vin.size() > nIn); | assert(tx.vin.size() > nIn); | ||||
data.scriptSig = tx.vin[nIn].scriptSig; | data.scriptSig = tx.vin[nIn].scriptSig; | ||||
return data; | return data; | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | for (const valtype &sig : allsigs) { | ||||
for (unsigned int i = 0; i < nPubKeys; i++) { | for (unsigned int i = 0; i < nPubKeys; i++) { | ||||
const valtype &pubkey = vSolutions[i + 1]; | const valtype &pubkey = vSolutions[i + 1]; | ||||
// Already got a sig for this pubkey | // Already got a sig for this pubkey | ||||
if (sigs.count(pubkey)) { | if (sigs.count(pubkey)) { | ||||
continue; | continue; | ||||
} | } | ||||
if (checker.CheckSig(sig, pubkey, scriptPubKey, | if (checker.CheckSig(sig, pubkey, scriptPubKey, | ||||
STANDARD_SCRIPT_VERIFY_FLAGS | | STANDARD_SCRIPT_VERIFY_FLAGS)) { | ||||
SCRIPT_ENABLE_SIGHASH_FORKID)) { | |||||
sigs[pubkey] = sig; | sigs[pubkey] = sig; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// Now build a merged CScript: | // Now build a merged CScript: | ||||
unsigned int nSigsHave = 0; | unsigned int nSigsHave = 0; | ||||
// pop-one-too-many workaround | // pop-one-too-many workaround | ||||
Show All 17 Lines | |||||
namespace { | namespace { | ||||
struct Stacks { | struct Stacks { | ||||
std::vector<valtype> script; | std::vector<valtype> script; | ||||
Stacks() {} | Stacks() {} | ||||
explicit Stacks(const std::vector<valtype> &scriptSigStack_) | explicit Stacks(const std::vector<valtype> &scriptSigStack_) | ||||
: script(scriptSigStack_) {} | : script(scriptSigStack_) {} | ||||
explicit Stacks(const SignatureData &data) { | explicit Stacks(const SignatureData &data) { | ||||
EvalScript(script, data.scriptSig, | EvalScript(script, data.scriptSig, MANDATORY_SCRIPT_VERIFY_FLAGS, | ||||
SCRIPT_VERIFY_STRICTENC | SCRIPT_ENABLE_SIGHASH_FORKID, | |||||
BaseSignatureChecker()); | BaseSignatureChecker()); | ||||
} | } | ||||
SignatureData Output() const { | SignatureData Output() const { | ||||
SignatureData result; | SignatureData result; | ||||
result.scriptSig = PushAll(script); | result.scriptSig = PushAll(script); | ||||
return result; | return result; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |