aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
AgeCommit message (Collapse)Author
2019-01-30[tools] Add wallet inspection and modification toolJonas Schnelli
This commit adds wallet-tool, a tool for creating and interacting with wallet files. Original implementation was by Jonas Schnelli <dev@jonasschnelli.ch> with modifications by John Newbery <john@johnnewbery.com> MSVC files were provided by Chun Kuan Lee <ken2812221@gmail.com>: build: Add MSVC project files for bitcoin-wallet-tool
2019-01-15Merge #14941: rpc: Make unloadwallet wait for complete wallet unloadWladimir J. van der Laan
645e905c327411555073fa7964b36f652998059f doc: Add release notes for unloadwallet change to synchronous call (João Barbosa) c37851de5752f107c16e19317f28038b6b7ca2dc rpc: Make unloadwallet wait for complete wallet unload (João Barbosa) Pull request description: Currently the `unloadwallet` RPC is asynchronous, it only signals the intent to unload the wallet and then returns the response to the client. The actual unload can happen later and the client has no way to be notified of that. This PR makes the `unloadwallet` RPC synchronous, meaning that it blocks until the wallet is fully unloaded. Replaces #14919, fixes #14917. Tree-SHA512: ad88b980e2f3652809a58f904afbfe020299f3aa6a517f495ba943b8d54d4520f6e70074d6749be8f5967065c0f476e0faedcde64c8b4899e5f99c70f0fd6534
2019-01-15rpc: Make unloadwallet wait for complete wallet unloadJoão Barbosa
2019-01-13Replace remaining 0 with nullptr in Qt codeBen Woosley
Also used type-appropriate enum values such as Qt::NoItemFlags in some cases. All cases identified via -Wzero-as-null-pointer-constant
2019-01-10Merge #15039: wallet: Avoid leaking nLockTime fingerprint when anti-fee-snipingWladimir J. van der Laan
fa48baf23eb2ec5e9b71e3e07c24432fc1fed39c wallet: Avoid leaking locktime fingerprint when anti-fee-sniping (MarcoFalke) 453803adc9325b83fc0532a8328d455e8bdf4de6 [test] wallet_txn_clone: Correctly clone txin sequence (MarcoFalke) Pull request description: The wallet sets the locktime to the current height of our active chain. This is fine, as long as our node is connected to other nodes. However, when we fall back and get stuck at a particular height (e.g. taking the wallet offline), the same (potentially unique) locktime is used for all transactions. This makes it easier for passive observers to cluster transactions by wallet. For reference, I visualized "locktime-reuse" with the data: * blocks 545k-555k (both inclusive) * locktimes<=60k * excluding coinbase txs ![distribution of height-based tx locktimes used at least twice](https://user-images.githubusercontent.com/6399679/50446163-b8256d80-0913-11e9-9832-40b76052b2b9.png) Tree-SHA512: 2af259dd8f9f863312e2732d80ca8ba6a20c8d6d1c486b10a48479e1c85ccf13b0c38723740ebadde0f28d321cd9c133ad3e5d1e925472eb27681143bda2d0e7
2019-01-09Merge #15109: refactor: Use C++11 default member initializersWladimir J. van der Laan
fa2510d5c1cdf9c2cd5cc9887302ced4378c7202 Use C++11 default member initializers (MarcoFalke) Pull request description: Changes: * Remove unused constructors that leave some members uninitialized * Remove manual initialization in each constructor and prefer C++11 default member initializers This is not a stylistic change, but a change that avoids bugs such as: * fix uninitialized read when stringifying an addrLocal #14728 * qt: Initialize members in WalletModel #12426 * net: correctly initialize nMinPingUsecTime #6636 * ... Tree-SHA512: 0f896f3b9fcc464d5fc7525f7c86343ef9ce9fb13425fbc68e9a9728fd8710c2b4e2fd039ee08279ea41ff20fd92b7185cf5cca95a0bcb6a5340a1e6f03cae6b
2019-01-05Use C++11 default member initializersMarcoFalke
2019-01-05test: Run invalid_txs.InputMissing test in feature_blockMarcoFalke
2018-12-27wallet: Avoid leaking locktime fingerprint when anti-fee-snipingMarcoFalke
2018-12-24Merge #14565: Overhaul importmulti logicMeshCollider
eacff95de Add release notes (Pieter Wuille) bdacbda25 Overhaul importmulti logic (Pieter Wuille) Pull request description: This is an alternative to #14558 (it will warn when fields are being ignored). In addition: * It makes sure no changes to the wallet are made when an error in the input exists. * It validates all arguments, and will fail if anything fails to parse. * Adds a whole bunch of sanity checks Tree-SHA512: fdee0b6aca8c643663f0bc295a7c1d69c1960951493b06abf32c58977f3e565f75918dbd0402dde36e508dc746c9310a968a0ebbacccc385a57ac2a68b49c1d0
2018-12-21Merge #14653: rpcwallet: Add missing transaction categories to rpc helptextsMarcoFalke
f3f6dde56e Test coinbase category in wallet rpcs (andrewtoth) e982f0b682 Add all category options to wallet rpc help (andrewtoth) Pull request description: The current helptext for `listtransactions`, `listsinceblock` and `gettransaction` only list two of the five possible options for `category`. This incorrectly implies that these are the only two options, and can cause problems if the other three options aren't accounted for. Also, some of the documentation is incorrect when specifying which options are returned for which categories. This PR updates the helptext for these RPCs and adds a functional regression test for the cases when the other three categories are returned. Tree-SHA512: 67dd7ff6269a3b0f17f5d1a61b0ae1fb1f3778f05e1c440bfbb9b3a005c9c6d740abcace20f3d597cf2bd6779c494448690f13fab0bd2340f206213bc7890b51
2018-12-17wallet: Initialize stop_block to nullptr in CWallet::ScanForWalletTransactionsBen Woosley
Previously the argument would be untouched if the first block scan failed. This makes the behavior predictable, and consistent with the documentation.
2018-12-14Merge #14821: Replace CAffectedKeysVisitor with descriptor based logicMeshCollider
0e75f44a0 Replace CAffectedKeysVisitor with descriptor based logic (Pieter Wuille) Pull request description: It seems we don't need a custom visitor pattern anymore to find what keys are affected by a script. Instead, infer the descriptor, and see which keys it expands to. Tree-SHA512: 8a52f61fb74e8ebfd8d02e759629e423ced6bd7d9a9ee7c4bdd2cca8465bc27b951cc69c8d835244a611ba55c6d22f83b81acef05487cb988c88c0951b797699
2018-12-12Overhaul importmulti logicPieter Wuille
This introduces various changes to the importmulti logic: * Instead of processing input and importing things at the same time, first process all input data and verify it, so no changes are made in case of an error. * Verify that no superfluous information is provided (no keys or scripts that don't contribute to solvability in particular). * Add way more sanity checks, by means of descending into all involved scripts.
2018-12-12Introduce a Shuffle for FastRandomContext and use it in wallet and coinselectionPieter Wuille
2018-12-12Merge #13076: Fix ScanForWalletTransactions to return an enum indicating ↵MeshCollider
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
2018-12-10Merge #14877: rpc: Document default values for optional argumentsMarcoFalke
fa0c24c96e rpc: Document default values for optional arguments (MarcoFalke) Pull request description: Tree-SHA512: e1f5ea67d7ac67526ae87bffaeb308a9ad68632e161fe0148cd431a340bb7a30def18f1dbc7e98c6c1c269ac8942fd5d5334c85c48e4fb1cead70a42536b6eef
2018-12-07rpc: Document default values for optional argumentsMarcoFalke
2018-12-06rpc: Avoid creating non-standard raw transactionsMarcoFalke
2018-12-05Merge #14796: rpc: Pass argument descriptions to RPCHelpManMarcoFalke
fabca42c68 RPCHelpMan: Add space after colons in extended description (MarcoFalke) fafd040f73 rpc: Add description to fundrawtransaction vout_index (MarcoFalke) 1db0096f61 rpc: Pass argument descriptions to RPCHelpMan (MarcoFalke) Pull request description: This will normalize the type names and formatting for the rpc arguments Tree-SHA512: 6ab344882f0fed36046ab4636cb2fa5d2479c6aae22666ca9a0d067edbb9eff8de98010ad97c8ce40ab532d15d1ae67120a561b0bf3da837090d7de427679f4f
2018-12-04rpc: Add description to fundrawtransaction vout_indexMarcoFalke
2018-12-04Merge #14760: Log env path in BerkeleyEnvironment::FlushWladimir J. van der Laan
467461030 Log env path in BerkeleyEnvironment::Flush (João Barbosa) Pull request description: With `bitcoind -regtest -wallet=w1 -wallet=w2 -debug`, before: ``` BerkeleyEnvironment::Flush: Flush(true) BerkeleyEnvironment::Flush: Flushing wallet.dat (refcount = 0)... BerkeleyEnvironment::Flush: wallet.dat checkpoint BerkeleyEnvironment::Flush: wallet.dat detach BerkeleyEnvironment::Flush: wallet.dat closed BerkeleyEnvironment::Flush: Flush(true) took 23ms BerkeleyEnvironment::Flush: Flush(true) BerkeleyEnvironment::Flush: Flushing wallet.dat (refcount = 0)... BerkeleyEnvironment::Flush: wallet.dat checkpoint BerkeleyEnvironment::Flush: wallet.dat detach BerkeleyEnvironment::Flush: wallet.dat closed BerkeleyEnvironment::Flush: Flush(true) took 19ms ``` After: ``` BerkeleyEnvironment::Flush: [/Users/joao/Library/Application Support/Bitcoin/regtest/wallets/w1] Flush(true) BerkeleyEnvironment::Flush: Flushing wallet.dat (refcount = 0)... BerkeleyEnvironment::Flush: wallet.dat checkpoint BerkeleyEnvironment::Flush: wallet.dat detach BerkeleyEnvironment::Flush: wallet.dat closed BerkeleyEnvironment::Flush: Flush(true) took 23ms BerkeleyEnvironment::Flush: [/Users/joao/Library/Application Support/Bitcoin/regtest/wallets/w2] Flush(true) BerkeleyEnvironment::Flush: Flushing wallet.dat (refcount = 0)... BerkeleyEnvironment::Flush: wallet.dat checkpoint BerkeleyEnvironment::Flush: wallet.dat detach BerkeleyEnvironment::Flush: wallet.dat closed BerkeleyEnvironment::Flush: Flush(true) took 19ms ``` Tree-SHA512: f90b413cca5d2527324a264ce371dc8baba69f5b541f7d7f6238a8dd79398cbd3c67c0d7a8a0b69aec6c44d77ba26a079c2241427e3669ed22c7da0e4d60039e
2018-12-01Add all category options to wallet rpc helpandrewtoth
2018-11-30Merge #14380: fix assert crash when specified change output spend size is ↵MarcoFalke
unknown 0fb2e69815 CreateTransaction: Assume minimum p2sh-p2wpkh spend size for unknown change (Gregory Sanders) b06483c96a Remove stale comment in CalculateMaximumSignedInputSize (Gregory Sanders) Pull request description: This is triggered anytime a fundraw type call(psbt or legacy) is used with a change output address that the wallet doesn't know how to sign for. This regression was added in 6a34ff5335786615771ca423134a484b04831c4e since BnB coin selection actually cares about this. The fix is to assume the smallest typical spend, a P2SH-P2WPKH, which is calculated using a "prototype" dummy signature flow. Future work could generalize this infrastructure to get estimated sizes of inputs for a variety of types. I also removed a comment which I believe is stale and misleading. Tree-SHA512: c7e2be189e524f81a7aa4454ad9370cefba715e3781f1e462c8bab77e4d27540191419029e3ebda11e3744c0703271e479dcd560d05e4d470048d9633e34da16
2018-11-27Replace CAffectedKeysVisitor with descriptor based logicPieter Wuille
2018-11-27Merge #14477: Add ability to convert solvability info to descriptorPieter Wuille
109699dd33 Add release notes (Pieter Wuille) b65326b562 Add matching descriptors to scantxoutset output + tests (Pieter Wuille) 16203d5df7 Add descriptors to listunspent and getaddressinfo + tests (Pieter Wuille) 9b2a25b13f Add tests for InferDescriptor and Descriptor::IsSolvable (Pieter Wuille) 225bf3e3b0 Add Descriptor::IsSolvable() to distinguish addr/raw from others (Pieter Wuille) 4d78bd93b5 Add support for inferring descriptors from scripts (Pieter Wuille) Pull request description: This PR adds functionality to convert a script to a descriptor, given a `SigningProvider` with the relevant information about public keys and redeemscripts/witnessscripts. The feature is exposed in `listunspent`, `getaddressinfo`, and `scantxoutset` whenever these calls are applied to solvable outputs/addresses. This is not very useful on its own, though when we add RPCs to import descriptors, or sign PSBTs using descriptors, these strings become a compact and standalone way of conveying everything necessary to sign an output (excluding private keys). Unit tests and rudimentary RPC tests are included (more relevant tests can be added once RPCs support descriptors). Fixes #14503. Tree-SHA512: cb36b84a3e0200375b7e06a98c7e750cfaf95cf5de132cad59f7ec3cbd201f739427de0dc108f515be7aca203652089fbf5f24ed283d4553bddf23a3224ab31f
2018-11-27rpc: Pass argument descriptions to RPCHelpManMarcoFalke
2018-11-26qa: Add wallet_encryption error testsMarcoFalke
2018-11-23Merge #14726: Use RPCHelpMan for all RPCsWladimir J. van der Laan
fa5e0452e875a7ca6bf6fe61fdd652d341eece40 rpc: Documentation fixups (MarcoFalke) fa91e8eda541acdb78ca481b74605639f319c108 Use RPCHelpMan for all RPCs (MarcoFalke) fa520e72f7b5964cea1ade666e71212914556cf3 lint: Must use RPCHelpMan to generate the RPC docs (MarcoFalke) Pull request description: The resulting documentation should not change unless the type in the oneline-summary was previously incorrect. (E.g. string vs bool) Tree-SHA512: 4ff355b6a53178f02781e97a7aca7ee1d0d97ff348b6bf5a01caa1c96904ee33c704465fae54c2cd7445097427fd04c71ad3779bb7a7ed886055ef36c1b5a1d0
2018-11-20Merge #14552: wallet: detecting duplicate wallet by comparing the db filename.Wladimir J. van der Laan
591203149f1700f594f781862e88cbbfe83d8d37 wallet: Create IsDatabaseLoaded function (Chun Kuan Lee) 15c93f075a881deb3ad7b1dd8a4516a9b06e5e11 wallet: Add trailing wallet.dat when detecting duplicate wallet if it's a directory. (Chun Kuan Lee) c456fbd8dfcc748e5ec9feaa57ec0f2900f99cde Refactor: Move m_db pointers into BerkeleyDatabase (Russell Yanofsky) Pull request description: Fix #14538 Fix crash attempting to load the same wallet with different path strings that resolve to the same absolute path. The primary check which prevents loading the same wallet twice is: https://github.com/bitcoin/bitcoin/blob/6b8d0a2164b30eab76e7bccb1ffb056a10fba406/src/wallet/db.cpp#L44 But this check is skipped if both wallet paths resolve to the same absolute path, due to caching here: https://github.com/bitcoin/bitcoin/blob/6b8d0a2164b30eab76e7bccb1ffb056a10fba406/src/wallet/db.cpp#L467 Meanwhile a secondary check for duplicate wallets is not reliable because it based on a literal comparison, instead of comparison using absolute paths: https://github.com/bitcoin/bitcoin/blob/6b8d0a2164b30eab76e7bccb1ffb056a10fba406/src/wallet/wallet.cpp#L3853 This PR fixes the latter check to compare the absolute path of a new wallet being loaded to absolute paths of wallets already loaded, so there should no longer be any way to load the same wallet more than once. Tree-SHA512: 2fa01811c160b57be3b76c6b4983556a04bbce71a3f8202429987ec020664a062e897deedcd9248bc04e9baaa2fc7b464e2595dcaeff2af0818387bf1fcdbf6f
2018-11-19Log env path in BerkeleyEnvironment::FlushJoão Barbosa
2018-11-14Add descriptors to listunspent and getaddressinfo + testsPieter Wuille
2018-11-14Use RPCHelpMan for all RPCsMarcoFalke
2018-11-14Merge #14411: [wallet] Restore ability to list incoming transactions by labelMarcoFalke
da427dbd48 Rename ListTransactions filter variable (Russell Yanofsky) 65b740f92b [wallet] Restore ability to list incoming transactions by label (Russell Yanofsky) Pull request description: This change partially reverts #13075 and #14023. Fixes #14382 Tree-SHA512: 8c4e56104b3a45784cdc06bae8e5facdfff04fe3545b63a35e0ec2e440a41b79d84833ca4c4e728d8af7ebb8a519303a9eda7bee4bbfb92bd50c58587a33eb30
2018-11-14Merge #14478: Show error to user when corrupt wallet unlock failsMarcoFalke
b4f6e58ca5 Better error message for user when corrupt wallet unlock fails (MeshCollider) Pull request description: Mentioned here: https://github.com/bitcoin/bitcoin/issues/14461#issuecomment-429183503 Current behavior is to assert(false) and crash, only info is printed in the log. This shows the message to the user before abort() instead. Tree-SHA512: 526f9ed9262257fca55caf7153ab913ed958b13b079d2f01db797485614d8c375815a1554276e8cf73d3838104b2691a9cf85c8d097973127ae8de9e111446bf
2018-11-13Rename ListTransactions filter variableRussell Yanofsky
Suggested by MeshCollider <dobsonsa68@gmail.com> in https://github.com/bitcoin/bitcoin/pull/14411#discussion_r232134086
2018-11-13Merge #14720: rpc: Correctly name argumentsMarcoFalke
fa0815c300 rpc: Correctly name arguments (Jon Layton) Pull request description: Consistently use the same name to describe arguments in the documentation and add a test that uses the name. By splitting it up, the changes are easier to potentially backport and also make review easier when we switch to `RPCHelpMan`. The tests should pass with or without the changes in `src`. Partly stolen from #14459 (More RPC help description fixes by ch4ot1c) Tree-SHA512: 1072992b1e93ac41006613523e54a0a8004f529fcb101eb9d74d91474abb0945a5a7539f249905151b904b87448f9efc0cacbd9e052fbe2ea9111e62f3e7249c
2018-11-13[wallet] Restore ability to list incoming transactions by labelRussell Yanofsky
This change partially reverts #13075 and #14023. Fixes #14382
2018-11-13Merge #14679: importmulti: Don't add internal addresses to address bookWladimir J. van der Laan
7afddfa8cefd01249ad59cf2370e7cec90b34f6f importmulti: Don't add internal addresses to address book (Gregory Sanders) Pull request description: Currently anything imported with `internal` will not be treated as change since checking the address book is a primary test of this. Added basic tests of all combinations of arguments and change identification. Resolves https://github.com/bitcoin/bitcoin/issues/14662 Tree-SHA512: a1f08dc624a3fadee93cc5392d50c4796b0c5eedf38e295382f71570f2066d9e978ed6e3962084b902989863fe1273a8642d8fdb094a266d69de10622a4176b0
2018-11-13rpc: Correctly name argumentsJon Layton
2018-11-13Add stop_block out arg to ScanForWalletTransactionsBen Woosley
Accurately reports the last block successfully scanned, replacing a return of the chain tip, which represented possibly inaccurated data in a race condition.
2018-11-13Merge #14530: Use RPCHelpMan to generate RPC doc stringsMarcoFalke
fa483e13b3 rpc: Add RPCHelpMan for machine-generated help (MarcoFalke) fa0d36f712 rpc: Include rpc/util.h where needed for RPCHelpMan (MarcoFalke) Pull request description: This introduces a manager for the RPC help generation and demonstrates its use of it in some RPCs. It is the first non-exhaustive step toward #14378 and I will create pull requests for the next steps after this one is merged. Tree-SHA512: 86f68322443ff01cd964aaf0ebe186be63fbebe4c47676cf7a622cc2b5305fd176bd57badfd1bbf788a036812253eb0dead74ecc3b30664c3e0d9392b2248054
2018-11-13Merge #13381: RPC: creates possibility to preserve labels on importprivkeyJonas Schnelli
a6b5ec18f rpc: creates possibility to preserve labels on importprivkey (marcoagner) Pull request description: Closes #13087. As discussed in the issue, this is a feature request instead of a bug report since the behaviour was as intended (i.e. label with default: `''`). With this, the old behaviour is kept while the possibility to achieve the preservation of labels, as expected in the open issue, is added. Tree-SHA512: b33be50e1e7f62f7ddfae953177ba0926e2d848961f9fac7501c2b513322c0cb95787745d07d137488267bad1104ecfdbe800c6747f94162eb07c976835c1386
2018-11-13Return a status enum from ScanForWalletTransactionsBen Woosley
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.
2018-11-13Make CWallet::ScanForWalletTransactions args and return value constBen Woosley
2018-11-12CreateTransaction: Assume minimum p2sh-p2wpkh spend size for unknown changeGregory Sanders
2018-11-12Remove stale comment in CalculateMaximumSignedInputSizeGregory Sanders
2018-11-12rpc: Add RPCHelpMan for machine-generated helpMarcoFalke
2018-11-09Merge #14588: Refactor PSBT signing logic to enforce invariant and fix ↵Pieter Wuille
signing bug e13fea975d Add regression test for PSBT signing bug #14473 (Glenn Willen) 565500508a Refactor PSBTInput signing to enforce invariant (Glenn Willen) 0f5bda2bd9 Simplify arguments to SignPSBTInput (Glenn Willen) 53e6fffb8f Add bool PSBTInputSigned (Glenn Willen) 65166d4cf8 New PartiallySignedTransaction constructor from CTransction (Glenn Willen) 4f3f5cb4b1 Remove redundant txConst parameter to FillPSBT (Glenn Willen) fe5d22bc67 More concise conversion of CDataStream to string (Glenn Willen) Pull request description: As discussed in the comments on #14473, I think that bug was caused primarily by failure to adhere to the invariant that a PSBTInput always has exactly one of the two utxo fields present -- an invariant that is already enforced by PSBTInput::IsSane, but which we were temporarily suspending during signing. This refactor repairs the invariant, also fixing the bug. It also simplifies some other code, and removes redundant parameters from some related functions. fixes #14473 Tree-SHA512: cbad3428175e30f9b7bac3f600668dd1a8f9acde16b915d27a940a2fa6d5149d4fbe236d5808fd590fb20a032274c99e8cac34bef17f79a53fdf69a5948c0fd0
2018-11-10Better error message for user when corrupt wallet unlock failsMeshCollider