PRCYCoin  2.0.0.7rc1
P2P Digital Currency
wallet_tests.cpp
Go to the documentation of this file.
1 // Copyright (c) 2012-2014 The Bitcoin Core developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include "wallet/wallet.h"
6 #include "miner.h"
7 
8 #include <set>
9 #include <stdint.h>
10 #include <utility>
11 #include <vector>
12 
13 #include <boost/test/unit_test.hpp>
14 #include "test_prcycoin.h"
15 
16 // how many times to run all the tests to have a chance to catch errors that only show up with particular random shuffles
17 #define RUN_TESTS 100
18 
19 // some tests fail 1% of the time due to bad luck.
20 // we repeat those tests this many times and only complain if all iterations of the test fail
21 #define RANDOM_REPEATS 5
22 
23 
24 typedef std::set<std::pair<const CWalletTx*,unsigned int> > CoinSet;
25 extern CWallet* pwalletMain;
26 extern int64_t nReserveBalance;
27 
28 BOOST_FIXTURE_TEST_SUITE(wallet_tests, TestingSetup)
29 
30 static void generate_block(int count) {
31  int nHeightStart = 0;
32  int nHeightEnd = 0;
33  int nHeight = 0;
34  int nGenerate = count;
35  CReserveKey reservekey(pwalletMain);
36 
37  { // Don't keep cs_main locked
38  // LOCK(cs_main);
39  nHeightStart = chainActive.Height();
40  nHeight = nHeightStart;
41  nHeightEnd = nHeightStart + nGenerate;
42  }
43  unsigned int nExtraNonce = 0;
44  while (nHeight < nHeightEnd) {
45  bool createPoSBlock = false;
46  if (nHeight > Params().LAST_POW_BLOCK())
47  createPoSBlock = true;
48 
49  std::unique_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey, pwalletMain, createPoSBlock));
50  BOOST_CHECK(pblocktemplate.get());
51 
52  CBlock* pblock = &pblocktemplate->block;
53  {
54  // LOCK(cs_main);
55  IncrementExtraNonce(pblock, chainActive.Tip(), nExtraNonce);
56  }
57  while (!CheckProofOfWork(pblock->GetHash(), pblock->nBits)) {
58  // Yes, there is a chance every nonce could fail to satisfy the -regtest
59  // target -- 1 in 2^(2^32). That ain't gonna happen.
60  ++pblock->nNonce;
61  }
62  CValidationState state;
63  BOOST_CHECK(ProcessNewBlock(state, NULL, pblock));
64  ++nHeight;
65  }
66 }
67 
68 #ifdef DISABLE_FAILED_TEST
69 static CWallet wallet;
70 static std::vector<COutput> vCoins;
71 
72 static void add_coin(const CAmount& nValue, int nAge = 6*24, bool fIsFromMe = false, int nInput=0)
73 {
74  static int nextLockTime = 0;
76  tx.nLockTime = nextLockTime++; // so all transactions get different hashes
77  tx.vout.resize(nInput+1);
78  tx.vout[nInput].nValue = nValue;
79  if (fIsFromMe) {
80  // IsFromMe() returns (GetDebit() > 0), and GetDebit() is 0 if vin.empty(),
81  // so stop vin being empty, and cache a non-zero Debit to fake out IsFromMe()
82  tx.vin.resize(1);
83  }
84  CWalletTx* wtx = new CWalletTx(&wallet, tx);
85  if (fIsFromMe)
86  {
87  wtx->fDebitCached = true;
88  wtx->nDebitCached = 1;
89  }
90  COutput output(wtx, nInput, nAge, true);
91  vCoins.push_back(output);
92 }
93 
94 static void empty_wallet(void)
95 {
96  for (COutput output : vCoins)
97  delete output.tx;
98  vCoins.clear();
99 }
100 
101 static bool equal_sets(CoinSet a, CoinSet b)
102 {
103  pair<CoinSet::iterator, CoinSet::iterator> ret = mismatch(a.begin(), a.end(), b.begin());
104  return ret.first == a.end() && ret.second == b.end();
105 }
106 
107 BOOST_AUTO_TEST_CASE(coin_selection_tests)
108 {
109  CoinSet setCoinsRet, setCoinsRet2;
110  CAmount nValueRet;
111 
113 
114  // test multiple times to allow for differences in the shuffle order
115  for (int i = 0; i < RUN_TESTS; i++)
116  {
117  empty_wallet();
118 
119  // with an empty wallet we can't even pay one cent
120  BOOST_CHECK(!wallet.SelectCoinsMinConf( 1 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet));
121 
122  add_coin(1*CENT, 4); // add a new 1 cent coin
123 
124  // with a new 1 cent coin, we still can't find a mature 1 cent
125  BOOST_CHECK(!wallet.SelectCoinsMinConf( 1 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet));
126 
127  // but we can find a new 1 cent
128  BOOST_CHECK( pwalletMain->SelectCoinsMinConf( 1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
129  BOOST_CHECK_EQUAL(nValueRet, 1 * CENT);
130 
131  add_coin(2*CENT); // add a mature 2 cent coin
132 
133  // we can't make 3 cents of mature coins
134  BOOST_CHECK(!wallet.SelectCoinsMinConf( 3 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet));
135 
136  // we can make 3 cents of new coins
137  BOOST_CHECK( wallet.SelectCoinsMinConf( 3 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
138  BOOST_CHECK_EQUAL(nValueRet, 3 * CENT);
139 
140  add_coin(5*CENT); // add a mature 5 cent coin,
141  add_coin(10*CENT, 3, true); // a new 10 cent coin sent from one of our own addresses
142  add_coin(20*CENT); // and a mature 20 cent coin
143 
144  // now we have new: 1+10=11 (of which 10 was self-sent), and mature: 2+5+20=27. total = 38
145 
146  // we can't make 38 cents only if we disallow new coins:
147  BOOST_CHECK(!wallet.SelectCoinsMinConf(38 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet));
148  // we can't even make 37 cents if we don't allow new coins even if they're from us
149  BOOST_CHECK(!wallet.SelectCoinsMinConf(38 * CENT, 6, 6, vCoins, setCoinsRet, nValueRet));
150  // but we can make 37 cents if we accept new coins from ourself
151  BOOST_CHECK( wallet.SelectCoinsMinConf(37 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet));
152  BOOST_CHECK_EQUAL(nValueRet, 37 * CENT);
153  // and we can make 38 cents if we accept all new coins
154  BOOST_CHECK( wallet.SelectCoinsMinConf(38 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
155  BOOST_CHECK_EQUAL(nValueRet, 38 * CENT);
156 
157  // try making 34 cents from 1,2,5,10,20 - we can't do it exactly
158  BOOST_CHECK( wallet.SelectCoinsMinConf(34 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
159  BOOST_CHECK_GT(nValueRet, 34 * CENT); // but should get more than 34 cents
160  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)
161 
162  // when we try making 7 cents, the smaller coins (1,2,5) are enough. We should see just 2+5
163  BOOST_CHECK( wallet.SelectCoinsMinConf( 7 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
164  BOOST_CHECK_EQUAL(nValueRet, 7 * CENT);
165  BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U);
166 
167  // when we try making 8 cents, the smaller coins (1,2,5) are exactly enough.
168  BOOST_CHECK( wallet.SelectCoinsMinConf( 8 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
169  BOOST_CHECK(nValueRet == 8 * CENT);
170  BOOST_CHECK_EQUAL(setCoinsRet.size(), 3U);
171 
172  // when we try making 9 cents, no subset of smaller coins is enough, and we get the next bigger coin (10)
173  BOOST_CHECK( wallet.SelectCoinsMinConf( 9 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
174  BOOST_CHECK_EQUAL(nValueRet, 10 * CENT);
175  BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
176 
177  // now clear out the wallet and start again to test choosing between subsets of smaller coins and the next biggest coin
178  empty_wallet();
179 
180  add_coin( 6*CENT);
181  add_coin( 7*CENT);
182  add_coin( 8*CENT);
183  add_coin(20*CENT);
184  add_coin(30*CENT); // now we have 6+7+8+20+30 = 71 cents total
185 
186  // check that we have 71 and not 72
187  BOOST_CHECK( wallet.SelectCoinsMinConf(71 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
188  BOOST_CHECK(!wallet.SelectCoinsMinConf(72 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
189 
190  // 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
191  BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
192  BOOST_CHECK_EQUAL(nValueRet, 20 * CENT); // we should get 20 in one coin
193  BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
194 
195  add_coin( 5*CENT); // now we have 5+6+7+8+20+30 = 75 cents total
196 
197  // 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
198  BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
199  BOOST_CHECK_EQUAL(nValueRet, 18 * CENT); // we should get 18 in 3 coins
200  BOOST_CHECK_EQUAL(setCoinsRet.size(), 3U);
201 
202  add_coin( 18*CENT); // now we have 5+6+7+8+18+20+30
203 
204  // 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
205  BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
206  BOOST_CHECK_EQUAL(nValueRet, 18 * CENT); // we should get 18 in 1 coin
207  BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U); // because in the event of a tie, the biggest coin wins
208 
209  // now try making 11 cents. we should get 5+6
210  BOOST_CHECK( wallet.SelectCoinsMinConf(11 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
211  BOOST_CHECK_EQUAL(nValueRet, 11 * CENT);
212  BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U);
213 
214  // check that the smallest bigger coin is used
215  add_coin( 1*COIN);
216  add_coin( 2*COIN);
217  add_coin( 3*COIN);
218  add_coin( 4*COIN); // now we have 5+6+7+8+18+20+30+100+200+300+400 = 1094 cents
219  BOOST_CHECK( wallet.SelectCoinsMinConf(95 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
220  BOOST_CHECK_EQUAL(nValueRet, 1 * COIN); // we should get 1 BTC in 1 coin
221  BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
222 
223  BOOST_CHECK( wallet.SelectCoinsMinConf(195 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
224  BOOST_CHECK_EQUAL(nValueRet, 2 * COIN); // we should get 2 BTC in 1 coin
225  BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
226 
227  // empty the wallet and start again, now with fractions of a cent, to test sub-cent change avoidance
228  empty_wallet();
229  add_coin(0.1*CENT);
230  add_coin(0.2*CENT);
231  add_coin(0.3*CENT);
232  add_coin(0.4*CENT);
233  add_coin(0.5*CENT);
234 
235  // try making 1 cent from 0.1 + 0.2 + 0.3 + 0.4 + 0.5 = 1.5 cents
236  // we'll get sub-cent change whatever happens, so can expect 1.0 exactly
237  BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
238  BOOST_CHECK_EQUAL(nValueRet, 1 * CENT);
239 
240  // but if we add a bigger coin, making it possible to avoid sub-cent change, things change:
241  add_coin(1111*CENT);
242 
243  // try making 1 cent from 0.1 + 0.2 + 0.3 + 0.4 + 0.5 + 1111 = 1112.5 cents
244  BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
245  BOOST_CHECK_EQUAL(nValueRet, 1 * CENT); // we should get the exact amount
246 
247  // if we add more sub-cent coins:
248  add_coin(0.6*CENT);
249  add_coin(0.7*CENT);
250 
251  // and try again to make 1.0 cents, we can still make 1.0 cents
252  BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
253  BOOST_CHECK_EQUAL(nValueRet, 1 * CENT); // we should get the exact amount
254 
255  // run the 'mtgox' test (see http://blockexplorer.com/tx/29a3efd3ef04f9153d47a990bd7b048a4b2d213daaa5fb8ed670fb85f13bdbcf)
256  // they tried to consolidate 10 50k coins into one 500k coin, and ended up with 50k in change
257  empty_wallet();
258  for (int i = 0; i < 20; i++)
259  add_coin(50000 * COIN);
260 
261  BOOST_CHECK( wallet.SelectCoinsMinConf(500000 * COIN, 1, 1, vCoins, setCoinsRet, nValueRet));
262  BOOST_CHECK_EQUAL(nValueRet, 500000 * COIN); // we should get the exact amount
263  BOOST_CHECK_EQUAL(setCoinsRet.size(), 10U); // in ten coins
264 
265  // if there's not enough in the smaller coins to make at least 1 cent change (0.5+0.6+0.7 < 1.0+1.0),
266  // we need to try finding an exact subset anyway
267 
268  // sometimes it will fail, and so we use the next biggest coin:
269  empty_wallet();
270  add_coin(0.5 * CENT);
271  add_coin(0.6 * CENT);
272  add_coin(0.7 * CENT);
273  add_coin(1111 * CENT);
274  BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
275  BOOST_CHECK_EQUAL(nValueRet, 1111 * CENT); // we get the bigger coin
276  BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
277 
278  // but sometimes it's possible, and we use an exact subset (0.4 + 0.6 = 1.0)
279  empty_wallet();
280  add_coin(0.4 * CENT);
281  add_coin(0.6 * CENT);
282  add_coin(0.8 * CENT);
283  add_coin(1111 * CENT);
284  BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
285  BOOST_CHECK_EQUAL(nValueRet, 1 * CENT); // we should get the exact amount
286  BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U); // in two coins 0.4+0.6
287 
288  // test avoiding sub-cent change
289  empty_wallet();
290  add_coin(0.0005 * COIN);
291  add_coin(0.01 * COIN);
292  add_coin(1 * COIN);
293 
294  // trying to make 1.0001 from these three coins
295  BOOST_CHECK( wallet.SelectCoinsMinConf(1.0001 * COIN, 1, 1, vCoins, setCoinsRet, nValueRet));
296  BOOST_CHECK_EQUAL(nValueRet, 1.0105 * COIN); // we should get all coins
297  BOOST_CHECK_EQUAL(setCoinsRet.size(), 3U);
298 
299  // but if we try to make 0.999, we should take the bigger of the two small coins to avoid sub-cent change
300  BOOST_CHECK( wallet.SelectCoinsMinConf(0.999 * COIN, 1, 1, vCoins, setCoinsRet, nValueRet));
301  BOOST_CHECK_EQUAL(nValueRet, 1.01 * COIN); // we should get 1 + 0.01
302  BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U);
303 
304  // test randomness
305  {
306  empty_wallet();
307  for (int i2 = 0; i2 < 100; i2++)
308  add_coin(COIN);
309 
310  // picking 50 from 100 coins doesn't depend on the shuffle,
311  // but does depend on randomness in the stochastic approximation code
312  BOOST_CHECK(wallet.SelectCoinsMinConf(50 * COIN, 1, 6, vCoins, setCoinsRet , nValueRet));
313  BOOST_CHECK(wallet.SelectCoinsMinConf(50 * COIN, 1, 6, vCoins, setCoinsRet2, nValueRet));
314  BOOST_CHECK(!equal_sets(setCoinsRet, setCoinsRet2));
315 
316  int fails = 0;
317  for (int i = 0; i < RANDOM_REPEATS; i++)
318  {
319  // selecting 1 from 100 identical coins depends on the shuffle; this test will fail 1% of the time
320  // run the test RANDOM_REPEATS times and only complain if all of them fail
321  BOOST_CHECK(wallet.SelectCoinsMinConf(COIN, 1, 6, vCoins, setCoinsRet , nValueRet));
322  BOOST_CHECK(wallet.SelectCoinsMinConf(COIN, 1, 6, vCoins, setCoinsRet2, nValueRet));
323  if (equal_sets(setCoinsRet, setCoinsRet2))
324  fails++;
325  }
326  BOOST_CHECK_NE(fails, RANDOM_REPEATS);
327 
328  // add 75 cents in small change. not enough to make 90 cents,
329  // then try making 90 cents. there are multiple competing "smallest bigger" coins,
330  // one of which should be picked at random
331  add_coin( 5*CENT); add_coin(10*CENT); add_coin(15*CENT); add_coin(20*CENT); add_coin(25*CENT);
332 
333  fails = 0;
334  for (int i = 0; i < RANDOM_REPEATS; i++)
335  {
336  // selecting 1 from 100 identical coins depends on the shuffle; this test will fail 1% of the time
337  // run the test RANDOM_REPEATS times and only complain if all of them fail
338  BOOST_CHECK(wallet.SelectCoinsMinConf(90*CENT, 1, 6, vCoins, setCoinsRet , nValueRet));
339  BOOST_CHECK(wallet.SelectCoinsMinConf(90*CENT, 1, 6, vCoins, setCoinsRet2, nValueRet));
340  if (equal_sets(setCoinsRet, setCoinsRet2))
341  fails++;
342  }
343  BOOST_CHECK_NE(fails, RANDOM_REPEATS);
344  }
345  }
346  empty_wallet();
347 }
348 
349 BOOST_AUTO_TEST_CASE(test_StealthSend)
350 {
352  std::string stealthAddr = "Pap9NcoXyLMQxDLoJ56faM5aRHVvWhmdTfrtBkmbySmb6cDjygrVcNUWqpUrLLrtQt89Ev3nDutQRMYcs7gWHtr11AN6pGMEELj";
353  CAmount nAmount = 100 * COIN;
354  CWalletTx wtx;
355  bool ret;
356 
357  // check stealth sending on 0 balance wallet
358  printf("Balance = %f, ReserveBalance = %f\n", pwalletMain->GetBalance() * 1.0f / COIN, nReserveBalance * 1.0f / COIN);
359  try {
360  ret = pwalletMain->SendToStealthAddress(stealthAddr, nAmount, wtx);
361  } catch (const std::exception& e) {
362  ret = false;
363  }
364  BOOST_CHECK_MESSAGE(!ret, "Sending to stealth address have to be failed on 0 balance wallet");
365 
366  // check stealth sending on not enough balance and reservebalance wallet
367  generate_block(101);
368  nReserveBalance = pwalletMain->GetBalance() - 90 * COIN;
369  printf("Balance = %f, ReserveBalance = %f\n", pwalletMain->GetBalance() * 1.0f / COIN, nReserveBalance * 1.0f / COIN);
370  try {
371  ret = pwalletMain->SendToStealthAddress(stealthAddr, nAmount, wtx);
372  } catch (const std::exception& e) {
373  ret = false;
374  }
375  BOOST_CHECK_MESSAGE(ret, "Sending to stealth address have to be success with reservebalance wallet");
376 
377  // check stealth sending on enough balance wallet
378  nReserveBalance = 0;
379  printf("Balance = %f, ReserveBalance = %f\n", pwalletMain->GetBalance() * 1.0f / COIN, nReserveBalance * 1.0f / COIN);
380  try {
381  ret = pwalletMain->SendToStealthAddress(stealthAddr, nAmount, wtx);
382  } catch (const std::exception& e) {
383  ret = false;
384  }
385  BOOST_CHECK_MESSAGE(ret, "Sending to stealth address have to be success on enough balance wallet");
386 
388 
389  // check stealth sending on not enough balance wallet
391 }
392 #endif
CWallet::GetUnlockedCoins
CAmount GetUnlockedCoins() const
Definition: wallet.cpp:2282
CMutableTransaction::vin
std::vector< CTxIn > vin
Definition: transaction.h:387
CWallet::SelectCoinsMinConf
bool SelectCoinsMinConf(bool needFee, CAmount &estimatedFee, int ringSize, int numOut, const CAmount &nTargetValue, int nConfMine, int nConfTheirs, std::vector< COutput > vCoins, std::set< std::pair< const CWalletTx *, unsigned int > > &setCoinsRet, CAmount &nValueRet)
Definition: wallet.cpp:2861
CBlockHeader::nBits
uint32_t nBits
Definition: block.h:65
b
void const uint64_t * b
Definition: field_5x52_asm_impl.h:10
chainActive
CChain chainActive
The currently-connected chain of blocks.
Definition: main.cpp:70
CReserveKey
A key allocated from the key pool.
Definition: wallet.h:679
wallet.h
tinyformat::printf
void printf(const char *fmt, const Args &... args)
Format list of arguments to std::cout, according to the given format string.
Definition: tinyformat.h:975
CWallet::GetSpendableBalance
CAmount GetSpendableBalance()
Definition: wallet.cpp:2260
RANDOM_REPEATS
#define RANDOM_REPEATS
Definition: wallet_tests.cpp:21
pwalletMain
CWallet * pwalletMain
Definition: wallet.cpp:49
BOOST_FIXTURE_TEST_SUITE
#define BOOST_FIXTURE_TEST_SUITE(a, b)
Definition: object.cpp:14
CBlockHeader::GetHash
uint256 GetHash() const
Definition: block.cpp:80
CBlockHeader::nNonce
uint32_t nNonce
Definition: block.h:66
RUN_TESTS
#define RUN_TESTS
Definition: wallet_tests.cpp:17
CMutableTransaction::nLockTime
uint32_t nLockTime
Definition: transaction.h:389
nReserveBalance
int64_t nReserveBalance
Definition: wallet.cpp:59
CWalletTx::nDebitCached
CAmount nDebitCached
Definition: wallet.h:819
miner.h
CWallet::GetLockedCoins
CAmount GetLockedCoins() const
Definition: wallet.cpp:2300
CBaseChainParams::MAIN
@ MAIN
Definition: chainparamsbase.h:19
CAmount
int64_t CAmount
Amount in PRCY (Can be negative)
Definition: amount.h:17
BOOST_AUTO_TEST_CASE
#define BOOST_AUTO_TEST_CASE(funcName)
Definition: object.cpp:15
CoinSet
std::set< std::pair< const CWalletTx *, unsigned int > > CoinSet
Definition: wallet_tests.cpp:24
CWallet::GetBalance
CAmount GetBalance()
Definition: wallet.cpp:2243
CWallet::SendToStealthAddress
bool SendToStealthAddress(const std::string &stealthAddr, CAmount nValue, CWalletTx &wtxNew, bool fUseIX=false, int ringSize=5)
Definition: wallet.cpp:6640
CheckProofOfWork
bool CheckProofOfWork(uint256 hash, unsigned int nBits)
Check whether a block hash satisfies the proof-of-work requirement specified by nBits.
Definition: poa.cpp:145
CChain::Height
int Height() const
Return the maximal height in the chain.
Definition: chain.h:641
SelectParams
void SelectParams(CBaseChainParams::Network network)
Sets the params returned by Params() to those for the given network.
Definition: chainparams.cpp:484
CBlock
Definition: block.h:142
CMutableTransaction::vout
std::vector< CTxOut > vout
Definition: transaction.h:388
LOCK
#define LOCK(cs)
Definition: sync.h:182
ProcessNewBlock
bool ProcessNewBlock(CValidationState &state, CNode *pfrom, CBlock *pblock, CDiskBlockPos *dbp)
Process an incoming block.
Definition: main.cpp:4890
CWallet
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
Definition: wallet.h:243
CBaseChainParams::REGTEST
@ REGTEST
Definition: chainparamsbase.h:21
CWalletTx
A transaction with a bunch of additional info that only the owner cares about.
Definition: wallet.h:792
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:463
CWallet::cs_wallet
RecursiveMutex cs_wallet
Definition: wallet.h:301
CChain::Tip
CBlockIndex * Tip(bool fProofOfStake=false) const
Returns the index entry for the tip of this chain, or NULL if none.
Definition: chain.h:596
CMutableTransaction
A mutable version of CTransaction.
Definition: transaction.h:384
COutput
Definition: wallet.h:922
IncrementExtraNonce
void IncrementExtraNonce(CBlock *pblock, CBlockIndex *pindexPrev, unsigned int &nExtraNonce)
Modify the extranonce in a block.
Definition: miner.cpp:609
CValidationState
Capture information about block/transaction validation.
Definition: validation.h:23
CWalletTx::fDebitCached
bool fDebitCached
Definition: wallet.h:809
BOOST_CHECK
#define BOOST_CHECK(expr)
Definition: object.cpp:17
BOOST_AUTO_TEST_SUITE_END
#define BOOST_AUTO_TEST_SUITE_END()
Definition: object.cpp:16
BOOST_CHECK_EQUAL
#define BOOST_CHECK_EQUAL(v1, v2)
Definition: object.cpp:18