Commit graph

13356 commits

Author SHA1 Message Date
Russell Yanofsky cc3836e8f9 Remove uses of fPruneMode in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky cc02c796d3 Remove uses of fee globals in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky 1fb0a4a04e Remove use of CalculateMemPoolAncestors in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky cd32160af0 Remove use of GetTransactionAncestry in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky 291276f7f4 Remove use of GetCountWithDescendants in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky bdc6628683 Remove use of IsRBFOptIn in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky 80f52a2267 Remove uses of CheckFinalTx in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
João Barbosa 28c86de3b1 gui: Drop unused return values in WalletFrame 2019-02-22 16:26:09 +00:00
MarcoFalke 169dced9a4
Merge #15408: Remove unused TransactionError constants
fa9b60c842 Remove unused TransactionError constants (MarcoFalke)

Pull request description:

  Fixup to #14978, which introduced a bunch of unused enum values, such as `UNKNOWN_ERROR`, `ERROR_COUNT` and `TRANSACTION_ERR_LAST`. None of those have a meaning in the context of an `enum class`, where the compiler can infer if all cases have been covered in a switch-case.

  Also, move the global `::maxTxFee` back to the rpc caller, so it can be set on a per call basis (in the future).

Tree-SHA512: 7f1e2d795f1c1278ecd54ddab2b92c2a862f3c637b482d1d008208925befa1c9dd4b3c4bb1bfcbc5ca4b66a41004aaf01ea96ea95236f944250b8a6cf99ff173
2019-02-22 11:13:43 -05:00
MarcoFalke 77fcf252f6
Merge #15458: refactor: Drop redundant wallet reference
53b310390c refactor: Drop redundant wallet reference (João Barbosa)

Pull request description:

  Removes the redudant wallet reference from `WalletImpl`.

  ```cpp
  // before:
  std::shared_ptr<CWallet> m_shared_wallet;
  CWallet& m_wallet;

  // after
  std::shared_ptr<CWallet> m_wallet;
  ```

Tree-SHA512: c78c5a75a59df20b1684f746305c5b3505f73adfd84f00fd800da61ca07c6a37a992fedea3da390afd9564dc6b6a022d183a38995124783ad62c0cc7610be92b
2019-02-22 10:44:02 -05:00
Wladimir J. van der Laan a83aedca18
Merge #13676: Explain that mempool memory is added to -dbcache
7cb1a1401d Explain that unused mempool memory is added to -dbcache (Sjors Provoost)

Pull request description:

  Since `-maxmempool` is 450 MB by default it's quite possible for a user to accidentally OOM a low
  memory device if they increase `-dbcache` beyond the default.

  <img width="563" alt="schermafbeelding 2018-09-06 om 17 02 40" src="https://user-images.githubusercontent.com/10217/45166219-c9c4f700-b1f6-11e8-9ee5-14b8b3a9830b.png">

Tree-SHA512: 44c7419d0b06c14aee5d2c02a41e5da488bcb40a5f65ba24554a45707b222f1e4b03d42486dfef9336d917ac2990eef2b1aec287a75b3ef1ccca0e88ac86a0c0
2019-02-21 18:57:21 +01:00
João Barbosa 53b310390c refactor: Drop redundant wallet reference 2019-02-21 16:19:29 +00:00
Wladimir J. van der Laan 3e1ca1348c
Merge #15278: Improve PID file error handling
3782075a5f Move all PID file stuff to init.cpp (Hennadii Stepanov)
561e375c73 Make PID file creating errors fatal (Hennadii Stepanov)
745a2ace18 Improve PID file removing errors logging (Hennadii Stepanov)

Pull request description:

  Digging into #15240 the lack of the proper logging has been discovered.
  Fixed by this PR.

  UPDATE (inspired by @laanwj's [comment](https://github.com/bitcoin/bitcoin/pull/15278#discussion_r252641810)):
  Not being able to create the PID file is fatal now.

  Output of `bitcoind`:

  ```
  $ src/bitcoind -pid=/run/bitcoind/bitcoind.pid
  2019-02-01T23:20:10Z Bitcoin Core version v0.17.99.0-561e375c7 (release build)
  2019-02-01T23:20:10Z Assuming ancestors of block 0000000000000037a8cd3e06cd5edbfe9dd1dbcc5dacab279376ef7cfc2b4c75 have valid signatures.
  2019-02-01T23:20:10Z Setting nMinimumChainWork=00000000000000000000000000000000000000000000007dbe94253893cbd463
  2019-02-01T23:20:10Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
  2019-02-01T23:20:10Z Using RdRand as an additional entropy source
  2019-02-01T23:20:11Z Error: Unable to create the PID file '/run/bitcoind/bitcoind.pid': No such file or directory
  Error: Unable to create the PID file '/run/bitcoind/bitcoind.pid': No such file or directory
  2019-02-01T23:20:11Z Shutdown: In progress...
  2019-02-01T23:20:11Z Shutdown: Unable to remove PID file: File does not exist
  2019-02-01T23:20:11Z Shutdown: done
  ```

  Output of `bitcoin-qt`:
  ![screenshot from 2019-02-02 01-19-05](https://user-images.githubusercontent.com/32963518/52154886-9349b600-2688-11e9-8128-470f16790305.png)

  **Notes for reviewers**
  1. `CreatePidFile()` has been moved from `util/system.cpp` to `init.cpp` for the following reasons:
  - to get the ability to use `InitError()`
  - now `init.cpp` contains code of both creating PID file and removing it

  2. Regarding 0.18 release process: this PR modifies 1 string and introduces 2 new ones.

Tree-SHA512: ac07d0f800e61ec759e427d0afc0ca43d67f232e977662253963afdd0a220d34b871050f58149fc9fabd427bfc8e0d3f6a6032f2a38f30ad366fc0d074b0f2b3
2019-02-21 09:23:10 +01:00
MarcoFalke fa4ce7038d
rpc: Actually throw help when passed invalid number of params 2019-02-20 13:34:16 -05:00
MarcoFalke fa05626ca7
rpc: Add RPCHelpMan::IsValidNumArgs() 2019-02-20 13:32:17 -05:00
Akio Nakamura 1a7ba84e11 Fix lack of warning of unrecognized section names
1. Fix lack of warning by collecting all section names by moving
   m_config_sections.clear() to ArgsManager::ReadConfigFiles().
2. Add info(file name, line number) to warning message.
3. Add a test code to confirm this situation.
3. Do clear() in ReadConfigString().
2019-02-19 10:49:19 +09:00
MeshCollider 904308dca3
Merge #15433: Use a single wallet batch for UpgradeKeyMetadata
0bedcbafd Use a single wallet batch for UpgradeKeyMetadata (Jonas Schnelli)

Pull request description:

  Opening wallets (the first time) after #14021 took on my end around 30 seconds due to the keymetadata migration (tested on regtest).

  Using a single wallet batch reduces the required time for the migration down to <1s on my system for a default 2k keypool wallet.

Tree-SHA512: f68739e452d382f5294186f47511b94884a1a0868688dd3179034a7e091a67f93bc9dd45cdfc9fa6b1fe90362772b719278012f2f56b752b803c87db8597a7b0
2019-02-19 09:39:06 +13:00
Daniel Kraft 39e20fc54f Add missing #include.
bd0dbe8763 introduced a dependency of
rpc/util.h on RPCErrorCode, defined in rpc/protocol.h.  The latter file
is only included from rpc/util.cpp, though.  This commit fixes the
missing include, by moving the #include of rpc/protocol.h to
rpc/util.h.
2019-02-18 12:11:41 +01:00
Wladimir J. van der Laan 29e82e460e
Merge #15250: Use RdSeed when available, and reduce RdRand load
1435fabc19 Use RdSeed when available, and reduce RdRand load (Pieter Wuille)

Pull request description:

  This introduces support for autodetecting and using the RdSeed instruction on x86/x86_64 systems.

  In addition:
  * In SeedFast, only 64 bits of entropy are generated through RdRand (256 was relatively slow).
  * In SeedStartup, 256 bits of entropy are generated, using RdSeed (preferably) or RdRand (otherwise).

Tree-SHA512: fb7d3e22e93e14592f4b07282aa79d7c3cc4e9debdd9978580b8d2562bbad345e289bf3f80de2c50c9b50b8bac2aa9b838f9f272f7f8d43f1efc0913aa8acce3
2019-02-18 10:56:55 +01:00
Jonas Schnelli 0bedcbafdf
Use a single wallet batch for UpgradeKeyMetadata 2019-02-17 19:32:58 -10:00
Gregory Maxwell a083f75ba7 Update assumevalid, minimumchainwork, and getchaintxstats to height 563378.
m_assumed_blockchain_size/m_assumed_chain_state_size were still accurate.
2019-02-17 03:38:08 +00:00
Wladimir J. van der Laan 4064d048d6
Merge #15425: [Doc] add missing newline to listunspent help for witnessScript
d3661a3fd2 [Doc] add missing newline to witnessScript in listunspent help (David A. Harding)

Pull request description:

Tree-SHA512: 85bb9c693bac36da0239eb6a1f42c2173d0170d5ff3d4c2fcd8897cfab233ef8c8ebc1eb5591e3dc89d091fde221d77c872f14a1eec201fee4dc83ba788390c3
2019-02-17 02:46:59 +01:00
David A. Harding a607c9ae4c
[Doc] importmulti: add missing description of keypool option 2019-02-16 16:59:55 -05:00
David A. Harding d3661a3fd2
[Doc] add missing newline to witnessScript in listunspent help 2019-02-16 16:27:28 -05:00
Wladimir J. van der Laan f60d029a2a
Merge #15368: Descriptor checksums
fd637be8d2 Add checksums to descriptors.md (Pieter Wuille)
be62903c41 Make descriptor checksums mandatory in deriveaddresses and importmulti (Pieter Wuille)
b52cb63688 Add getdescriptorinfo to compute checksum (Pieter Wuille)
3b40bff988 Descriptor checksum (Pieter Wuille)

Pull request description:

  This adds support for a descriptor-specific 8-character checksum.

  Descriptors may optionally be suffixed with a `#` plus these 8 checksum characters. Any descriptor that contains a `#` at the end must be followed by a valid checksum. If the `#` is missing entirely, it is valid without checksum.

  All RPCs are updated to report descriptors that include the checksum. On input, they are optional except in `deriveaddress` and `importmulti`, which require descriptors which include a checksum.

  A new RPC is also added to analyse descriptors (`getdescriptorinfo`), which can be used to compute the checksum for a descriptor without.

Tree-SHA512: a8294b09155eb6c67fbc178b5e2d3fbc0e9bec8b6de57a13f8835550d51c2cb32a428b3c9a188ded42b454d594e9305edbd4797906b755de77a8f33c79165f6b
2019-02-16 21:39:32 +01:00
Wladimir J. van der Laan d5b929c813
Merge #13932: Additional utility RPCs for PSBT
540729ef4b Implement analyzepsbt RPC and tests (Andrew Chow)
77542cf2a5 Move PSBT UTXO fetching to a separate method (Andrew Chow)
cb40b3abd4 Figure out what is missing during signing (Andrew Chow)
08f749c914 Implement joinpsbts RPC and tests (Andrew Chow)
7344a7b998 Implement utxoupdatepsbt RPC and tests (Andrew Chow)

Pull request description:

  This PR adds 3 new utility RPCs for interacting with PSBTs.

  `utxoupdatepsbt` updates a PSBT with UTXO information from the node. It only works with witness UTXOs because full transactions (as would be needed for non-witness UTXOs) are not available unless txindex is enabled.

  `joinpsbts` joins the inputs from multiple distinct PSBTs into one PSBT. e.g. if PSBT 1 has inputs 1 and 2, and PSBT 2 has inputs 3 and 4, `joinpsbts` would create a new PSBT with inputs 1, 2, 3, and 4.

  `analyzepsbt` analyzes a PSBT and determines the current state of it and all of its inputs, and the next step that needs to be done.

Tree-SHA512: 3c1fa302201abca76a8901d0c2be7b4ccbce334d989533c215f8b3e50e22f2f018ce6209544b26789f58f5980a253c0655111e1e20d47d5656e0414c64891a5c
2019-02-16 20:45:03 +01:00
MarcoFalke f9d50e83e2
Merge #15410: test: txindex: interrupt threadGroup before calling destructor
fab6b07c16 test: txindex: interrupt threadGroup before calling destructor (MarcoFalke)

Pull request description:

  Fixes the data races with the tread sanitizer such as

  * https://travis-ci.org/MarcoFalke/bitcoin/jobs/492330554
  * https://github.com/bitcoin/bitcoin/pull/15402#discussion_r256676622
  * ...

Tree-SHA512: 40608c70d92a1dd68efc1d41eecc8e2fb7738508e21f91f0ad353adcceed60fa624f15bf72a5b69a9444157b261183abbe9fc4cc5dd8aebc1c49506b239e8e88
2019-02-16 12:58:26 -05:00
Andrew Chow 540729ef4b Implement analyzepsbt RPC and tests 2019-02-16 11:51:02 -05:00
Pieter Wuille be62903c41 Make descriptor checksums mandatory in deriveaddresses and importmulti 2019-02-15 22:36:05 -08:00
Pieter Wuille b52cb63688 Add getdescriptorinfo to compute checksum 2019-02-15 22:36:05 -08:00
Pieter Wuille 3b40bff988 Descriptor checksum 2019-02-15 22:36:05 -08:00
Andrew Chow 77542cf2a5 Move PSBT UTXO fetching to a separate method 2019-02-16 00:04:27 -05:00
Andrew Chow cb40b3abd4 Figure out what is missing during signing
When signing an input, figure out what was requested for but was unable
to be found and store it in a SignatureData.

Return this information in SignPSBTInput.
2019-02-16 00:04:27 -05:00
Andrew Chow 08f749c914 Implement joinpsbts RPC and tests
Adds a joinpsbts RPC which combines multiple distinct PSBTs into
one PSBT.
2019-02-16 00:04:27 -05:00
Andrew Chow 7344a7b998 Implement utxoupdatepsbt RPC and tests 2019-02-16 00:04:27 -05:00
MarcoFalke 743c2f461c
Merge #15399: fuzz: Script validation flags
fab15ff70e fuzz: Script validation flags (MarcoFalke)
fabcfa5f0c fuzz: Move deserialize tests to test/fuzz/deserialize.cpp (MarcoFalke)

Pull request description:

Tree-SHA512: 83c0cfeae0771b7ffe14e6b0eaeda06602b91f5bf4aa2f54fd4f7ef2350299679fd2d9339b02e43309bfddccc01d3aef25ce1a3d2c4f9b54f26e16e1249e05db
2019-02-15 13:14:24 -05:00
Wladimir J. van der Laan 95801902b9
Merge #15391: Add compile time verification of assumptions we're currently making implicitly/tacitly
7cee85807c Add compile time verification of assumptions we're currently making implicitly/tacitly (practicalswift)

Pull request description:

  Add compile time verification of assumptions we're currently making implicitly/tacitly.

  As suggested by @sipa in https://github.com/bitcoin/bitcoin/pull/14239#issuecomment-462508012 and @MarcoFalke in https://github.com/bitcoin/bitcoin/pull/14479#issuecomment-462534878.

Tree-SHA512: e68fe51164dbd3eeb76aa8a7e83dfcd3b4d5a66037c0f1822bbbd189bbe3c280e03b3b10af870880ecc09b612e62fb3d9bcd6cf1e16cb7ba818c257db0712ce4
2019-02-15 16:05:27 +01:00
MarcoFalke eca1273c35
Merge #15383: [rpc] mining: Omit uninitialized currentblockweight, currentblocktx
fa178a6385 [rpc] mining: Omit uninitialized currentblockweight, currentblocktx (MarcoFalke)

Pull request description:

  Previously we'd report "0", which could be mistaken for a valid number. E.g. the number of transactions is 0 or the block weight is 0, whatever that means.

Tree-SHA512: ee94ab203a329e272211b726f4c23edec4b09c650ec363b77fd59ad9264165d73064f78ebb9e11b5c2c543b73c157752410a307655560531c7d5444d203aa0ea
2019-02-15 08:57:50 -05:00
practicalswift 543ef7d626 tests: Add missing cs_main locks required when accessing pcoinsdbview, pcoinsTip or pblocktree 2019-02-15 10:41:52 +01:00
Andrew Chow f4b00b70e8 Import public keys in order
Do public key imports in the order that they are specified in the import
or in the descriptor range.
2019-02-14 18:34:03 -05:00
Andrew Chow 513719c5f8 Add option to importmulti add an imported pubkey to the keypool
Adds a new option to importmulti where the pubkeys specified in the import
object can be added to the keypool. This only works if the wallet has
private keys disabled.
2019-02-14 18:14:42 -05:00
Andrew Chow 9b81fd19ac Fetch keys from keypool when private keys are disabled
When private keys are disabled, still fetch keys from the keypool
if the keypool has keys. Those keys come from importing them and
adding them to the keypool.
2019-02-14 18:14:00 -05:00
Andrew Chow 99cccb900b Add a method to add a pubkey to the keypool
Introduces AddKeypoolPubkey in order to add a pubkey to the keypool
2019-02-14 18:14:00 -05:00
MeshCollider 8d0ec74801
Merge #14021: Import key origin data through descriptors in importmulti
cb3511b9d Add release notes for importing key origin info change (Andrew Chow)
4c75a69f3 Test importing descriptors with key origin information (Andrew Chow)
02d6586d7 Import KeyOriginData when importing descriptors (Andrew Chow)
3d235dff5 Implement a function to add KeyOriginInfo to a wallet (Andrew Chow)
eab63bc26 Store key origin info in key metadata (Andrew Chow)
345bff601 Remove hdmasterkeyid (Andrew Chow)
bac8c676a Add a method to CWallet to write just CKeyMetadata (Andrew Chow)
e7652d3f6 Add WriteHDKeypath function and move *HDKeypath to util/bip32.{h,cpp} (Andrew Chow)
c45415f73 Refactor keymetadata writing to a separate method (Andrew Chow)

Pull request description:

  This PR allows for key origin data as defined by the descriptors document to be imported to the wallet when importing a descriptor using `importmulti`. This allows the `walletprocesspsbt` to include the BIP 32 derivation paths for keys that it is watching that are from a different HD wallet.

  In order to make this easier to use, a new field `hdmasterkeyfingerprint` has been added to `getaddressinfo`. Additionally I have removed `hdmasterkeyid` as was planned. I think that this API change is fine since it was going to be removed in 0.18 anyways. `CKeyMetadata` has also been extended to store key origin info to facilitate this.

Tree-SHA512: 9c7794f3c793da57e23c5abbdc3d58779ee9dea3d53168bb86c0643a4ad5a11a446264961e2f772f35eea645048cb60954ed58050002caee4e43cd9f51215097
2019-02-15 12:11:28 +13:00
Andrew Chow 02d6586d7a Import KeyOriginData when importing descriptors 2019-02-14 17:58:25 -05:00
Andrew Chow 3d235dff5d Implement a function to add KeyOriginInfo to a wallet 2019-02-14 17:58:25 -05:00
Andrew Chow eab63bc264 Store key origin info in key metadata
Store the master key fingerprint and derivation path in the
key metadata. hdKeypath is kept to indicate the seed and for
backwards compatibility, but all key derivation path output
uses the key origin info instead of hdKeypath.
2019-02-14 17:58:25 -05:00
MarcoFalke 31f7c6dd21
Merge #15295: fuzz: Add test/fuzz/test_runner.py and run it in travis
fa535af92c fuzz: test_runner: Better error message when built with afl (MarcoFalke)
fa7ca8ef58 qa: Add test/fuzz/test_runner.py (MarcoFalke)

Pull request description:

  Can be run with `./test/fuzz/test_runner.py` after building as described in `doc/fuzzing.md`

Tree-SHA512: f6a3cd8165ec2de4b363be4fd0a936b4a60829cce923f93fe5d6a046b1bbd64c959cdf790440bf70c0e13b0bb1b956a746a24c6fd92bddeab15b837ed50ffad2
2019-02-14 16:32:26 -05:00
Wladimir J. van der Laan 3facd9fdc4
Merge #14481: Add P2SH-P2WSH support to listunspent RPC
6ca836ab3a Add release note for listunspent P2WSH change (MeshCollider)
928beae007 Add test for P2SH-P2WSH in signrawtransactionwithkey and listunspent (MeshCollider)
314784a60f Make listunspent and signrawtransaction RPCs support witnessScript (MeshCollider)

Pull request description:

  This is a reworked version of #11708 after #12427 and the `signrawtransaction` split.

  For a P2WSH address, listunspent should return the witness script, and for a P2SH-P2WSH address, it should also return the inner witness script (because SignTransaction will automatically wrap it in P2SH if required).

  Includes a test which also tests the behaviour of #12427, and release note.

Tree-SHA512: a8e72cf16930312bf48ec47e44a68f8d7e26664043c1b4cc0983eb25aec4087e511188ff9a0f181cd7b8a0c068c60d7f1e7e3f226b79e8c48890039dcf57f7b7
2019-02-14 22:17:52 +01:00
MarcoFalke cd8ca8be31
Merge #14626: Select orphan transaction uniformly for eviction
7257353b93 Select orphan transaction uniformly for eviction (Pieter Wuille)

Pull request description:

  The previous code was biased towards evicting transactions whose txid has a larger gap (lexicographically) with the previous txid in the orphan pool.

Tree-SHA512: e35f700aea5ed79d1bc57f64bffcb623424b40156fd0a12f05f74f981a8aa4175d5c18d042989243f7559242bdf1d6d720bcf588d28f43d74a798a4843f09c70
2019-02-14 16:11:44 -05:00
Hennadii Stepanov 3782075a5f
Move all PID file stuff to init.cpp
It is only used from init.cpp.
Move-only refactoring.
2019-02-14 22:53:03 +02:00
Jonas Schnelli b7456e6bf9
Merge #15195: gui: Add Close Wallet action
94086fb59 gui: Add close wallet action (João Barbosa)
f77ba3431 gui: Add closeWallet to WalletController (João Barbosa)
f6122abe0 interfaces: Add remove to Wallet (João Barbosa)

Pull request description:

  This PR adds support to close the current wallet in the GUI.

  <img width="543" alt="screenshot 2019-01-18 at 00 44 26" src="https://user-images.githubusercontent.com/3534524/51358241-424b9680-1aba-11e9-88f2-b85869507737.png">
  <img width="532" alt="screenshot 2019-01-18 at 00 44 38" src="https://user-images.githubusercontent.com/3534524/51358242-424b9680-1aba-11e9-83e2-fa275a9017b3.png">

Tree-SHA512: fd7da4d0f73dc240864cc57a1ff1526daf2376904ce3872e52eeca5d40cc21c6dd29eb2ef25f85ffa63697362c150221a2369d80ad36ae445cc99989d337b688
2019-02-14 10:46:48 -10:00
Jonas Schnelli 3b33cbc2b6
Merge #15393: build: Bump minimum Qt version to 5.5.1
fd46c4c00 Bump minimum Qt version to 5.5.1 (Sjors Provoost)

Pull request description:

  Fixes #13478

  Compiled and lightly tested on 10.14.3 against QT 5.12.0.

Tree-SHA512: 6890331969bbf4c66dc0993b8817b1f0831d008f5863554e9c09a38f4700260b84044ff961664c377decc9fb8300e3543c267f935ec64fbc97b20f8fb396247a
2019-02-14 10:17:53 -10:00
MarcoFalke fab6b07c16
test: txindex: interrupt threadGroup before calling destructor 2019-02-14 14:40:49 -05:00
Jonas Schnelli 758c6d784d
Merge #15063: GUI: If BIP70 is disabled, attempt to fall back to BIP21 parsing
84f53154e Travis: Add test without BIP70 (but still full wallet + tests) (Luke Dashjr)
113f0004b GUI: If BIP70 is disabled, give a proper error when trying to open a payment request file (Luke Dashjr)
9975282fa GUI: If BIP70 is disabled, attempt to fall back to BIP21 parsing (Luke Dashjr)

Pull request description:

Tree-SHA512: 66a684ce4336d0eac8b0107b405ff3a2cf312258a967f3e1b14734cd39db11e2db3e9b03492755583170d94d54754ef536b0776e5f19a0cc2caca8379eeb4495
2019-02-14 09:31:17 -10:00
Andrew Chow 345bff6013 Remove hdmasterkeyid 2019-02-14 14:00:29 -05:00
Andrew Chow bac8c676a7 Add a method to CWallet to write just CKeyMetadata 2019-02-14 14:00:29 -05:00
Andrew Chow e7652d3f64 Add WriteHDKeypath function and move *HDKeypath to util/bip32.{h,cpp}
Creates new files util/bip32.h and util/bip32.cpp for containing
BIP 32 stuff.
Moves FormatKeyPath from descriptor.cpp to util/bip32.
Adds a wrapper around it to prepent the 'm' for when just the
BIP 32 style keypath is needed.
2019-02-14 14:00:28 -05:00
Andrew Chow c45415f73a Refactor keymetadata writing to a separate method 2019-02-14 14:00:28 -05:00
MarcoFalke fa9b60c842
Remove unused TransactionError constants 2019-02-14 10:32:02 -05:00
practicalswift 7cee85807c Add compile time verification of assumptions we're currently making implicitly/tacitly 2019-02-14 16:10:02 +01:00
marcoagner 8c3fdd3a6d
fixes m_assumed_blockchain_size variables values:
This commit was a fix to `m_assumed_blockchain_size` reverted from
3fc2063's 220 to 9d0e528's 200 since work on 9d0e528 was being done in
parallel and ended up reverting `m_assumed_blockchain_size`.

This commits is now a intended to be a bump of
`m_assumed_blockchain_size` for both mainnet and testnet for new
reasonable values.
2019-02-14 12:43:10 +00:00
Sjors Provoost fd46c4c001
Bump minimum Qt version to 5.5.1 2019-02-14 11:12:30 +01:00
MeshCollider 2452c6cc0a
Merge #14978: Factor out PSBT utilities from RPCs for use in GUI code; related refactoring.
102faad81 Factor out combine / finalize / extract PSBT helpers (Glenn Willen)
78b9893d0 Remove op== on PSBTs; check compatibility in Merge (Glenn Willen)
bd0dbe876 Switch away from exceptions in refactored tx code (Glenn Willen)
c6c3d42a7 Move PSBT definitions and code to separate files (Glenn Willen)
81cd95884 Factor BroadcastTransaction out of sendrawtransaction (Glenn Willen)
c734aaa15 Split DecodePSBT into Base64 and Raw versions (Glenn Willen)
162ffefd2 Add pf_invalid arg to std::string DecodeBase{32,64} (Glenn Willen)

Pull request description:

  * Move most PSBT definitions into psbt.h.
  * Move most PSBT RPC utilities into psbt.{h,cpp}.
  * Move wallet-touching PSBT RPC utilities (FillPSBT) into
      wallet/psbtwallet.{h,cpp}.
  * Switch exceptions from JSONRPCError() to new PSBTException class.
  * Split DecodePSBT into DecodeBase64PSBT (old behavior) and DecodeRawPSBT.
  * Add one new version of DecodeBase64 utility in strencodings.h (and
      corresponding DecodeBase32 for completeness).
  * Factor BroadcastTransaction utility function out of sendrawtransaction RPC
      handler in rpc/rawtransaction.cpp

  Note: For those keeping score at home wondering why refactor, this is in anticipation of (and developed in parallel with) a change to actually introduce GUI use of all this stuff, which is already under development and working-ish.

Tree-SHA512: 2197c448e657421f430943025357597e7b06c4c377d5d4b2622b9edea52a7193c48843dd731abb3a88ac4023a9c88d211991e0a9b740c22f2e1cbe72adefe390
2019-02-14 21:49:01 +13:00
MarcoFalke fa7ca8ef58
qa: Add test/fuzz/test_runner.py 2019-02-13 17:12:28 -05:00
Wladimir J. van der Laan 9c93f5d9fc
Merge #15334: wallet: Log absolute paths for the wallets
a4b92e467d Log full paths for wallets (Hennadii Stepanov)

Pull request description:

  Fix #15333

  `debug.log` with this PR:
  ```
  ...
  2019-02-03T19:02:35Z Using wallet directory /home/hebasto/.bitcoin/testnet3/wallets
  2019-02-03T19:02:35Z init message: Verifying wallet(s)...
  2019-02-03T19:02:35Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
  2019-02-03T19:02:35Z Using wallet test_alpha/wallet.dat
  2019-02-03T19:02:35Z BerkeleyEnvironment::Open: LogDir=/home/hebasto/.bitcoin/testnet3/wallets/test_alpha/database ErrorFile=/home/hebasto/.bitcoin/testnet3/wallets/test_alpha/db.log
  2019-02-03T19:02:35Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
  2019-02-03T19:02:35Z Using wallet alpha_wallet/wallet.dat
  2019-02-03T19:02:35Z BerkeleyEnvironment::Open: LogDir=/home/hebasto/.bitcoin/testnet3/wallets/alpha_wallet/database ErrorFile=/home/hebasto/.bitcoin/testnet3/wallets/alpha_wallet/db.log
  2019-02-03T19:02:35Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
  2019-02-03T19:02:35Z Using wallet wallet.dat
  2019-02-03T19:02:35Z BerkeleyEnvironment::Open: LogDir=/home/hebasto/.bitcoin/testnet3/wallets/database ErrorFile=/home/hebasto/.bitcoin/testnet3/wallets/db.log
  2019-02-03T19:02:35Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
  2019-02-03T19:02:35Z Using wallet none/wallet.dat
  2019-02-03T19:02:35Z BerkeleyEnvironment::Open: LogDir=/home/hebasto/.bitcoin/testnet3/wallets/none/database ErrorFile=/home/hebasto/.bitcoin/testnet3/wallets/none/db.log
  2019-02-03T19:02:35Z init message: Loading banlist...
  ...
  ```

Tree-SHA512: 8dd4408d3f6b04f396dd0ae0d248fedc3a0f6d36788556ae1662443f06f2ecce1c2be9456bf8d1b3d25b29c2a0cfb03cb805bde0a40387e68988ab932e17e118
2019-02-13 22:51:44 +01:00
MarcoFalke 9c4a90040d
Merge #15390: [wallet-tool] Close bdb when flushing wallet
318b1f7af1 [wallet] Close bdb when flushing wallet. (John Newbery)

Pull request description:

  bdb would not be closed when closing the wallet in wallet-tool. Fix this by calling wallet->flush with true.

Tree-SHA512: f722e527e4806eca5254221e944f57853d11bf89a9264309fa558a6cc2b23feefb7bb2963e87b4fad9cfb31ac4cffe563688988e0614a481a8ff1d393aceb132
2019-02-13 15:49:13 -05:00
MarcoFalke fab15ff70e
fuzz: Script validation flags 2019-02-13 14:53:57 -05:00
MarcoFalke fabcfa5f0c
fuzz: Move deserialize tests to test/fuzz/deserialize.cpp 2019-02-13 11:46:36 -05:00
Wladimir J. van der Laan cbe7efe9ea
Merge #15389: Remove unnecessary const_cast
5039e4b61b Remove unnecessary const_cast (Julian Fleischer)

Pull request description:

  The const_cast

  ```C++
  CBlock &block = const_cast<CBlock&>(chainparams.GenesisBlock());
  ```

  is not necessary as all the functions invoked form this block receive a `const CBlock&` anyway. Simply add the `const` to `block`:

  ```C++
  const CBlock& block = chainparams.GenesisBlock();
  ```

  Casting away `const`, especially from something as precious as the genesis block, feels really weird to me as a reader of bitcoin-core source code.

Tree-SHA512: 0290b2cabb216a60655ded153ed1f213c051fb216cec6f3f810f8b760e276f8def86eb696c492e89631682531e215f56d7897b59685d3aa787bcd80cc4f86c90
2019-02-13 17:09:32 +01:00
MeshCollider 314784a60f Make listunspent and signrawtransaction RPCs support witnessScript 2019-02-13 14:26:19 +13:00
MarcoFalke 0d1160e421
Merge #14918: RPCHelpMan: Check default values are given at compile-time
fa0ad4e7ce RPCHelpMan: Check default values are given at compile-time (MarcoFalke)

Pull request description:

  Remove the run time assertions on the default values and ensure that the correct default type and value is provided at compile time.

Tree-SHA512: 80df2f3fab4379b500c773c27da63f22786c58be5963fe99744746320e43627a5d433eedf8b32209158df7805ebdce65ed4d242c829c4fe6e5d13deb4799ed42
2019-02-12 18:43:06 -05:00
Hennadii Stepanov a4b92e467d
Log full paths for wallets 2019-02-13 00:47:45 +02:00
João Barbosa 94086fb59d gui: Add close wallet action 2019-02-12 22:07:45 +00:00
João Barbosa f77ba34313 gui: Add closeWallet to WalletController 2019-02-12 22:07:45 +00:00
João Barbosa f6122abe03 interfaces: Add remove to Wallet 2019-02-12 22:07:45 +00:00
Julian Fleischer 5039e4b61b Remove unnecessary const_cast
Signed-off-by: Julian Fleischer <julian@thirdhash.com>
2019-02-12 22:25:47 +01:00
John Newbery 318b1f7af1 [wallet] Close bdb when flushing wallet.
bdb would not be closed when closing the wallet in wallet-tool. Fix this
by calling wallet->flush with true.
2019-02-12 13:27:18 -05:00
Jonas Schnelli 7d3f255316
Merge #15153: gui: Add Open Wallet menu
1951ea434 gui: Show indeterminate progress dialog while opening walllet (João Barbosa)
8847cdaaa gui: Add OpenWalletActivity (João Barbosa)
4c8982a88 interfaces: Avoid interface instance if wallet is null (João Barbosa)
be82dea23 gui: Add thread to run background activity in WalletController (João Barbosa)
6c49a55b4 gui: Add Open Wallet menu (João Barbosa)
32a8c6abf gui: Add openWallet and getWalletsAvailableToOpen to WalletController (João Barbosa)
ab288b4e5 interfaces: Add loadWallet to Node (João Barbosa)
17abc0fd5 wallet: Factor out LoadWallet (João Barbosa)

Pull request description:

  The *Open Wallet* menu has all the available wallets currently not loaded. The list of the available wallets comes from `listWalletDir`.

  In the future the menu can be replaced by a custom dialog.

  <img width="674" alt="screenshot 2019-01-12 at 12 17 02" src="https://user-images.githubusercontent.com/3534524/51073166-ac041480-1664-11e9-8302-be81702bc146.png">

Tree-SHA512: ebfd75eee0c8264863748899843afab67dadb7dff21313c11e3cb5b6108d954978dd1f1ae786bc07580c5a771ea4ab38d18c1643c9b9b3683ed53f0f6c582e38
2019-02-12 08:20:50 -10:00
MarcoFalke fa178a6385
[rpc] mining: Omit uninitialized currentblockweight, currentblocktx 2019-02-12 11:34:57 -05:00
Wladimir J. van der Laan 65435701ef
Merge #15358: util: Add SetupHelpOptions()
a99999cc04 util: Add SetupHelpOptions() (MarcoFalke)

Pull request description:

  Every binary we have sets up the help option in their own way and wording.

  Solve that by having one function take care of it for all of them.

Tree-SHA512: 6e947fa8bc2a46fa6ca9f45777020aa269a5df0dd916ebc863224f9a1e0f79e8e7754a1478567307edd9461e8babd77d26bc2710bbd56e8f8da9020aa85a8c9c
2019-02-12 15:27:39 +01:00
Glenn Willen 102faad81e Factor out combine / finalize / extract PSBT helpers
Refactor the new CombinePSBT, FinalizePSBT, and FinalizeAndExtractPSBT
general-purpose functions out of the combinepsbt and finalizepsbt RPCs,
for use in the GUI code.
2019-02-11 14:08:04 -08:00
Glenn Willen 78b9893d02 Remove op== on PSBTs; check compatibility in Merge
Remove the op== on PartiallySignedTransaction, which only checks that the
CTransactions are equal. Instead, check this directly in Merge, and return
false if the CTransactions are not equal (so the PSBTs cannot be merged.)
2019-02-11 14:08:04 -08:00
Glenn Willen bd0dbe8763 Switch away from exceptions in refactored tx code
After refactoring general-purpose PSBT and transaction code out of RPC code,
for use in the GUI, it's no longer appropriate to throw exceptions. Instead we
now return bools for success, and take an output parameter for an error object.
We still use JSONRPCError() for the error objects, since only RPC callers
actually care about the error codes.
2019-02-11 14:08:04 -08:00
Glenn Willen c6c3d42a7d Move PSBT definitions and code to separate files
Move non-wallet PSBT code to src/psbt.{h,cpp}, and PSBT wallet code to
src/wallet/psbtwallet.{h,cpp}. This commit contains only code movement (and
adjustments to includes and Makefile.am.)
2019-02-11 12:23:14 -08:00
Glenn Willen 81cd958848 Factor BroadcastTransaction out of sendrawtransaction
Factor out a new BroadcastTransaction function, performing the core work of the
sendrawtransaction rpc, so that it can be used from the GUI code. Move it from
src/rpc/ to src/node/.
2019-02-11 12:23:14 -08:00
Glenn Willen c734aaa15d Split DecodePSBT into Base64 and Raw versions
Split up DecodePSBT, which both decodes base64 and then deserializes a
PartiallySignedTransaction, into two functions: DecodeBase64PSBT, which retains
the old behavior, and DecodeRawPSBT, which only performs the deserialization.

Add a test for base64 decoding failure.
2019-02-11 12:23:14 -08:00
Glenn Willen 162ffefd2f Add pf_invalid arg to std::string DecodeBase{32,64}
Add support for the optional "pf_invalid" out parameter (which allows the caller
to detect decoding failures) to the std::string versions of DecodeBase32 and
DecodeBase64. The char* versions already have this feature.

Also, rename all uses of pfInvalid to pf_invalid to match style guidelines.
2019-02-11 12:23:14 -08:00
Luke Dashjr 113f0004be GUI: If BIP70 is disabled, give a proper error when trying to open a payment request file 2019-02-11 15:08:41 +00:00
Luke Dashjr 9975282fa8 GUI: If BIP70 is disabled, attempt to fall back to BIP21 parsing 2019-02-11 15:08:41 +00:00
MarcoFalke fa0ad4e7ce
RPCHelpMan: Check default values are given at compile-time 2019-02-11 08:40:10 -05:00
MarcoFalke ad039aa0d3
Merge #15373: Move ParseConfirmTarget from rpc/mining to rpc/util
50e647210d Move ParseConfirmTarget from rpc/mining to rpc/util (Russell Yanofsky)

Pull request description:

  Util is a better home since it's called both by wallet and mining code.

  Suggested https://github.com/bitcoin/bitcoin/pull/15288#discussion_r254449444

Tree-SHA512: 4320caf2a3f70d2885c421de04f2ec68ff3f6519258c5155fc46e245dc1765fd15c81f260af5096318f24ff9deb88fc3c5ef40eec8b7393f467f5b963d17215b
2019-02-11 08:34:14 -05:00
MarcoFalke ff9e197212
Merge #15380: trivial: correct parameter name in comments
1a0139cbaf trivial: correct parameter name in comments (andrewtoth)

Pull request description:

Tree-SHA512: 029b5ca5406cd7bf704b4d7611dac072cdc46a8659041bf631d77372ed4c16fa9ddf02c754044e310b16ea9bdd0803d051bef6ef6a86815d523826666134c649
2019-02-11 08:20:27 -05:00
MarcoFalke e84e0d4b5e
Merge #15337: rpc: Fix for segfault if combinepsbt called with empty inputs
30d0f7be6e rpc: Fix for segfault if combinepsbt called with empty inputs (benthecarman)

Pull request description:

  Fixes #15300

Tree-SHA512: 25e7b4e6e48d8b0d197f0ab96df308fff33e2110f8929cb48914877fa7f4c4a84f173b1378fdb2dec5d03fe7d6d1aced4b577e55f9fe180d8147d9106ebf543f
2019-02-11 08:08:17 -05:00
andrewtoth 1a0139cbaf trivial: correct parameter name in comments 2019-02-10 17:17:32 -05:00
MeshCollider 6f4e0d1542
Merge #15226: Allow creating blank (empty) wallets (alternative)
7687f7873 [wallet] Support creating a blank wallet (Andrew Chow)

Pull request description:

  Alternative (kind of) to #14938

  This PR adds a `blank` parameter to the `createwallet` RPC to create a wallet that has no private keys initially. `sethdseed` can then be used to make a clean wallet with a custom seed. `encryptwallet` can also be used to make a wallet that is born encrypted.

  Instead of changing the version number as done in #14938, a wallet flag is used to indicate that the wallet should be blank. This flag is set at creation, and then unset when the wallet is no longer blank. A wallet becomes non-blank when a HD seed is set or anything is imported. The main change to create a blank wallet is primarily taken from #14938.

  Also with this, the term "blank wallet" is used instead of "empty wallet" to avoid confusion with wallets that have balance which would also be referred to as "empty".

  This is built on top of #15225 in order to fix GUI issues.

Tree-SHA512: 824d685e11ac2259a26b5ece99c67a7bda94a570cd921472c464243ee356b7734595ad35cc439b34357135df041ed9cba951e6edac194935c3a55a1dc4fcbdea
2019-02-11 08:08:33 +13:00
Andrew Chow 7687f7873b [wallet] Support creating a blank wallet
A blank wallet is a wallet that has no keys, script or watch only things.
A new wallet flag indicating that it is blank will be set when the wallet
is blank. Once it is no longer blank (a seed has been generated, keys or
scripts imported, etc), the flag will be unset.
2019-02-10 12:24:53 -05:00
Russell Yanofsky 50e647210d Move ParseConfirmTarget from rpc/mining to rpc/util
Util is a better home since it's called both by wallet and mining code.

Suggested https://github.com/bitcoin/bitcoin/pull/15288#discussion_r254449444
2019-02-08 15:29:45 -05:00
MarcoFalke 2945492424
Merge #15357: rpc: Don't ignore -maxtxfee when wallet is disabled
dfbf117bbb Move maxTxFee initialization to init.cpp (Jordan Baczuk)

Pull request description:

  Resolves #15355

Tree-SHA512: 6eafacc6a3b0589fb645b0080fd3c01598566df1bd7ee7929284853866a23493960fbd4d6f9c3417e192f8a21706d9f593197734f6189e046e4747991305a0b8
2019-02-08 14:41:25 -05:00
MarcoFalke 0206956608
Merge #15365: wallet: Add lock annotation for mapAddressBook
faa46475d7 wallet: Add lock annotation for mapAddressBook (MarcoFalke)

Pull request description:

  This adds lock annotations for `mapAddressBook` and also moves one lock from inside `GetDestValues` to the caller to be in line with the other methods (`eraseDestData`, `addDestData`, ...)

Tree-SHA512: cef9397523e2f5717d4a9a6b2da1fe07042484a51b3c067ae64425768637f334350a2c3db4ab7e00af99b2a587f6b656b68ee1195f6a3db6d47298d0b2b6174a
2019-02-08 10:36:02 -05:00
Jordan Baczuk dfbf117bbb Move maxTxFee initialization to init.cpp 2019-02-08 07:06:44 -07:00
MarcoFalke 30495d1e75
Merge #15201: net: Add missing locking annotation for vNodes. vNodes is guarded by cs_vNodes.
eea02be70e Add locking annotation for vNodes. vNodes is guarded by cs_vNodes. (practicalswift)

Pull request description:

  Add locking annotation for `vNodes`. `vNodes` is guarded by `cs_vNodes`.

Tree-SHA512: b1e18be22ba5b9dd153536380321b09b30a75a20575f975af9af94164f51982b32267ba0994e77c801513b59da05d923a974a9d2dfebdac48024c4bda98b53af
2019-02-08 08:58:29 -05:00
Wladimir J. van der Laan 6fc656a410
Merge #14242: Avoid triggering undefined behaviour (std::memset(nullptr, 0, 0)) if an invalid string is passed to DecodeSecret(...)
d855e4cac8 Avoid triggering undefined behaviour (std::memset(nullptr, 0, 0)) if an invalid string is passed to DecodeSecret(...) (practicalswift)

Pull request description:

  Avoid triggering undefined behaviour (`std::memset(nullptr, 0, 0)`) if an invalid string is passed to `DecodeSecret(...)`.

  Background reading: [memcpy (and friends) with NULL pointers](https://www.imperialviolet.org/2016/06/26/nonnull.html)

  Steps to reproduce:

  ```
  ./configure --with-sanitizers=undefined && make check && ./test/functional/test_runner.py
  ```

Tree-SHA512: b8325ced4f724d9c03065e0747af56b1f297a90d9fb09a24d46c3231a90dce3df6299f2c41f863b5cec18eaeded7b46ee4b93d9a52adc2541eb4c44d2c0965d9
2019-02-08 12:30:21 +01:00
Pieter Wuille b9b26d9c36
Merge #14897: randomize GETDATA(tx) request order and introduce bias toward outbound
1cff3d6cb0 Change in transaction pull scheduling to prevent InvBlock-related attacks (Gleb Naumenko)

Pull request description:

  This code makes executing two particular (and potentially other) attacks harder.

  ### InvBlock
  This behavior was described well [here](https://www.cs.umd.edu/projects/coinscope/coinscope.pdf) (page 11).

  Per current implementation, if node A receives _INV_ (tx) from node B, node A sends _GETDATA_ to B and waits for _TX_ message back.

  Node A is likely to receive more _INVs_ (regarding the same tx) from other peers. But node A would not send another _GETDATA_ unless it does not hear _TX_ back from node B for next 2 minutes (to save bandwidth)

  Thus, if B is a malicious node, it can prevent node A from getting the transaction (even if all A’s peers have it) for 2 minutes.

  This behavior seems to be an inherent limitation of the current P2P relay protocol, and I don’t see how it can be fundamentally changed (I can see workarounds which involve rewriting a lot of P2P code though).

  ### What does this PR fix?

  The attacks I’m looking at involve preventing A from learning the transaction for 2*N minutes. To do that, an attacker has to spin up N nodes and send N _INVs_ simultaneously to node A (then InvBlocks will be queued with an interval of 2 minutes according to current implementation)

  More precisely, 2 scenarios I’m looking at are:
  1. An attacker censors a particular transaction. By performing InvBlock from different nodes, an attacker can execute a network-wide censorship of a particular transaction (or all transactions). The earlier an attacker founds the transaction he wants to censor, the easier it is to perform an attack. As it was pointed out by @gwillen, this is even more dangerous in the case of lightning, where transactions are known in advance.
  2. Topology inference described in papers [1](https://www.cs.umd.edu/projects/coinscope/coinscope.pdf), [2](https://arxiv.org/pdf/1812.00942.pdf) involve network-wide InvBlock. This fix would not mitigate this type of inference, but I believe it will make it more expensive to perform (an attacker would have to create more transactions and perform more rounds to learn the topology, the second paper itself notes that InvBlock isolation is important for the attack).

  ### How does it work
  This PR introduces bias toward outbound connections (they have higher priority when a node chooses from whom it should request a transaction) and randomizes the order.
  As per @gmaxwell suggestion, GETDATA requests queue is created after processing all incoming messages from all nodes.

  After this fix, if the incoming messages were [I1, I2, I3, O1, O2, O3, O4], the queue for _GETDATA_ may look like [O2, O1, O3, O4, I1, I3, I2, ….].

  If {I1, I2, I3} were significantly earlier (but the difference is less than TX_TIMEOUT=60 s) than others, the queue for _GETDATA_ may look like [I2, O2, O1, O3, O4, I1, I3, ….].

  ### Other comments:
  1. This mitigation works better if the connectivity is higher (especially outbound, because it would be less likely that 2 _GETDATAs_ for inbound malicious nodes queued together)

Tree-SHA512: 2ad1e80c3c7e16ff0f2d1160aa7d9a5eaae88baa88467f156b987fe2a387f767a41e11507d7f99ea02ab75e89ab93b6a278d138cb1054f1aaa2df336e9b2ca6a
2019-02-07 20:12:16 -08:00
Wladimir J. van der Laan 9127bd7aba
Merge #14491: Allow descriptor imports with importmulti
b985e9c850 Add release notes for importmulti descriptor support (MeshCollider)
fbb5e935ea Add test for importing via descriptor (MeshCollider)
9f48053d8f [wallet] Allow descriptor imports with importmulti (MeshCollider)
d2b381cc91 [wallet] Refactor ProcessImport() to call ProcessImportLegacy() (John Newbery)
4cac0ddd25 [wallet] Add ProcessImportLegacy() (John Newbery)
a1b25e12a5 [wallet] Refactor ProcessImport() (John Newbery)

Pull request description:

  ~~Based on #14454 #14565, last two commits only are for review.~~

  Best reviewed with `?w=1`

  Allows a descriptor to be imported into the wallet using `importmulti` RPC. Start and end of range can be specified for ranged descriptors. The descriptor is implicitly converted to old structures on import.

  Also adds a simple test of a P2SH-P2WPKH address being imported as a descriptor. More tests to come, as well as release notes.

Tree-SHA512: 160eb6fd574c4ae5b70e0109f7e5ccc95d9309138603408a1114ceb3c558065409c0d7afb66926bc8e1743c365a3b300c5f944ff18b2451acc0514fbeca1f2b3
2019-02-07 22:43:33 +01:00
practicalswift d855e4cac8 Avoid triggering undefined behaviour (std::memset(nullptr, 0, 0)) if an invalid string is passed to DecodeSecret(...) 2019-02-07 22:30:25 +01:00
MarcoFalke faa46475d7
wallet: Add lock annotation for mapAddressBook 2019-02-07 15:22:14 -05:00
MeshCollider 1933e38c1a
Merge #14667: Add deriveaddresses RPC util method
595283851 [rpc] util: add deriveaddresses method (Sjors Provoost)

Pull request description:

  Usage:

  ```sh
  bitcoin-cli deriveaddresses "wpkh([d34db33f/84h/0h/0h]xpub6DJ2dNUysrn5Vt36jH2KLBT2i1auw1tTSSomg8PhqNiUtx8QX2SvC9nrHu81fT41fvDUnhMjEzQgXnQjKEu3oaqMSzhSrHMxyyoEAmUHQbY/0/0)"
  [
    "bc1qg6ucjz7kgdedam7v5yarecy54uqw82yym06z3q"
  ] // part of the BIP32 test vector
  ```

  Avoids the need for external (BIP32) libraries to derive an address. Can be used in conjunction with `scantxoutset` as a poor mans wallet. Might be useful to test more complicated future descriptors.

  ~To keep it as simple as possible it only supports descriptors that result in a single address, so no `combo()` and ranges.~

  As discussed recently on IRC it might make sense to put this in a separate utility along with other descriptor and psbt utility functions which don't need a chain or wallet context. However I prefer to leave that to another PR.

Tree-SHA512: b8e53db11a8fd87638cc98766270cc3be9adc4b3e5085798a6a4e2e6ad252bf6d2189346bbb2da72d04d13f7f1e80b5cb88e8039653bea1f150602a876ef7f34
2019-02-08 08:21:52 +13:00
Gleb Naumenko 1cff3d6cb0 Change in transaction pull scheduling to prevent InvBlock-related attacks
Co-authored-by: Suhas Daftuar <sdaftuar@gmail.com>
2019-02-06 20:25:27 -08:00
Wladimir J. van der Laan 72d34c0edc
Merge #15343: [doc] netaddress: Make IPv4 loopback comment more descriptive
87aa0b48af netaddress: Make IPv4 loopback comment more descriptive (Carl Dong)
6180b5f32b netaddress: Fix indentation in IsLocal (Carl Dong)

Pull request description:

  This also makes the comment match the IPv6 comment just below this hunk.

Tree-SHA512: 9b91195e71e18156c9e013f63a6d430c67951aabb4a0c2f48f3bf852570c13887572b9e2fa52f4e1beba8685a9cae8949d4d03cd618a78f88566cf9e85dc64a8
2019-02-06 22:47:32 +01:00
MarcoFalke a99999cc04
util: Add SetupHelpOptions() 2019-02-06 14:16:43 -05:00
MarcoFalke 5cdb82111c
Merge #15321: doc: Add cs_main lock annotations for mapBlockIndex
fa2a69fcb9 doc: Add cs_main lock annotations for mapBlockIndex (practicalswift)

Pull request description:

  Marked as "doc" because it didn't change the bitcoind on my system with default configure settings for both gcc and clang.

Tree-SHA512: ba203f16c1cdc834a61c65bb5fb20bbaf7d8bff0c3a1b8ef46bc1d3669092191221e26abd7e580efab2f9bd5a992dc363251f1b68c6cd68f8204d62675868cf1
2019-02-06 13:26:52 -05:00
Wladimir J. van der Laan 12a910c943
Merge #15091: GUI: fix model overlay header sync
e8db6b8044 Qt: Fix update headers-count (Jonas Schnelli)
7bb45e4b7a Qt: update header count regardless of update delay (Jonas Schnelli)

Pull request description:

  Update the block and header tip is constraint to have a minimal distance of 250ms between updates... which can lead to miss the last header update.

  The modal overlay then assumes we are still in header sync and the view get stuck in "syncing headers,..." (while it's actually syncing blocks).

  This removes the 250ms minimal delta for header updates as well as it fixes the correct display of how header updates should update the labels.

Tree-SHA512: 57608dac822b135cd604fc6ba1c80f25c0202a6e20bb140362026615d4bf243ef4fcc254a11bad36419c554a222a2f4947438d4ce44aa14041d1874751643d68
2019-02-06 17:00:30 +01:00
MarcoFalke baf125b31d
Merge #15332: [Docs] Small updates to getrawtransaction description
47012391ec [Docs] Small updates to getrawtransaction description (Amiti Uttarwar)

Pull request description:

  As per review comments on https://github.com/bitcoin/bitcoin/pull/15159

Tree-SHA512: 0bbbe956b47d177f7e67c5ab2048287783327d9e07a679d64d79aee3ea8633e769f75b59d3dbce517924ba5d64d6c44f26bf49e16d40612463e460ad1a238129
2019-02-05 17:18:40 -05:00
MarcoFalke 9e7f8f6c82
Merge #15327: tests: Make test updatecoins_simulation_test deterministic
ef0b01217a tests: Make updatecoins_simulation_test deterministic (practicalswift)

Pull request description:

  Make test `updatecoins_simulation_test` deterministic.

  Can be verified using `contrib/test_deterministic_coverage.sh` introduced in #15296.

  Related:
  * #15296: "tests: Add script checking for deterministic line coverage in unit tests"
  * #15324: "test: Make bloom tests deterministic"
  * #14343: "coverage reports non-deterministic"

Tree-SHA512: 3466e28a42dd3735effb8542044d88e8350a470729d4a4f02abce9d6367de6568d698131469ba154d3dc76d448bacb360b7aefd066bb5b91408c0be375dd3ecb
2019-02-05 17:14:30 -05:00
MarcoFalke 9b63c436a6
Merge #15203: Fix issue #9683 "gui, wallet: random abort (segmentation fault)
364cff1cab Fix issue #9683 "gui, wallet: random abort (segmentation fault) running master/HEAD". (Chris Moore)

Pull request description:

  Patch taken from @ryanofsky's comment https://github.com/bitcoin/bitcoin/issues/9683#issuecomment-448035913.

  [MarcoFalke wrote](https://github.com/bitcoin/bitcoin/issues/9683#issuecomment-454066004):
  > Mind to submit this patch as a pull request?

  So that's what I'm doing.

  I was regularly seeing crashes on startup before applying this patch and haven't seen a single crash on startup since applying it almost a month ago.

Tree-SHA512: 3bbb2291cdf03ab7e7b5b796df68d76272491e35d473a89f4550065554c092f867659a7b8d7a1a91461ae4dc9a3b13b72541eafdbd732536463e9f3cf82300c8
2019-02-05 16:39:18 -05:00
MeshCollider 30e799a5f7
Merge #15297: wallet: Releases dangling files on BerkeleyEnvironment::Close
d3bf3b930 qa: Test .walletlock file is closed (João Barbosa)
2f8b8f479 wallet: Close wallet env lock file (João Barbosa)
8602a1e6a wallet: Close dbenv error file db.log (João Barbosa)

Pull request description:

  This PR closes `db.log` and removes `.walletlock` files when `BerkeleyEnvironment` is closed.

  Fixes https://github.com/bitcoin/bitcoin/issues/15291#issuecomment-459131886.

Tree-SHA512: 05d8b027feea914e0ba873e75d117857473d1fd7b400e41bd473d638171fa39d5be048990bf685dc0807f7d92418579b763056dc2a6dcf6b96777d5688ddee04
2019-02-06 10:10:51 +13:00
Wladimir J. van der Laan 3a573fd46c
Merge #14922: windows: Set _WIN32_WINNT to 0x0601 (Windows 7)
0164b0f5cf build: Remove WINVER pre define in Makefile.leveldb.inlcude (Chun Kuan Lee)
d0522ec94e Drop defunct Windows compat fixes (Ben Woosley)
d8a2992067 windows: Call SetProcessDEPPolicy directly (Chun Kuan Lee)
1bd9ffdd44 windows: Set _WIN32_WINNT to 0x0601 (Windows 7) (Chun Kuan Lee)

Pull request description:

  The current minimum support Windows version is Vista. So set it to 0x0600
  5a88def8ad/mingw-w64-headers/include/sdkddkver.h (L19)

Tree-SHA512: 38e2afc79426ae547131c8ad3db2e0a7f54a95512f341cfa0c06e4b2fe79521ae67d2795ef96b0192e683e4f1ba6183c010d7b4b8d6b3e68b9bf48c374c59e7d
2019-02-05 18:15:01 +01:00
MarcoFalke fc21bb4e35
Merge #15245: remove deprecated mentions of signrawtransaction from fundraw help
851380ce17 remove deprecated mentions of signrawtransaction from fundraw help (Gregory Sanders)

Pull request description:

  RPC call has been removed as of 0.17.99.

Tree-SHA512: a6a12a0e4572acd9b532c1719be85ed6f29d1c1a28f9ce691398528b8dde4fb4a3222b8f68632fcb1a8eddfe2d31e96d5efd5bc51c041af8e7cb99b61ca3a167
2019-02-05 10:48:36 -05:00
MarcoFalke bbdcc0b0ff
Merge #15342: Suggested wallet code cleanups from #14711
aebafd0edf Rename Chain getLocator -> getTipLocator (Russell Yanofsky)
2c1fbaa771 Drop redundant get_value_or (Russell Yanofsky)
84adb206fc Fix ScanForWalletTransactions start_block comment (Russell Yanofsky)
2efa66b464 Document rescanblockchain returned stop_height being null (Russell Yanofsky)
db2d093233 Add suggested rescanblockchain comments (Russell Yanofsky)
a8d645c934 Update ScanForWalletTransactions result comment (Russell Yanofsky)
95a812b599 Rename ScanResult stop_block field (Russell Yanofsky)

Pull request description:

  This implements suggested changes from #14711 review comments that didn't make make it in before merging.

  There are no changes in behavior in this PR, just documentation updates, simplifications, and variable renames.

Tree-SHA512: 39f1a5718195732b70b5e427c3b3e4295ea5af6328a5991763a422051212dfb95383186db0c0504ce2c2782fb61998dfd2fe9851645b7cb4e75d849049483cc8
2019-02-05 10:38:13 -05:00
MeshCollider 9f48053d8f [wallet] Allow descriptor imports with importmulti 2019-02-05 19:42:04 +13:00
John Newbery d2b381cc91 [wallet] Refactor ProcessImport() to call ProcessImportLegacy()
This is almost entirely a move-only commit.

Reviewer hint: use --color-moved=zebra for review.
2019-02-05 19:41:24 +13:00
John Newbery 4cac0ddd25 [wallet] Add ProcessImportLegacy()
This commit adds a ProcessImportLegacy() function which
currently does nothing. It also unindents a block of
code for a future move-only change.

Reviewer hint: review with -w to ignore whitespace changes.
2019-02-05 19:41:24 +13:00
John Newbery a1b25e12a5 [wallet] Refactor ProcessImport()
This commit is move-only and doesn't make any functional changes. It
simply moves code around within ProcessImport() in preparation for
refactors in the next commits.
2019-02-05 19:41:24 +13:00
benthecarman 30d0f7be6e rpc: Fix for segfault if combinepsbt called with empty inputs 2019-02-04 21:26:52 -06:00
Chris Moore 364cff1cab Fix issue #9683 "gui, wallet: random abort (segmentation fault) running master/HEAD".
Patch taken from @ryanofsky's comment
  https://github.com/bitcoin/bitcoin/issues/9683#issuecomment-448035913
and refined according to
  https://github.com/bitcoin/bitcoin/pull/15203#discussion_r249168229
2019-02-04 20:14:26 -04:00
Hennadii Stepanov e1b6436aad
Fix build after pr 15266 merged 2019-02-05 01:27:39 +02:00
MarcoFalke 452acee4da
Merge #15266: memory: Construct globals on first use
77777c5624 log: Construct global logger on first use (MarcoFalke)

Pull request description:

  The (de)initialization order is not well defined in C++, so generally it is not safe to use globals as the (de/con)structor of one global could use the (de/con)structor of another global before/after it has been (con/de)structed.

  Specifically this fixes:
  * `g_logger` might not be initialized on the first use, so do that. (Fixes #15111)

Tree-SHA512: eb9c22f4baf31ebc5b0b9ee6a51d1354bae1f0df186cc0ce818b4483c7b5a7f90268d2b549ee96b4c57f8ef36ab239dc6497f74f3e2ef166038f7437c368297d
2019-02-04 14:26:07 -05:00
Carl Dong 87aa0b48af netaddress: Make IPv4 loopback comment more descriptive 2019-02-04 13:47:55 -05:00
Carl Dong 6180b5f32b netaddress: Fix indentation in IsLocal 2019-02-04 13:47:46 -05:00
Carl Dong 107623c26c net: Correct comparison of addr count
LOCAL_NONE is supposed to be an enum indicating the score of a
LocalServiceInfo rather than the count of an addr in mapLocalHost.
2019-02-04 13:12:20 -05:00
Amiti Uttarwar 47012391ec [Docs] Small updates to getrawtransaction description 2019-02-04 08:32:08 -08:00
Gregory Sanders 851380ce17 remove deprecated mentions of signrawtransaction from fundraw help 2019-02-04 10:26:46 -05:00
Wladimir J. van der Laan df8a7d3408 qt: Pre-0.18 split-off translations update
- Update transifex slug
- Mention update of MSVC build in `doc/translation_process.md`
- Do a `make translate` to update English translations
- Pull current translations from transifex
2019-02-04 15:24:37 +01:00
João Barbosa 1951ea4342 gui: Show indeterminate progress dialog while opening walllet 2019-02-04 12:23:43 +00:00
João Barbosa 8847cdaaae gui: Add OpenWalletActivity 2019-02-04 12:23:40 +00:00
João Barbosa 2f8b8f479b wallet: Close wallet env lock file
Close .walletlock file when a BerkeleyEnvironment is deleted.
2019-02-04 12:22:55 +00:00
João Barbosa 8602a1e6ae wallet: Close dbenv error file db.log
The error file db.log is opened by BerkeleyEnvironment instance and
should be closed after dbenv is closed.
2019-02-04 12:22:55 +00:00
João Barbosa 4c8982a88e interfaces: Avoid interface instance if wallet is null 2019-02-04 12:20:42 +00:00
João Barbosa be82dea23c gui: Add thread to run background activity in WalletController 2019-02-04 12:20:42 +00:00
João Barbosa 6c49a55b47 gui: Add Open Wallet menu 2019-02-04 12:20:42 +00:00
João Barbosa 32a8c6abfe gui: Add openWallet and getWalletsAvailableToOpen to WalletController 2019-02-04 12:20:42 +00:00
João Barbosa ab288b4e59 interfaces: Add loadWallet to Node 2019-02-04 12:20:42 +00:00
João Barbosa 17abc0fd52 wallet: Factor out LoadWallet 2019-02-04 12:20:42 +00:00
Wladimir J. van der Laan ebc6542d98
Merge #15322: wallet: Add missing cs_db lock
712d35bc56 wallet: Add missing cs_db lock (João Barbosa)

Pull request description:

  Without this lock `BerkeleyEnvironment::~BerkeleyEnvironment` and `GetWalletEnv` would race for `g_dbenvs`. This wasn't detected before because thread safety analysis does not check constructors
  and destructors.

  Reference: http://releases.llvm.org/5.0.2/tools/clang/docs/ThreadSafetyAnalysis.html#no-checking-inside-constructors-and-destructors

Tree-SHA512: 350cb2b991ca699a6bca85f87c82c38f0814484c8ccb0d7d83cb3bff9afcf60dd32b2a9554a9e72eb5803bfad8b6970fe7da618b39be5889178b86faa1b74124
2019-02-04 13:02:43 +01:00
Wladimir J. van der Laan 424327e1a8
Merge #15324: test: Make bloom tests deterministic
fae169c95e test: Make bloom tests deterministic (MarcoFalke)

Pull request description:

  non-deterministic tests are useless, since a failing test could not be reproduced unless the seed is known.

Tree-SHA512: 4f634ff0c6adf663444f1ac504f6dbceaa46b78d697b840531977ba30006453ac559d5c21cc3eaef6d92b87d46008a34b0db6331ea3318001987fcfaec634acf
2019-02-04 12:26:42 +01:00
Pieter Wuille 1435fabc19 Use RdSeed when available, and reduce RdRand load
This introduces support for autodetecting and using the RdSeed instruction.

In addition:
* In SeedFast, only 64 bits of entropy are generated through RdRand (256 was relatively slow).
* In SeedStartup, 256 bits of entropy are generated, using RdSeed (preferably) or RdRand (otherwise).
2019-02-03 17:34:26 -08:00
João Barbosa 0dd6a8c124 Check m_internals in UnregisterValidationInterface
When a wallet is created it is registered in the validation interface (in
CWallet::CreateWalletFromFile) but it is not immediately added to the
wallets list. If a shutdown is requested before AddWallet (case more
evident when -rescan is set) then m_internals can be released (in
Shutdown -> UnregisterBackgroundSignalScheduler) before the wallet and
then ReleaseWallet would call UnregisterValidationInterface with
m_internals already released.
2019-02-03 22:23:44 +00:00
João Barbosa fd6d499bda gui: Fix m_node.startShutdown() order
This change forwards the shutdown request on the GUI (close the
application for instace) to the node as soon as possible. This way the
GUI doesn't have to wait for long operations to complete (rescan the
wallet for instance), instead those operations detect the shutdown
request and abort/interrupt.
2019-02-03 22:23:43 +00:00
João Barbosa 07b9aadcfc gui: Expose BitcoinGUI::unsubscribeFromCoreSignals
Move only change that makes unsubscribeFromCoreSignals public. It must be
called if the event loop is not running otherwise core signals handlers
can deadlock.
2019-02-03 22:23:43 +00:00
João Barbosa 60e190ceb3 gui: Fix WalletController deletion
The wallet controller instanced must be deleted after the window instance
since it is used there.
2019-02-03 22:23:43 +00:00
practicalswift ef0b01217a tests: Make updatecoins_simulation_test deterministic 2019-02-03 10:34:22 +01:00
MeshCollider 6e6b859f85
Merge #15263: Descriptor expansions only need pubkey entries for PKH/WPKH
11e0fd8d6 Descriptor expansions only need pubkey entries for PKH/WPKH (Pieter Wuille)

Pull request description:

  Currently, calling `Expand` on a `Descriptor` object will populate the output FlatSigningProvider with all public keys involved in the descriptor. This is overkill, as pubkey entries are only needed when the lookup of a public key based on its hash is desired (which is the case for `pkh`, `wpkh`, and `combo` descriptors).

  Fix this by pushing the population of pubkey entries down into the individual descriptor implementation's `MakeScript` function, instead of doing it generically.

  This should make it easier to implement #14491 without importing P2PKH outputs for the individual public keys listed inside a multisig.

Tree-SHA512: 5bc7e9bd29f1b3bc63514803e9489b3bf126bfc177d46313aa9eeb98770ec61a97b55bd8ad4e2384154799f24b1bc4183bfdb4708b2ffa6e37ed2601a451cabc
2019-02-03 10:52:39 +13:00
MarcoFalke fae169c95e
test: Make bloom tests deterministic 2019-02-02 14:12:01 -05:00
Hennadii Stepanov 561e375c73
Make PID file creating errors fatal 2019-02-02 01:07:23 +02:00
Hennadii Stepanov 745a2ace18
Improve PID file removing errors logging 2019-02-02 00:33:33 +02:00
Russell Yanofsky aebafd0edf Rename Chain getLocator -> getTipLocator
Suggested https://github.com/bitcoin/bitcoin/pull/14711#discussion_r252044389
2019-02-01 16:17:43 -05:00
Russell Yanofsky 2c1fbaa771 Drop redundant get_value_or
Suggested https://github.com/bitcoin/bitcoin/pull/14711#discussion_r252041954
2019-02-01 16:16:16 -05:00
Russell Yanofsky 84adb206fc Fix ScanForWalletTransactions start_block comment
Suggested https://github.com/bitcoin/bitcoin/pull/14711#discussion_r252036436
2019-02-01 16:15:13 -05:00
João Barbosa 712d35bc56 wallet: Add missing cs_db lock
Without this lock BerkeleyEnvironment::~BerkeleyEnvironment and
GetWalletEnv would race for g_dbenvs. This wasn't detected before
because thread safety analysis does not check constructors and
destructors.
2019-02-01 21:13:08 +00:00
Russell Yanofsky 2efa66b464 Document rescanblockchain returned stop_height being null
Suggested https://github.com/bitcoin/bitcoin/pull/14711#discussion_r252031485
2019-02-01 16:11:05 -05:00
practicalswift fa2a69fcb9
doc: Add cs_main lock annotations for mapBlockIndex 2019-02-01 15:32:16 -05:00
MarcoFalke 2c0867a181
Merge #15308: build: Restore compatibility with older boost
119d360aab travis: Document whether functional tests are run in the job name (Ben Woosley)
64f28545e3 Revert "travis: Compile trusty with depends for now" (Ben Woosley)
267eac00f9 Prefer boost::optional#get_value_or over #value_or (Ben Woosley)
1971f5ba04 Piecewise construct to avoid invalid construction (Ben Woosley)

Pull request description:

  In light of #14979, I realized that only qt 5.5+ was being tested under CI, while compatibility lists 5.2+.

  In #15276, Marco added Trusty to CI, building with depends. This changes that build to system libraries, in order to ensure ongoing compatibility with our claimed minimum required versions.

  Fixes #14983, previously open as #14998

Tree-SHA512: 6cff5e28c756ecb8bf797c8f6eb77c1944ba61a8dd6d7d4984e63eef384f6429dc79c505da3241c05b9c4db31c72b2a9846c7365aba9280f2e0620e5f3998d07
2019-02-01 13:05:30 -05:00
Russell Yanofsky db2d093233 Add suggested rescanblockchain comments
From https://github.com/bitcoin/bitcoin/pull/14711#discussion_r252043990
2019-02-01 13:05:30 -05:00
Russell Yanofsky a8d645c934 Update ScanForWalletTransactions result comment
Suggested https://github.com/bitcoin/bitcoin/pull/14711#discussion_r252038666
2019-02-01 13:05:30 -05:00
Russell Yanofsky 95a812b599 Rename ScanResult stop_block field
Avoid confusion with stop_block argument as suggested
https://github.com/bitcoin/bitcoin/pull/14711#discussion_r252038449
2019-02-01 13:05:30 -05:00
Wladimir J. van der Laan 3e38d40873
Merge #15235: Do not import private keys to wallets with private keys disabled
e6c58d3b01 Do not import private keys to wallets with private keys disabled (Andrew Chow)
b5c5021b64 Refactor importwallet to extract data from the file and then import (Andrew Chow)
1f77f6754c tests: unify RPC argument to cli argument conversion and handle dicts and lists (Andrew Chow)

Pull request description:

  Fixes a bug where private keys could be imported to wallets with private keys disabled. Now every RPC which can import private keys checks for whether the wallet has private keys are disabled and errors if it is. Also added an belt-and-suspenders check to `AddKeyPubkeyWithDB` to have it assert that the wallet has private keys enabled.

Tree-SHA512: 5cd04febce9aa2bd9bfd02f312c6ff8705e37278cae59efd3895f6d6e2f1b477aefd297e2dd0860791bdd3d4f3cad8eb1a404f8f3d4e2035b91314ad2c1028ae
2019-02-01 14:01:32 +01:00
Ben Woosley 267eac00f9
Prefer boost::optional#get_value_or over #value_or
The latter is not defined in the earliest supported version of boost,
1.47.
https://www.boost.org/doc/libs/1_47_0/libs/optional/doc/html/boost_optional/detailed_semantics.html
https://travis-ci.org/bitcoin/bitcoin/jobs/486674823
2019-01-31 22:10:55 -08:00
Ben Woosley 1971f5ba04
Piecewise construct to avoid invalid construction
In CMainSignals::RegisterWithMempoolSignals running under Ubuntu 14.04
(QT 5.2), absent piecewise construction this fails to create the pair
because the argument is a connection, which is converted into a
non-copyable scoped_connection.

    validationinterface.cpp:80:186:   required from here
    /usr/include/boost/signals2/connection.hpp:234:7: error: ‘boost::signals2::scoped_connection::scoped_connection(const boost::signals2::scoped_connection&)’ is private
           scoped_connection(const scoped_connection &other);
           ^
    In file included from /usr/include/c++/4.8/utility:70:0,
                     from /usr/include/c++/4.8/algorithm:60,
                     from ./prevector.h:13,
                     from ./script/script.h:10,
                     from ./primitives/transaction.h:11,
                     from ./validationinterface.h:9,
                     from validationinterface.cpp:6:
    /usr/include/c++/4.8/bits/stl_pair.h:134:45: error: within this context
      : first(std::forward<_U1>(__x)), second(__y) { }
https://travis-ci.org/bitcoin/bitcoin/jobs/473689141#L2172
2019-01-31 22:10:54 -08:00
Andrew Chow e6c58d3b01 Do not import private keys to wallets with private keys disabled 2019-01-31 14:29:28 -05:00
Andrew Chow b5c5021b64 Refactor importwallet to extract data from the file and then import
Instead of importing keys and scripts as each line in the file is
read, first extract the data then import them.
2019-01-31 14:29:28 -05:00
Wladimir J. van der Laan 4b6673d382
Merge #15299: Fix assertion in CKey::SignCompact
3617f11739 Fix assertion in CKey::SignCompact (João Barbosa)

Pull request description:

  Fixes #15286.

Tree-SHA512: b39b6f26f87cf1850b13f625ab6de963937b6ecb5b6d4ac4932134f0491a6c0fa61c6d6e6980e8b1770775578dc365fdd1b6ba426bba1f7c23430f68b3a2339a
2019-01-31 19:13:45 +01:00
Wladimir J. van der Laan efb6ddef9c
Merge #11911: Free BerkeleyEnvironment instances when not in use
14bc2a17dd Trivial: add doxygen-compatible comments relating to BerkeleyEnvironment (Pierre Rochard)
88b1d956fe Tests: add unit tests for GetWalletEnv (Pierre Rochard)
f1f4bb7345 Free BerkeleyEnvironment instances when not in use (Russell Yanofsky)

Pull request description:

  Instead of adding BerkeleyEnvironment objects permanently to the g_dbenvs map, use reference counted shared pointers and remove map entries when the last BerkeleyEnvironment reference goes out of scope.

  This change was requested by @TheBlueMatt and makes code that sets up mock databases cleaner. The mock database environment will now go out of scope and be reset on destruction so there is no need to call BerkeleyEnvironment::Reset() during wallet construction to clear out prior state.

  This change does affect bitcoin behavior slightly. On startup, instead of same wallet environments staying open throughout VerifyWallets() and OpenWallets() calls, VerifyWallets() will open and close an environment once for each wallet, and OpenWallets() will create its own environment(s) later.

Tree-SHA512: 219d77a9e2268298435b86088f998795e059fdab1d2050ba284a9ab8d8a44961c9b5cf96e94ee521688108d23c6db680e3e3a999b8cb2ac2a8590f691d50668b
2019-01-31 18:05:24 +01:00
MarcoFalke 252fd15add
Merge #13926: [Tools] bitcoin-wallet - a tool for creating and managing wallets offline
3c3e31c3a4 [tests] Add wallet-tool test (João Barbosa)
49d2374acf [tools] Add wallet inspection and modification tool (Jonas Schnelli)

Pull request description:

  Adds an offline tool `bitcoin-wallet-tool` for wallet creation and maintenance.

  Currently this tool can create a new wallet file, display information on an existing wallet, and run the salvage and zapwallettxes maintenance tasks on an existing wallet. It can later be extended to support other common wallet maintenance tasks.

  Doing wallet maintenance tasks in an offline tool makes much more sense (and is potentially safer) than having to spin up a full node.

Tree-SHA512: 75a28b8a58858d9d76c7532db40eacdefc5714ea5aab536fb1dc9756e2f7d750d69d68d59c50a68e633ce38fb5b8c3e3d4880db30fe01561e07ce58d42bceb2b
2019-01-31 11:07:51 -05:00
João Barbosa 3617f11739 Fix assertion in CKey::SignCompact 2019-01-31 15:00:56 +00:00
Wladimir J. van der Laan 7c09e209ef
Merge #15225: GUI: Change the receive button to respond to keypool state changing
2bc4c3eaf9 Notify the GUI that the keypool has changed to set the receive button (Andrew Chow)
14bcdbe09c Check for more than private keys disabled to show receive button (Andrew Chow)

Pull request description:

  Currently the Receive button in the GUI is displayed enabled or disabled by the initial state of the wallet when the wallet is first loaded. The button is only enabled or disabled depending on whether the disable private keys flag is set when the wallet is loaded. However, future changes to the wallet means that this initial state and check may no longer be accurate. #14938 introduces empty wallets which do not have private keys. An empty wallet that is loaded should have the Receive button disabled, and then it should become enabled once `sethdseed` is used so that a keypool can be generated and new keys generated. Likewise, with #14075, a wallet can be loaded with no keypool initially, so the button should be disabled. Later, public keys can be imported into the keypool, at which time the button should become enabled. When the keypool runs out again (no new keys are generated as the keypool only consists of imports), the button should become disabled.

  This PR makes it so that the button becomes enabled and disabled as the keypool state changes. The check for whether to enable or disable the receive button has changed to checking whether it is possible to get new keys. It now checks for whether the wallet has an HD seed and, if not, whether the private keys are disabled. When an action happens which would make it possible for a new address to be retrieved or make it possible for a no more addresses to be retrieved, a signal is emitted which has the GUI recheck the conditions for the Receive button. These actions are setting a new HD seed, topping up the keypool, retrieving a key from the keypool, and returning a key to the keypool.

Tree-SHA512: eff15a5337f4c64ecd7169414fb47053c04f6a0f0130341b6dd9799ac4d79f451e25284701c668971fca33f0909d5352a474a2c12349375bedfdb59b63077d50
2019-01-31 15:11:32 +01:00
Wladimir J. van der Laan a0d657bd31
Merge #15272: doc: correct logging return type and RPC example
e1c27da303 doc: correct logging rpc return type and example (fanquake)

Pull request description:

  Logging status is returned as a bool.
  ```
  src/bitcoin-cli logging "[\"all\"]" "[\"http\"]"
  {
    "net": true,
    "tor": true,
    "mempool": true,
    "http": false,
    "bench": true,
    "zmq": true,
    "db": true,
    "rpc": true,
    "estimatefee": true,
    "addrman": true,
    "selectcoins": true,
    "reindex": true,
    "cmpctblock": true,
    "rand": true,
    "prune": true,
    "proxy": true,
    "mempoolrej": true,
    "libevent": true,
    "coindb": true,
    "qt": true,
    "leveldb": true
  }
  ```

  Also corrects the RPC example so that `libevent` logging will actually be turned off.

Tree-SHA512: 2de7130df51688d2d6636c12fd56326362794118a10efc8100f0bf541a7da00a12a6cd9d75e599a104513a050bbe49b418ea460ee8033ac6cf6ffb8e8e9140d6
2019-01-31 13:38:13 +01:00
Sjors Provoost 7cb1a1401d
Explain that unused mempool memory is added to -dbcache 2019-01-31 10:56:06 +01:00
Wladimir J. van der Laan cb77dc820f
Merge #15292: Remove 'boost::optional'-related false positive -Wmaybe-uninitialized warnings on GCC compiler
2d483142a7 Remove 'boost::optional'-related gcc warnings (Hennadii Stepanov)

Pull request description:

  #14711 introduced some warnings when building with gcc compiler.

  See:
  - https://github.com/bitcoin/bitcoin/pull/14711#issuecomment-454760017 by @laanwj
  - https://github.com/bitcoin/bitcoin/pull/14711#pullrequestreview-193702611 by @ryanofsky

  This gcc [issue](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47679) has been known since version 4.6.0 and last updated in 2017.
  From the boost [docs](https://www.boost.org/doc/libs/1_69_0/libs/optional/doc/html/boost_optional/quick_start/optional_automatic_variables.html):
  > The default constructor of `optional` creates an _uninitialized_ `optional` object.

  Also: [False positive with -Wmaybe-uninitialized](https://www.boost.org/doc/libs/1_69_0/libs/optional/doc/html/boost_optional/tutorial/gotchas/false_positive_with__wmaybe_uninitialized.html) ([pointed out](https://github.com/bitcoin/bitcoin/pull/15292#issuecomment-459063170) by @Empact)

  This PR removes these warnings.

  cc: @Empact @practicalswift

Tree-SHA512: 752ae3c3ca6282bbf98726236fbc3069ab9d1aee57ae2ec2668b32e4541e7bc1acb15b7d6fa9e2b6daf1ec29c0987a1053ee1ca0f523b71367ff911221c58c94
2019-01-30 23:39:00 +01:00
Jonas Schnelli 49d2374acf [tools] Add wallet inspection and modification tool
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-30 16:26:52 -05:00
Hennadii Stepanov 2d483142a7
Remove 'boost::optional'-related gcc warnings 2019-01-30 22:44:28 +02:00
Wladimir J. van der Laan 9553102c38
Merge #15043: test: Build fuzz targets into seperate executables
2ca632e5b4 test: Build fuzz targets into seperate executables (MarcoFalke)
fab4bed68a [test] fuzz: make test_one_input return void (MarcoFalke)

Pull request description:

  Currently our fuzzer is a single binary that decides on the first few bits of the buffer what target to pick. This is ineffective as the fuzzer needs to "learn" how the fuzz targets are organized and could get easily confused. Not to mention that the (seed) corpus can not be categorized by target, since targets might "leak" into each other. Also the corpus would potentially become invalid if we ever wanted to remove a target...

  Solve that by building each fuzz target into their own executable.

Tree-SHA512: a874febc85a3c5e6729199542b65cad10640553fba6f663600c827fe144543744dd0f844fb62b4c95c6a04c670bfce32cdff3d5f26de2dfc25f10b258eda18ab
2019-01-30 21:10:21 +01:00
Wladimir J. van der Laan 77339e5c24
Merge #15163: Correct units for "-dbcache" and "-prune"
6f6514a080 Correct units for "-dbcache" and "-prune" (Hennadii Stepanov)

Pull request description:

  Actually, all `dbcache`-related values in the code are measured in MiB (not in megabytes, MB) or in bytes (e.g., `nTotalCache`).

  See: https://github.com/bitcoin/bitcoin/blob/master/src/txdb.h

  ba8c8b2227/src/init.cpp (L1405-L1424)

  Also, "-prune" is fixed:
  1. The GUI values in GB are translated to the node values in MiB correctly.
  2. The maximum of the "prune" `QSpinBox` is not limited by default value of 99 (GB).

  Fix: #15106

Tree-SHA512: 151ec43b31b1074db8b345fedb1dcc10bde225899a5296bfc183f57e1553d13ac27db8db100226646769ad03c9fcab29d88763065a471757c6c41ac51108459d
2019-01-30 20:22:57 +01:00
MarcoFalke 04226f8706
Merge #15279: wallet: Clarify rescanblockchain doc
fa5e6ef55c wallet: Fixup rescanblockchain result doc (MarcoFalke)

Pull request description:

  This was probably accidentally added to the wrong line when addressing the feedback here: https://github.com/bitcoin/bitcoin/pull/7061#discussion_r142199778

  I already added the default values in #14877, but it could be clarified more that this really has no specific block height as default value, since the tip can change during a rescan.

Tree-SHA512: 48a3c5143e2b7129ee8f396d2e77550cb393fbe45f5936aeebeb7a201d61560336a3ae47b26bb757a4dbbe217e06abfd67a5a673aef266b6c4d7a80d049a2b49
2019-01-30 13:35:55 -05:00
MarcoFalke a47319dada
Merge #15159: [RPC] Remove lookup to UTXO set from GetTransaction
04da9f4834 [RPC] Update getrawtransaction interface (Amiti Uttarwar)

Pull request description:

  - stop checking unspent UTXOs for a transaction when txindex is not enabled, as per conversation here: https://github.com/bitcoin/bitcoin/issues/3220#issuecomment-377458383
  - code contributed by sipa

Tree-SHA512: aa07353bccc14b81b7803992a25d076d6bc06d15ec7c1b85828dc10aea7e0498d9b49f71783e352ab8a14b0bb2010cfb7835de3dfd1bc6f2323f460449348e66
2019-01-30 11:18:44 -05:00
Wladimir J. van der Laan 29396bd669
Merge #15270: Pull leveldb subtree
4f2e6c8b88 Squashed 'src/leveldb/' changes from 524b7e36a8..f545dfabff (MarcoFalke)

Pull request description:

  Some windows-related fixes.

  Sanity check with:

  ```
  git fetch https://github.com/bitcoin-core/leveldb
  ./test/lint/git-subtree-check.sh src/leveldb

Tree-SHA512: ff94907ff3075b81cffb733129673a9bfd2abbe84240686b29274382b64b4e5845880236458043d6db0332bf70d12942d9c0e68b4fffab43931103d224cb59d4
2019-01-30 15:52:14 +01:00
Hennadii Stepanov 6f6514a080
Correct units for "-dbcache" and "-prune"
All dbcache-related values in the code are measured in MiB (not in
megabytes, MB) or in bytes.
The GUI "-prune" values in GB are translated to the node values in MiB
correctly. The maximum of the "-prune" QSpinBox is not limited by the
default value of 99 (GB).
Also, this improves log readability.
2019-01-30 07:17:22 +02:00
MeshCollider 72ca72e637
Merge #14711: Remove uses of chainActive and mapBlockIndex in wallet code
44de1561a Remove remaining chainActive references from CWallet (Russell Yanofsky)
db21f0264 Convert CWallet::ScanForWalletTransactions and SyncTransaction to the new Chain apis (Russell Yanofsky)
2ffb07929 Add findFork and findBlock to the Chain interface (Russell Yanofsky)
d93c4c1d6 Add time methods to the Chain interface (Russell Yanofsky)
700c42b85 Add height, depth, and hash methods to the Chain interface (Russell Yanofsky)

Pull request description:

  This change removes uses of `chainActive` and `mapBlockIndex` globals in wallet code. It is a refactoring change which does not affect external behavior.

  This is the next step in the larger #10973 refactoring change, which removes all other accesses to node global variables from wallet code. Doing this is useful to provide a better defined interface between the wallet and node, and necessary to allow wallet and node code to run in separate processes in #10102.

Tree-SHA512: 4dcec8a31c458f54e2ea6ecf01e430469b0994c5b41a21a2d150efa67cd209f4c93ae210a101e064b3a87c52c6edfc70b070e979992be0e3a00fd425de6230a8
2019-01-30 13:03:32 +13:00
MarcoFalke 2ca632e5b4 test: Build fuzz targets into seperate executables 2019-01-29 19:03:06 -05:00
Jonas Schnelli 2d790e82c8
Merge #14929: net: Allow connections from misbehavior banned peers
0297be61a Allow connections from misbehavior banned peers. (Gregory Maxwell)

Pull request description:

  This allows incoming connections from peers which are only banned
   due to an automatic misbehavior ban if doing so won't fill inbound.

  These peers are preferred for eviction when inbound fills, but may
   still be kept if they fall into the protected classes.  This
   eviction preference lasts the entire life of the connection even
   if the ban expires.

  If they misbehave again they'll still get disconnected.

  The main purpose of banning on misbehavior is to prevent our
   connections from being wasted on unhelpful peers such as ones
   running incompatible consensus rules.  For inbound peers this
   can be better accomplished with eviction preferences.

  A secondary purpose was to reduce resource waste from repeated
   abuse but virtually any attacker can get a nearly unlimited
   supply of addresses, so disconnection is about the best we can
   do.

  This can reduce the potential from negative impact due to incorrect misbehaviour bans.

Tree-SHA512: 03bc8ec8bae365cc437daf70000c8f2edc512e37db821bc4e0fafa6cf56cc185e9ab40453aa02445f48d6a2e3e7268767ca2017655aca5383108416f1e2cf20f
2019-01-29 13:41:04 -10:00
MarcoFalke 77777c5624
log: Construct global logger on first use 2019-01-29 15:30:24 -05:00
MarcoFalke fa5e6ef55c
wallet: Fixup rescanblockchain result doc 2019-01-29 12:52:55 -05:00
Sjors Provoost 595283851d
[rpc] util: add deriveaddresses method 2019-01-29 18:14:23 +01:00
fanquake e1c27da303
doc: correct logging rpc return type and example 2019-01-29 23:05:52 +08:00
MarcoFalke 7275365c9b
Merge #14987: RPCHelpMan: Pass through Result and Examples
faa1522e5e RPCHelpMan: Pass through Result and Examples (MarcoFalke)

Pull request description:

  Passing the rpc result and rpc examples through `RPCHelpMan` makes it clear in what order they appear in the stringified version. Future improvements could then autoformat or autogenerate them.

Tree-SHA512: b32a5c178cc80f50a7e9b93a38e2b26d5994188ecafe9e61bbc599941b44b9b0e4e4be6413d4464fac6e8e73661a191a77d34917f2e6293de19fb59519dd4487
2019-01-29 09:55:48 -05:00
MarcoFalke d6e700e40f
Merge #15248: rpc: Compile on GCC4.8
fa5f890aeb rpc: Compile on GCC4.8 (MarcoFalke)

Pull request description:

  GCC 4.8 is lacking some C++11 signatures (see "Adjust C++11 signatures to take a const_iterator." in GCC 4.9: 3d2b2f494d)

  Fix that by changing the code to use the pre-GCC 4.9 signature.

  Can be reverted after #13356.

  Fixes #15172 (reports on `Linux Mint 17.3 Rosa` and `CentOS Linux release 7.5.1804 (Core)`)

Tree-SHA512: 0c0b18968270ad4fcd0c2000c57485be881a461135dac3ad0bdab22c1a2292cf6b28ebeb930ccaa0290ff20ce87547fd07ab8189c4c4fb54d652a3d0bc9615f8
2019-01-28 10:39:51 -05:00
MarcoFalke fa5f890aeb
rpc: Compile on GCC4.8 2019-01-27 12:33:23 -05:00
Wladimir J. van der Laan 5e0c0fd62f
Merge #15254: Trivial: fixup a few doxygen comments
70e7cee960 Trivial: Doxygenize existing CBufferedFile and VectorReader comments (Ben Woosley)
9431e1b915 Trivial: fixup a few doxygen comments (Ben Woosley)

Pull request description:

  These were not declared properly, so their results are not properly
  processed. E.g.:
  https://dev.visucore.com/bitcoin/doxygen/rpcdump_8cpp.html#a994c8748aaa60fbb78009ff8a0638dea
  https://dev.visucore.com/bitcoin/doxygen/coins_8cpp.html#aa03af24ef3570144b045f4fca7a0d603
  https://dev.visucore.com/bitcoin/doxygen/wallet_2wallet_8cpp.html#a5c2a7725ff8796f03471f844ecded3d9

  > A third alternative is to use a block of at least two C++ comment lines, where each line starts with an additional slash or an exclamation mark.

  http://www.doxygen.nl/manual/docblocks.html

Tree-SHA512: c13fd48ac78f25e51b1281385747e8be4bd6e27e0a0f8704608aa5c66c16715c639f1cf27018b1bf05fc2eaed6c7b9be05a68365ffe1d88dd3f400d453b7bead
2019-01-27 16:17:58 +01:00
Amiti Uttarwar 04da9f4834 [RPC] Update getrawtransaction interface 2019-01-26 18:36:53 -08:00
MarcoFalke fa6180188b
Pull leveldb subtree 2019-01-26 12:45:48 -05:00
Chun Kuan Lee 0164b0f5cf build: Remove WINVER pre define in Makefile.leveldb.inlcude 2019-01-26 09:28:48 +08:00
MarcoFalke fab4bed68a
[test] fuzz: make test_one_input return void
The return value is always 0 and not used, so might as well return void
2019-01-25 19:05:07 -05:00
Ben Woosley 70e7cee960
Trivial: Doxygenize existing CBufferedFile and VectorReader comments 2019-01-25 12:32:37 -08:00
MarcoFalke faa1522e5e
RPCHelpMan: Pass through Result and Examples 2019-01-25 14:16:07 -05:00
Pieter Wuille 11e0fd8d66 Descriptor expansions only need pubkey entries for PKH/WPKH 2019-01-25 10:39:06 -08:00
MarcoFalke d14ef5721f
Merge #15233: Prevent mutex lock fail even if --enable-debug
b09dab0f2d Prevent mutex lock fail even if --enable-debug (Akio Nakamura)

Pull request description:

  This PR intends to resolve #15227.

  ```configure --enable-debug```  enables ```#ifdef DEBUG_LOCKORDER```.

  Then ```lockdata``` (in sync.cpp) will be initialized same as other static objects.

  But unfortunately, ```lockdata.push_lock()``` was called before its initialization (via initializing ```signatureCache``` which is declared in ```script/sigcache.cpp```) on macOS.

  This PR apply the "Construct On First Use Idiom" to ```lockdata``` to prevent it.

  edited --- fix typo.

Tree-SHA512: 59df99ef78a335b1b7ebed7207d4719ea4412900eea38739f6e8eaaba1f594e1950044851659ce83f4f69813fc96978244bd176676e1aa2277c813ede832e6fb
2019-01-25 01:11:24 -05:00
Akio Nakamura b09dab0f2d Prevent mutex lock fail even if --enable-debug
This PR intends to resolve #15227.

"configure --debug-enabled" enables "#ifdef DEBUG_LOCKORDER".
Then "lockdata" (in sync.cpp) will be initialized same as other
static objects.

But unfortunately, lockdata.push_lock() was called before its
initialization (via initializing signatureCache which is declared
in script/sigcache.cpp) on macOS.

This PR apply the "Construct On First Use Idiom" to "lockdata"
to prevent it.
2019-01-25 13:21:59 +09:00
Ben Woosley 9431e1b915
Trivial: fixup a few doxygen comments
These were not declared properly, so their results are not properly
processed. E.g.:
https://dev.visucore.com/bitcoin/doxygen/rpcdump_8cpp.html#a994c8748aaa60fbb78009ff8a0638dea
https://dev.visucore.com/bitcoin/doxygen/coins_8cpp.html#aa03af24ef3570144b045f4fca7a0d603
https://dev.visucore.com/bitcoin/doxygen/wallet_2wallet_8cpp.html#a5c2a7725ff8796f03471f844ecded3d9
2019-01-24 19:47:07 -08:00
Ben Woosley d0522ec94e
Drop defunct Windows compat fixes
"The AI_ADDRCONFIG flag is defined on the Windows SDK for Windows Vista
and later. The AI_ADDRCONFIG flag is supported on Windows Vista and
later."
https://docs.microsoft.com/en-us/windows/desktop/api/ws2tcpip/nf-ws2tcpip-getaddrinfo

However, the version of MinGW we use on Travis is not current and does
not carry the relevant definition, as such I defined it in compat.
https://github.com/wine-mirror/wine/blob/master/include/ws2tcpip.h

Testing confirms that the PROTECTION_LEVEL_UNRESTRICTED,
IPV6_PROTECTION_LEVEL, PROCESS_DEP_ENABLE, AI_ADDRCONFIG, are now
supported by the version of Windows that we test against, so can be
removed.
https://travis-ci.org/bitcoin/bitcoin/jobs/483255439
https://travis-ci.org/Empact/bitcoin/jobs/484123087
2019-01-24 15:58:49 -08:00
Wladimir J. van der Laan 72bd4ab867
Merge #15193: Default -whitelistforcerelay to off
a36d97d866 Default -whitelistforcerelay to off (Suhas Daftuar)

Pull request description:

  No one seems to use this "feature", and at any rate the behavior of relaying transactions when they violate local policy is error-prone, if we ever consider changing the ban behavior of our software from one version to the next.

  Defaulting this to off means that users who use -whitelist won't be unexpectedly surprised by this interaction.  If anyone is still relying on this feature, it can still be explicitly turned on.

Tree-SHA512: 52650ad464a728d1648f496751e3f713077ea3a1de7278ed03531b2e8723e63cf2f6f41b56c98c0f73ffa22c36e01d9170b409ab452c737aca35b7ecd7a6b448
2019-01-24 15:25:17 +01:00
Andrew Chow 2bc4c3eaf9 Notify the GUI that the keypool has changed to set the receive button
Whenever the keypool changes (new keys generated, new seed set,
keypool runs out, etc.), notify the GUI that the keypool has changed. The
receive button can then be enabled and disabled as necessary.
2019-01-23 15:18:03 -05:00
Chun Kuan Lee d8a2992067 windows: Call SetProcessDEPPolicy directly 2019-01-23 21:37:44 +08:00
Chun Kuan Lee 1bd9ffdd44 windows: Set _WIN32_WINNT to 0x0601 (Windows 7)
Also remove all defines in many places and define it in configure stage to keep consistency.
2019-01-23 16:28:27 +08:00
Jonas Schnelli 82cf6813a4
Merge #14353: REST: add blockhash call, fetch blockhash by height
42ff30ec6 [Docs] add short documentation for /rest/blockhashbyheight (Jonas Schnelli)
579d418f7 [QA] add rest tests for /rest/blockhashbyheight/<HEIGHT>.<FORMAT> (Jonas Schnelli)
eb9ef04c4 REST: add "blockhashbyheight" call, fetch blockhash by height (Jonas Schnelli)

Pull request description:

  Completes the REST interface for trivial block exploring by adding a call that allows to fetch the blockhash in the main chain by a given height.

Tree-SHA512: 94be9e56718f857279b11cc16dfa8d04f3b5a762e87ae54281b4d87247c71c844895f4944d5a47f09056bf851f4c4761ac4fbdbaaee957265d14de5c1c73e8d2
2019-01-22 19:59:02 -10:00
Wladimir J. van der Laan 94167e2b5b
Merge #15208: Qt: remove macOS launch-at-startup when compiled with > macOS 10.11, fix memory missmanagement
da6011826a Fix macOS launch-at-startup memory issue (Jonas Schnelli)
516437a1b7 Qt: remove macOS launch-at-startup option when compiled with > macOS 10.11 (Jonas Schnelli)

Pull request description:

  The launch-at-startup API Bitcoin Core uses on macOS where removed in macOS 10.11 leading to a segmentation-fault due to the weak-linking when not actively compiled against SDK 10.11 (`-mmacosx-version-min=10.11`)

  This PR removes the launch-at-startup feature on macOS when compiled with macOS min version > 10.11 (the default is always the macOS version you compile on).

  **The depends built binaries (Gitian) are not affected since we are building with min macOS 10.10.**

  Users self compiling on macOS > 10.11 can re-enable the feature by compiling with min version <= 10.11 (`CXXFLAGS="-mmacosx-version-min=10.11" CFLAGS="-mmacosx-version-min=10.11" ./configure`)

  **Isn't there a new API from Apple?**
  Yes, [there is](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLoginItems.html).
  It will require to create a helper application which needs to be embedded in the .app folder (needs code signing as well). Developers willing to go down that rabbit hole are welcome.

  Fixes #15142

Tree-SHA512: fa9cc4e39d5a2d2559919b7e22b7766f5e0269a361719294d4a4a2df2fd9d955e5b23b5907e68023fdeee297f652f844f3c447904bf18f9c1145348ad101c432
2019-01-22 22:53:17 +01:00
Gregory Maxwell 0297be61ac Allow connections from misbehavior banned peers.
This allows incoming connections from peers which are only banned
 due to an automatic misbehavior ban if doing so won't fill inbound.

These peers are preferred for eviction when inbound fills, but may
 still be kept if they fall into the protected classes.  This
 eviction preference lasts the entire life of the connection even
 if the ban expires.

If they misbehave again they'll still get disconnected.

The main purpose of banning on misbehavior is to prevent our
 connections from being wasted on unhelpful peers such as ones
 running incompatible consensus rules.  For inbound peers this
 can be better accomplished with eviction preferences.

A secondary purpose was to reduce resource waste from repeated
 abuse but virtually any attacker can get a nearly unlimited
 supply of addresses, so disconnection is about the best we can
 do.
2019-01-22 21:10:48 +00:00
Suhas Daftuar a36d97d866 Default -whitelistforcerelay to off 2019-01-22 12:18:45 -05:00
Jonas Schnelli da6011826a
Fix macOS launch-at-startup memory issue 2019-01-21 22:43:03 -10:00
Jonas Schnelli 516437a1b7
Qt: remove macOS launch-at-startup option when compiled with > macOS 10.11 2019-01-21 22:42:51 -10:00
Andrew Chow 14bcdbe09c Check for more than private keys disabled to show receive button 2019-01-21 19:39:01 -05:00
Jonas Schnelli eb9ef04c4e
REST: add "blockhashbyheight" call, fetch blockhash by height 2019-01-21 11:54:54 -10:00
Wladimir J. van der Laan f0c9e1c22b
Merge #14906: refactor: Make explicit CMutableTransaction -> CTransaction conversion.
b301950df3  Made expicit constructor CTransaction(const CMutableTransaction &tx). (lucash-dev)
faf29dd019  Minimal changes to comply with explicit CMutableTransaction -> CTranaction conversion. (lucash-dev)

Pull request description:

  This PR is re-submission of #14156, which was automatically closed by github (glitch?)

  Original description:

  This PR makes explicit the now implicit conversion constructor `CTransaction(const CMutableTransaction&)` in `transaction.h`.
  Minimal changes were made elsewhere to make the code compilable. I'll follow up with other PRs to address individually refactoring functions that should have a `CMutableTransaction` version, or where a `CTransaction` should be reused.

  The rationale for this change is:

   - Conversion constructors should not be explicit unless there's a strong reason for it (in the opinion of, for example, https://google.github.io/styleguide/cppguide.html, and https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Ro-conversion. Let me know your take on this).
   - This particular conversion is very costly -- it implies a serialization plus hash of the transaction.
   - Even though `CTransaction` and `CMutableTransaction` represent the same data, they have very different use cases and performance properties.
   - Making it explicit allows for easier reasoning of performance trade-offs.
   - There has been previous performance issues caused by unneeded use of this implicit conversion.
   - This PR creates a map for places to look for possible refactoring and performance gains (this benefit still holds if the PR is not merged).

Tree-SHA512: 2427462e7211b5ffc7299dae17339d27f8c43266e0895690fda49a83c72751bd2489d4471b3993075a18f3fef25d741243e5010b2f49aeef4a9688b30b6d0631
2019-01-21 20:28:56 +01:00
Wladimir J. van der Laan 6e6b3b944d
Merge #14955: Switch all RNG code to the built-in PRNG
223de8d94d Document RNG design in random.h (Pieter Wuille)
f2e60ca985 Use secure allocator for RNG state (Pieter Wuille)
cddb31bb0a Encapsulate RNGState better (Pieter Wuille)
152146e782 DRY: Implement GetRand using FastRandomContext::randrange (Pieter Wuille)
a1f252eda8 Sprinkle some sweet noexcepts over the RNG code (Pieter Wuille)
4ea8e50837 Remove hwrand_initialized. (Pieter Wuille)
9d7032e4f0 Switch all RNG code to the built-in PRNG. (Pieter Wuille)
16e40a8b56 Integrate util/system's CInit into RNGState (Pieter Wuille)
2ccc3d3aa3 Abstract out seeding/extracting entropy into RNGState::MixExtract (Pieter Wuille)
aae8b9bf0f Add thread safety annotations to RNG state (Pieter Wuille)
d3f54d1c82 Rename some hardware RNG related functions (Pieter Wuille)
05fde14e3a Automatically initialize RNG on first use. (Pieter Wuille)
2d1cc50939 Don't log RandAddSeedPerfmon details (Pieter Wuille)
6a57ca91da Use FRC::randbytes instead of reading >32 bytes from RNG (Pieter Wuille)

Pull request description:

  This does not remove OpenSSL, but makes our own PRNG the 'main' one; for GetStrongRandBytes, the OpenSSL RNG is still used (indirectly, by feeding its output into our PRNG state).

  It includes a few policy changes (regarding what entropy is seeded when).

  Before this PR:
  * GetRand*:
    * OpenSSL
  * GetStrongRand*:
    * CPU cycle counter
    * Perfmon data (on Windows, once 10 min)
    * /dev/urandom (or equivalent)
    * rdrand (if available)
  * From scheduler when idle:
    * CPU cycle counter before and after 1ms sleep
  * At startup:
    * CPU cycle counter before and after 1ms sleep

  After this PR:
  * GetRand*:
    * Stack pointer (which indirectly identifies thread and some call stack information)
    * rdrand (if available)
    * CPU cycle counter
  * GetStrongRand*:
    * Stack pointer (which indirectly identifies thread and some call stack information)
    * rdrand (if available)
    * CPU cycle counter
    * /dev/urandom (or equivalent)
    * OpenSSL
    * CPU cycle counter again
  * From scheduler when idle:
    * Stack pointer (which indirectly identifies thread and some call stack information)
    * rdrand (if available)
    * CPU cycle counter before and after 1ms sleep
    * Perfmon data (on Windows, once every 10 min)
  * At startup:
    * Stack pointer (which indirectly identifies thread and some call stack information)
    * rdrand (if available)
    * CPU cycle counter
    * /dev/urandom (or equivalent)
    * OpenSSL
    * CPU cycle counter again
    * Perfmon data (on Windows, once every 10 min)

  The interface of random.h is also simplified, and documentation is added.

  This implements most of #14623.

Tree-SHA512: 0120e19bd4ce80a509b5c180a4f29497d299ce8242e25755880851344b825bc2d64a222bc245e659562fb5463fb7c70fbfcf003616be4dc59d0ed6534f93dd20
2019-01-21 19:46:45 +01:00
Wladimir J. van der Laan ace87ea2b0
Merge #14970: [net] add dnsseed.emzy.de to DNS seeds
de7266fc3c [net] add dnsseed.emzy.de to DNS seeds (Stephan Oeste)

Pull request description:

  ACK https://github.com/bitcoin/bitcoin/blob/master/doc/dnsseed-policy.md

  I'm willing to keep it up and running, unless something bad happens.
  I have 15+ years experience running dns servers.

  About my setup:

  - the server may change over time, but the service will be up all the time
  - running [sipa/bitcoin-seeder](https://github.com/sipa/bitcoin-seeder) with default settings (and the non-root port redirect)

Tree-SHA512: 7abc975c148cc738d045c79d5bdb8d9926da41bb8dde66c21e954652b3c72a7aa2526af0c3c4fb8c234d3deaed5563542defe8a5137188d65ad7201b6b1d80eb
2019-01-21 19:16:45 +01:00
Wladimir J. van der Laan 5baa9092c4
Merge #14605: Return of the Banman
18185b57c3 scripted-diff: batch-recase BanMan variables (Carl Dong)
c2e04d37f3 banman: Add, use CBanEntry ctor that takes ban reason (Carl Dong)
1ffa4ce27d banman: reformulate nBanUtil calculation (Carl Dong)
daae598feb banman: add thread annotations and mark members const where possible (Cory Fields)
84fc3fbd03 scripted-diff: batch-rename BanMan members (Cory Fields)
af3503d903 net: move BanMan to its own files (Cory Fields)
d0469b2e93 banman: pass in default ban time as a parameter (Cory Fields)
2e56702ece banman: pass the banfile path in (Cory Fields)
4c0d961eb0 banman: create and split out banman (Cory Fields)
83c1ea2e5e net: split up addresses/ban dumps in preparation for moving them (Cory Fields)
136bd7926c tests: remove member connman/peerLogic in TestingSetup (Cory Fields)
7cc2b9f678 net: Break disconnecting out of Ban() (Cory Fields)

Pull request description:

  **Old English à la Beowulf**
  ```
  Banman wæs bréme    --blaéd wíde sprang--
  Connmanes eafera    Coreum in.
  aéglaéca            léodum forstandan
  Swá bealdode        bearn Connmanes
  guma gúðum cúð      gódum daédum·
  dréah æfter dóme·   nealles druncne slóg
  ```

  **Modern English Translation**
  ```
  Banman was famed              --his renown spread wide--
  Conman's hier,                in Core-land.
  against the evil creature     defend the people
  Thus he was bold,             the son of Connman
  man famed in war,             for good deeds;
  he led his life for glory,    never, having drunk, slew
  ```

  --

  With @theuni's blessing, here is Banman, rebased. Original PR: https://github.com/bitcoin/bitcoin/pull/11457

  --

  Followup PRs:
  1. Give `CNode` a `Disconnect` method ([source](https://github.com/bitcoin/bitcoin/pull/14605#discussion_r248065847))
  2. Add a comment to `std::atomic_bool fDisconnect` in `net.h` that setting this to true will cause the node to be disconnected the next time `DisconnectNodes()` runs ([source](https://github.com/bitcoin/bitcoin/pull/14605#discussion_r248384309))

Tree-SHA512: 9c207edbf577415c22c9811113e393322d936a843d4ff265186728152a67c057779ac4d4f27b895de9729f7a53e870f828b9ebc8bcdab757520c2aebe1e9be35
2019-01-21 18:58:52 +01:00
Wladimir J. van der Laan 0f1576ab32
Merge #15167: qt: Fix wallet selector size adjustment
ca91661adf Fix wallet selector size adjustment (Hennadii Stepanov)

Pull request description:

  This PR sets `QComboBox::AdjustToContents` instead of default `QComboBox::AdjustToContentsOnFirstShow` for wallet selectors.

  Before (in master):
  ![screenshot from 2019-01-14 20-47-22](https://user-images.githubusercontent.com/32963518/51133771-83d00d80-183e-11e9-812c-3a1119fa766e.png)

  After (with this PR):
  ![screenshot from 2019-01-14 20-48-43](https://user-images.githubusercontent.com/32963518/51133788-90546600-183e-11e9-8394-eb62a998b90f.png)

Tree-SHA512: c23ac91905bb31aaa32f2fccc02b01f5707d8b094020fe6a75a9e099e78f9191670474920234a01c46480f67d3d311f44ff46f1f4202cd50a4a6d4d09a8342ce
2019-01-21 17:40:33 +01:00
Wladimir J. van der Laan 6be52d6f7e
Merge #15213: doc: Remove errant paste from walletcreatefundedpsbt for nLocktime replaceable
85f0ca95f3 Remove errant past from walletcreatefundedpsbt for nLocktime replaceability (Gregory Sanders)

Pull request description:

  nLockTime has no bearing on bip125

Tree-SHA512: cb123242ee7e1eeff10dbfcab8e57f9aa88590e2da6794343a90a18472a97f23ce7c6bbc55b88163e007fe38c5d8ee5b749cc4ce2bf145f560e084d61b568159
2019-01-21 17:26:30 +01:00
Wladimir J. van der Laan 1522079d54
Merge #15209: zmq: log outbound message high water mark when reusing socket
f1dc6932e9 zmq: log outbound message high water mark when reusing socket (fanquake)

Pull request description:

  Running master with `src/bitcoind -zmqpubhashblockhwm=12345 -zmqpubrawtx=tcp://127.0.0.1:28332 -zmqpubhashtxhwm=5000 -zmqpubrawblock=tcp://127.0.0.1:28332 -zmqpubhashtx=tcp://127.0.0.1:28332 -zmqpubhashblock=tcp://127.0.0.1:28332 -debug=zmq`:
  ```
  2019-01-19T14:11:01Z zmq: version 4.3.1
  2019-01-19T14:11:01Z zmq: Initialize notification interface
  2019-01-19T14:11:01Z zmq: Outbound message high water mark for pubhashblock at tcp://127.0.0.1:28332 is 12345
  2019-01-19T14:11:01Z zmq: Notifier pubhashblock ready (address = tcp://127.0.0.1:28332)
  2019-01-19T14:11:01Z zmq: Reusing socket for address tcp://127.0.0.1:28332
  2019-01-19T14:11:01Z zmq: Notifier pubhashtx ready (address = tcp://127.0.0.1:28332)
  2019-01-19T14:11:01Z zmq: Reusing socket for address tcp://127.0.0.1:28332
  2019-01-19T14:11:01Z zmq: Notifier pubrawblock ready (address = tcp://127.0.0.1:28332)
  2019-01-19T14:11:01Z zmq: Reusing socket for address tcp://127.0.0.1:28332
  2019-01-19T14:11:01Z zmq: Notifier pubrawtx ready (address = tcp://127.0.0.1:28332)
  ```

  This PR:
  ```
  2019-01-19T14:06:57Z zmq: version 4.3.1
  2019-01-19T14:06:57Z zmq: Initialize notification interface
  2019-01-19T14:06:57Z zmq: Outbound message high water mark for pubhashblock at tcp://127.0.0.1:28332 is 12345
  2019-01-19T14:06:57Z zmq: Notifier pubhashblock ready (address = tcp://127.0.0.1:28332)
  2019-01-19T14:06:57Z zmq: Reusing socket for address tcp://127.0.0.1:28332
  2019-01-19T14:06:57Z zmq: Outbound message high water mark for pubhashtx at tcp://127.0.0.1:28332 is 5000
  2019-01-19T14:06:57Z zmq: Notifier pubhashtx ready (address = tcp://127.0.0.1:28332)
  2019-01-19T14:06:57Z zmq: Reusing socket for address tcp://127.0.0.1:28332
  2019-01-19T14:06:57Z zmq: Outbound message high water mark for pubrawblock at tcp://127.0.0.1:28332 is 1000
  2019-01-19T14:06:57Z zmq: Notifier pubrawblock ready (address = tcp://127.0.0.1:28332)
  2019-01-19T14:06:57Z zmq: Reusing socket for address tcp://127.0.0.1:28332
  2019-01-19T14:06:57Z zmq: Outbound message high water mark for pubrawtx at tcp://127.0.0.1:28332 is 1000
  2019-01-19T14:06:57Z zmq: Notifier pubrawtx ready (address = tcp://127.0.0.1:28332)
  ```

Tree-SHA512: 6915184d8a0f4764f1cc76dce0099eed411a123d7a4bc8cee1664bb5a233a8119ddd2c78ad980c6e1d9f6dadaba48800ee6bc57de906d4e1b4108df745f1458e
2019-01-21 17:20:32 +01:00
Wladimir J. van der Laan 7455ca2ae6
Merge #15210: gui: Fix window title update
1ed425ea17 gui: Fix window title update (João Barbosa)

Pull request description:

  Removes trailing `-` from window title when running on mainnet.

  Reported by @Sjors in https://github.com/bitcoin/bitcoin/pull/15149#issuecomment-455787938.

Tree-SHA512: 22f13c361496720f30a4926d928851ed74456c0d70bd313b0ebaca91a9ebfde96991091ac3d1b094f33d3ce9afafd709eb1917f00d96fa3ca69751b6b14e1d2b
2019-01-21 16:49:27 +01:00
Wladimir J. van der Laan 978682b9dc
Merge #15194: Add comment describing fDisconnect behavior
5b4283cb81 Add comment describing fDisconnect behavior (Carl Dong)

Pull request description:

  Motivated by @Sjors here: https://github.com/bitcoin/bitcoin/pull/14605#discussion_r248384309

Tree-SHA512: 8fc52eb4d3b5651c19c49b47fad75e8fb939cf524ada647e88d8d5aad7726052d94e500c1ebdb2a41b67bc4669ee61ff151a5cff81a52c68c900da562ef21751
2019-01-20 16:11:41 +01:00
Gregory Sanders 85f0ca95f3 Remove errant past from walletcreatefundedpsbt for nLocktime replaceability 2019-01-19 22:32:59 -05:00
João Barbosa 1ed425ea17 gui: Fix window title update 2019-01-19 21:17:51 +00:00
practicalswift eea02be70e Add locking annotation for vNodes. vNodes is guarded by cs_vNodes. 2019-01-19 18:23:53 +01:00
fanquake f1dc6932e9
zmq: log outbound message high water mark when reusing socket 2019-01-19 22:06:14 +08:00
Wladimir J. van der Laan fe60ee96e9
Merge #15186: rpc: remove duplicate solvable field from getaddressinfo
a2a6c8f453 rpc: remove duplicate solvable field from getaddressinfo (fanquake)

Pull request description:

  Also added optional to `iscompressed`.

Tree-SHA512: 28442a9dbfb2a9992b9b57142fa13d374d39444f04ae63460cb6330d896160cfd4b9651a3e231893eac3142ce55eff597a54cbafd3b57ffa46d3711c64044acb
2019-01-19 14:52:33 +01:00
Wladimir J. van der Laan 3b59fa2ce8
Merge #15178: qt: Improve "help-console" message
979bc0c206 Improve "help-console" message (Hennadii Stepanov)

Pull request description:

  Added a note that results can be queried in the parenthesized syntax as it does not work in the standard syntax.

  Deprecated (since #8704) boolean `verbose` replaced with numerical `verbosity` in `getblock` examples.

  Current master (acec9e45c6):
  ![screenshot from 2019-01-16 13-40-10](https://user-images.githubusercontent.com/32963518/51248127-d96bfd80-1997-11e9-83d3-47cf157e2f8d.png)

  Master + this PR:
  ![screenshot from 2019-01-16 14-00-39](https://user-images.githubusercontent.com/32963518/51248137-e852b000-1997-11e9-94dc-e9c949690beb.png)

Tree-SHA512: 663e359ed117306f789fdefcae298194fdd6f5477c87912740e1683323974a333dcca13f17bb2c0aa66639ab7658bd53e535ae8fe671ea5fc557a3db4b192908
2019-01-19 14:50:31 +01:00
Jonas Schnelli 63144335be
Merge #15101: gui: Add WalletController
0dd9bdefa gui: Refactor to use WalletController (João Barbosa)
8fa271f08 gui: Add WalletController (João Barbosa)
cefb399e2 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa)

Pull request description:

  This PR is a subset of the work done in the context of #13100. This change consists in extracting from the application class the code that manages the wallet models.

  The role of the `WalletController` instance is to coordinate wallet operations and the window.

Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
2019-01-18 10:21:08 -10:00
fanquake a2a6c8f453
rpc: remove duplicate solvable field from getaddressinfo 2019-01-18 13:59:11 +08:00
João Barbosa 0dd9bdefa1 gui: Refactor to use WalletController 2019-01-18 00:34:51 +00:00
João Barbosa 8fa271f089 gui: Add WalletController 2019-01-18 00:34:47 +00:00
João Barbosa cefb399e21 gui: Use AutoConnection for WalletModel::unload signal 2019-01-18 00:27:34 +00:00
Carl Dong 5b4283cb81 Add comment describing fDisconnect behavior 2019-01-17 18:27:13 -05:00
Jonas Schnelli cd42553b11
Merge #15040: qt: Add workaround for QProgressDialog bug on macOS
7c572c488 Add workaround for QProgressDialog bug on macOS (Hennadii Stepanov)

Pull request description:

  Fix #15016.

  Refs:
  - [QTBUG-65750: QProgressDialog too small width at larger font size on Mac](https://bugreports.qt.io/browse/QTBUG-65750)
  - [QTBUG-70357: QProgressDialog is too narrow to fit the text of its label](https://bugreports.qt.io/browse/QTBUG-70357)

  With this PR:
  ![screenshot from 2018-12-26 22-01-30](https://user-images.githubusercontent.com/32963518/50456571-1aa35b80-095e-11e9-8442-c285555f2bee.png)

Tree-SHA512: dde668dfa7d2144973c0e868aea7fdb7d90f78584836d024ffefb8df4a709d6842fa3601954759b4462856a80e81df15b861ea39506599230a16928b621d9f8f
2019-01-17 11:17:06 -10:00
Wladimir J. van der Laan 7ee604487f
Merge #14250: qt: Remove redundant stopThread() and stopExecutor() signals
24313fbf7e Remove redundant stopExecutor() signal (Hennadii Stepanov)
1c0e0a5e38 Remove redundant stopThread() signal (Hennadii Stepanov)

Pull request description:

  The `QThread::finished` signal do this work.

Tree-SHA512: 1afce23d30232276d50c3af5af79d83b88e390a2b71f7df585cc1079585d330447d179bbc34c0a89599beb2da035dfd5b9ce23238171490825cabc3a19ae6e67
2019-01-17 14:40:26 +01:00
Pieter Wuille 223de8d94d Document RNG design in random.h 2019-01-16 16:35:54 -08:00
Pieter Wuille f2e60ca985 Use secure allocator for RNG state 2019-01-16 16:34:57 -08:00
Pieter Wuille cddb31bb0a Encapsulate RNGState better 2019-01-16 16:34:57 -08:00
Pieter Wuille 152146e782 DRY: Implement GetRand using FastRandomContext::randrange 2019-01-16 16:34:57 -08:00
Pieter Wuille a1f252eda8 Sprinkle some sweet noexcepts over the RNG code 2019-01-16 16:34:56 -08:00
Pieter Wuille 4ea8e50837 Remove hwrand_initialized.
All access to hwrand is now gated by GetRNGState, which initializes the hwrand code.
2019-01-16 16:34:56 -08:00
Pieter Wuille 9d7032e4f0 Switch all RNG code to the built-in PRNG.
It includes the following policy changes:
* All GetRand* functions seed the stack pointer and rdrand result
  (in addition to the performance counter)
* The periodic entropy added by the idle scheduler now seeds stack pointer,
  rdrand and perfmon data (once every 10 minutes) in addition to
  just a sleep timing.
* The entropy added when calling GetStrongRandBytes no longer includes
  the once-per-10-minutes perfmon data on windows (it is moved to the
  idle scheduler instead, where latency matters less).

Other changes:
* OpenSSL is no longer seeded directly anywhere. Instead, any generated
  randomness through our own RNG is fed back to OpenSSL (after an
  additional hashing step to prevent leaking our RNG state).
* Seeding that was previously done directly in RandAddSeedSleep is now
  moved to SeedSleep(), which is indirectly invoked through ProcRand
  from RandAddSeedSleep.
* Seeding that was previously done directly in GetStrongRandBytes()
  is now moved to SeedSlow(), which is indirectly invoked through
  ProcRand from GetStrongRandBytes().
2019-01-16 16:34:56 -08:00
Pieter Wuille 16e40a8b56 Integrate util/system's CInit into RNGState
This guarantees that OpenSSL is initialized properly whenever randomness
is used, even when that randomness is invoked from global constructors.

Note that this patch uses Mutex directly, rather than CCriticalSection.
This is because the lock-detection code is not necessarily initialized
during global constructors.
2019-01-16 16:33:08 -08:00
Pieter Wuille 2ccc3d3aa3 Abstract out seeding/extracting entropy into RNGState::MixExtract 2019-01-16 16:31:37 -08:00
Pieter Wuille aae8b9bf0f Add thread safety annotations to RNG state 2019-01-16 16:31:34 -08:00
Pieter Wuille d3f54d1c82 Rename some hardware RNG related functions 2019-01-16 15:46:31 -08:00
Pieter Wuille 05fde14e3a Automatically initialize RNG on first use. 2019-01-16 15:46:27 -08:00
Pieter Wuille 2d1cc50939 Don't log RandAddSeedPerfmon details
These are hard to deal with, as in a follow-up this function can get
called before the logging infrastructure is initialized.
2019-01-16 15:08:03 -08:00
Carl Dong 18185b57c3 scripted-diff: batch-recase BanMan variables
-BEGIN VERIFY SCRIPT-
sed -i "s/banMap/banmap/g" src/banman.h src/banman.cpp
sed -i "s/netAddr/net_addr/g" src/banman.h src/banman.cpp
sed -i "s/sinceUnixEpoch/since_unix_epoch/g" src/banman.h src/banman.cpp
sed -i "s/bantimeoffset/ban_time_offset/g" src/banman.h src/banman.cpp
sed -i "s/subNet/sub_net/g" src/banman.h src/banman.cpp
sed -i "s/banReason/ban_reason/g" src/banman.h src/banman.cpp
sed -i "s/notifyUI/notify_ui/g" src/banman.h src/banman.cpp
sed -i "s/banEntry/ban_entry/g" src/banman.h src/banman.cpp
sed -i "s/nStart/n_start/g" src/banman.h src/banman.cpp
-END VERIFY SCRIPT-
2019-01-16 13:54:18 -05:00
Carl Dong c2e04d37f3 banman: Add, use CBanEntry ctor that takes ban reason 2019-01-16 13:54:18 -05:00
Carl Dong 1ffa4ce27d banman: reformulate nBanUtil calculation
Avoid reassigning parameters.
2019-01-16 13:54:18 -05:00
Cory Fields daae598feb banman: add thread annotations and mark members const where possible
Also remove misleading comment. ClearBanned is used by rpc as well.
2019-01-16 13:54:18 -05:00
Cory Fields 84fc3fbd03 scripted-diff: batch-rename BanMan members
-BEGIN VERIFY SCRIPT-
sed -i "s/clientInterface/m_client_interface/g" src/banman.h src/banman.cpp
sed -i "s/setBannedIsDirty/m_is_dirty/g" src/banman.h src/banman.cpp
sed -i "s/cs_setBanned/m_cs_banned/g" src/banman.h src/banman.cpp
sed -i "s/setBanned/m_banned/g" src/banman.h src/banman.cpp
-END VERIFY SCRIPT-
2019-01-16 13:54:18 -05:00
Cory Fields af3503d903 net: move BanMan to its own files 2019-01-16 13:54:18 -05:00
Cory Fields d0469b2e93 banman: pass in default ban time as a parameter
Removes the dependency on arg parsing.
2019-01-16 13:54:18 -05:00
Cory Fields 2e56702ece banman: pass the banfile path in
There's no need to hard-code the path here. Passing it in means that there are
no ordering concerns wrt establishing the datadir.
2019-01-16 13:54:18 -05:00
Cory Fields 4c0d961eb0 banman: create and split out banman
Some say he has always been.
2019-01-16 13:54:18 -05:00
Cory Fields 83c1ea2e5e net: split up addresses/ban dumps in preparation for moving them 2019-01-16 13:54:18 -05:00
Wladimir J. van der Laan fcb6694a99
Merge #14839: [rebase] threads: fix unitialized members in sched_param
89282379ba threads: fix unitialized members in sched_param (Cory Fields)

Pull request description:

  Rebased theuni's #14342.

  Building with gcc 8.2 against musl libc, which apparently has more attributes available in its sched_param. The following warnings were produced:

      warning: missing initializer for member 'sched_param::sched_ss_low_priority' [-Wmissing-field-initializers]
      warning: missing initializer for member 'sched_param::sched_ss_repl_period' [-Wmissing-field-initializers]
      warning: missing initializer for member 'sched_param::sched_ss_init_budget' [-Wmissing-field-initializers]
      warning: missing initializer for member 'sched_param::sched_ss_max_repl' [-Wmissing-field-initializers]

  Since the current thread may have interesting non-zero values for these fields, we want to be sure to only change the intended one. Query and modify the current sched_param rather than starting from a zeroed one.

Tree-SHA512: a0bedbcf0130b3ee8261bb704e4bf6c9b760ad377c8a28c258765d54e54462b76707efc188b936b0a635cdd2bdf6b3b9298ab06ba361dc4806150b670d9702a3
2019-01-16 17:09:12 +01:00
Cory Fields 136bd7926c tests: remove member connman/peerLogic in TestingSetup 2019-01-16 11:04:14 -05:00
Cory Fields 7cc2b9f678 net: Break disconnecting out of Ban()
These are separate events which need to be carried out by separate subsystems.

This also cleans up some whitespace and tabs in qt to avoid getting flagged by
the linter.

Current behavior is preserved.
2019-01-16 11:04:05 -05:00
Wladimir J. van der Laan f71c2ea662
Merge #15122: [RPC] Expand help text for importmulti changes
b745e149c2 [docs] Expand help text for importmulti changes (John Newbery)

Pull request description:

  Expands the RPC help text for changes to the importmulti RPC method.

Tree-SHA512: e90e5abf66bba3863e7519b5f79c26d18a4d624e6e7878293bdd4ebb57f1a01c67de52e4a5621901a8cb87fb3516264b3b1a826997c7c3c17b11216f1f1a3db0
2019-01-16 16:15:17 +01:00
Wladimir J. van der Laan d44b01f028
Merge #14268: Introduce SafeDbt to handle Dbt with free or memory_cleanse raii-style
4a86a0acd9 Make SafeDbt DB_DBT_MALLOC on default initialization (Ben Woosley)
1a9f9f7e5e Introduce SafeDbt to handle DB_DBT_MALLOC raii-style (Ben Woosley)
951a44e9cd Drop unused setRange arg to BerkeleyBatch::ReadAtCursor (Ben Woosley)

Pull request description:

  This provides additional exception-safety and case handling for the proper
  freeing of the associated buffers.

Tree-SHA512: a038d728290cdb3905e7d881608052a6675b6425729ceaf7cfe69a6e91c2ee293cdb01e4b695a20963459ffdd9d4a1f9a08b3c07b1b5ba1aa8590a8149f686db
2019-01-16 14:56:21 +01:00
Wladimir J. van der Laan 19c60ca497
Merge #14151: windows: Fix remaining compiler warnings (MSVC)
b9dafe7d9f Fix remaining compiler warnings (MSVC). Move disabling of specific warnings from /nowarn to project file. (practicalswift)

Pull request description:

  Fix remaining compiler warnings (MSVC).

  Before:

  ```
  $ msbuild /p:TrackFileAccess=false /p:CLToolExe=clcache.exe build_msvc\bitcoin.sln /m /v:q /nowarn:C4244;C4267;C4715 /nologo
  …\script\script.cpp(272): warning C4018: '>': signed/unsigned mismatch
  …\test\allocator_tests.cpp(147): warning C4312: 'reinterpret_cast': conversion from 'int' to 'void *' of greater size
  …\boost\test\tools\old\impl.hpp(107): warning C4805: '==': unsafe mix of type 'const Left' and type 'const Right' in operation
  …\test\crypto_tests.cpp(535): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
  …\test\script_tests.cpp(188): warning C4805: '==': unsafe mix of type 'int' and type 'bool' in operation
  …\test\script_tests.cpp(190): warning C4805: '==': unsafe mix of type 'int' and type 'bool' in operation
  …\test\script_tests.cpp(191): warning C4805: '==': unsafe mix of type 'int' and type 'bool' in operation
  $
  ```

  After:

  ```
  $ msbuild /p:TrackFileAccess=false /p:CLToolExe=clcache.exe build_msvc\bitcoin.sln /m /v:q /nowarn:C4244;C4267;C4715;C4805 /nologo
  $
  ```

Tree-SHA512: 5b30334d3804e869779e77dad75a799e8e5e7eb2e08634cd40035cce140edd623cbb6c8b5806d2158c3df97888d3ea9ff4b8b6a5a83de3fe2cb361e29588c115
2019-01-16 13:50:37 +01:00
Wladimir J. van der Laan 64ee94356f
Merge #14409: utils and libraries: Make 'blocksdir' always net specific
e4a0c3547e Improve blocksdir functional test. (Hennadii Stepanov)
c3f1821ac7 Make blockdir always net specific (Hennadii Stepanov)

Pull request description:

  The blocks directory is net specific by definition.

  Also this prevents the side effect of calling `GetBlocksDir(false)` in the non-mainnet environment.
  Currently a new node creates an unused `blocks\` directory in the root of the data directory when `-testnet` or `-regtest` is specified.

  Refs:
  - #12653
  - https://github.com/bitcoin/bitcoin/pull/12653#discussion_r174784834 by @laanwj
  - https://github.com/bitcoin/bitcoin/issues/14595#issuecomment-436011186

Tree-SHA512: c9957a68a4a200ebd2010823a56db7e61563afedcb7c9828e86b13f3af2990e07854b622c1f3374756f94574acb3ea32de7d2a399eef6c0623f0e11265155627
2019-01-16 13:40:27 +01:00
Hennadii Stepanov 979bc0c206
Improve "help-console" message
Added a note that results can be queried in the parenthesized syntax.
Deprecated boolean `verbose` replaced with numerical `verbosity` in
`getblock` examples.
2019-01-16 13:50:06 +02:00
Wladimir J. van der Laan acec9e45c6
Merge #15136: qt: "Peers" tab overhaul
3537c8345c Do not deselect peer when switching away from tab (Hennadii Stepanov)
b0037c5190 Improve Peers tab layout (Hennadii Stepanov)

Pull request description:

  This is an alternative to #14798.

  The "Peers" tab of the "Debug" window improved to address comments https://github.com/bitcoin/bitcoin/pull/6209#issuecomment-108072605 (by @jonasschnelli) and https://github.com/bitcoin/bitcoin/pull/14798#issuecomment-441618268 (by @promag).

  This allows to keep the peer selection while navigating to other places and effectively reverts e059726811.

  Screenshots with this PR:
  ![screenshot from 2019-01-09 22-01-36](https://user-images.githubusercontent.com/32963518/50927352-2e6fb700-1460-11e9-9173-582348210492.png)
  ![screenshot from 2019-01-09 22-02-11](https://user-images.githubusercontent.com/32963518/50927354-329bd480-1460-11e9-9926-d0eb0f026a35.png)
  ![screenshot from 2019-01-09 22-02-37](https://user-images.githubusercontent.com/32963518/50927358-3596c500-1460-11e9-864d-c8704451f3d9.png)

Tree-SHA512: 3d086007f6d72930bc2fc3c395175adda0f1a7722de3842bc246ee4f3bfc5ebda4b9a626fb68a7ee8663a88d0842deb37c0c460ad84cc58e22f138acf8bc71ea
2019-01-16 12:38:27 +01:00
John Newbery b745e149c2 [docs] Expand help text for importmulti changes 2019-01-15 17:24:46 -05:00
practicalswift b9dafe7d9f Fix remaining compiler warnings (MSVC). Move disabling of specific warnings from /nowarn to project file. 2019-01-15 20:15:26 +01:00
Jonas Schnelli c7c84209bb
Merge #15149: gui: Show current wallet name in window title
fe7048b39 gui: Show current wallet name in window title (João Barbosa)
8a7926112 gui: Keep network style in BitcoinGUI (João Barbosa)
f411c8b35 gui: Remove unused return type in some BitcoinGUI methods (João Barbosa)

Pull request description:

  <img width="876" alt="screenshot 2019-01-11 at 23 58 26" src="https://user-images.githubusercontent.com/3534524/51065458-d7ebaf80-15fc-11e9-9162-e37e9a10d448.png">

Tree-SHA512: 5c43f615834983bc1c5045e07c6e119044dd78ca947fd2679d302b519d5ce1d08d29ca00b1c11e88c4bbc4d56f2e6f4a8adc42084f3503e751e642e8a13112dc
2019-01-15 09:01:53 -10:00
MarcoFalke 82ffd4d918
Merge #14963: mempool, validation: Explain cs_main locking semantics
fa5e373365 validation: Add cs_main locking annotations (MarcoFalke)
fa5c346c5a doc: Add comment to cs_main and mempool::cs (MarcoFalke)
fafe941bdd test: Add missing validation locks (MarcoFalke)
fac4558462 sync: Add RecursiveMutex type alias (MarcoFalke)

Pull request description:

  Both the chain state and the transaction pool are validation specific, but access to them is protected by two locks. The two locks have the following semantics:

  * Writing to the chain state or adding transactions to the transaction pool -> Take both `cs_main` and `mempool::cs`
  * Reading either or removing transactions from the the transaction pool -> Take only the appropriate lock

Tree-SHA512: 6f6e612ffc391904c6434a79a4f3f8de1b928bf0a3e3434b73561037b395e2b40a70a5a4bd8472dd230e9eacc8e5d5374c904a3c509910cf3971dd7ff59a626c
2019-01-15 13:42:05 -05:00
Russell Yanofsky 44de1561aa Remove remaining chainActive references from CWallet
This commit does not change behavior.

Co-authored-by: Ben Woosley <ben.woosley@gmail.com>
2019-01-15 08:42:00 -08:00
Russell Yanofsky db21f02648 Convert CWallet::ScanForWalletTransactions and SyncTransaction to the new Chain apis
Only change in behavior is "Rescan started from block <height>" message
replaced by "Rescan started from block <hash>" message in
ScanForWalletTransactions.

Co-authored-by: Ben Woosley <ben.woosley@gmail.com>
2019-01-15 08:42:00 -08:00
Russell Yanofsky 2ffb07929e Add findFork and findBlock to the Chain interface
And use them to remove uses of chainActive and mapBlockIndex in wallet code

This commit does not change behavior.

Co-authored-by: Ben Woosley <ben.woosley@gmail.com>
2019-01-15 08:42:00 -08:00
Russell Yanofsky d93c4c1d6e Add time methods to the Chain interface
And use them to remove uses of chainActive and mapBlockIndex in wallet code

This commit does not change behavior.

Co-authored-by: Ben Woosley <ben.woosley@gmail.com>
2019-01-15 08:42:00 -08:00
Russell Yanofsky 700c42b85d Add height, depth, and hash methods to the Chain interface
And use them to remove uses of chainActive and mapBlockIndex in wallet code

This commit does not change behavior.

Co-authored-by: Ben Woosley <ben.woosley@gmail.com>
2019-01-15 12:42:00 -04:00
Wladimir J. van der Laan e8ad580f51
Merge #14556: qt: fix confirmed transaction labeled "open" (#13299)
fb3ce75807 Don't label transactions "Open" while catching up (Hennadii Stepanov)

Pull request description:

  Fix #13299.

  Since the default `nSequence` is `0xFFFFFFFE` and locktime is enabled, the checking `wtx.is_final` is meaningless until the syncing has completed (ref: #1026).

  This PR makes the wallet mark a transaction "Unconfirmed" instead of misleading "Open for NNN more blocks" when syncing after a period of being offline.

  Before this PR (with the issue):
  ![screenshot from 2018-12-12 15-56-23](https://user-images.githubusercontent.com/32963518/49874288-cdd06880-fe26-11e8-8441-f3ceb479611b.png)

  With this PR (the issue has been resolved):
  ![screenshot from 2018-12-12 15-54-41](https://user-images.githubusercontent.com/32963518/49874336-e9d40a00-fe26-11e8-8c05-9aeee2eb1bba.png)

Tree-SHA512: 358ec83b43c266a4d32a37a79dda80e80d40a2b77ad38261c84a095e613399f674aa7184805b3f6310e51ddb83ae2636b8849fcc7c4333e1b3ecbb0f70ad86d3
2019-01-15 17:39:19 +01:00
João Barbosa fe7048b39b gui: Show current wallet name in window title 2019-01-15 16:23:55 +00:00
João Barbosa 8a79261124 gui: Keep network style in BitcoinGUI 2019-01-15 16:23:55 +00:00
João Barbosa f411c8b35b gui: Remove unused return type in some BitcoinGUI methods 2019-01-15 14:31:22 +00:00
Wladimir J. van der Laan a5daf70ffb
Merge #14594: qt: Fix minimized window bug on Linux
a88640e123 Fix minimized window bug on Linux (Hennadii Stepanov)

Pull request description:

  Fix #14591

  On some Linux systems the minimized to the taskbar (iconified) main window cannot be restored properly using actions from the systray icon menu when `QSystemTrayIcon::contextMenu()` is a child of the main window.

Tree-SHA512: 05c9f724fc2278d45dac6fe72b09859f12b5d71f54659bb779403c8cd81b55e610fb7b5aa912ac273d3cd19bf953b0405bbc6451feb00d1827c95dd9f0876aa4
2019-01-15 15:27:10 +01:00
Wladimir J. van der Laan 1b6fc30530
Merge #14941: rpc: Make unloadwallet wait for complete wallet unload
645e905c32 doc: Add release notes for unloadwallet change to synchronous call (João Barbosa)
c37851de57 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-15 14:38:23 +01:00
João Barbosa c37851de57 rpc: Make unloadwallet wait for complete wallet unload 2019-01-15 00:01:00 +00:00
Hennadii Stepanov 7c572c488d
Add workaround for QProgressDialog bug on macOS
See: QTBUG-65750, QTBUG-70357.
2019-01-15 01:28:00 +02:00
Hennadii Stepanov ca91661adf
Fix wallet selector size adjustment 2019-01-14 20:49:19 +02:00
Wladimir J. van der Laan cf0c67b62c
Merge #14982: rpc: Add getrpcinfo command
a0ac15459a doc: Add getrpcinfo release notes (João Barbosa)
251a91c1bf qa: Add tests for getrpcinfo (João Barbosa)
d0730f5ce4 rpc: Add getrpcinfo command (João Barbosa)
068a8fc05f rpc: Track active commands (João Barbosa)
bf4383277d rpc: Remove unused PreCommand signal (João Barbosa)

Pull request description:

  The new `getrpcinfo` command exposes details of the RPC interface. The details can be configuration properties or runtime values/stats.

  This can be particular useful to coordinate concurrent functional tests (see #14958 from where this was extracted).

Tree-SHA512: 7292cb6087f4c429973d991aa2b53ffa1327d5a213df7d6ba5fc69b01b2e1a411f6d1609fed9234896293317dab05f65064da48b8f2b4a998eba532591d31882
2019-01-14 18:07:15 +01:00
Wladimir J. van der Laan 76335298f4
Merge #15114: Qt: Replace remaining 0 with nullptr
3a0e76fc12 Replace remaining 0 with nullptr in Qt code (Ben Woosley)
9096276e0b Don't use zero as null pointer constant (-Wzero-as-null-pointer-constant) (practicalswift)

Pull request description:

  This corrects all violations of `-Wzero-as-null-pointer-constant` identified in the Qt codebase.

  These changes are extracted from #15112 as suggested by @MarcoFalke to ease review. This is in service of enabling `-Wzero-as-null-pointer-constant`, which should eliminate this as a concern going forward.

  Note there are 2 non-Qt changes: `src/test/allocator_tests.cpp` and `src/wallet/db.cpp`.

Tree-SHA512: 206bd668802147ba42bc413c2d7d259cb59aca9ec1da74a6bf2ca3932e60ae492faacbc61bcee0fd6b4b49a4d59d075b7e5404f0526b36c47718f9b0587e7768
2019-01-14 15:21:32 +01:00
Wladimir J. van der Laan 070eaf7fe5
Merge #15144: [refactor] CNode: Use C++11 default member initializers
fac2f5ecae Use C++11 default member initializers (MarcoFalke)

Pull request description:

  The second and last change on this topic (c.f. #15109). Split up because the diff would otherwise interleave, making review harder than necessary.

  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: 547ae72b87aeaed5890eb5fdcff612bfc93354632b238d89e1e1c0487187f39609bcdc537ef21345e0aea8cfcf1ea48da432d672c5386dd87cf58742446a86b1
2019-01-14 14:48:51 +01:00
Wladimir J. van der Laan 43a79d22c1
Merge #15138: Drop IsLimited in favor of IsReachable
d6b076c17b Drop IsLimited in favor of IsReachable (Ben Woosley)

Pull request description:

  These two methods have had the same meaning, but inverted, since
  110b62f069. Having one name for a single
  concept simplifies the code.

  This is a follow-up to #15051.
  /cc #7553

Tree-SHA512: 347ceb9e2a55ea06f4c01226411c7bbcade09dd82130e4c59d0824ecefd960875938022edbe5d4bfdf12b0552c9b4cb78b09a688284d707119571daf4eb371b4
2019-01-14 14:30:51 +01:00
Ben Woosley d6b076c17b
Drop IsLimited in favor of IsReachable
These two methods have had the same meaning, but inverted, since
110b62f069. Having one name for a single
concept simplifies the code.
2019-01-13 22:50:36 -08:00
Pieter Wuille 6a57ca91da Use FRC::randbytes instead of reading >32 bytes from RNG
There was only one place in the codebase where we're directly reading >32 bytes from
the RNG. One possibility would be to make the built-in RNG support large reads, but
using FastRandomContext lets us reuse code better.

There is no change in behavior here, because the FastRandomContext constructor
uses GetRandBytes internally.
2019-01-13 09:53:47 -08:00