Skip to content

Commit 5a70572

Browse files
committed
Merge #9262: Prefer coins that have fewer ancestors, sanity check txn before ATMP
cee1612 reduce number of lookups in TransactionWithinChainLimit (Gregory Sanders) af9bedb Test for fix of txn chaining in wallet (Gregory Sanders) 5882c09 CreateTransaction: Don't return success with too-many-ancestor txn (Gregory Sanders) 0b2294a SelectCoinsMinConf: Prefer coins with fewer ancestors (Gregory Sanders)
2 parents 3097ea4 + cee1612 commit 5a70572

File tree

7 files changed

+105
-44
lines changed

7 files changed

+105
-44
lines changed

qa/rpc-tests/wallet.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,12 @@ def run_test (self):
330330
# disabled until issue is fixed: https://github.com/bitcoin/bitcoin/issues/7463
331331
# '-salvagewallet',
332332
]
333+
chainlimit = 6
333334
for m in maintenance:
334335
print("check " + m)
335336
stop_nodes(self.nodes)
336-
self.nodes = start_nodes(3, self.options.tmpdir, [[m]] * 3)
337+
# set lower ancestor limit for later
338+
self.nodes = start_nodes(3, self.options.tmpdir, [[m, "-limitancestorcount="+str(chainlimit)]] * 3)
337339
while m == '-reindex' and [block_count] * 3 != [self.nodes[i].getblockcount() for i in range(3)]:
338340
# reindex will leave rpc warm up "early"; Wait for it to finish
339341
time.sleep(0.1)
@@ -346,5 +348,26 @@ def run_test (self):
346348
assert_equal(coinbase_tx_1["transactions"][0]["blockhash"], blocks[1])
347349
assert_equal(len(self.nodes[0].listsinceblock(blocks[1])["transactions"]), 0)
348350

351+
# ==Check that wallet prefers to use coins that don't exceed mempool limits =====
352+
353+
# Get all non-zero utxos together
354+
chain_addrs = [self.nodes[0].getnewaddress(), self.nodes[0].getnewaddress()]
355+
singletxid = self.nodes[0].sendtoaddress(chain_addrs[0], self.nodes[0].getbalance(), "", "", True)
356+
self.nodes[0].generate(1)
357+
node0_balance = self.nodes[0].getbalance()
358+
# Split into two chains
359+
rawtx = self.nodes[0].createrawtransaction([{"txid":singletxid, "vout":0}], {chain_addrs[0]:node0_balance/2-Decimal('0.01'), chain_addrs[1]:node0_balance/2-Decimal('0.01')})
360+
signedtx = self.nodes[0].signrawtransaction(rawtx)
361+
singletxid = self.nodes[0].sendrawtransaction(signedtx["hex"])
362+
txids = [singletxid, singletxid]
363+
self.nodes[0].generate(1)
364+
365+
# Make a long chain of unconfirmed payments without hitting mempool limit
366+
txid_list = []
367+
for i in range(chainlimit*2):
368+
txid_list.append(self.nodes[0].sendtoaddress(chain_addrs[0], Decimal('0.0001')))
369+
assert_equal(self.nodes[0].getmempoolinfo()['size'], chainlimit*2)
370+
assert_equal(len(txid_list), chainlimit*2)
371+
349372
if __name__ == '__main__':
350373
WalletTest().main()

src/bench/coin_selection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static void CoinSelection(benchmark::State& state)
5252

5353
set<pair<const CWalletTx*, unsigned int> > setCoinsRet;
5454
CAmount nValueRet;
55-
bool success = wallet.SelectCoinsMinConf(1003 * COIN, 1, 6, vCoins, setCoinsRet, nValueRet);
55+
bool success = wallet.SelectCoinsMinConf(1003 * COIN, 1, 6, 0, vCoins, setCoinsRet, nValueRet);
5656
assert(success);
5757
assert(nValueRet == 1003 * COIN);
5858
assert(setCoinsRet.size() == 2);

src/txmempool.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,3 +1137,10 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<uint256>* pvNoSpendsRe
11371137
if (maxFeeRateRemoved > CFeeRate(0))
11381138
LogPrint("mempool", "Removed %u txn, rolling minimum fee bumped to %s\n", nTxnRemoved, maxFeeRateRemoved.ToString());
11391139
}
1140+
1141+
bool CTxMemPool::TransactionWithinChainLimit(const uint256& txid, size_t chainLimit) const {
1142+
LOCK(cs);
1143+
auto it = mapTx.find(txid);
1144+
return it == mapTx.end() || (it->GetCountWithAncestors() < chainLimit &&
1145+
it->GetCountWithDescendants() < chainLimit);
1146+
}

src/txmempool.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,9 @@ class CTxMemPool
605605
/** Expire all transaction (and their dependencies) in the mempool older than time. Return the number of removed transactions. */
606606
int Expire(int64_t time);
607607

608+
/** Returns false if the transaction is in the mempool and not within the chain limit specified. */
609+
bool TransactionWithinChainLimit(const uint256& txid, size_t chainLimit) const;
610+
608611
unsigned long size()
609612
{
610613
LOCK(cs);

src/wallet/test/wallet_tests.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,24 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests)
7878
empty_wallet();
7979

8080
// with an empty wallet we can't even pay one cent
81-
BOOST_CHECK(!wallet.SelectCoinsMinConf( 1 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet));
81+
BOOST_CHECK(!wallet.SelectCoinsMinConf( 1 * CENT, 1, 6, 0, vCoins, setCoinsRet, nValueRet));
8282

8383
add_coin(1*CENT, 4); // add a new 1 cent coin
8484

8585
// with a new 1 cent coin, we still can't find a mature 1 cent
86-
BOOST_CHECK(!wallet.SelectCoinsMinConf( 1 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet));
86+
BOOST_CHECK(!wallet.SelectCoinsMinConf( 1 * CENT, 1, 6, 0, vCoins, setCoinsRet, nValueRet));
8787

8888
// but we can find a new 1 cent
89-
BOOST_CHECK( wallet.SelectCoinsMinConf( 1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
89+
BOOST_CHECK( wallet.SelectCoinsMinConf( 1 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
9090
BOOST_CHECK_EQUAL(nValueRet, 1 * CENT);
9191

9292
add_coin(2*CENT); // add a mature 2 cent coin
9393

9494
// we can't make 3 cents of mature coins
95-
BOOST_CHECK(!wallet.SelectCoinsMinConf( 3 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet));
95+
BOOST_CHECK(!wallet.SelectCoinsMinConf( 3 * CENT, 1, 6, 0, vCoins, setCoinsRet, nValueRet));
9696

9797
// we can make 3 cents of new coins
98-
BOOST_CHECK( wallet.SelectCoinsMinConf( 3 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
98+
BOOST_CHECK( wallet.SelectCoinsMinConf( 3 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
9999
BOOST_CHECK_EQUAL(nValueRet, 3 * CENT);
100100

101101
add_coin(5*CENT); // add a mature 5 cent coin,
@@ -105,33 +105,33 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests)
105105
// now we have new: 1+10=11 (of which 10 was self-sent), and mature: 2+5+20=27. total = 38
106106

107107
// we can't make 38 cents only if we disallow new coins:
108-
BOOST_CHECK(!wallet.SelectCoinsMinConf(38 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet));
108+
BOOST_CHECK(!wallet.SelectCoinsMinConf(38 * CENT, 1, 6, 0, vCoins, setCoinsRet, nValueRet));
109109
// we can't even make 37 cents if we don't allow new coins even if they're from us
110-
BOOST_CHECK(!wallet.SelectCoinsMinConf(38 * CENT, 6, 6, vCoins, setCoinsRet, nValueRet));
110+
BOOST_CHECK(!wallet.SelectCoinsMinConf(38 * CENT, 6, 6, 0, vCoins, setCoinsRet, nValueRet));
111111
// but we can make 37 cents if we accept new coins from ourself
112-
BOOST_CHECK( wallet.SelectCoinsMinConf(37 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet));
112+
BOOST_CHECK( wallet.SelectCoinsMinConf(37 * CENT, 1, 6, 0, vCoins, setCoinsRet, nValueRet));
113113
BOOST_CHECK_EQUAL(nValueRet, 37 * CENT);
114114
// and we can make 38 cents if we accept all new coins
115-
BOOST_CHECK( wallet.SelectCoinsMinConf(38 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
115+
BOOST_CHECK( wallet.SelectCoinsMinConf(38 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
116116
BOOST_CHECK_EQUAL(nValueRet, 38 * CENT);
117117

118118
// try making 34 cents from 1,2,5,10,20 - we can't do it exactly
119-
BOOST_CHECK( wallet.SelectCoinsMinConf(34 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
119+
BOOST_CHECK( wallet.SelectCoinsMinConf(34 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
120120
BOOST_CHECK_EQUAL(nValueRet, 35 * CENT); // but 35 cents is closest
121121
BOOST_CHECK_EQUAL(setCoinsRet.size(), 3U); // the best should be 20+10+5. it's incredibly unlikely the 1 or 2 got included (but possible)
122122

123123
// when we try making 7 cents, the smaller coins (1,2,5) are enough. We should see just 2+5
124-
BOOST_CHECK( wallet.SelectCoinsMinConf( 7 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
124+
BOOST_CHECK( wallet.SelectCoinsMinConf( 7 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
125125
BOOST_CHECK_EQUAL(nValueRet, 7 * CENT);
126126
BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U);
127127

128128
// when we try making 8 cents, the smaller coins (1,2,5) are exactly enough.
129-
BOOST_CHECK( wallet.SelectCoinsMinConf( 8 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
129+
BOOST_CHECK( wallet.SelectCoinsMinConf( 8 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
130130
BOOST_CHECK(nValueRet == 8 * CENT);
131131
BOOST_CHECK_EQUAL(setCoinsRet.size(), 3U);
132132

133133
// when we try making 9 cents, no subset of smaller coins is enough, and we get the next bigger coin (10)
134-
BOOST_CHECK( wallet.SelectCoinsMinConf( 9 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
134+
BOOST_CHECK( wallet.SelectCoinsMinConf( 9 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
135135
BOOST_CHECK_EQUAL(nValueRet, 10 * CENT);
136136
BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
137137

@@ -145,30 +145,30 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests)
145145
add_coin(30*CENT); // now we have 6+7+8+20+30 = 71 cents total
146146

147147
// check that we have 71 and not 72
148-
BOOST_CHECK( wallet.SelectCoinsMinConf(71 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
149-
BOOST_CHECK(!wallet.SelectCoinsMinConf(72 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
148+
BOOST_CHECK( wallet.SelectCoinsMinConf(71 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
149+
BOOST_CHECK(!wallet.SelectCoinsMinConf(72 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
150150

151151
// now try making 16 cents. the best smaller coins can do is 6+7+8 = 21; not as good at the next biggest coin, 20
152-
BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
152+
BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
153153
BOOST_CHECK_EQUAL(nValueRet, 20 * CENT); // we should get 20 in one coin
154154
BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
155155

156156
add_coin( 5*CENT); // now we have 5+6+7+8+20+30 = 75 cents total
157157

158158
// now if we try making 16 cents again, the smaller coins can make 5+6+7 = 18 cents, better than the next biggest coin, 20
159-
BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
159+
BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
160160
BOOST_CHECK_EQUAL(nValueRet, 18 * CENT); // we should get 18 in 3 coins
161161
BOOST_CHECK_EQUAL(setCoinsRet.size(), 3U);
162162

163163
add_coin( 18*CENT); // now we have 5+6+7+8+18+20+30
164164

165165
// and now if we try making 16 cents again, the smaller coins can make 5+6+7 = 18 cents, the same as the next biggest coin, 18
166-
BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
166+
BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
167167
BOOST_CHECK_EQUAL(nValueRet, 18 * CENT); // we should get 18 in 1 coin
168168
BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U); // because in the event of a tie, the biggest coin wins
169169

170170
// now try making 11 cents. we should get 5+6
171-
BOOST_CHECK( wallet.SelectCoinsMinConf(11 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
171+
BOOST_CHECK( wallet.SelectCoinsMinConf(11 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
172172
BOOST_CHECK_EQUAL(nValueRet, 11 * CENT);
173173
BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U);
174174

@@ -177,11 +177,11 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests)
177177
add_coin( 2*COIN);
178178
add_coin( 3*COIN);
179179
add_coin( 4*COIN); // now we have 5+6+7+8+18+20+30+100+200+300+400 = 1094 cents
180-
BOOST_CHECK( wallet.SelectCoinsMinConf(95 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
180+
BOOST_CHECK( wallet.SelectCoinsMinConf(95 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
181181
BOOST_CHECK_EQUAL(nValueRet, 1 * COIN); // we should get 1 BTC in 1 coin
182182
BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
183183

184-
BOOST_CHECK( wallet.SelectCoinsMinConf(195 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
184+
BOOST_CHECK( wallet.SelectCoinsMinConf(195 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
185185
BOOST_CHECK_EQUAL(nValueRet, 2 * COIN); // we should get 2 BTC in 1 coin
186186
BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
187187

@@ -196,22 +196,22 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests)
196196

197197
// try making 1 * MIN_CHANGE from the 1.5 * MIN_CHANGE
198198
// we'll get change smaller than MIN_CHANGE whatever happens, so can expect MIN_CHANGE exactly
199-
BOOST_CHECK( wallet.SelectCoinsMinConf(MIN_CHANGE, 1, 1, vCoins, setCoinsRet, nValueRet));
199+
BOOST_CHECK( wallet.SelectCoinsMinConf(MIN_CHANGE, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
200200
BOOST_CHECK_EQUAL(nValueRet, MIN_CHANGE);
201201

202202
// but if we add a bigger coin, small change is avoided
203203
add_coin(1111*MIN_CHANGE);
204204

205205
// try making 1 from 0.1 + 0.2 + 0.3 + 0.4 + 0.5 + 1111 = 1112.5
206-
BOOST_CHECK( wallet.SelectCoinsMinConf(1 * MIN_CHANGE, 1, 1, vCoins, setCoinsRet, nValueRet));
206+
BOOST_CHECK( wallet.SelectCoinsMinConf(1 * MIN_CHANGE, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
207207
BOOST_CHECK_EQUAL(nValueRet, 1 * MIN_CHANGE); // we should get the exact amount
208208

209209
// if we add more small coins:
210210
add_coin(MIN_CHANGE * 6 / 10);
211211
add_coin(MIN_CHANGE * 7 / 10);
212212

213213
// and try again to make 1.0 * MIN_CHANGE
214-
BOOST_CHECK( wallet.SelectCoinsMinConf(1 * MIN_CHANGE, 1, 1, vCoins, setCoinsRet, nValueRet));
214+
BOOST_CHECK( wallet.SelectCoinsMinConf(1 * MIN_CHANGE, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
215215
BOOST_CHECK_EQUAL(nValueRet, 1 * MIN_CHANGE); // we should get the exact amount
216216

217217
// run the 'mtgox' test (see http://blockexplorer.com/tx/29a3efd3ef04f9153d47a990bd7b048a4b2d213daaa5fb8ed670fb85f13bdbcf)
@@ -220,7 +220,7 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests)
220220
for (int j = 0; j < 20; j++)
221221
add_coin(50000 * COIN);
222222

223-
BOOST_CHECK( wallet.SelectCoinsMinConf(500000 * COIN, 1, 1, vCoins, setCoinsRet, nValueRet));
223+
BOOST_CHECK( wallet.SelectCoinsMinConf(500000 * COIN, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
224224
BOOST_CHECK_EQUAL(nValueRet, 500000 * COIN); // we should get the exact amount
225225
BOOST_CHECK_EQUAL(setCoinsRet.size(), 10U); // in ten coins
226226

@@ -233,7 +233,7 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests)
233233
add_coin(MIN_CHANGE * 6 / 10);
234234
add_coin(MIN_CHANGE * 7 / 10);
235235
add_coin(1111 * MIN_CHANGE);
236-
BOOST_CHECK( wallet.SelectCoinsMinConf(1 * MIN_CHANGE, 1, 1, vCoins, setCoinsRet, nValueRet));
236+
BOOST_CHECK( wallet.SelectCoinsMinConf(1 * MIN_CHANGE, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
237237
BOOST_CHECK_EQUAL(nValueRet, 1111 * MIN_CHANGE); // we get the bigger coin
238238
BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
239239

@@ -243,7 +243,7 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests)
243243
add_coin(MIN_CHANGE * 6 / 10);
244244
add_coin(MIN_CHANGE * 8 / 10);
245245
add_coin(1111 * MIN_CHANGE);
246-
BOOST_CHECK( wallet.SelectCoinsMinConf(MIN_CHANGE, 1, 1, vCoins, setCoinsRet, nValueRet));
246+
BOOST_CHECK( wallet.SelectCoinsMinConf(MIN_CHANGE, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
247247
BOOST_CHECK_EQUAL(nValueRet, MIN_CHANGE); // we should get the exact amount
248248
BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U); // in two coins 0.4+0.6
249249

@@ -254,12 +254,12 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests)
254254
add_coin(MIN_CHANGE * 100);
255255

256256
// trying to make 100.01 from these three coins
257-
BOOST_CHECK(wallet.SelectCoinsMinConf(MIN_CHANGE * 10001 / 100, 1, 1, vCoins, setCoinsRet, nValueRet));
257+
BOOST_CHECK(wallet.SelectCoinsMinConf(MIN_CHANGE * 10001 / 100, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
258258
BOOST_CHECK_EQUAL(nValueRet, MIN_CHANGE * 10105 / 100); // we should get all coins
259259
BOOST_CHECK_EQUAL(setCoinsRet.size(), 3U);
260260

261261
// but if we try to make 99.9, we should take the bigger of the two small coins to avoid small change
262-
BOOST_CHECK(wallet.SelectCoinsMinConf(MIN_CHANGE * 9990 / 100, 1, 1, vCoins, setCoinsRet, nValueRet));
262+
BOOST_CHECK(wallet.SelectCoinsMinConf(MIN_CHANGE * 9990 / 100, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
263263
BOOST_CHECK_EQUAL(nValueRet, 101 * MIN_CHANGE);
264264
BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U);
265265

@@ -269,7 +269,7 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests)
269269
// Create 676 inputs (= (old MAX_STANDARD_TX_SIZE == 100000) / 148 bytes per input)
270270
for (uint16_t j = 0; j < 676; j++)
271271
add_coin(amt);
272-
BOOST_CHECK(wallet.SelectCoinsMinConf(2000, 1, 1, vCoins, setCoinsRet, nValueRet));
272+
BOOST_CHECK(wallet.SelectCoinsMinConf(2000, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
273273
if (amt - 2000 < MIN_CHANGE) {
274274
// needs more than one input:
275275
uint16_t returnSize = std::ceil((2000.0 + MIN_CHANGE)/amt);
@@ -291,17 +291,17 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests)
291291

292292
// picking 50 from 100 coins doesn't depend on the shuffle,
293293
// but does depend on randomness in the stochastic approximation code
294-
BOOST_CHECK(wallet.SelectCoinsMinConf(50 * COIN, 1, 6, vCoins, setCoinsRet , nValueRet));
295-
BOOST_CHECK(wallet.SelectCoinsMinConf(50 * COIN, 1, 6, vCoins, setCoinsRet2, nValueRet));
294+
BOOST_CHECK(wallet.SelectCoinsMinConf(50 * COIN, 1, 6, 0, vCoins, setCoinsRet , nValueRet));
295+
BOOST_CHECK(wallet.SelectCoinsMinConf(50 * COIN, 1, 6, 0, vCoins, setCoinsRet2, nValueRet));
296296
BOOST_CHECK(!equal_sets(setCoinsRet, setCoinsRet2));
297297

298298
int fails = 0;
299299
for (int j = 0; j < RANDOM_REPEATS; j++)
300300
{
301301
// selecting 1 from 100 identical coins depends on the shuffle; this test will fail 1% of the time
302302
// run the test RANDOM_REPEATS times and only complain if all of them fail
303-
BOOST_CHECK(wallet.SelectCoinsMinConf(COIN, 1, 6, vCoins, setCoinsRet , nValueRet));
304-
BOOST_CHECK(wallet.SelectCoinsMinConf(COIN, 1, 6, vCoins, setCoinsRet2, nValueRet));
303+
BOOST_CHECK(wallet.SelectCoinsMinConf(COIN, 1, 6, 0, vCoins, setCoinsRet , nValueRet));
304+
BOOST_CHECK(wallet.SelectCoinsMinConf(COIN, 1, 6, 0, vCoins, setCoinsRet2, nValueRet));
305305
if (equal_sets(setCoinsRet, setCoinsRet2))
306306
fails++;
307307
}
@@ -321,8 +321,8 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests)
321321
{
322322
// selecting 1 from 100 identical coins depends on the shuffle; this test will fail 1% of the time
323323
// run the test RANDOM_REPEATS times and only complain if all of them fail
324-
BOOST_CHECK(wallet.SelectCoinsMinConf(90*CENT, 1, 6, vCoins, setCoinsRet , nValueRet));
325-
BOOST_CHECK(wallet.SelectCoinsMinConf(90*CENT, 1, 6, vCoins, setCoinsRet2, nValueRet));
324+
BOOST_CHECK(wallet.SelectCoinsMinConf(90*CENT, 1, 6, 0, vCoins, setCoinsRet , nValueRet));
325+
BOOST_CHECK(wallet.SelectCoinsMinConf(90*CENT, 1, 6, 0, vCoins, setCoinsRet2, nValueRet));
326326
if (equal_sets(setCoinsRet, setCoinsRet2))
327327
fails++;
328328
}
@@ -346,7 +346,7 @@ BOOST_AUTO_TEST_CASE(ApproximateBestSubset)
346346
add_coin(1000 * COIN);
347347
add_coin(3 * COIN);
348348

349-
BOOST_CHECK(wallet.SelectCoinsMinConf(1003 * COIN, 1, 6, vCoins, setCoinsRet, nValueRet));
349+
BOOST_CHECK(wallet.SelectCoinsMinConf(1003 * COIN, 1, 6, 0, vCoins, setCoinsRet, nValueRet));
350350
BOOST_CHECK_EQUAL(nValueRet, 1003 * COIN);
351351
BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U);
352352
}

0 commit comments

Comments
 (0)