11 static void addCoin(
const CAmount& nValue,
const CWallet& wallet, std::vector<OutputGroup>& groups)
15 static int nextLockTime = 0;
18 tx.
vout.resize(nInput + 1);
19 tx.
vout[nInput].nValue = nValue;
23 COutput output(wtx, nInput, nAge,
true ,
true ,
true );
24 groups.emplace_back(output.GetInputCoin(), 6,
false, 0, 0);
40 std::vector<OutputGroup> groups;
41 for (
int i = 0; i < 1000; ++i) {
42 addCoin(1000 * COIN, wallet, groups);
44 addCoin(3 * COIN, wallet, groups);
49 std::set<CInputCoin> setCoinsRet;
54 assert(nValueRet == 1003 * COIN);
55 assert(setCoinsRet.size() == 2);
61 std::vector<std::unique_ptr<CWalletTx>>
wtxn;
64 static void add_coin(
const CAmount& nValue,
int nInput, std::vector<OutputGroup>&
set)
67 tx.
vout.resize(nInput + 1);
68 tx.
vout[nInput].nValue = nValue;
69 std::unique_ptr<CWalletTx> wtx = MakeUnique<CWalletTx>(&testWallet, MakeTransactionRef(std::move(tx)));
70 set.emplace_back(
COutput(wtx.get(), nInput, 0,
true,
true,
true).GetInputCoin(), 0,
true, 0, 0);
71 wtxn.emplace_back(std::move(wtx));
74 static CAmount make_hard_case(
int utxos, std::vector<OutputGroup>& utxo_pool)
78 for (
int i = 0; i < utxos; ++i) {
79 target += (
CAmount)1 << (utxos+i);
80 add_coin((
CAmount)1 << (utxos+i), 2*i, utxo_pool);
81 add_coin(((
CAmount)1 << (utxos+i)) + ((
CAmount)1 << (utxos-1-i)), 2*i + 1, utxo_pool);
89 std::vector<OutputGroup> utxo_pool;
96 CAmount target = make_hard_case(17, utxo_pool);
97 SelectCoinsBnB(utxo_pool, target, 0, selection, value_ret, not_input_fees);
static std::unique_ptr< BerkeleyDatabase > CreateDummy()
Return object for accessing dummy database with no read/write capabilities.
std::set< CInputCoin > CoinSet
bool SelectCoinsBnB(std::vector< OutputGroup > &utxo_pool, const CAmount &target_value, const CAmount &cost_of_change, std::set< CInputCoin > &out_set, CAmount &value_ret, CAmount not_input_fees)
bool SelectCoinsMinConf(const CAmount &nTargetValue, const CoinEligibilityFilter &eligibility_filter, std::vector< OutputGroup > groups, std::set< CInputCoin > &setCoinsRet, CAmount &nValueRet, const CoinSelectionParams &coin_selection_params, bool &bnb_used) const
Shuffle and select coins until nTargetValue is reached while avoiding small change; This method is st...
CoinEligibilityFilter filter_standard(1, 6, 0)
std::vector< std::unique_ptr< CWalletTx > > wtxn
int64_t CAmount
Amount in satoshis (Can be negative)
CCriticalSection cs_wallet
std::vector< CTxOut > vout
A transaction with a bunch of additional info that only the owner cares about.
CoinSelectionParams coin_selection_params(false, 0, 0, CFeeRate(0), 0)
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Fee rate in satoshis per kilobyte: CAmount / kB.
A mutable version of CTransaction.
BENCHMARK(CoinSelection, 650)