Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 713 Lines • ▼ Show 20 Lines | for (const CTxIn &txin : tx.vin) { | ||||
extraFlags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | extraFlags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | ||||
} | } | ||||
if (IsMagneticAnomalyEnabledForCurrentBlock(config)) { | if (IsMagneticAnomalyEnabledForCurrentBlock(config)) { | ||||
extraFlags |= SCRIPT_VERIFY_CHECKDATASIG_SIGOPS; | extraFlags |= SCRIPT_VERIFY_CHECKDATASIG_SIGOPS; | ||||
} | } | ||||
if (IsGreatWallEnabledForCurrentBlock(config)) { | if (IsGreatWallEnabledForCurrentBlock(config)) { | ||||
if (!fRequireStandard) { | |||||
extraFlags |= SCRIPT_ALLOW_SEGWIT_RECOVERY; | |||||
} | |||||
extraFlags |= SCRIPT_ENABLE_SCHNORR; | extraFlags |= SCRIPT_ENABLE_SCHNORR; | ||||
} | } | ||||
// Make sure whatever we need to activate is actually activated. | // Make sure whatever we need to activate is actually activated. | ||||
const uint32_t scriptVerifyFlags = | const uint32_t scriptVerifyFlags = | ||||
STANDARD_SCRIPT_VERIFY_FLAGS | extraFlags; | STANDARD_SCRIPT_VERIFY_FLAGS | extraFlags; | ||||
// Check against previous transactions. This is done last to help | // Check against previous transactions. This is done last to help | ||||
▲ Show 20 Lines • Show All 500 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < tx.vin.size(); i++) { | ||||
txdata); | txdata); | ||||
if (pvChecks) { | if (pvChecks) { | ||||
pvChecks->push_back(std::move(check)); | pvChecks->push_back(std::move(check)); | ||||
} else if (!check()) { | } else if (!check()) { | ||||
// Compute flags without the optional standardness flags. | // Compute flags without the optional standardness flags. | ||||
// This differs from MANDATORY_SCRIPT_VERIFY_FLAGS as it contains | // This differs from MANDATORY_SCRIPT_VERIFY_FLAGS as it contains | ||||
// additional upgrade flags (see AcceptToMemoryPoolWorker variable | // additional upgrade flags (see AcceptToMemoryPoolWorker variable | ||||
// extraFlags). | // extraFlags). | ||||
// Even though it is not a mandatory flag, | |||||
// SCRIPT_ALLOW_SEGWIT_RECOVERY is strictly more permissive than the | |||||
// set of standard flags. It therefore needs to be added in order to | |||||
// check if we need to penalize the peer that sent us the | |||||
// transaction or not. | |||||
uint32_t mandatoryFlags = | uint32_t mandatoryFlags = | ||||
(flags & ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS) | | flags & ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS; | ||||
SCRIPT_ALLOW_SEGWIT_RECOVERY; | |||||
if (flags != mandatoryFlags) { | if (flags != mandatoryFlags) { | ||||
// Check whether the failure was caused by a non-mandatory | // Check whether the failure was caused by a non-mandatory | ||||
// script verification check. If so, don't trigger DoS | // script verification check. If so, don't trigger DoS | ||||
// protection to avoid splitting the network on the basis of | // protection to avoid splitting the network on the basis of | ||||
// relay policy disagreements. | // relay policy disagreements. | ||||
CScriptCheck check2(scriptPubKey, amount, tx, i, mandatoryFlags, | CScriptCheck check2(scriptPubKey, amount, tx, i, mandatoryFlags, | ||||
sigCacheStore, txdata); | sigCacheStore, txdata); | ||||
if (check2()) { | if (check2()) { | ||||
▲ Show 20 Lines • Show All 358 Lines • ▼ Show 20 Lines | static uint32_t GetBlockScriptFlags(const Config &config, | ||||
// alternative. We also start enforcing push only signatures and | // alternative. We also start enforcing push only signatures and | ||||
// clean stack. | // clean stack. | ||||
if (IsMagneticAnomalyEnabled(config, pChainTip)) { | if (IsMagneticAnomalyEnabled(config, pChainTip)) { | ||||
flags |= SCRIPT_VERIFY_CHECKDATASIG_SIGOPS; | flags |= SCRIPT_VERIFY_CHECKDATASIG_SIGOPS; | ||||
flags |= SCRIPT_VERIFY_SIGPUSHONLY; | flags |= SCRIPT_VERIFY_SIGPUSHONLY; | ||||
flags |= SCRIPT_VERIFY_CLEANSTACK; | flags |= SCRIPT_VERIFY_CLEANSTACK; | ||||
} | } | ||||
// If the Great Wall fork is enabled, we start accepting transactions | // If the Great Wall fork is enabled, we start accepting | ||||
// recovering coins sent to segwit addresses. We also start accepting | |||||
// 65/64-byte Schnorr signatures in CHECKSIG and CHECKDATASIG respectively, | // 65/64-byte Schnorr signatures in CHECKSIG and CHECKDATASIG respectively, | ||||
// and their verify variants. We also stop accepting 65 byte signatures in | // and their verify variants. We also stop accepting 65 byte signatures in | ||||
// CHECKMULTISIG and its verify variant. | // CHECKMULTISIG and its verify variant. | ||||
if (IsGreatWallEnabled(config, pChainTip)) { | if (IsGreatWallEnabled(config, pChainTip)) { | ||||
flags |= SCRIPT_ALLOW_SEGWIT_RECOVERY; | |||||
flags |= SCRIPT_ENABLE_SCHNORR; | flags |= SCRIPT_ENABLE_SCHNORR; | ||||
} | } | ||||
// We make sure this node will have replay protection during the next hard | // We make sure this node will have replay protection during the next hard | ||||
// fork. | // fork. | ||||
if (IsReplayProtectionEnabled(config, pChainTip)) { | if (IsReplayProtectionEnabled(config, pChainTip)) { | ||||
flags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | flags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 4,015 Lines • Show Last 20 Lines |