MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / create_placeholder_tx

Method create_placeholder_tx

src/test/txpackage_tests.cpp:32–48  ·  view source on GitHub ↗

Create placeholder transactions that have no meaning.

Source from the content-addressed store, hash-verified

30struct TxPackageTest : TestChain100Setup {
31// Create placeholder transactions that have no meaning.
32inline CTransactionRef create_placeholder_tx(size_t num_inputs, size_t num_outputs)
33{
34 CMutableTransaction mtx = CMutableTransaction();
35 mtx.vin.resize(num_inputs);
36 mtx.vout.resize(num_outputs);
37 auto random_script = CScript() << ToByteVector(m_rng.rand256()) << ToByteVector(m_rng.rand256());
38 for (size_t i{0}; i < num_inputs; ++i) {
39 mtx.vin[i].prevout.hash = Txid::FromUint256(m_rng.rand256());
40 mtx.vin[i].prevout.n = 0;
41 mtx.vin[i].scriptSig = random_script;
42 }
43 for (size_t o{0}; o < num_outputs; ++o) {
44 mtx.vout[o].nValue = 1 * CENT;
45 mtx.vout[o].scriptPubKey = random_script;
46 }
47 return MakeTransactionRef(mtx);
48}
49}; // struct TxPackageTest
50
51BOOST_FIXTURE_TEST_SUITE(txpackage_tests, TxPackageTest)

Callers

nothing calls this directly

Calls 6

ToByteVectorFunction · 0.85
MakeTransactionRefFunction · 0.85
rand256Method · 0.80
CMutableTransactionClass · 0.50
CScriptClass · 0.50
resizeMethod · 0.45

Tested by

no test coverage detected