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

Function MakeCoin

src/wallet/test/coinselection_tests.cpp:63–74  ·  view source on GitHub ↗

Make one OutputGroup with a single UTXO that either has a given effective value (default) or a given amount (`is_eff_value = false`). */

Source from the content-addressed store, hash-verified

61
62/** Make one OutputGroup with a single UTXO that either has a given effective value (default) or a given amount (`is_eff_value = false`). */
63static OutputGroup MakeCoin(const CAmount& amount, bool is_eff_value = true, CoinSelectionParams cs_params = default_cs_params, int custom_spending_vsize = P2WPKH_INPUT_VSIZE)
64{
65 // Always assume that we only have one input
66 CMutableTransaction tx;
67 tx.vout.resize(1);
68 CAmount fees = cs_params.m_effective_feerate.GetFee(custom_spending_vsize);
69 tx.vout[0].nValue = amount + int(is_eff_value) * fees;
70 tx.nLockTime = next_lock_time++; // so all transactions get different hashes
71 OutputGroup group(cs_params);
72 group.Insert(std::make_shared<COutput>(COutPoint(tx.GetHash(), 0), tx.vout.at(0), /*depth=*/1, /*input_bytes=*/custom_spending_vsize, /*solvable=*/true, /*safe=*/true, /*time=*/0, /*from_me=*/false, /*fees=*/fees), /*ancestors=*/0, /*cluster_count=*/0);
73 return group;
74}
75
76/** Make multiple OutputGroups with the given values as their effective value */
77static void AddCoins(std::vector<OutputGroup>& utxo_pool, std::vector<CAmount> coins, CoinSelectionParams cs_params = default_cs_params)

Callers 6

AddCoinsFunction · 0.85
AddDuplicateCoinsFunction · 0.85
TestBnBSuccessFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
TestFlushBehaviorMethod · 0.85
BOOST_FIXTURE_TEST_CASEFunction · 0.85

Calls 6

COutPointClass · 0.50
resizeMethod · 0.45
GetFeeMethod · 0.45
InsertMethod · 0.45
GetHashMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected