Changeset View
Changeset View
Standalone View
Standalone View
src/test/sighash_tests.cpp
Show First 20 Lines • Show All 102 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 = (InsecureRandBool()) ? insecure_rand() : 0; | tx.nLockTime = (InsecureRandBool()) ? insecure_rand() : 0; | ||||
int ins = (InsecureRandBits(2)) + 1; | int ins = (InsecureRandBits(2)) + 1; | ||||
int outs = fSingle ? ins : (InsecureRandBits(2)) + 1; | int outs = fSingle ? ins : (InsecureRandBits(2)) + 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 = InsecureRand256(); | txin.prevout = COutPoint(InsecureRand256(), InsecureRandBits(2)); | ||||
txin.prevout.n = InsecureRandBits(2); | |||||
RandomScript(txin.scriptSig); | RandomScript(txin.scriptSig); | ||||
txin.nSequence = | txin.nSequence = | ||||
(InsecureRandBool()) ? insecure_rand() : (unsigned int)-1; | (InsecureRandBool()) ? 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(); | ||||
txout.nValue = Amount(int64_t(insecure_rand()) % 100000000); | txout.nValue = Amount(int64_t(insecure_rand()) % 100000000); | ||||
▲ Show 20 Lines • Show All 162 Lines • Show Last 20 Lines |