Changeset View
Changeset View
Standalone View
Standalone View
src/test/script_p2sh_tests.cpp
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(sign) { | ||||
// Check to make sure signature verification fails if we use the wrong | // Check to make sure signature verification fails if we use the wrong | ||||
// ScriptSig: | // ScriptSig: | ||||
for (int i = 0; i < 8; i++) { | for (int i = 0; i < 8; i++) { | ||||
CTransaction tx(txTo[i]); | CTransaction tx(txTo[i]); | ||||
PrecomputedTransactionData txdata(tx); | PrecomputedTransactionData txdata(tx); | ||||
for (int j = 0; j < 8; j++) { | for (int j = 0; j < 8; j++) { | ||||
CScript sigSave = txTo[i].vin[0].scriptSig; | CScript sigSave = txTo[i].vin[0].scriptSig; | ||||
txTo[i].vin[0].scriptSig = txTo[j].vin[0].scriptSig; | txTo[i].vin[0].scriptSig = txTo[j].vin[0].scriptSig; | ||||
const CTxOut &output = txFrom.vout[txTo[i].vin[0].prevout.GetN()]; | bool sigOK = | ||||
bool sigOK = CScriptCheck( | CScriptCheck(txFrom.vout[txTo[i].vin[0].prevout.GetN()], | ||||
output.scriptPubKey, output.nValue, CTransaction(txTo[i]), 0, | CTransaction(txTo[i]), 0, | ||||
SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC | | SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC | | ||||
SCRIPT_ENABLE_SIGHASH_FORKID, | SCRIPT_ENABLE_SIGHASH_FORKID, | ||||
false, txdata)(); | false, txdata)(); | ||||
if (i == j) { | if (i == j) { | ||||
BOOST_CHECK_MESSAGE(sigOK, | BOOST_CHECK_MESSAGE(sigOK, | ||||
strprintf("VerifySignature %d %d", i, j)); | strprintf("VerifySignature %d %d", i, j)); | ||||
} else { | } else { | ||||
BOOST_CHECK_MESSAGE(!sigOK, | BOOST_CHECK_MESSAGE(!sigOK, | ||||
strprintf("VerifySignature %d %d", i, j)); | strprintf("VerifySignature %d %d", i, j)); | ||||
} | } | ||||
txTo[i].vin[0].scriptSig = sigSave; | txTo[i].vin[0].scriptSig = sigSave; | ||||
▲ Show 20 Lines • Show All 251 Lines • Show Last 20 Lines |