Commit graph

1374 commits

Author SHA1 Message Date
João Barbosa 0b82bac76d bugfix: Remove dangling wallet env instance 2018-06-18 16:35:39 +01:00
João Barbosa ccbf7ae749 test: Wallet methods are disabled when no wallet is loaded 2018-06-18 16:35:17 +01:00
João Barbosa 6608c369b1 rpc: Add unloadwallet RPC 2018-06-18 16:35:17 +01:00
Wladimir J. van der Laan 0882406854
Merge #13437: wallet: Erase wtxOrderd wtx pointer on removeprunedfunds
faa18ca046 wallet: Erase wtxOrderd wtx pointer on removeprunedfunds (MarcoFalke)

Pull request description:

  This prevents segfaults, when reading from the freed memory.

Tree-SHA512: 04f8190dea7901cf1cc298d5db98c83b02858f27114c5ef4da738accd176d6647d6b81f3dc39f3d5912b1a981cf0599370fd391c4154ffbde97afc1fac389123
2018-06-18 17:34:20 +02:00
Pieter Wuille bb582a59c7 Add P2WSH destination helper and use it instead of manual hashing 2018-06-17 19:44:50 -07:00
Cory Fields 466e16e0e8 cleanup: avoid hidden copies in range-for loops 2018-06-15 13:40:00 -04:00
MarcoFalke be27048a18
Merge #13241: scripted-diff: Avoid temporary copies when looping over std::map
9b72c988a0 scripted-diff: Avoid temporary copies when looping over std::map (Ben Woosley)

Pull request description:

  The ::value_type of the std::map/std::multimap/std::unordered_map containers is
  std::pair<const Key, T>. Dropping the const results in an unnecessary copy,
  for example in C++11 range-based loops.

  For this I started with a more general scripted diff, then narrowed it down
  based on the inspection showing that all actual map/multimap/unordered_map
  variables used in loops start with m or have map in the name.

Tree-SHA512: b656d66b69ffa1eb954124aa8ae2bc5436ca50262abefa93bdda55cfcdaffc5ff90cd40539051a2bd06355ba69ddf245265cc8764eebff66d761b3aec06155a9
2018-06-15 12:32:39 -04:00
Gregory Sanders 3c292cc190 ScanforWalletTransactions should mark input txns as dirty 2018-06-14 09:57:34 -04:00
Wladimir J. van der Laan ca2a23387b
Merge #13120: policy: Treat segwit as always active
fa7a6cf1b3 policy: Treat segwit as always active (MarcoFalke)

Pull request description:

  Now that segwit is active for a long time, there is no need to reject transactions with the reason that segwit hasn't activated.

  Strictly speaking, this is a bug fix, because with the release of 0.16, we create segwit transactions in our wallet by default without checking if they are allowed by local policy.

  More broadly, this simplifies the code as if "premature witness" was always set to true with the corresponding command line args.

Tree-SHA512: 484c26aa3a66faba6b41e8554a91a29bfc15fbf6caae3d5363a3966283143189c4bd5333a610b0669c1238f75620691264e73f6b9f1161cdacf7574d946436da
2018-06-12 17:20:34 +02:00
João Barbosa 537efe19e6 rpc: Extract GetWalletNameFromJSONRPCRequest from GetWalletForJSONRPCRequest 2018-06-12 16:11:28 +01:00
Ben Woosley 9b72c988a0
scripted-diff: Avoid temporary copies when looping over std::map
The ::value_type of the std::map/std::multimap/std::unordered_map containers is
std::pair<const Key, T>. Dropping the const results in an unnecessary copy,
for example in C++11 range-based loops.

For this I started with a more general scripted diff, then narrowed it down
based on the inspection showing that all actual map/multimap/unordered_map
variables used in loops start with m or have map in the name.

-BEGIN VERIFY SCRIPT-
sed -i -E 's/for \(([^<]*)std::pair<([^c])(.+) : m/for (\1std::pair<const \2\3 : m/' src/*.cpp src/**/*.cpp
sed -i -E 's/for \(([^<]*)std::pair<([^c])(.+) : (.*)map/for (\1std::pair<const \2\3 : \4map/' src/*.cpp src/**/*.cpp
-END VERIFY SCRIPT-
2018-06-11 13:12:55 -07:00
Wladimir J. van der Laan 7c32b414b6
Merge #13230: Simplify include analysis by enforcing the developer guide's include syntax
16e3cd380a Clarify include recommendation (practicalswift)
6d10f43738 Enforce the use of bracket syntax includes ("#include <foo.h>") (practicalswift)
906bee8e5f Use bracket syntax includes ("#include <foo.h>") (practicalswift)

Pull request description:

  When analysing includes in the project it is often assumed that the preferred bracket include syntax (`#include <foo.h>`) mentioned in `developer-docs.md` is used consistently. @sipa:s excellent circular dependencies script [`circular-dependencies.py`](50c69b7801/contrib/devtools/circular-dependencies.py) (#13228) is an example of a script making this reasonable assumption.

  This PR enables automatic Travis checking of the include syntax making sure that the bracket syntax includes (`#include <foo.h>`) is used consistently.

Tree-SHA512: a414921aabe8e487ebed42f3f1cbd02fecd1add385065c1f2244cd602c31889e61fea5a801507ec501ef9bd309b05d3c999f915cec1c2b44f085bb0d2835c182
2018-06-11 20:24:58 +02:00
MarcoFalke faa18ca046
wallet: Erase wtxOrderd wtx pointer on removeprunedfunds 2018-06-11 14:06:59 -04:00
Wladimir J. van der Laan 43ae5ee9e4
Merge #12634: [refactor] Make TransactionWithinChainLimit more flexible
f77e1d34fd test: Add MempoolAncestryTests (Karl-Johan Alm)
a08d76bcfe mempool: Calculate descendant maximum thoroughly (Karl-Johan Alm)
6d3568371e wallet: Switch to using ancestor/descendant limits (Karl-Johan Alm)
6888195b06 wallet: Strictly greater than for ancestor caps (Karl-Johan Alm)
322b12ac4e Remove deprecated TransactionWithinChainLimit (Karl-Johan Alm)
4784751547 Switch to GetTransactionAncestry() in OutputEligibleForSpending (Karl-Johan Alm)
475a385a80 Add GetTransactionAncestry to CTxMemPool for general purpose chain limit checking (Karl-Johan Alm)
46847d69d2 mempool: Fix max descendants check (Karl-Johan Alm)
b9ef21dd72 mempool: Add explicit max_descendants (Karl-Johan Alm)

Pull request description:

  Currently, `TransactionWithinChainLimit` is restricted to single-output use, and needs to be called every time for different limits. If it is replaced with a chain limit value calculator, that can be called once and reused, and is generally more flexible (see e.g. #12257).

  Update: this PR now corrects usage of max ancestors / max descendants, including calculating the correct max descendant value, as advertised for the two limits.

  ~~This change also makes `nMaxAncestors` signed, as the replacement method will return `-1` for "not in the mempool", which is different from "0", which means "no ancestors/descendants in mempool".~~

  ~~This is a subset of #12257.~~

Tree-SHA512: aa59c849360542362b3126c0e29d44d3d58f11898e277d38c034dc4b86a5b4500f77ac61767599ce878c876b5c446fec9c02699797eb2fa41e530ec863a00cf9
2018-06-11 16:25:46 +02:00
Wladimir J. van der Laan 3f0f39415b
Merge #13060: [wallet] [rpc] Remove getlabeladdress RPC
67e0e04140 [wallet] [docs] Update release notes for removing `getlabeladdress` (John Newbery)
81608178cf [wallet] [rpc] Remove getlabeladdress RPC (John Newbery)

Pull request description:

  labels are associated with addresses (rather than addresses being
  associated with labels, as was the case with accounts). The
  getlabeladdress does not make sense in this model, so remove it.

  getaccountaddress is still supported for one release as the accounts
  API is deprecated.

Tree-SHA512: 7f45d0456248ebcc4e54dd34e2578a09a8ea8e4fceda75238ccea9d731dc99a3f3c0519b18a9739de17d2e6e59c9c2259ba67c9ae2e3cb2a40ddb14b9193fe29
2018-06-11 15:21:24 +02:00
Karl-Johan Alm 6d3568371e
wallet: Switch to using ancestor/descendant limits
Instead of combining the -limitancestorcount and -limitdescendantcount into a nMaxChainLength, this commit uses each one separately in the coin eligibility filters.
2018-06-11 19:04:56 +09:00
Karl-Johan Alm 6888195b06
wallet: Strictly greater than for ancestor caps 2018-06-11 19:04:56 +09:00
Karl-Johan Alm 4784751547
Switch to GetTransactionAncestry() in OutputEligibleForSpending 2018-06-11 19:04:55 +09:00
Karl-Johan Alm b9ef21dd72
mempool: Add explicit max_descendants
TransactionWithinChainLimits would take a 'limit' and check it against ascendants and descendants. This is changed to take an explicit
max ancestors and max descendants value, and to test the corresponding value against its corresponding max.
2018-06-11 19:04:55 +09:00
practicalswift 906bee8e5f Use bracket syntax includes ("#include <foo.h>") 2018-06-06 11:09:05 +02:00
Wladimir J. van der Laan f0fd39f376
Merge #13269: refactoring: Drop UpdateTransaction in favor of UpdateInput
6aa33feadb Drop UpdateTransaction in favor of UpdateInput (Ben Woosley)

Pull request description:

  Updating the input explicitly requires the caller to present a mutable
  input, which more clearly communicates the effects and intent of the call
  (and, often, the enclosing loop).

  In most cases, this input is already immediately available and need not be
  looked up.

Tree-SHA512: 8c7914a8b7ae975d8ad0e9d760e3c5da65776a5f79d060b8ffb6b3ff7a32235f71ad705f2185b368d9263742d7796bb562395d22b806d90e8502d8c496011e57
2018-06-05 19:06:16 +02:00
Jonas Schnelli 343d4e44ef
Merge #13058: [wallet] createwallet RPC - create new wallet at runtime
f7e153e95 [wallets] [docs] Add release notes for createwallet RPC. (John Newbery)
32167e830 [wallet] [tests] Add tests for `createwallet` RPC. (John Newbery)
942131774 [wallet] [rpc] Add `createwallet` RPC (John Newbery)

Pull request description:

  Adds a `createwallet` RPC to dynamically create a new wallet at runtime.

  Includes tests and release notes.

Tree-SHA512: e0d89e3ae498234e9db5b827c56804cbab64f18a1875e2b5e676172c110278ea1b9e93a8a61b8dd80e2f2a691490bf229e923e4ccb284a1d3e420b8317815866
2018-06-01 10:46:45 +02:00
John Newbery f7e153e95f [wallets] [docs] Add release notes for createwallet RPC. 2018-05-31 17:10:20 -04:00
Wladimir J. van der Laan 36fc8052f6
Merge #13309: Directly operate with CMutableTransaction in SignSignature
6b8b63af14 Generic TransactionSignatureCreator works with both CTransaction and CMutableTransaction (Martin Ankerl)

Pull request description:

  Refactored `TransactionSignatureCreator` into a templated `GenericTransactionSignatureCreator` that works with both `CMutableTransaction` and `CTransaction`.

  The advantage is that now in `SignSignature`, the `MutableTransactionSignatureCreator` can now operate directly with the `CMutableTransaction` without the need to copy the data into a `CTransaction`.

  Running all unit tests brings a very noticable speedup on my machine:

      48.4 sec before this change
      36.4 sec with this change
      --------
      12.0 seconds saved

  running only `--run_test=transaction_tests/test_big_witness_transaction`:

      16.7 sec before this change
       5.9 sec with this change
      --------
      10.8 seconds saved

  This relates to my first attempt with the const_cast hack #13202, and to the slow unit test issue #10026.

  Also see #13050 which modifies the tests but not the production code (like this PR) to get a speedup.

Tree-SHA512: 2cff0e9699f484f26120a40e431a24c8bc8f9e780fd89cb0ecf20c5be3eab6c43f9c359cde244abd9f3620d06c7c354e3b9dd3da41fa2ca1ac1e09386fea25fb
2018-05-31 10:40:11 +02:00
MarcoFalke 472fe8a2ce
Merge #13069: docs: Fix typos
d8c4998f31 Fix typos (practicalswift)

Pull request description:

  Fix typos.

Tree-SHA512: 9af52a9799e6892b162e4aa1bcd6585502e10650b8aced59e7346dbb2f08544330081eb79328255fad1d358c095507956e049d354c4383b6965d4d5a7d635425
2018-05-30 16:02:09 -04:00
Wladimir J. van der Laan c4cc8d9930
Merge #13252: Wallet: Refactor ReserveKeyFromKeyPool for safety
4b62bdf513 Wallet: Refactor ReserveKeyFromKeyPool for safety (Ben Woosley)

Pull request description:

  ReserveKeyFromKeyPool's previous behaviour is to set nIndex to -1 if the keypool is
  empty, OR throw an exception for technical failures. Instead, we now return false
  if the keypool is empty, true if the operation succeeded.

  This is to make failure more easily detectable by calling code.

Tree-SHA512: 753f057ad13bd4c28d121f426bf0967ed72b827d97fb24582f9326ec60072abc5482e3db69ccada7c5fc66de9957fc59098432dd223fc4116991cab44c6d7aef
2018-05-30 19:39:17 +02:00
Martin Ankerl 6b8b63af14 Generic TransactionSignatureCreator works with both CTransaction and CMutableTransaction
Templated version so that no copying of CMutableTransaction into a CTransaction is
necessary. This speeds up the test case transaction_tests/test_big_witness_transaction
from 7.9 seconds to 3.1 seconds on my machine.
2018-05-30 16:01:36 +02:00
Wladimir J. van der Laan 3d4fa83587 Stop translating command line options
Many options are extremely technical, and refer internals, making it
difficult to translate usefully. This came up in discussion of e.g.
 #10949. If a message is not understood by translators (which are
typically end-users, not developers) they'll either translate it
literally, making it harder to understand instead of easier, with the
added drawback of the user no longer being able to google it.

Also the translation was only working for bitcoin-qt as with
the console programs, there is no translation backend. So it was
injecting never-used translation messages for bitcoin-cli, -tx.

For these reasons, stop translating options help completely. This should
not affect the output **in any way** except for bitcoin-qt when a
non-English language is configured in the locale.

This implements #10962.
2018-05-30 14:23:35 +02:00
MarcoFalke fa7a6cf1b3
policy: Treat segwit as always active 2018-05-29 16:49:52 -04:00
Wladimir J. van der Laan 56fe3dc235
Merge #13142: Separate IsMine from solvability
c004ffc9b4 Make handling of invalid in IsMine more uniform (Pieter Wuille)
a53f0feff8 Add some checks for invalid recursion in IsMine (Pieter Wuille)
b5802a9f5f Simplify IsMine logic (Pieter Wuille)
4e91820531 Make IsMine stop distinguishing solvable/unsolvable (Pieter Wuille)
6d714c3419 Make coincontrol use IsSolvable to determine solvability (Pieter Wuille)

Pull request description:

  Our current `IsMine` logic does several things with outputs:
  * Determine "spendability" (roughly corresponding to "could we sign for this")
  * Determine "watching" (is this an output directly or indirectly a watched script)
  * Determine invalidity (is this output definitely not legally spendable, detecting accidental uncompressed pubkeys in witnesses)
  * Determine "solvability" (would we be able to sign for this ignoring the fact that we may be missing some private keys).

  The last item (solvability) is mostly unrelated and only rarely needed (there is just one instance, inside the wallet's coin control logic). This PR changes that instance to use the separate `IsSolvable` function, and stop `IsMine` from distinguishing between solvable and unsolvable.

  As an extra, this also simplifies the `IsMine` logic and adds some extra checks (which wouldn't be hit unless someone adds already invalid scripts to their wallet).

Tree-SHA512: 95a6ef75fbf2eedc5ed938c48a8e5d77dcf09c933372acdd0333129fb7301994a78498f9aacce2c8db74275e19260549dd67a83738e187d40b5090cc04f33adf
2018-05-29 15:12:16 +02:00
John Newbery 9421317740 [wallet] [rpc] Add createwallet RPC
Add a `createwallet` RPC to allow wallets to be created dynamically at
runtime. This functionality is currently only available through RPC and
newly created wallets will not be displayed in the GUI.
2018-05-25 12:10:21 -04:00
João Barbosa 54c3bb4cf8 wallet: Unlock spent outputs 2018-05-25 14:27:58 +01:00
Wladimir J. van der Laan 6378eef18f
Merge #13063: Use shared pointer to retain wallet instance
80b4910f7d wallet: Use shared pointer to retain wallet instance (João Barbosa)

Pull request description:

  Currently there are 3 places where it makes sense to retain a wallet shared pointer:
   - `vpwallets`;
   - `interfaces::Wallet` interface instance - used by the UI;
   - wallet RPC functions - given by `GetWalletForJSONRPCRequest`.

  The way it is now it is possible to have, for instance, listunspent RPC and in parallel unload the wallet (once #13111 is merged) without blocking. Once the RPC finishes, the shared pointer will release the wallet.

  It is also possible to get all existing wallets without blocking because the caller keeps a local list of shared pointers.

  This is mostly relevant for wallet unloading.

  This PR replaces #11402.

Tree-SHA512: b7e37c7e1ab56626085afe2d40b1628e8d4f0dbda08df01b7e618ecd2d894ce9b83d4219443f444ba889096286eff002f163cb0a48f37063b62e9ba4ccfa6cce
2018-05-24 11:58:41 +02:00
Wladimir J. van der Laan 3c2a41a9fc
Merge #13011: Cache witness hash in CTransaction
fac1223a56 Cache witness hash in CTransaction (MarcoFalke)
faab55fbb1 Make CMutableTransaction constructor explicit (MarcoFalke)

Pull request description:

  This speeds up:
  * compactblocks (v2)
  * ATMP
  * validation and miner (via `BlockWitnessMerkleRoot`)
  * sigcache (see also unrelated #13204)
  * rpc and rest (nice, but irrelevant)

  This presumably slows down rescan, which uses a `CTransaction` and its `GetHash`, but never uses the `GetWitnessHash`. The slow down is proportional to the number of witness transactions in the rescan window. I.e. early in the chain there should be no measurable slow down. Later in the chain, there should be a slow down, but acceptable given the speedups in the modules mentioned above.

Tree-SHA512: 443e86acfcceb5af2163e68840c581d44159af3fd1fce266cab3504b29fcd74c50812b69a00d41582e7e1c5ea292f420ce5e892cdfab691da9c24ed1c44536c7
2018-05-23 19:26:18 +02:00
João Barbosa 80b4910f7d wallet: Use shared pointer to retain wallet instance 2018-05-22 16:56:20 +01:00
John Newbery be87c6f837 [wallet] Fix incorrect comment for DeriveNewSeed. 2018-05-21 12:57:40 -04:00
John Newbery 79053a5f2b [rpc] [wallet] Add 'hdmasterkeyid' alias return values.
Restores the  return value in getwalletinfo() and getaddressinfo()
RPC methods for backwards compatibility
2018-05-19 11:21:20 -04:00
John Newbery c75c351419 [refactor] manually change remaining instances of master key to seed. 2018-05-19 11:21:15 -04:00
John Newbery 131d4450b9 scripted-diff: Rename master key to seed
-BEGIN VERIFY SCRIPT-

ren() { git grep -l "\<$1\>" 'src/*.cpp' 'src/*.h' test | xargs sed -i "s:\<$1\>:$2:g"; }
ren GenerateNewHDMasterKey  GenerateNewSeed
ren DeriveNewMasterHDKey    DeriveNewSeed
ren SetHDMasterKey          SetHDSeed
ren hdMasterKeyID           hd_seed_id
ren masterKeyID             seed_id
ren SetMaster               SetSeed
ren hdmasterkeyid           hdseedid
ren hdmaster                hdseed

-END VERIFY SCRIPT-
2018-05-19 11:16:00 -04:00
Ben Woosley 6aa33feadb
Drop UpdateTransaction in favor of UpdateInput
Updating the input explicitly requires the caller to present a mutable
input, which more clearly communicates the effects and intent of the method.

In most cases, this input is already immediately available and need not be
looked up.
2018-05-18 11:08:13 -07:00
Wladimir J. van der Laan b0d2ca9fb6 wallet: Exit SyncMetaData if there are no transactions to sync
Instead of crash with an assertion error, simply exit the function
`SyncMetaData` if there is no metadata to sync.

Fixes #13110.
2018-05-17 22:07:32 +02:00
Ben Woosley 4b62bdf513
Wallet: Refactor ReserveKeyFromKeyPool for safety
ReserveKeyFromKeyPool's previous behaviour is to set nIndex to -1 if the keypool is
empty, OR throw an exception for technical failures. Instead, we now return false
if the keypool is empty, true if the operation succeeded.

This is to make failure more easily detectable by calling code.
2018-05-16 22:58:02 -07:00
John Newbery 81608178cf [wallet] [rpc] Remove getlabeladdress RPC
labels are associated with addresses (rather than addresses being
associated with labels, as was the case with accounts). The
getlabeladdress does not make sense in this model, so remove it.

getaccountaddress is still supported for one release as the accounts
API is deprecated.
2018-05-16 17:45:19 -04:00
John Newbery 5d152601e9 [wallet] [rpc] Add loadwallet RPC
The new `loadwallet` RPC method allows an existing wallet to be loaded
dynamically at runtime.

`unloadwallet` and `createwallet` are not implemented. Notably,
`loadwallet` can only be used to load existing wallets, not to create a
new wallet.
2018-05-16 12:00:01 -04:00
John Newbery 876eb64680 [wallet] Pass error message back from CWallet::Verify()
Pass an error message back from CWallet::Verify(), and call
InitError/InitWarning from WalletInit::Verify().

This means that we can call CWallet::Verify() independently from
WalletInit and not have InitErrors printed to stdout. It also means that
the error can be reported to the user if dynamic wallet load fails.
2018-05-16 11:59:58 -04:00
John Newbery e0e90db07b [wallet] Add CWallet::Verify function
This allows a single wallet to be verified. Prior to this commit, all
wallets were verified together by the WalletInit::Verify() function at
start-up.

Individual wallet verification will be done when loading wallets
dynamically at runtime.
2018-05-16 11:55:38 -04:00
John Newbery 470316c3bf [wallet] setup wallet background flushing in WalletInit directly
WalletInit::Start calls postInitProcess() for each wallet. Previously
each call to postInitProcess() would attempt to schedule wallet
background flushing.

Just start wallet background flushing once from WalletInit::Start().
2018-05-15 13:28:29 -04:00
John Newbery 59b87a27ef [wallet] Fix potential memory leak in CreateWalletFromFile
Fix proposed by ryanofsky in
https://github.com/bitcoin/bitcoin/pull/12647#discussion_r174875670
2018-05-15 13:28:29 -04:00
MarcoFalke c5870ab689
Merge #12963: Fix Clang Static Analyzer warnings
159c32d1f1 Add assertion to guide static analyzers. Clang Static Analyzer needs this guidance. (practicalswift)
fd447a6efe Fix dead stores. Values were stored but never read. Limit scope. (practicalswift)

Pull request description:

  Fix Clang Static Analyzer warnings reported by @kallewoof in #12961:

  * Fix dead stores. Values were stored but never read.
  * Add assertion to guide static analyzers. See #12961 for details.

Tree-SHA512: 83dbec821f45217637316bee978e7543f2d2caeb7f7b0b3aec107fede0fff8baa756da8f6b761ae0d38537740839ac9752f6689109c38a4b05c0c041aaa3a1fb
2018-05-14 10:45:24 -04:00
MarcoFalke 19a3a9e8fb
Merge #13127: wallet: Add Clang thread safety annotations for variables guarded by cs_db
56921f9369 wallet: Add Clang thread safety annotations for variables guarded by cs_db (practicalswift)

Pull request description:

  Add Clang thread safety annotations for variables guarded by `cs_db`.

Tree-SHA512: d59723598e918143f36408b4f49d31138b5d8968ba191472f6a207a63af147627f21e48fd6cc1606dd901d8a58183271e65ea4346a380db3c09e404764a28063
2018-05-14 09:56:47 -04:00
MarcoFalke 0dec5b5af4
Merge #13081: wallet: Add compile time checking for cs_wallet runtime locking assertions
66b0b1b2a6 Add compile time checking for all cs_wallet runtime locking assertions (practicalswift)

Pull request description:

  Add compile time checking for `cs_wallet` runtime locking assertions.

  This PR is a subset of #12665. The PR was broken up to make reviewing easier.

  The intention is that literally all `EXCLUSIVE_LOCKS_REQUIRED`/`LOCKS_EXCLUDED`:s added in this PR should follow either directly or indirectly from `AssertLockHeld(…)`/`AssertLockNotHeld(…)`:s already existing in the repo.

  Consider the case where function `A(…)` contains `AssertLockHeld(cs_foo)` (without
  first locking `cs_foo` in `A`), and that `B(…)` calls `A(…)` (without first locking `cs_main`):
  * It _directly_ follows that: `A(…)` should have an `EXCLUSIVE_LOCKS_REQUIRED(cs_foo)` annotation.
  * It _indirectly_ follows that: `B(…)` should have an `EXCLUSIVE_LOCKS_REQUIRED(cs_foo)` annotation.

Tree-SHA512: d561d89e98a823922107e56dbd493f0f82e22edac91e51e6422f17daf2b446a70c143b7b157ca618fadd33d0ec63eb7a57dde5a83bfdf1fc19d71459b43e21fd
2018-05-14 09:17:35 -04:00
Wladimir J. van der Laan 7cc1bd3aae
Merge #13161: wallet: Reset BerkeleyDB handle after connection fails
b6f0b4d wallet: Improve logging when BerkeleyDB environment fails to close (Tim Ruffing)
264c643 wallet: Reset BerkeleyDB handle after connection fails (Tim Ruffing)

Pull request description:

  According to the BerkeleyDB docs, the DbEnv handle may not be accessed
  after close() has been called. This change ensures that we create a new
  handle after close() is called. This avoids a segfault when the first
  connection attempt fails and then a second connection attempt tries to
  call open() on the already closed DbEnv handle.

  Without the patch, bitcoindd reliably crashes in the second call to `set_lg_dir()` after `close()` if
  there is an issue with the database:
  ```
  2018-05-03T13:27:21Z Bitcoin Core version v0.16.99.0-a024a1841-dirty (debug build)
  [...]
  2018-05-03T13:27:21Z Using wallet directory /home/tim/.bitcoin
  2018-05-03T13:27:21Z init message: Verifying wallet(s)...
  2018-05-03T13:27:21Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
  2018-05-03T13:27:21Z Using wallet wallet.dat
  2018-05-03T13:27:21Z BerkeleyEnvironment::Open: LogDir=/home/tim/.bitcoin/database
  2018-05-03T13:27:21Z BerkeleyEnvironment::Open: Error -30974 opening database environment: DB_RUNRECOVERY: Fatal error, run database recovery
  2018-05-03T13:27:21Z Moved old /home/tim/.bitcoin/database to /home/tim/.bitcoin/database.1525354041.bak. Retrying.
  2018-05-03T13:27:21Z BerkeleyEnvironment::Open: LogDir=/home/tim/.bitcoin/database ErrorFile=/home/tim/.bitcoin/db.log
  [1]    14533 segmentation fault (core dumped)  ./src/bitcoind
  ```

  After the fix:
  ```
  2018-05-03T17:19:32Z Bitcoin Core version v0.16.99.0-cc09e3bd0-dirty (release build)
  [...]
  2018-05-03T17:19:32Z Using wallet directory /home/tim/.bitcoin
  2018-05-03T17:19:32Z init message: Verifying wallet(s)...
  2018-05-03T17:19:32Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
  2018-05-03T17:19:32Z Using wallet wallet.dat
  2018-05-03T17:19:32Z BerkeleyEnvironment::Open: LogDir=/home/tim/.bitcoin/database ErrorFile=/home/tim/.bitcoin/db.log
  2018-05-03T17:19:32Z scheduler thread start
  2018-05-03T17:19:32Z BerkeleyEnvironment::Open: Error -30974 opening database environment: DB_RUNRECOVERY: Fatal error, run database recovery
  2018-05-03T17:19:32Z Moved old /home/tim/.bitcoin/database to /home/tim/.bitcoin/database.1525367972.bak. Retrying.
  2018-05-03T17:19:32Z BerkeleyEnvironment::Open: LogDir=/home/tim/.bitcoin/database ErrorFile=/home/tim/.bitcoin/db.log
  2018-05-03T17:19:32Z Cache configuration:
  2018-05-03T17:19:32Z * Using 2.0MiB for block index database
  2018-05-03T17:19:32Z * Using 8.0MiB for chain state database
  2018-05-03T17:19:32Z * Using 440.0MiB for in-memory UTXO set (plus up to 286.1MiB of unused mempool space)
  2018-05-03T17:19:32Z init message: Loading block index..
  [...]
  ```

Tree-SHA512: b809b318e5014ec47d023dc3dc40826b9706bfb211fa08bc2d29f36971b96caa10ad48d9a3f96c03933be46fa4ff7e00e952ac77bfffb6563767fb08aa4f23d6
2018-05-14 15:06:48 +02:00
practicalswift 66b0b1b2a6 Add compile time checking for all cs_wallet runtime locking assertions 2018-05-14 14:57:25 +02:00
Wladimir J. van der Laan e03c0db08f
Merge #12560: [wallet] Upgrade path for non-HD wallets to HD
a8da482 Bump wallet version for pre split keypool (Andrew Chow)
dfcd9f3 Use a keypool of presplit keys after upgrading to hd chain split (Andrew Chow)
5c50e93 Allow -upgradewallet to upgradewallets to HD (Andrew Chow)
2bcf2b5 Test sethdseed (Andrew Chow)
b5ba01a Add 'sethdseed' RPC to initialize or replace HD seed (Chris Moore)
dd3c07a Separate HaveKey function that checks whether a key is in a keystore (Andrew Chow)

Pull request description:

  Revival/rebase of #11085

  Adds a new command `sethdseed` which allows you to either set or generate a new HD seed to be used. A new keypool can be generated or the original one kept and new keys added to the keypool will come from the new HD seed.

  Wallets that are not HD will be upgraded to be version FEATURE_HD_SPLIT when the `sethdseed` RPC command is used.

  I have also add some tests for this.

  Additionally `-upgradewallet` can now be used to upgrade a wallet from non-HD to HD. When it is used for such an upgrade, the keypool will be regenerated.

Tree-SHA512: e56c792e150590429ac4a1061e8d6f7b20cca06366e184eb9bbade4cd6ae82699a28fe84f87031eadba97ad2c1606517a105f00fb7b45779c979243020071adb
2018-05-14 11:17:29 +02:00
Andrew Chow a8da482a8b Bump wallet version for pre split keypool
Bump the wallet version to indicate support for the pre split keypool.
Also prevents any wallets from upgrading to versions between HD_SPLIT
and PRE_SPLIT_KEYPOOL.
2018-05-12 13:15:21 -04:00
Andrew Chow dfcd9f3e6a Use a keypool of presplit keys after upgrading to hd chain split
After upgrading to HD chain split, we want to continue to use keys
from the old keypool. To do this, before we generate any new keys after
upgrading, we mark all of the keypool entries as being pre-chain
split and move them to a separate pre chain split keypool. Keys are
fetched from that keypool until it is emptied. Only then are the new
internal and external keypools used.
2018-05-12 13:15:21 -04:00
Andrew Chow 5c50e93d52 Allow -upgradewallet to upgradewallets to HD
Changes the maximum upgradewallet version to the latest wallet version
number, 159900. Non-HD wallets will be upgraded to use HD derivation.
Non HD chain split wallets will be upgraded to HD chain split.

If a non-HD wallet is upgraded to HD, the keypool will be entirely
regenerated.

Since upgradewallet is effectively run during a first run, all of the
first run initial setup stuff is combined with the upgrade to HD
2018-05-12 13:15:21 -04:00
Chris Moore b5ba01a187 Add 'sethdseed' RPC to initialize or replace HD seed 2018-05-12 13:15:21 -04:00
Andrew Chow 4d4185a4f0 Make gArgs aware of the arguments
gArgs knows what the available arguments are and their help. Getting
the help message is moved to gArgs and HelpMessage() is removed
2018-05-09 12:21:05 -04:00
Tim Ruffing b6f0b4d859
wallet: Improve logging when BerkeleyDB environment fails to close 2018-05-09 15:23:16 +02:00
Jonas Schnelli 5778d44aa8
Merge #13079: Fix rescanblockchain rpc to properly report progress
16be13345 Fix rescanblockchain rpc to property report progress (Ben Woosley)

Pull request description:

  Previously it assumed tip in all cases. This also extracts a RescanVerificationProgress helper object whose role is to manage reporting, in order to simplify ScanForWalletTransactions - more lines in total, but much simpler to follow the core logic.

Tree-SHA512: 5ebed0c56fae4ccfe613ff1d7082cb6da5a86635a8993ed3af70b500a4ea43074121aea9219b2f0321fbfeb7efcb964bdc2199297a64ca0fa85d9d07aa637d40
2018-05-07 15:03:38 +02:00
practicalswift d8c4998f31 Fix typos 2018-05-07 14:32:50 +02:00
MarcoFalke faab55fbb1
Make CMutableTransaction constructor explicit
Silently converting to a CMutableTransaction will drop all caches
and should thus be done explicitly
2018-05-04 17:40:52 -04:00
Johnson Lau 2f1a30c63e Fix MAX_STANDARD_TX_WEIGHT check
As suggested by the constant name and its comment in policy.h, a transaction with a weight of exactly MAX_STANDARD_TX_WEIGHT should be allowed
2018-05-05 00:00:28 +08:00
practicalswift c3f34d06be Make it clear which functions that are intended to be translation unit local
Do not share functions that are meant to be translation unit local with
other translation units. Use internal linkage for those consistently.
2018-05-03 21:47:40 +02:00
Pieter Wuille 6d714c3419 Make coincontrol use IsSolvable to determine solvability 2018-05-03 11:01:57 -07:00
Ben Woosley 16be13345e
Fix rescanblockchain rpc to property report progress
CWallet::ScanForWalletTransactions did not previously take into account
pindexStop when calculating progress.

Renamed progress vars to progress_*.

rescanblockchain is the only rpc that uses this parameter.
2018-05-03 13:18:10 -04:00
Tim Ruffing 264c643809
wallet: Reset BerkeleyDB handle after connection fails
According to the BerkeleyDB docs, the DbEnv handle may not be accessed
after close() has been called. This change ensures that we create a new
handle after close() is called. This avoids a segfault when the first
connection attempt fails and then a second connection attempt tries to
call open() on the already closed DbEnv handle.
2018-05-03 19:15:11 +02:00
João Barbosa a59dac35ab refactor: Avoid extra lookups of mapAddressBook in listunspent RPC 2018-05-03 11:32:57 +01:00
João Barbosa d76962e056 rpc: Reduce cs_main lock in listunspent 2018-05-03 11:31:21 +01:00
Wladimir J. van der Laan 979150bc23
Merge #12729: Get rid of ambiguous OutputType::NONE value
1e46d8a Get rid of ambiguous OutputType::NONE value (Russell Yanofsky)

Pull request description:

  Based on suggestion by @sipa https://github.com/bitcoin/bitcoin/pull/12119#issuecomment-357982763

  After #12119, the NONE output type was overloaded to refer to either an output type that couldn't be parsed, or to an automatic change output mode.  This change drops the NONE enum and uses a simple bool to indicate parse failure, and a new CHANGE_AUTO enum to refer the change output type.

  This change is almost a pure refactoring except it makes RPCs reject empty string ("") address types instead of treating them like they were unset. This simplifies the parsing code a little bit and could prevent RPC usage mistakes. It's noted in the release notes.

  Follows up #12408 by @MarcoFalke

  Followups for future PRs:

  - [ ] Add explicit support for specifying "auto" in `ParseOutputType` as suggested by promag and sipa: https://github.com/bitcoin/bitcoin/pull/12729#issuecomment-374799567 and https://github.com/bitcoin/bitcoin/pull/12729#discussion_r175969481
  - [ ] Add wallet `AddressChangeType` method to complement `TransactionChangeType`:  https://github.com/bitcoin/bitcoin/pull/12729#discussion_r175969618.

Tree-SHA512: 8b08b272bcb177a0a9e556dcd965840a7fe601ef83ca97938b879c9b1a33b5b3f96939e1bceef11ba7c644ac21bfd6c1dbc6ca715cd1da4ace50475240e4ee48
2018-05-03 11:53:30 +02:00
Wladimir J. van der Laan 2afdc29403
Merge #12507: Interrupt rescan on shutdown request
c4fda76 wallet: Interrupt rescan on shutdown request (João Barbosa)

Pull request description:

  Fixes #10987.

  Here are the steps to test the feature:

  1. start bitcoind, generate a couple of transactions and then stop:
  ```
  bitcoind -regtest -printtoconsole
  bitcoin-cli -regtest generate 100
  ```
  2. apply the following patch
  ```diff
  diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
  index 2478d67ce..8f8cea40c 100644
  --- a/src/wallet/wallet.cpp
  +++ b/src/wallet/wallet.cpp
  @@ -1671,6 +1671,7 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
           }
           while (pindex && !fAbortRescan && !ShutdownRequested())
           {
  +            MilliSleep(500);
               if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0) {
                   double gvp = 0;
                   {
  ```
  3. start bitcoind with rescan flag, interrupt with CTRL+C and the output should look like:
  ```
  bitcoind -regtest -printtoconsole -rescan
  ...
  ^C2018-02-22 01:00:55 AddToWallet e8bfb4501b630ad2acb91e88ab0112a779766536d2c564b04faae45ae90e18f7
  2018-02-22 01:00:55 Rescan interrupted by shutdown request at block 5. Progress=1.000000
  2018-02-22 01:00:55  rescan                 1774ms
  2018-02-22 01:00:55 setKeyPool.size() = 1995
  2018-02-22 01:00:55 mapWallet.size() = 10145
  2018-02-22 01:00:55 mapAddressBook.size() = 3
  2018-02-22 01:00:55 Shutdown: In progress...
  2018-02-22 01:00:55 scheduler thread interrupt
  2018-02-22 01:00:55 Shutdown: done
  ```

Tree-SHA512: f9bebe2cdacf0359b6cbfcbc48ac2818a3ae7aa7822ff0c2c0de4ca2fff7c88493380b74a1c5ff2ce1de01fe605b0e5ef3576f124ea9cff8ef25a9e762477b92
2018-05-03 11:27:36 +02:00
Wladimir J. van der Laan ff2ad2d569 Add missing newlines to LogPrint debug logging
The linter only checked `LogPrintf`, not `LogPrint`.
Fix the remaining cases.
2018-05-02 15:14:04 +02:00
Wladimir J. van der Laan 598db389c3
Merge #13106: Simplify semantics of ChainStateFlushed callback
9cb6cdc Simplify semantics of ChainStateFlushed callback (Matt Corallo)
50b6533 scripted-diff: Rename SetBestChain callback ChainStateFlushed (Matt Corallo)

Pull request description:

  Previously, ChainStateFlushed would fire either if a full flush
  completed (which can happen due to memory limits, forced flush, or
  on its own DATABASE_WRITE_INTERVAL timer) *or* on a
  ChainStateFlushed-specific DATABASE_WRITE_INTERVAL timer. This is
  both less clear for clients (as there are no guarantees about a
  flush having actually happened prior to the call), and reults in
  extra flushes not clearly intended by the code. We drop the second
  case, providing a strong guarantee without removing the periodit
  timer-based flushing.

  This is a follow-up to discussion in #11857.

Tree-SHA512: 22ba3a0954d265d28413dbf87040790ca5b439820ee7bbadab14028295ec190de82ce5cd664426c82e58b706dc84278868026fa8d066702eb6e6962c9ace1f8e
2018-05-02 13:11:52 +02:00
João Barbosa c4fda7672a wallet: Interrupt rescan on shutdown request 2018-05-02 11:58:02 +01:00
Wladimir J. van der Laan 783bb6455e
Merge #13028: Make vpwallets usage thread safe
e2f58f4 wallet: Make vpwallets usage thread safe (João Barbosa)

Pull request description:

  This PR turns the functions introduced in #13017 thread safe. This is required to correctly support dynamically loading wallets, which is implemented in #10740.

Tree-SHA512: efaa09e501636cf957aa33de83719ce09dc0c2a19daff741a94ef10d6b7ba5dee538355b80c96ead995140f99f5df0c92fb0e22ae1adb8f397eb478280c8d8c7
2018-04-30 17:26:30 +02:00
practicalswift 56921f9369 wallet: Add Clang thread safety annotations for variables guarded by cs_db 2018-04-30 11:42:20 +02:00
practicalswift 968b76f77c Add missing cs_KeyStore lock 2018-04-29 20:15:05 +02:00
practicalswift 4bcd5bb87d Add locking annotations for variables guarded by cs_KeyStore 2018-04-29 20:14:27 +02:00
Matt Corallo 50b6533aa2 scripted-diff: Rename SetBestChain callback ChainStateFlushed
This much more accurately captures the meaning of the callback.

-BEGIN VERIFY SCRIPT-
sed -i 's/SetBestChain/ChainStateFlushed/g' src/validationinterface.h src/validationinterface.cpp src/wallet/wallet.h src/wallet/wallet.cpp src/validation.cpp src/index/txindex.h src/index/txindex.cpp
-END VERIFY SCRIPT-
2018-04-27 14:44:22 -04:00
Wladimir J. van der Laan 17266a1306
Merge #13090: Remove Safe mode (achow101)
d8e9a2a Remove "rpc" category from GetWarnings (Wladimir J. van der Laan)
7da3b0a rpc: Move RPC_FORBIDDEN_BY_SAFE_MODE code to reserved section (Wladimir J. van der Laan)
2ae705d Remove Safe mode (Andrew Chow)

Pull request description:

  Rebase of #10563. Safe mode was [disabled by default and deprecated in 0.16](https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-0.16.0.md#safe-mode-disabled-by-default), so probably should be removed for 0.17.

  > Rationale:
  >
  > Safe mode is useless. It only disables some RPC commands when large work forks are detected. Nothing else is affected by safe mode. It seems that very few people would be affected by safe mode. The people who use Core as a wallet are primarily using it through the GUI, which safe mode does not effect. In the GUI, transactions will still be made as normal; only a warning is displayed.
  >
  > I also don't think that we should be disabling RPC commands or any functionality in general. If we do, it should be done consistently, which safe mode is not. If we want to keep the idea of a safe mode around, I think that the current system needs to go first before a new system can be implemented.

Tree-SHA512: 067938f47ca6e879fb6c3c4e21f9946fd7c5da3cde67ef436f1666798c78d049225b9111dc97064f42b3bc549d3915229fa19ad5a634588f381e34fc65d64044
2018-04-27 17:03:44 +02:00
Wladimir J. van der Laan 487dcbe80c
Merge #13002: Do not treat bare multisig outputs as IsMine unless watched
7d0f80b Use anonymous namespace instead of static functions (Pieter Wuille)
b61fb71 Mention removal of bare multisig IsMine in release notes (Pieter Wuille)
9c2a8b8 Do not treat bare multisig as IsMine (Pieter Wuille)
08f3228 Optimization: only test for witness scripts at top level (Pieter Wuille)
3619735 Track difference between scriptPubKey and P2SH execution in IsMine (Pieter Wuille)
ac6ec62 Switch to a private version of SigVersion inside IsMine (Pieter Wuille)
19fc973 Do not expose SigVersion argument to IsMine (Pieter Wuille)
fb1dfbb Remove unused IsMine overload (Pieter Wuille)
952d821 Make CScript -> CScriptID conversion explicit (Pieter Wuille)

Pull request description:

  Currently our wallet code will treat bare multisig outputs (meaning scriptPubKeys with multiple public keys + `OP_CHECKMULTISIG` operator in it) as ours without the user asking for it, as long as all private keys in it are in our wallet.

  This is a pointless feature. As it only works when all private keys are in one place, it's useless compared to single key outputs (P2PK, P2PKH, P2WPKH, P2SH-P2WPKH), and worse in terms of space, cost, UTXO size, and ability to test (due to lack of address format for them).

  Furthermore, they are problematic in that producing a list of all `scriptPubKeys` we accept is not tractable (it involves all combinations of all public keys that are ours). In further wallet changes I'd like to move to a model where all scriptPubKeys that are treated as ours are explicit, rather than defined by whatever keys we have. The current behavior of the wallet is very hard to model in such a design, so I'd like to get rid of it.

  I think there are two options:
  * Remove it entirely (do not ever accept bare multisig outputs as ours, unless watched)
  * Only accept bare multisig outputs in situations where the P2SH version of that output would also be acceptable

  This PR implements the first option. The second option was explored in #12874.

Tree-SHA512: 917ed45b3cac864cee53e27f9a3e900390c576277fbd6751b1250becea04d692b3b426fa09065a3399931013bd579c4f3dbeeb29d51d19ed0c64da75d430ad9a
2018-04-26 20:10:12 +02:00
Andrew Chow 2ae705d841 Remove Safe mode 2018-04-26 15:33:11 +02:00
John Newbery 2c71edc2fc [wallet] [rpc] Fix importaddress help text 2018-04-25 13:08:35 -05:00
João Barbosa e2f58f421b wallet: Make vpwallets usage thread safe 2018-04-24 17:26:04 +01:00
Wladimir J. van der Laan 476cb35551
Merge #12909: wallet: Make fee settings to be non-static members
fac0db0 wallet: Make fee settings non-static members (MarcoFalke)

Pull request description:

  The wallet header defined some globals (they were called "settings"), that should be class members instead.

  This commit is hopefully only refactoring, apart from a multiwallet bugfix: Calling the rpc `settxfee` for one wallet, would set (and change) the fee rate for all loaded wallets. (See added test case)

Tree-SHA512: 4ab6ec2f5c714742396ded5e451ec3b1ceb771e3696492de29889d866de4365b3fbe4a2784d085c8b8bd11b1ebb8a1fec99ab2c62eee716791cfc67c0cf29e1b
2018-04-24 16:37:30 +02:00
Wladimir J. van der Laan d1d54ae6a3
Merge #12953: Deprecate accounts
cead28b [docs] Add release notes for deprecated 'account' API (John Newbery)
72c9575 [wallet] [tests] Add tests for accounts/labels APIs (John Newbery)
109e05d [wallet] [rpc] Deprecate wallet 'account' API (John Newbery)
3576ab1 [wallet] [rpc] Deprecate account RPC methods (John Newbery)
3db1ba0 [tests] Set -deprecatedrpc=accounts in tests (John Newbery)
4e671f0 [tests] Rename rpc_listtransactions.py to wallet_listtransactions.py (John Newbery)
a28b907 [wallet] [rpc] Remove duplicate entries in rpcwallet.cpp's CRPCCommand table (John Newbery)

Pull request description:

  Deprecate all accounts functionality and make it only accessible by using `-deprecatedrpc=accounts`.

  Accounts specific RPCs, account arguments, and account related results all require the `-deprecatedrpc=accunts` startup option now in order to see account things.

  Several wallet functional tests use the accounts system. Those tests are unchanged, except to start the nodes with `-deprecatedrpc=accounts`. We can slowly migrate those tests to use the 'label' API instead of the 'account' API before accounts are fully removed.

Tree-SHA512: 89f4ae2fe6de4a1422f1817b0997ae22d63ab5a1a558362ce923a3871f3e42963405d6573c69c27f1764679cdee5b51bf52202cc407f1361bfd8066d652f3f37
2018-04-24 15:21:27 +02:00
Wladimir J. van der Laan d3f04c0e81
Merge #13030: [bugfix] [wallet] Fix zapwallettxes/multiwallet interaction.
1f83839 [wallet] [tests] Test disallowed multiwallet params (John Newbery)
3476e3c [wallet] Fix zapwallettxes/multiwallet interaction. (John Newbery)

Pull request description:

  `-zapwallettxes` should be disallowed when starting bitcoin in multiwallet mode.

  There's code in `WalletInit::ParameterInteraction()` to disallow `-zapwallettxes` when running in multiwallet mode. This code functioned as expected when passing the parameter `-zapwallettxes=1`, but not when passing the parameter `-zapwallettxes` (ie without the value specified). Fix that and add a test.

  The new test in the
  _[wallet] [tests] Test disallowed multiwallet params_ commit reproduces the bug and should fail against master.

  Fixes #12505

Tree-SHA512: 6cd921717e9c7d2773ca84c946c310c2adec8430e37cbecdb33a620f510db3058a72bd328411812ba415111bc52a3367b332c9d15a37a92ccfd7ae785d2f32ab
2018-04-23 20:23:18 +02:00
MarcoFalke fac0db0ff8
wallet: Make fee settings non-static members 2018-04-23 10:49:21 -04:00
John Newbery 3476e3c48b [wallet] Fix zapwallettxes/multiwallet interaction.
-zapwallettxes should be disallowed when starting bitcoin in multiwallet
mode.
2018-04-19 11:07:54 -04:00
Pieter Wuille 952d8213a6 Make CScript -> CScriptID conversion explicit 2018-04-18 17:08:50 -07:00
João Barbosa 3c058fdcc8 wallet: Add HasWallets 2018-04-18 22:07:58 +01:00
João Barbosa 373aee26c3 wallet: Add AddWallet, RemoveWallet, GetWallet and GetWallets
With these new functions all vpwallets usage are removed
and vpwallets is now a static variable (no external linkage).
2018-04-18 22:07:33 +01:00
João Barbosa 6efd9644cf refactor: Drop CWalletRef typedef 2018-04-18 13:41:28 +01:00
Wladimir J. van der Laan 0d12570a80
Merge #13007: test: Fix dangling wallet pointer in vpwallets
d41a420 test: Fix dangling wallet pointer in vpwallets (João Barbosa)

Pull request description:

Tree-SHA512: 83e4ec571f1675b3dab6f7606f29d6fae495d998b4e5794ff14315943783d4518cfa66eba4113293e349eb74aa22a024b21272fdb29c212477edb4c09aec9fa7
2018-04-18 11:30:24 +02:00
João Barbosa d41a420562 test: Fix dangling wallet pointer in vpwallets 2018-04-17 18:28:54 +01:00
MarcoFalke 6b46288a08
Merge #12949: tests: Avoid copies of CTransaction
fae58eca93 tests: Avoid copies of CTransaction (MarcoFalke)

Pull request description:

  Avoid the copy (or move) constructor of `CTransaction` in test code, whereever a simple reference can be used instead.

Tree-SHA512: 8ef2077a277d6182996f4671722fdc01a90909ae7431c1e52604aab8ed028910615028caf9b4cb07a9b15fdc04939dea2209cc3189dde7d38271256d9fe1076c
2018-04-17 13:28:12 -04:00
John Newbery 109e05dcd1 [wallet] [rpc] Deprecate wallet 'account' API
This commit finalizes the deprecation of the wallet 'accounts' API by
removing all account arguments and return values.

RPC behaviour is slightly different if the 'accounts' or 'labels' API is
being used. Those behaviour changes are fully documented in the RPC help
text.
2018-04-17 12:43:26 -04:00
John Newbery 3576ab1261 [wallet] [rpc] Deprecate account RPC methods
All account RPC methods are now deprecated and can only be called if
bitcoind has been started with the -deprecatedrpc=accounts switch.

Affected RPC methods are:

- getaccount
- getaccountaddress
- getaddressesbyaccount
- getreceivedbyaccount
- listaccouts
- listreceivedbyaccount
- move
- setaccount
2018-04-17 12:42:33 -04:00
Wladimir J. van der Laan 434150aef7
Merge #12977: Refactor g_wallet_init_interface to const reference
6ec78f1 wallet: Refactor g_wallet_init_interface to const reference (João Barbosa)
1936125 wallet: Make WalletInitInterface members const (João Barbosa)

Pull request description:

Tree-SHA512: c382156a38d4c6beaa6c48f911d7b314542b9500d88724b2b3029dae4491cb1e60e10628f6632d1366818ccf343f494650b3171593b5450149544ba198f49bb5
2018-04-17 15:58:13 +02:00