Changeset View
Changeset View
Standalone View
Standalone View
src/script/interpreter.cpp
Show First 20 Lines • Show All 1,471 Lines • ▼ Show 20 Lines | PrecomputedTransactionData::PrecomputedTransactionData( | ||||
hashSequence = GetSequenceHash(txTo); | hashSequence = GetSequenceHash(txTo); | ||||
hashOutputs = GetOutputsHash(txTo); | hashOutputs = GetOutputsHash(txTo); | ||||
} | } | ||||
uint256 SignatureHash(const CScript &scriptCode, const CTransaction &txTo, | uint256 SignatureHash(const CScript &scriptCode, const CTransaction &txTo, | ||||
unsigned int nIn, SigHashType sigHashType, | unsigned int nIn, SigHashType sigHashType, | ||||
const Amount amount, | const Amount amount, | ||||
const PrecomputedTransactionData *cache, uint32_t flags) { | const PrecomputedTransactionData *cache, uint32_t flags) { | ||||
assert(nIn < txTo.vin.size()); | |||||
if (flags & SCRIPT_ENABLE_REPLAY_PROTECTION) { | if (flags & SCRIPT_ENABLE_REPLAY_PROTECTION) { | ||||
// Legacy chain's value for fork id must be of the form 0xffxxxx. | // Legacy chain's value for fork id must be of the form 0xffxxxx. | ||||
// By xoring with 0xdead, we ensure that the value will be different | // By xoring with 0xdead, we ensure that the value will be different | ||||
// from the original one, even if it already starts with 0xff. | // from the original one, even if it already starts with 0xff. | ||||
uint32_t newForkValue = sigHashType.getForkValue() ^ 0xdead; | uint32_t newForkValue = sigHashType.getForkValue() ^ 0xdead; | ||||
sigHashType = sigHashType.withForkValue(0xff0000 | newForkValue); | sigHashType = sigHashType.withForkValue(0xff0000 | newForkValue); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if (sigHashType.hasForkId() && (flags & SCRIPT_ENABLE_SIGHASH_FORKID)) { | ||||
// Sighash type | // Sighash type | ||||
ss << sigHashType; | ss << sigHashType; | ||||
return ss.GetHash(); | return ss.GetHash(); | ||||
} | } | ||||
static const uint256 one(uint256S( | static const uint256 one(uint256S( | ||||
"0000000000000000000000000000000000000000000000000000000000000001")); | "0000000000000000000000000000000000000000000000000000000000000001")); | ||||
if (nIn >= txTo.vin.size()) { | |||||
// nIn out of range | |||||
return one; | |||||
} | |||||
// Check for invalid use of SIGHASH_SINGLE | // Check for invalid use of SIGHASH_SINGLE | ||||
if ((sigHashType.getBaseType() == BaseSigHashType::SINGLE) && | if ((sigHashType.getBaseType() == BaseSigHashType::SINGLE) && | ||||
(nIn >= txTo.vout.size())) { | (nIn >= txTo.vout.size())) { | ||||
// nOut out of range | // nOut out of range | ||||
return one; | return one; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 222 Lines • Show Last 20 Lines |