Changeset View
Changeset View
Standalone View
Standalone View
src/test/sighash_tests.cpp
Show First 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | for (int i = 0; i < nRandomTests; i++) { | ||||
BOOST_CHECK(shreg == shref); | BOOST_CHECK(shreg == shref); | ||||
} | } | ||||
// Make sure replay protection works as expected. | // Make sure replay protection works as expected. | ||||
uint256 shrep = SignatureHash(scriptCode, CTransaction(txTo), nIn, | uint256 shrep = SignatureHash(scriptCode, CTransaction(txTo), nIn, | ||||
sigHashType, Amount::zero(), nullptr, | sigHashType, Amount::zero(), nullptr, | ||||
SCRIPT_ENABLE_SIGHASH_FORKID | | SCRIPT_ENABLE_SIGHASH_FORKID | | ||||
SCRIPT_ENABLE_REPLAY_PROTECTION); | SCRIPT_ENABLE_REPLAY_PROTECTION); | ||||
uint32_t newForValue = 0xff0000 | ((nHashType >> 8) ^ 0xdead); | uint32_t newForkValue = 0xff0000 | ((nHashType >> 8) ^ 0xdead); | ||||
uint256 manualshrep = SignatureHash( | uint256 manualshrep = SignatureHash( | ||||
scriptCode, CTransaction(txTo), nIn, | scriptCode, CTransaction(txTo), nIn, | ||||
sigHashType.withForkValue(newForValue), Amount::zero()); | sigHashType.withForkValue(newForkValue), Amount::zero()); | ||||
BOOST_CHECK(shrep == manualshrep); | BOOST_CHECK(shrep == manualshrep); | ||||
// Replay protection works even if the hash is of the form 0xffxxxx | // Replay protection works even if the hash is of the form 0xffxxxx | ||||
uint256 shrepff = SignatureHash( | uint256 shrepff = SignatureHash( | ||||
scriptCode, CTransaction(txTo), nIn, | scriptCode, CTransaction(txTo), nIn, | ||||
sigHashType.withForkValue(newForValue), Amount::zero(), nullptr, | sigHashType.withForkValue(newForkValue), Amount::zero(), nullptr, | ||||
SCRIPT_ENABLE_SIGHASH_FORKID | SCRIPT_ENABLE_REPLAY_PROTECTION); | SCRIPT_ENABLE_SIGHASH_FORKID | SCRIPT_ENABLE_REPLAY_PROTECTION); | ||||
uint256 manualshrepff = SignatureHash( | uint256 manualshrepff = SignatureHash( | ||||
scriptCode, CTransaction(txTo), nIn, | scriptCode, CTransaction(txTo), nIn, | ||||
sigHashType.withForkValue(newForValue ^ 0xdead), Amount::zero()); | sigHashType.withForkValue(newForkValue ^ 0xdead), Amount::zero()); | ||||
BOOST_CHECK(shrepff == manualshrepff); | BOOST_CHECK(shrepff == manualshrepff); | ||||
uint256 shrepabcdef = SignatureHash( | uint256 shrepabcdef = SignatureHash( | ||||
scriptCode, CTransaction(txTo), nIn, | scriptCode, CTransaction(txTo), nIn, | ||||
sigHashType.withForkValue(0xabcdef), Amount::zero(), nullptr, | sigHashType.withForkValue(0xabcdef), Amount::zero(), nullptr, | ||||
SCRIPT_ENABLE_SIGHASH_FORKID | SCRIPT_ENABLE_REPLAY_PROTECTION); | SCRIPT_ENABLE_SIGHASH_FORKID | SCRIPT_ENABLE_REPLAY_PROTECTION); | ||||
uint256 manualshrepabcdef = | uint256 manualshrepabcdef = | ||||
SignatureHash(scriptCode, CTransaction(txTo), nIn, | SignatureHash(scriptCode, CTransaction(txTo), nIn, | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |