Skip to content

Commit 20f3cd7

Browse files
committed
wallet: Revert input selection post-pruning
This reverts PR #4906, "Coinselection prunes extraneous inputs from ApproximateBestSubset". Apparently the previous behavior of slightly over-estimating the set of inputs was useful in cleaning up UTXOs. See also #7664, #7657, as well as 2016-07-01 discussion on #bitcoin-core-dev IRC.
1 parent da50997 commit 20f3cd7

File tree

2 files changed

+0
-24
lines changed

2 files changed

+0
-24
lines changed

src/wallet/test/wallet_tests.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -349,20 +349,6 @@ BOOST_AUTO_TEST_CASE(ApproximateBestSubset)
349349
BOOST_CHECK(wallet.SelectCoinsMinConf(1003 * COIN, 1, 6, vCoins, setCoinsRet, nValueRet));
350350
BOOST_CHECK_EQUAL(nValueRet, 1003 * COIN);
351351
BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U);
352-
353-
empty_wallet();
354-
355-
// Test trimming
356-
for (int i = 0; i < 100; i++)
357-
add_coin(10 * COIN);
358-
for (int i = 0; i < 100; i++)
359-
add_coin(1000 * COIN);
360-
361-
BOOST_CHECK(wallet.SelectCoinsMinConf(100001 * COIN, 1, 6, vCoins, setCoinsRet, nValueRet));
362-
// We need all 100 larger coins and exactly one small coin.
363-
// Superfluous small coins must be trimmed from the set:
364-
BOOST_CHECK_EQUAL(nValueRet, 100010 * COIN);
365-
BOOST_CHECK_EQUAL(setCoinsRet.size(), 101);
366352
}
367353

368354
BOOST_AUTO_TEST_SUITE_END()

src/wallet/wallet.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,16 +1879,6 @@ static void ApproximateBestSubset(vector<pair<CAmount, pair<const CWalletTx*,uns
18791879
}
18801880
}
18811881
}
1882-
1883-
//Reduces the approximate best subset by removing any inputs that are smaller than the surplus of nTotal beyond nTargetValue.
1884-
for (unsigned int i = 0; i < vValue.size(); i++)
1885-
{
1886-
if (vfBest[i] && (nBest - vValue[i].first) >= nTargetValue )
1887-
{
1888-
vfBest[i] = false;
1889-
nBest -= vValue[i].first;
1890-
}
1891-
}
18921882
}
18931883

18941884
bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, vector<COutput> vCoins,

0 commit comments

Comments
 (0)