Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
Lint: Code style violation: '/Users/tobiasruck/workspace/bitcoin/bitcoin-abc/src/validation.cpp' has code style errors. | |||||
deadalnixUnsubmitted Not Done Inline ActionsIt seems that the linter has a message for you. deadalnix: It seems that the linter has a message for you. | |||||
// Copyright (c) 2009-2018 The Bitcoin Core developers | // Copyright (c) 2009-2018 The Bitcoin Core developers | ||||
// Copyright (c) 2017-2018 The Bitcoin developers | // Copyright (c) 2017-2018 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <validation.h> | #include <validation.h> | ||||
#include <arith_uint256.h> | #include <arith_uint256.h> | ||||
▲ Show 20 Lines • Show All 472 Lines • ▼ Show 20 Lines | static uint32_t GetStandardScriptFlags(const Consensus::Params ¶ms, | ||||
flags &= ~SCRIPT_VERIFY_INPUT_SIGCHECKS; | flags &= ~SCRIPT_VERIFY_INPUT_SIGCHECKS; | ||||
// 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(params, pindexTip)) { | if (IsReplayProtectionEnabled(params, pindexTip)) { | ||||
flags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | flags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | ||||
} | } | ||||
if (IsPhononEnabled(params, pindexTip)) { | |||||
flags |= SCRIPT_ENABLE_OP_REVERSEBYTES; | |||||
} | |||||
deadalnixUnsubmitted Not Done Inline ActionsThat is somewhat scary this needs to be duplicated. deadalnix: That is somewhat scary this needs to be duplicated. | |||||
markblundebergUnsubmitted Not Done Inline ActionsYeah when I made this function I looked a bit into copying from GetNextBlockScriptFlags. i.e., flags = (GetNextBlockScriptFlags & ~CONSENSUS_ONLY_SCRIPT_VERIFY_FLAGS) | STANDARD_SCRIPT_VERIFY_FLAGS, something like that. It's a possibility, and would remove the need for duplication of most activations. markblundeberg: Yeah when I made this function I looked a bit into copying from GetNextBlockScriptFlags.
i.e. | |||||
return flags; | return flags; | ||||
} | } | ||||
// Used to avoid mempool polluting consensus critical paths if CCoinsViewMempool | // Used to avoid mempool polluting consensus critical paths if CCoinsViewMempool | ||||
// were somehow broken and returning the wrong scriptPubKeys | // were somehow broken and returning the wrong scriptPubKeys | ||||
static bool CheckInputsFromMempoolAndCache( | static bool CheckInputsFromMempoolAndCache( | ||||
const CTransaction &tx, CValidationState &state, | const CTransaction &tx, CValidationState &state, | ||||
const CCoinsViewCache &view, const CTxMemPool &pool, const uint32_t flags, | const CCoinsViewCache &view, const CTxMemPool &pool, const uint32_t flags, | ||||
▲ Show 20 Lines • Show All 776 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < tx.vin.size(); i++) { | ||||
false, REJECT_NONSTANDARD, | false, REJECT_NONSTANDARD, | ||||
strprintf("non-mandatory-script-verify-flag (%s)", | strprintf("non-mandatory-script-verify-flag (%s)", | ||||
ScriptErrorString(scriptError))); | ScriptErrorString(scriptError))); | ||||
} | } | ||||
// update the error message to reflect the mandatory violation. | // update the error message to reflect the mandatory violation. | ||||
scriptError = check2.GetScriptError(); | scriptError = check2.GetScriptError(); | ||||
} | } | ||||
// Before banning, we need to check whether the transaction would | |||||
// be valid on the other side of the upgrade, so as to avoid | |||||
// splitting the network between upgraded and non-upgraded nodes. | |||||
// Note that this will create strange error messages like | |||||
// "upgrade-conditional-script-failure (Opcode missing or not | |||||
// understood)". | |||||
CScriptCheck check3(scriptPubKey, amount, tx, i, | |||||
mandatoryFlags ^ SCRIPT_ENABLE_OP_REVERSEBYTES, | |||||
sigCacheStore, txdata); | |||||
if (check3()) { | |||||
return state.Invalid( | |||||
false, REJECT_INVALID, | |||||
strprintf("upgrade-conditional-script-failure (%s)", | |||||
ScriptErrorString(check.GetScriptError()))); | |||||
} | |||||
// Failures of other flags indicate a transaction that is invalid in | // Failures of other flags indicate a transaction that is invalid in | ||||
// new blocks, e.g. a invalid P2SH. We DoS ban such nodes as they | // new blocks, e.g. a invalid P2SH. We DoS ban such nodes as they | ||||
// are not following the protocol. That said during an upgrade | // are not following the protocol. That said during an upgrade | ||||
// careful thought should be taken as to the correct behavior - we | // careful thought should be taken as to the correct behavior - we | ||||
// may want to continue peering with non-upgraded nodes even after | // may want to continue peering with non-upgraded nodes even after | ||||
// soft-fork super-majority signaling has occurred. | // soft-fork super-majority signaling has occurred. | ||||
return state.DoS( | return state.DoS( | ||||
100, false, REJECT_INVALID, | 100, false, REJECT_INVALID, | ||||
▲ Show 20 Lines • Show All 323 Lines • ▼ Show 20 Lines | if (IsMagneticAnomalyEnabled(params, pindex)) { | ||||
flags |= SCRIPT_VERIFY_CLEANSTACK; | flags |= SCRIPT_VERIFY_CLEANSTACK; | ||||
} | } | ||||
if (IsGravitonEnabled(params, pindex)) { | if (IsGravitonEnabled(params, pindex)) { | ||||
flags |= SCRIPT_ENABLE_SCHNORR_MULTISIG; | flags |= SCRIPT_ENABLE_SCHNORR_MULTISIG; | ||||
flags |= SCRIPT_VERIFY_MINIMALDATA; | flags |= SCRIPT_VERIFY_MINIMALDATA; | ||||
} | } | ||||
if (IsPhononEnabled(params, pindex)) { | |||||
flags |= SCRIPT_ENABLE_OP_REVERSEBYTES; | |||||
} | |||||
// 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(params, pindex)) { | if (IsReplayProtectionEnabled(params, pindex)) { | ||||
flags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | flags |= SCRIPT_ENABLE_REPLAY_PROTECTION; | ||||
} | } | ||||
return flags; | return flags; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 4,096 Lines • Show Last 20 Lines |
'/Users/tobiasruck/workspace/bitcoin/bitcoin-abc/src/validation.cpp' has code style errors.