Skip to content

Commit

Permalink
Revert "Merge bitcoin#12694: Actually disable BnB when there are pres…
Browse files Browse the repository at this point in the history
…et inputs"

This reverts commit 9552dfb, reversing
changes made to f686002.
  • Loading branch information
achow101 authored and instagibbs committed Aug 14, 2019
1 parent b799ebc commit d06ed67
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 17 deletions.
14 changes: 0 additions & 14 deletions src/wallet/test/coinselector_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include <wallet/wallet.h>
#include <wallet/coinselection.h>
#include <wallet/coincontrol.h>
#include <amount.h>
#include <primitives/transaction.h>
#include <random.h>
Expand Down Expand Up @@ -73,7 +72,6 @@ static void add_coin(const CAmount& nValue, int nAge = 6*24, bool fIsFromMe = fa
}
COutput output(wtx.get(), nInput, nAge, true /* spendable */, true /* solvable */, true /* safe */);
vCoins.push_back(output);
testWallet.AddToWallet(*wtx.get());
wtxn.emplace_back(std::move(wtx));
}

Expand Down Expand Up @@ -249,18 +247,6 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
add_coin(1);
vCoins.at(0).nInputBytes = 40; // Make sure that it has a negative effective value. The next check should assert if this somehow got through. Otherwise it will fail
BOOST_CHECK(!testWallet.SelectCoinsMinConf( 1 * CENT, filter_standard, GroupCoins(vCoins), setCoinsRet, nValueRet, coin_selection_params_bnb, bnb_used));

// Make sure that we aren't using BnB when there are preset inputs
empty_wallet();
add_coin(5 * CENT);
add_coin(3 * CENT);
add_coin(2 * CENT);
CCoinControl coin_control;
coin_control.fAllowOtherInputs = true;
coin_control.Select(COutPoint(vCoins.at(0).tx->GetHash(), vCoins.at(0).i));
BOOST_CHECK(testWallet.SelectCoins(vCoins, 10 * CENT, setCoinsRet, nValueRet, coin_control, coin_selection_params_bnb, bnb_used));
BOOST_CHECK(!bnb_used);
BOOST_CHECK(!coin_selection_params_bnb.use_bnb);
}

BOOST_AUTO_TEST_CASE(knapsack_solver_test)
Expand Down
3 changes: 1 addition & 2 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2681,7 +2681,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const CoinEligibil
}
}

bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAmount& nTargetValue, std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet, const CCoinControl& coin_control, CoinSelectionParams& coin_selection_params, bool& bnb_used) const
bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAmount& nTargetValue, std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet, const CCoinControl& coin_control, const CoinSelectionParams& coin_selection_params, bool& bnb_used) const
{
std::vector<COutput> vCoins(vAvailableCoins);

Expand Down Expand Up @@ -2711,7 +2711,6 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
{
// For now, don't use BnB if preset inputs are selected. TODO: Enable this later
bnb_used = false;
coin_selection_params.use_bnb = false;

std::map<uint256, CWalletTx>::const_iterator it = mapWallet.find(outpoint.hash);
if (it != mapWallet.end())
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ class CWallet final : public FillableSigningProvider, private interfaces::Chain:

WalletBatch *encrypted_batch GUARDED_BY(cs_wallet) = nullptr;


//! the current wallet version: clients below this version are not able to load the wallet
int nWalletVersion GUARDED_BY(cs_wallet){FEATURE_BASE};

Expand Down Expand Up @@ -857,7 +858,6 @@ class CWallet final : public FillableSigningProvider, private interfaces::Chain:
const CCoinControl& coin_control, CoinSelectionParams& coin_selection_params, bool& bnb_used) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);

const WalletLocation& GetLocation() const { return m_location; }

/** Get a name for this wallet for logging/debugging purposes.
*/
const std::string& GetName() const { return m_location.GetName(); }
Expand Down

0 comments on commit d06ed67

Please sign in to comment.