Commit Graph

1298 Commits

Author SHA1 Message Date
jc 18d0083895 [cleanup] replace brackets in includes, update copyrights and use std::array instead of boost::array 2018-06-04 07:22:39 -04:00
jc 27a9fcf14c [primitives] Add Joinsplit primitives 2018-06-03 15:27:02 -04:00
jc 77d280acfc [wallet] Add asyncrpc and paymentdisclosure related files 2018-06-03 09:35:30 -04: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
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
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
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 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
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