Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/test/coinselector_tests.cpp
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | if (fIsFromMe) { | ||||
// IsFromMe() returns (GetDebit() > 0), and GetDebit() is 0 if | // IsFromMe() returns (GetDebit() > 0), and GetDebit() is 0 if | ||||
// vin.empty(), so stop vin being empty, and cache a non-zero Debit to | // vin.empty(), so stop vin being empty, and cache a non-zero Debit to | ||||
// fake out IsFromMe() | // fake out IsFromMe() | ||||
tx.vin.resize(1); | tx.vin.resize(1); | ||||
} | } | ||||
auto wtx = | auto wtx = | ||||
std::make_unique<CWalletTx>(&wallet, MakeTransactionRef(std::move(tx))); | std::make_unique<CWalletTx>(&wallet, MakeTransactionRef(std::move(tx))); | ||||
if (fIsFromMe) { | if (fIsFromMe) { | ||||
wtx->fDebitCached = true; | wtx->m_amounts[CWalletTx::DEBIT].Set(ISMINE_SPENDABLE, SATOSHI); | ||||
wtx->nDebitCached = SATOSHI; | |||||
} | } | ||||
COutput output(wtx.get(), nInput, nAge, true /* spendable */, | COutput output(wtx.get(), nInput, nAge, true /* spendable */, | ||||
true /* solvable */, true /* safe */); | true /* solvable */, true /* safe */); | ||||
vCoins.push_back(output); | vCoins.push_back(output); | ||||
wallet.AddToWallet(*wtx.get()); | wallet.AddToWallet(*wtx.get()); | ||||
wtxn.emplace_back(std::move(wtx)); | wtxn.emplace_back(std::move(wtx)); | ||||
} | } | ||||
Show All 34 Lines | |||||
inline std::vector<OutputGroup> &GroupCoins(const std::vector<COutput> &coins) { | inline std::vector<OutputGroup> &GroupCoins(const std::vector<COutput> &coins) { | ||||
static std::vector<OutputGroup> static_groups; | static std::vector<OutputGroup> static_groups; | ||||
static_groups.clear(); | static_groups.clear(); | ||||
for (auto &coin : coins) { | for (auto &coin : coins) { | ||||
// HACK: we can't figure out the is_me flag so we use the conditions | // HACK: we can't figure out the is_me flag so we use the conditions | ||||
// defined below; perhaps set safe to false for !fIsFromMe in add_coin() | // defined below; perhaps set safe to false for !fIsFromMe in add_coin() | ||||
const bool is_me = | const bool is_me = | ||||
coin.tx->fDebitCached && coin.tx->nDebitCached == SATOSHI; | coin.tx->m_amounts[CWalletTx::DEBIT].m_cached[ISMINE_SPENDABLE] && | ||||
coin.tx->m_amounts[CWalletTx::DEBIT].m_value[ISMINE_SPENDABLE] == | |||||
SATOSHI; | |||||
static_groups.emplace_back(coin.GetInputCoin(), coin.nDepth, is_me, 0, | static_groups.emplace_back(coin.GetInputCoin(), coin.nDepth, is_me, 0, | ||||
0); | 0); | ||||
} | } | ||||
return static_groups; | return static_groups; | ||||
} | } | ||||
// Branch and bound coin selection tests | // Branch and bound coin selection tests | ||||
BOOST_AUTO_TEST_CASE(bnb_search_test) { | BOOST_AUTO_TEST_CASE(bnb_search_test) { | ||||
▲ Show 20 Lines • Show All 638 Lines • Show Last 20 Lines |