MCPcopy Create free account
hub / github.com/bitcoin-sv/bitcoin-sv / VerifyScript

Function VerifyScript

src/script/interpreter.cpp:2304–2451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2302}
2303
2304std::optional<ScriptError> VerifyScript(
2305 const verify_script_params& params,
2306 const task::CCancellationToken& token,
2307 const CScript& scriptSig,
2308 const CScript& scriptPubKey,
2309 uint32_t flags,
2310 const BaseSignatureChecker& checker)
2311{
2312 if(!valid_flags(flags))
2313 return SCRIPT_ERR_INVALID_FLAGS;
2314
2315 if (flags & SCRIPT_ENABLE_SIGHASH_FORKID)
2316 {
2317 // If FORKID is enabled, we also ensure strict encoding.
2318 flags |= SCRIPT_VERIFY_STRICTENC;
2319 }
2320
2321 if(VerifySigPushOnly(flags))
2322 {
2323 // Check for push-only scriptSig if:
2324 // - we are post-Genesis but pre-Chronicle, or
2325 // - we are post-Chronicle and the txn is non-malleable
2326 if((IsGenesis(flags) && !IsChronicle(flags)) ||
2327 (IsChronicle(flags) && !IsMalleableTxnVersion(checker.Version())))
2328 {
2329 if(!scriptSig.IsPushOnly())
2330 {
2331 return SCRIPT_ERR_SIG_PUSHONLY;
2332 }
2333 }
2334 }
2335
2336 LimitedStack stack{params.MaxStackMemoryUsage()};
2337 LimitedStack stackCopy{params.MaxStackMemoryUsage()};
2338 if(const auto o = EvalScript(params.EvalScriptParams(),
2339 token,
2340 stack,
2341 scriptSig,
2342 &scriptPubKey,
2343 flags,
2344 checker);
2345 !o.has_value())
2346 {
2347 return {};
2348 }
2349 else if(o.value() != SCRIPT_ERR_OK)
2350 {
2351 return o;
2352 }
2353
2354 if ((flags & SCRIPT_VERIFY_P2SH) && !(flags & SCRIPT_UTXO_AFTER_GENESIS)) {
2355 stackCopy = stack.makeRootStackCopy();
2356 }
2357
2358 if(const auto o = EvalScript(params.EvalScriptParams(),
2359 token,
2360 stack,
2361 scriptPubKey,

Callers 12

MutateTxSignFunction · 0.85
operator()Method · 0.85
verify_scriptFunction · 0.85
SignAndVerifyFunction · 0.85
VerifyWithFlagFunction · 0.85
RunTestsFunction · 0.85
CheckWithFlagFunction · 0.85
DoTestFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
VerifyFunction · 0.85
signrawtransactionFunction · 0.85

Calls 15

valid_flagsFunction · 0.85
VerifySigPushOnlyFunction · 0.85
IsGenesisFunction · 0.85
IsChronicleFunction · 0.85
IsMalleableTxnVersionFunction · 0.85
EvalScriptFunction · 0.85
CastToBoolFunction · 0.85
IsP2SHFunction · 0.85
VerifyCleanStackFunction · 0.85
EnforceNonMalleabilityFunction · 0.85
IsPushOnlyMethod · 0.80
MaxStackMemoryUsageMethod · 0.80

Tested by 7

VerifyWithFlagFunction · 0.68
RunTestsFunction · 0.68
CheckWithFlagFunction · 0.68
DoTestFunction · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68
VerifyFunction · 0.68