aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/test/wallet_tests.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge #15226: Allow creating blank (empty) wallets (alternative)MeshCollider2019-02-111-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7687f7873 [wallet] Support creating a blank wallet (Andrew Chow) Pull request description: Alternative (kind of) to #14938 This PR adds a `blank` parameter to the `createwallet` RPC to create a wallet that has no private keys initially. `sethdseed` can then be used to make a clean wallet with a custom seed. `encryptwallet` can also be used to make a wallet that is born encrypted. Instead of changing the version number as done in #14938, a wallet flag is used to indicate that the wallet should be blank. This flag is set at creation, and then unset when the wallet is no longer blank. A wallet becomes non-blank when a HD seed is set or anything is imported. The main change to create a blank wallet is primarily taken from #14938. Also with this, the term "blank wallet" is used instead of "empty wallet" to avoid confusion with wallets that have balance which would also be referred to as "empty". This is built on top of #15225 in order to fix GUI issues. Tree-SHA512: 824d685e11ac2259a26b5ece99c67a7bda94a570cd921472c464243ee356b7734595ad35cc439b34357135df041ed9cba951e6edac194935c3a55a1dc4fcbdea
| * [wallet] Support creating a blank walletAndrew Chow2019-02-101-0/+1
| | | | | | | | | | | | | | A blank wallet is a wallet that has no keys, script or watch only things. A new wallet flag indicating that it is blank will be set when the wallet is blank. Once it is no longer blank (a seed has been generated, keys or scripts imported, etc), the flag will be unset.
* | Merge #15321: doc: Add cs_main lock annotations for mapBlockIndexMarcoFalke2019-02-061-0/+3
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | fa2a69fcb9 doc: Add cs_main lock annotations for mapBlockIndex (practicalswift) Pull request description: Marked as "doc" because it didn't change the bitcoind on my system with default configure settings for both gcc and clang. Tree-SHA512: ba203f16c1cdc834a61c65bb5fb20bbaf7d8bff0c3a1b8ef46bc1d3669092191221e26abd7e580efab2f9bd5a992dc363251f1b68c6cd68f8204d62675868cf1
| * | doc: Add cs_main lock annotations for mapBlockIndexpracticalswift2019-02-011-0/+3
| |/
* / Rename ScanResult stop_block fieldRussell Yanofsky2019-02-011-15/+15
|/ | | | | Avoid confusion with stop_block argument as suggested https://github.com/bitcoin/bitcoin/pull/14711#discussion_r252038449
* Convert CWallet::ScanForWalletTransactions and SyncTransaction to the new ↵Russell Yanofsky2019-01-151-22/+25
| | | | | | | | | | Chain apis Only change in behavior is "Rescan started from block <height>" message replaced by "Rescan started from block <hash>" message in ScanForWalletTransactions. Co-authored-by: Ben Woosley <[email protected]>
* Add height, depth, and hash methods to the Chain interfaceRussell Yanofsky2019-01-151-2/+2
| | | | | | | | And use them to remove uses of chainActive and mapBlockIndex in wallet code This commit does not change behavior. Co-authored-by: Ben Woosley <[email protected]>
* test: Run invalid_txs.InputMissing test in feature_blockMarcoFalke2019-01-051-2/+2
|
* wallet: Initialize stop_block to nullptr in CWallet::ScanForWalletTransactionsBen Woosley2018-12-171-4/+51
| | | | | Previously the argument would be untouched if the first block scan failed. This makes the behavior predictable, and consistent with the documentation.
* Merge #13076: Fix ScanForWalletTransactions to return an enum indicating ↵MeshCollider2018-12-121-4/+14
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | scan result: success / failure / user_abort bd3b0361d Add stop_block out arg to ScanForWalletTransactions (Ben Woosley) 3002d6cf3 Return a status enum from ScanForWalletTransactions (Ben Woosley) bb24d6865 Make CWallet::ScanForWalletTransactions args and return value const (Ben Woosley) Pull request description: Return the failed block as an out arg. Fixes #11450. /cc #12275 Tree-SHA512: 6a523e5425ebfe24e664a942ae21c797ccc1281c25b1bf8d02ad95c19dae343fd8051985ef11853474de7628fd6bed5f15190fbc087c3466ce6fdecab37d72a9
| * Add stop_block out arg to ScanForWalletTransactionsBen Woosley2018-11-131-9/+12
| | | | | | | | | | Accurately reports the last block successfully scanned, replacing a return of the chain tip, which represented possibly inaccurated data in a race condition.
| * Return a status enum from ScanForWalletTransactionsBen Woosley2018-11-131-4/+11
| | | | | | | | | | | | | | Return the failed block as an out var. This clarifies the outcome as the prior return value could be null due to user abort or failure.
* | CreateTransaction: Assume minimum p2sh-p2wpkh spend size for unknown changeGregory Sanders2018-11-121-0/+44
|/
* Pass chain locked variables where neededRussell Yanofsky2018-11-061-8/+8
| | | | | | | | | This commit does not change behavior. All it does is pass new function parameters. It is easiest to review this change with: git log -p -n1 -U0 --word-diff-regex=.
* Remove uses of cs_main in wallet codeRussell Yanofsky2018-11-061-4/+7
| | | | | | | | This commit does not change behavior. It is easiest to review this change with: git log -p -n1 -U0
* Pass chain and client variables where neededRussell Yanofsky2018-11-061-8/+15
| | | | | | | | | This commit does not change behavior. All it does is pass new function parameters. It is easiest to review this change with: git log -p -n1 -U0 --word-diff-regex=.
* wallet: Refactor to use WalletLocationJoão Barbosa2018-10-251-8/+8
|
* Merge #10605: Add AssertLockHeld assertions in CWallet::ListCoinsMarcoFalke2018-08-311-3/+13
|\ | | | | | | | | | | | | | | | | | | | | 62b6f0f21e Add EXCLUSIVE_LOCKS_REQUIRED to CWallet::ListCoins (Russell Yanofsky) 545e85eccc Add AssertLockHeld assertions in CWallet::ListCoins (Russell Yanofsky) Pull request description: Fixes TODO from #10295 Tree-SHA512: 2dd03a8217e5e1313aa2119cb530e0c0daf3ae3a751b6fdec611df57b8090201a90b52ff05f8f696e978a1344aaf21989d67a03beb5ef6ef79b77be38d04b451
| * Add AssertLockHeld assertions in CWallet::ListCoinsRussell Yanofsky2018-04-111-3/+13
| |
* | [wallet] Kill accountsJohn Newbery2018-08-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit does the following changes: - [wallet] Remove 'account' argument from GetLegacyBalance() - GetLegacyBalance() is never called with an account argument. Remove the argument and helper functions. - [wallet] Remove CWallet::ListAccountCreditDebit() - Function no longer used. - [wallet] Remove AccountMove() - Function no longer used. - [wallet] Remove AddAccountingEntry() - Function no longer used. - [wallet] Remove GetAccountCreditDebit() - Function no longer used. - [wallet] Don't rewrite accounting entries when reordering wallet transactions. - Accounting entries are deprecated. Don't rewrite them to the wallet database when re-ordering transactions. - [wallet] Remove WriteAccountingEntry() - Function no longer used. - [wallet] Don't read acentry key-values from wallet on load. - [wallet] Remove ListAccountCreditDebit() - Function no longer used. - [wallet] Remove CAccountingEntry class - No longer used - [wallet] Remove GetLabelDestination - Function no longer used. - [wallet] Delete unused account functions - ReadAccount - WriteAccount - EraseAccount - DeleteLabel - [wallet] Remove fromAccount argument from CommitTransaction() - [wallet] Remove strFromAccount. - No longer used. - [wallet] Remove strSentAccount from GetAmounts(). - No longer used. - [wallet] Update zapwallettxes comment to remove accounts. - [wallet] Remove CAccount - No longer used - [docs] fix typo in release notes for PR 14023
* | Update copyright headers to 2018DrahtBot2018-07-271-1/+1
| |
* | Merge #9662: Add createwallet "disableprivatekeys" option: a sane mode for ↵Wladimir J. van der Laan2018-07-201-0/+9
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | watchonly-wallets a3fa4d6a6acf19d640a1d5879a00aa1f059e2380 QA: Fix bug in -usecli logic that converts booleans to non-lowercase strings (Jonas Schnelli) 4704e5f074e57782d058404a594a7313cf170cf0 [QA] add createwallet disableprivatekey test (Jonas Schnelli) c7b8f343e99d9d53ea353ddce9a977f1886caf30 [Qt] Disable creating receive addresses when private keys are disabled (Jonas Schnelli) 2f15c2bc20d583b4c1788da78c9c635c36e03ed0 Add disable privatekeys option to createwallet (Jonas Schnelli) cebefba0855cee7fbcb9474b34e6779369e8e9ce Add option to disable private keys during internal wallet creation (Jonas Schnelli) 9995a602a639b64a749545b7c3bafbf67f97324f Add facility to store wallet flags (64 bits) (Jonas Schnelli) Pull request description: This mode ('createwallet {"disableprivatekeys": true}') is intended for a sane pure watch-only mode, ideal for a use-case where one likes to use Bitcoin-Core in conjunction with a hardware-wallet or another solutions for cold-storage. Since we have support for custom change addresses in `fundrawtransaction`, pure watch-only wallets including coin-selection are possible and do make sense for some use cases. This new mode disables all forms of private key generation and ensure that no mix between hot and cold keys are possible. Tree-SHA512: 3ebe7e8d54c4d4e5f790c348d4c292d456f573960a5b04d69ca5ef43a9217c7e7671761c6968cdc56f9a8bc235f3badd358576651af9f10855a0eb731f3fc508
| * | [QA] add createwallet disableprivatekey testJonas Schnelli2018-07-121-0/+9
| | |
* | | Use common SetDataDir method to create temp directory in tests.winder2018-07-111-2/+4
|/ /
* | wallet: Use shared pointer to retain wallet instanceJoão Barbosa2018-05-221-15/+15
| |
* | wallet: Add AddWallet, RemoveWallet, GetWallet and GetWalletsJoão Barbosa2018-04-181-6/+6
| | | | | | | | | | With these new functions all vpwallets usage are removed and vpwallets is now a static variable (no external linkage).
* | Merge #13007: test: Fix dangling wallet pointer in vpwalletsWladimir J. van der Laan2018-04-181-2/+3
|\ \ | | | | | | | | | | | | | | | | | | | | | d41a420 test: Fix dangling wallet pointer in vpwallets (João Barbosa) Pull request description: Tree-SHA512: 83e4ec571f1675b3dab6f7606f29d6fae495d998b4e5794ff14315943783d4518cfa66eba4113293e349eb74aa22a024b21272fdb29c212477edb4c09aec9fa7
| * | test: Fix dangling wallet pointer in vpwalletsJoão Barbosa2018-04-171-2/+3
| |/
* / tests: Avoid copies of CTransactionMarcoFalke2018-04-111-7/+7
|/
* Merge #12920: test: Fix sign for expected valuesWladimir J. van der Laan2018-04-111-11/+11
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | c55aa4f test: Fix sign for expected values (Karl-Johan Alm) Pull request description: A number of `BOOST_CHECK_EQUAL` calls would result in warnings about signs. This PR fixes signedness for all expectation values, sometimes resulting in `int` → `unsigned int`. No other code changes besides adding/removing `U` to/from values. Running `make &> make_output_...` on master versus on this PR: ``` $ wc make_output_* 1464 5925 90357 make_output_master 613 1469 28370 make_output_signfixed ``` More than halves the output lines from compiling. Tree-SHA512: b06c9fb81704fd32a6a61fe7b2ceb5f1bb381e9873d79e13d7e4d26bbd9b67c9725a84e6fb2903bcda775aea2a792e544b0799d36735c19f5d1c7225e8c6d14e
| * test: Fix sign for expected valuesKarl-Johan Alm2018-04-111-11/+11
| | | | | | | | A number of BOOST_CHECK_EQUAL calls would result in warnings about signs.
* | scripted-diff: Rename wallet database classesRussell Yanofsky2018-04-071-7/+7
|/ | | | | | | | | | | | | | | | | | | | | -BEGIN VERIFY SCRIPT- sed -i 's/\<CWalletDBWrapper\>/BerkeleyDatabase/g' src/wallet/db.h src/wallet/db.cpp sed -i '/statuses/i/** Backend-agnostic database type. */\nusing WalletDatabase = BerkeleyDatabase\;\n' src/wallet/walletdb.h ren() { git grep -l "\<$1\>" 'src/*.cpp' 'src/*.h' ':(exclude)*dbwrapper*' test | xargs sed -i "s:\<$1\>:$2:g"; } ren CDBEnv BerkeleyEnvironment ren CDB BerkeleyBatch ren CWalletDBWrapper WalletDatabase ren CWalletDB WalletBatch ren dbw database ren m_dbw m_database ren walletdb batch ren pwalletdb batch ren pwalletdbIn batch_in ren wallet/batch.h wallet/walletdb.h ren pwalletdbEncryption encrypted_batch -END VERIFY SCRIPT-
* Merge #12859: Bugfix: Include <memory> for std::unique_ptrWladimir J. van der Laan2018-04-051-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | a5bca13 Bugfix: Include <memory> for std::unique_ptr (Luke Dashjr) Pull request description: Not sure why all these includes were missing, but it's breaking builds for some users: https://bugs.gentoo.org/show_bug.cgi?id=652142 (Added to all files with a reference to `std::unique_ptr`) Tree-SHA512: 8a2c67513ca07b9bb52c34e8a20b15e56f8af2530310d9ee9b0a69694dd05e02e7a3683f14101a2685d457672b56addec591a0bb83900a0eb8e2a43d43200509
| * Bugfix: Include <memory> for std::unique_ptrLuke Dashjr2018-04-021-0/+1
| |
* | wallet: Change output type globals to membersMarcoFalke2018-03-171-5/+0
| |
* | Merge #10637: Coin Selection with Murch's algorithmWladimir J. van der Laan2018-03-141-337/+0
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 73b5bf2cb Add a test to make sure that negative effective values are filtered (Andrew Chow) 76d2f068a Benchmark BnB in the worst case where it exhausts (Andrew Chow) 6a34ff533 Have SelectCoinsMinConf and SelectCoins use BnB or Knapsack and use it (Andrew Chow) fab04887c Add a GetMinimumFeeRate function which is wrapped by GetMinimumFee (Andrew Chow) cd927ff32 Move original knapsack solver tests to coinselector_tests.cpp (Andrew Chow) fb716f7b2 Move current coin selection algorithm to coinselection.{cpp,h} (Andrew Chow) 4566ab75f Add tests for the Branch and Bound algorithm (Andrew Chow) 4b2716da4 Remove coinselection.h -> wallet.h circular dependency (Andrew Chow) 7d77eb1a5 Use a struct for output eligibility (Andrew Chow) ce7435cf1 Move output eligibility to a separate function (Andrew Chow) 0185939be Implement Branch and Bound coin selection in a new file (Andrew Chow) f84fed8eb Store effective value, fee, and long term fee in CInputCoin (Andrew Chow) 12ec29d3b Calculate and store the number of bytes required to spend an input (Andrew Chow) Pull request description: This is an implementation of the [Branch and Bound coin selection algorithm written by Murch](http://murch.one/wp-content/uploads/2016/11/erhardt2016coinselection.pdf) (@xekyo). I have it set so this algorithm will run first and if it fails, it will fall back to the current coin selection algorithm. The coin selection algorithms and tests have been refactored to separate files instead of having them all in wallet.cpp. I have added some tests for the new algorithm and a test for all of coin selection in general. However, more tests may be needed, but I will need help with coming up with more test cases. This PR uses some code borrowed from #10360 to use effective values when selecting coins. Tree-SHA512: b0500f406bf671e74984fae78e2d0fbc5e321ddf4f06182c5855e9d1984c4ef2764c7586d03e16fa4b578c340b21710324926f9ca472d5447a0d1ed43eb4357e
| * | Move original knapsack solver tests to coinselector_tests.cppAndrew Chow2018-03-131-341/+0
| | |
| * | Use a struct for output eligibilityAndrew Chow2018-03-131-37/+41
| | | | | | | | | | | | | | | Instead of specifying 3 parameters, use a struct for those parameters in order to reduce the number of arguments to SelectCoinsMinConf.
* | | Merge #9680: Unify CWalletTx constructionPieter Wuille2018-03-131-5/+5
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | b4bc32a451 [wallet] Get rid of CWalletTx default constructor (Russell Yanofsky) a128bdc9e1 [wallet] Construct CWalletTx objects in CommitTransaction (Russell Yanofsky) Pull request description: Two commits: - `Construct CWalletTx objects in CommitTransaction` moves a bunch of CWalletTx initialization into CWallet::CommitTransaction to dedup some code and avoid future inconsistencies in how wallet transactions are created. - `Get rid of CWalletTx default constructor` does what is described and eliminates the possibility of empty transaction entries being inadvertently created by mapWallet[hash] accesses. Both of these changes were originally part of #9381 Tree-SHA512: af3841c4f0539e0662d81b33c5369fc70aa06ddde1c59cb00fb21c9e4c7d9ff47f1edc5040cb463af1333838802c56b3ef875b939e2b804ee45b8e0294a4371c
| * | | [wallet] Construct CWalletTx objects in CommitTransactionRussell Yanofsky2018-03-071-5/+5
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Construct CWalletTx objects in CWallet::CommitTransaction, instead of having callers do it. This ensures CWalletTx objects are constructed in a uniform way and all fields are set. This also makes it possible to avoid confusing and wasteful CWalletTx copies in https://github.com/bitcoin/bitcoin/pull/9381 There is no change in behavior.
* / / Fix ComputeTimeSmart test failure with -DDEBUG_LOCKORDERRussell Yanofsky2018-03-131-1/+4
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Failure looks like: Entering test case "ComputeTimeSmart" test_bitcoin: sync.cpp:100: void potential_deadlock_detected(const std::pair<void*, void*>&, const LockStack&, const LockStack&): Assertion `false' failed. unknown location(0): fatal error in "ComputeTimeSmart": signal: SIGABRT (application abort requested) wallet/test/wallet_tests.cpp(566): last checkpoint Reproducible with: ./configure --enable-debug make -C src test/test_bitcoin && src/test/test_bitcoin --log_level=test_suite --run_test=wallet_tests/ComputeTimeSmart Happens due to "92fabcd443 Add LookupBlockIndex function" which acquires cs_main from inside CWallet::ComputeTimeSmart.
* | Allow wallet files in multiple directoriesRussell Yanofsky2018-03-031-24/+19
| | | | | | | | | | | | | | | | | | Remove requirement that two wallet files can only be opened at the same time if they are contained in the same directory. This change mostly consists of updates to function signatures (updating functions to take fs::path arguments, instead of combinations of strings, fs::path, and CDBEnv / CWalletDBWrapper arguments).
* | Fix rescan test failure due to unset g_address_type, g_change_typeRussell Yanofsky2018-02-131-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New global variables were introduced in #11403 and not setting them causes: test_bitcoin: wallet/wallet.cpp:4259: CTxDestination GetDestinationForKey(const CPubKey&, OutputType): Assertion `false' failed. unknown location(0): fatal error in "importwallet_rescan": signal: SIGABRT (application abort requested) It's possible to reproduce the failure reliably by running: src/test/test_bitcoin --log_level=test_suite --run_test=wallet_tests/importwallet_rescan Failures happen nondeterministically because boost test framework doesn't run tests in a specified order, and tests that run previously can set the global variables and mask the bug.
* | [wallet] Make CWallet::ListCoins atomicJoão Barbosa2018-02-081-6/+12
| |
* | Fix typospracticalswift2018-01-281-1/+1
|/
* Make sure WalletRescanReserver has successfully reserved the rescanJonas Schnelli2018-01-231-3/+9
|
* Fix ListCoins test failure due to unset g_address_type, g_change_typeRussell Yanofsky2018-01-111-0/+2
| | | | | | | | | | | | | | | New global variables were introduced in #11403 and not setting them causes: test_bitcoin: wallet/wallet.cpp:4199: CTxDestination GetDestinationForKey(const CPubKey&, OutputType): Assertion `false' failed. unknown location(0): fatal error in "ListCoins": signal: SIGABRT (application abort requested) It's possible to reproduce the failure reliably by running: src/test/test_bitcoin --log_level=test_suite --run_test=wallet_tests/ListCoins Failures happen nondeterministically because boost test framework doesn't run tests in a specified order, and tests that run previously can set the global variables and mask the bug.
* Increment MIT Licence copyright header year on files modified in 2017Akira Takizawa2018-01-031-1/+1
|
* Require no cs_main lock for ProcessNewBlock/ActivateBestChainMatt Corallo2017-12-261-6/+11
| | | | | | This requires the removal of some very liberal (incorrect) cs_mains sprinkled in some tests. It adds some chainActive.Tip() races, but the tests are all single-threaded anyway.
* tests: move pwalletMain to wallet test fixtureWladimir J. van der Laan2017-11-181-2/+0
| | | | | | | Scope the variable instead of using an external global; this is how test fixtures are intended to be used. Followup to #11713.