Changeset View
Changeset View
Standalone View
Standalone View
src/test/sighash_tests.cpp
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | static void RandomTransaction(CMutableTransaction &tx, bool fSingle) { | ||||
tx.vin.clear(); | tx.vin.clear(); | ||||
tx.vout.clear(); | tx.vout.clear(); | ||||
tx.nLockTime = (insecure_rand() % 2) ? insecure_rand() : 0; | tx.nLockTime = (insecure_rand() % 2) ? insecure_rand() : 0; | ||||
int ins = (insecure_rand() % 4) + 1; | int ins = (insecure_rand() % 4) + 1; | ||||
int outs = fSingle ? ins : (insecure_rand() % 4) + 1; | int outs = fSingle ? ins : (insecure_rand() % 4) + 1; | ||||
for (int in = 0; in < ins; in++) { | for (int in = 0; in < ins; in++) { | ||||
tx.vin.push_back(CTxIn()); | tx.vin.push_back(CTxIn()); | ||||
CTxIn &txin = tx.vin.back(); | CTxIn &txin = tx.vin.back(); | ||||
txin.prevout.hash = GetRandHash(); | txin.prevout.unspentid = unspentid_t(GetRandHash()); | ||||
txin.prevout.n = insecure_rand() % 4; | txin.prevout.n = insecure_rand() % 4; | ||||
RandomScript(txin.scriptSig); | RandomScript(txin.scriptSig); | ||||
txin.nSequence = | txin.nSequence = | ||||
(insecure_rand() % 2) ? insecure_rand() : (unsigned int)-1; | (insecure_rand() % 2) ? insecure_rand() : (unsigned int)-1; | ||||
} | } | ||||
for (int out = 0; out < outs; out++) { | for (int out = 0; out < outs; out++) { | ||||
tx.vout.push_back(CTxOut()); | tx.vout.push_back(CTxOut()); | ||||
CTxOut &txout = tx.vout.back(); | CTxOut &txout = tx.vout.back(); | ||||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |