Commit graph

10843 commits

Author SHA1 Message Date
Pieter Wuille cf2c0b6f5c Support P2WPKH and P2SH-P2WPKH in dumpprivkey 2018-01-09 15:27:55 -08:00
Pieter Wuille 37c03d3e05 Support P2WPKH addresses in create/addmultisig 2018-01-09 15:27:51 -08:00
Suhas Daftuar 9a51319578 Sort mempool by min(feerate, ancestor_feerate)
This more closely approximates the desirability of a given transaction for
mining.
2018-01-09 12:27:57 -05:00
Suhas Daftuar 6773f92b30 Refactor CompareTxMemPoolEntryByDescendantScore 2018-01-09 11:53:40 -05:00
Suhas Daftuar 8e617e3708 Remove unused mempool index 2018-01-09 08:59:21 -05:00
donaloconnor 30ded3e3d8 [Refactor] Remove unused fQuit var from checkqueue.h 2018-01-07 20:44:21 +00:00
Pieter Wuille b3ecb7bab6
Merge #10677: RPC Docs: addmultisigaddress is intended for non-watchonly addresses
73041c3c99 RPC Docs: addmultisigaddress is intended for non-watchonly addresses (Gregory Sanders)

Pull request description:

  Spent a couple hours debugging why my p2sh watchonly funds were not appearing in various accounting calls when address was imported via `addmultisigaddress`.

Tree-SHA512: 0673e276e5ca8cdc4c9357bd835a29bd5a994520a78179600944932c700917142930288bf179f5e89b0874beaf1a88bd70129f3a297a46df42a10bab847017bb
2018-01-06 02:54:33 -08:00
251 8a93543419 Replaces numbered place marker %2 with %1.
Replaces numbered place marker %2 with %1, because the QString::arg() member function is called once on the string used to create the QString object.
2018-01-04 20:57:22 +01:00
MarcoFalke ddff3447f2
Merge #11997: [tests] util_tests.cpp: actually check ignored args
c99a3c32c8 [tests] util_tests.cpp: actually check ignored args (Anthony Towns)

Pull request description:

  An array with 7 elements was setup for checking argument parsing, but
  was passed to ParseParamaeters with argc=5, meaning the interpretation
  of the last two arguments was never actually checked.

Tree-SHA512: 7b81fde49742e524f1bb67e2ec084f5909ae36125f237f0210df4587c62e5a5a8f277f13543f0a85ad145c4bb80d62339a7d50d7ed41659df318c8198ea7f428
2018-01-04 05:08:13 -09:00
Wladimir J. van der Laan a9a49e6e7e
Merge #12001: [RPC] Adding ::minRelayTxFee amount to getmempoolinfo and updating help
aad3090 [rpc] Adding ::minRelayTxFee amount to getmempoolinfo and updating mempoolminfee help description (Jeff Rade)

Pull request description:

  These are RPC document changes from #11475 which is now merged.  Took into consideration comments from #11475 and #6941 for this PR.

  Biggest change here is when calling `getmempoolinfo`, will now show the `minrelaytxfee` in the JSON reponse (see below):

  ```
  $ bitcoin-cli getmempoolinfo
  {
    "size": 50,
    "bytes": 13102,
    "usage": 70480,
    "maxmempool": 300000000,
    "mempoolminfee": 0.00001000,
    "minrelaytxfee": 0.00001000
  }
  ```

  Fixes #8953

Tree-SHA512: 5ca583961365ee1cfe6e0d19afb0b41d542e179efee3b3c5f3fcf7d3ebca9cc3eedfd1434a0da40c5eed84fba98b35646fda201e6e61c689b58bee9cbea44b9e
2018-01-04 09:22:53 +01:00
Jonas Schnelli eeb6d5271d
Merge #12035: [qt] change µBTC to bits
ebcee1de2 bips: add bip176 (Bits Denomination) (William Casarin)
275b2eeed [qt] change µBTC to bits (William Casarin)

Pull request description:

  Now that we have bip176, change "µBTC" to the more colloquial "bits"

Tree-SHA512: eba5e5f89c392728a4f0a3bd81a9779a117b8d72a490390fd031d4e7cc56c2bfee0016aba7ef9535903e8cf2262ce46497283424e378906d0e3bf5b0d2d981c7
2018-01-03 22:16:13 -10:00
Jonas Schnelli a1136f0cb4
Merge #12074: [qt] Optimizes boolean expression model && model->haveWatchOnly()
6dda059bd [qt] Simplifies boolean expression model && model->haveWatchOnly() (251)

Pull request description:

  This PR optimizes the boolean expression `model && model->haveWatchOnly()` to `model->haveWatchOnly()`.

  The boolean expression can be optimized because the method `TransactionView::exportClicked` already guards against a potential dereferenced null pointer by returning early if `model` is null.
  63a4dc1087/src/qt/transactionview.cpp (L351-L353)

Tree-SHA512: 8bdd0d05bf879745fa39d3ca7524471720ae08ceee9427d5a08776e7b56d18542ae87a6991cd6779e232305f504fdfc77223702b72ecbe231f5f5e98453456dd
2018-01-03 21:58:46 -10:00
Chris Stewart 18be3ab139 Adding test case for SINGLE|ANYONECANPAY hash type in tx_valid.json 2018-01-03 11:07:29 -06:00
Anthony Towns c99a3c32c8 [tests] util_tests.cpp: actually check ignored args
An array with 7 elements was setup for checking argument parsing, but
was passed to ParseParamaeters with argc=5, meaning the interpretation
of the last two arguments was never actually checked.
2018-01-04 00:02:52 +10:00
Pieter Wuille 3eaa003c88 Extend validateaddress information for P2SH-embedded witness
This adds new fields 'pubkeys' and 'embedded' to the RPC's output, and improves the
documentation for previously added 'witness_version' and 'witness_program' fields.
2018-01-03 05:43:06 -08:00
Pieter Wuille 30a27dc5b1 Expose method to find key for a single-key destination 2018-01-03 05:43:06 -08:00
Pieter Wuille 985c79552c Improve witness destination types and use them more 2018-01-03 05:43:06 -08:00
Pieter Wuille cbe197470e [refactor] GetAccount{PubKey,Address} -> GetAccountDestination 2018-01-03 05:42:57 -08:00
Wladimir J. van der Laan 5961b23898
Merge #12062: Increment MIT Licence copyright header year on files modified in 2017
595a7ba Increment MIT Licence copyright header year on files modified in 2017 (Akira Takizawa)

Pull request description:

  Edited via:

  $ contrib/devtools/copyright_header.py update .

  ps) It is the same commit as #9450

Tree-SHA512: 274bfcd6cf2914315ed52f6db773a68800ce9d6bd225a3142654483f0bbc3fd865009e62f9d954f65765d038c626e55d2a64e37e16843809adc2f67abe659b6d
2018-01-03 14:33:28 +01:00
Pieter Wuille 0c8ea6380c Abstract out IsSolvable from Witnessifier 2018-01-03 05:32:00 -08:00
251 0d663f8197 Fixes issue #12067 sendmany curl example is wrong.
This commit removes the escaped backslash and quote characters from the keys in the JSON object to make it a plain JSON object.
2018-01-02 20:53:30 +01:00
Akira Takizawa 595a7bab23 Increment MIT Licence copyright header year on files modified in 2017 2018-01-03 02:26:56 +09:00
251 6dda059bde [qt] Simplifies boolean expression model && model->haveWatchOnly()
The boolean expression model && model->haveWatchOnly() can be simplified to model->haveWatchOnly(), because if (!model || !model->getOptionsModel()) { return; } guards against a potential dereferenced null pointer.
2018-01-02 01:06:23 +01:00
251 bdb3231bee Implements a virtual destructor on the BaseRequestHandler class.
Implements a virtual destructor on the BaseRequestHandler class to protect against undefined behavior in
the event that a derived BaseRequestHandler class has a destructor and an object of such derived class
is destroyed through a pointer to its base class.
2017-12-29 16:20:28 +01:00
Jeff Rade aad309065d [rpc] Adding ::minRelayTxFee amount to getmempoolinfo and updating mempoolminfee help description 2017-12-29 08:56:44 -06:00
Pieter Wuille d9fdac130a
Merge #11824: Block ActivateBestChain to empty validationinterface queue
97d2b09c12 Add helper to wait for validation interface queue to catch up (Matt Corallo)
36137497f1 Block ActivateBestChain to empty validationinterface queue (Matt Corallo)
5a933cefcc Add an interface to get the queue depth out of CValidationInterface (Matt Corallo)
a99b76f269 Require no cs_main lock for ProcessNewBlock/ActivateBestChain (Matt Corallo)
a734896038 Avoid cs_main in net_processing ActivateBestChain calls (Matt Corallo)
66aa1d58a1 Refactor ProcessGetData in anticipation of avoiding cs_main for ABC (Matt Corallo)
818075adac Create new mutex for orphans, no cs_main in PLV::BlockConnected (Matt Corallo)

Pull request description:

  This should fix #11822.

  It ended up bigger than I hoped for, but its not too gnarly. Note that "
  Require no cs_main lock for ProcessNewBlock/ActivateBestChain" is mostly pure code-movement.

Tree-SHA512: 1127688545926f6099449dca6a4e6609eefc3abbd72f1c66e03d32bd8c7b31e82097d8307822cfd1dec0321703579cfdd82069cab6e17b1024e75eac694122cb
2017-12-29 01:51:23 -08:00
William Casarin 275b2eeed4 [qt] change µBTC to bits
* Now that we have bip176, change "µBTC" to the more colloquial "bits"

* We retain the `µBTC (bits)` description in dropdowns and status bars.
  The more concise "bits" is used when appended to numbers.

Signed-off-by: William Casarin <jb55@jb55.com>
2017-12-28 09:54:58 -08:00
Matt Corallo 97d2b09c12 Add helper to wait for validation interface queue to catch up 2017-12-26 11:56:00 -05:00
Matt Corallo 36137497f1 Block ActivateBestChain to empty validationinterface queue 2017-12-26 11:54:49 -05:00
Matt Corallo 5a933cefcc Add an interface to get the queue depth out of CValidationInterface 2017-12-26 11:54:49 -05:00
Matt Corallo a99b76f269 Require no cs_main lock for ProcessNewBlock/ActivateBestChain
This requires the removal of some very liberal (incorrect) cs_mains
sprinkled in some tests. It adds some chainActive.Tip() races, but
the tests are all single-threaded anyway.
2017-12-26 11:54:43 -05:00
Matt Corallo a734896038 Avoid cs_main in net_processing ActivateBestChain calls 2017-12-24 13:20:52 -05:00
Matt Corallo 66aa1d58a1 Refactor ProcessGetData in anticipation of avoiding cs_main for ABC 2017-12-24 13:08:38 -05:00
Matt Corallo fb6f6b1519 bluematt's testnet-seed now supports x9 (and is just a static list) 2017-12-24 11:47:19 -05:00
Wladimir J. van der Laan 5180a86c96
Merge #11517: Tests: Improve benchmark precision
760af84 Removed CCheckQueueSpeed benchmark (Martin Ankerl)
00721e6 Improved microbenchmarking with multiple features. (Martin Ankerl)

Pull request description:

  The benchmark's KeepRunning() used to make a function call for each call, inflating measurement times for short running code. This change inlines the critical code that is executed each run and moves the slow timer updates into a new function.

  This change increases the average runtime for Trig from 0.000000082339208 sec to 0.000000080948591.

Tree-SHA512: 36b3bc55fc9b1d4cbf526b7103af6af18e9783e6b8f3ad3adbd09fac0bf9401cfefad58fd1e6fa2615d3c4e677998f912f3323d61d7b00b1c660d581c257d577
2017-12-23 14:53:05 +01:00
Wladimir J. van der Laan 20166f8a44
Merge #11748: [Tests] Adding unit tests for GetDifficulty in blockchain.cpp.
3e1ee31 [Tests] Adding unit tests for GetDifficulty in blockchain.cpp. (sean)

Pull request description:

  blockchain.cpp has low unit test coverage. This commit is intended
  to start improving its code coverage to reasonable levels. One or more
  follow up commits will complete the task that this commit is starting
  (though the usefulness of this commit is not dependent upon later
  commits).

  Note that these tests were not written based upon a specification of how
  GetDifficulty *should* work, but rather how it actually *does* work. As
  a result, if there are any bugs in the current GetDifficulty
  implementation, these unit tests serve to lock them in rather than
  expose them.

  -- Why has blockchain.cpp been modified if this is a unit testing change?

  Since the existing GetDifficulty function relies on a global variable,
  chainActive, it was not suitable for unit testing purposes. Both the
  existing GetDifficulty function and the unit tests now call through to
  a new, more modular version of GetDifficulty that can work on any chain,
  not just chainActive.

  -- Why does blockchain_tests.cpp directly include blockchain.cpp instead
  of blockchain.h?

  While the new GetDifficulty function's signature is arguably better than
  the old one's, it still isn't great, and doesn't seem to warrant inclusion
  as part of the blockchain.h API, especially since only test code is
  directly using it. If a better way of exposing the new GetDifficulty
  function to unit tests exists, please mention it and the commit will be
  updated accordingly.

  -- Why is the test fixture named blockchain_difficulty_tests rather than
  blockchain_tests?

  The Bitcoin Core policy for naming unit test files is to match the the
  file under test ("blockchain" becomes "blockchain_tests"). While this
  commit complies with that, blockchain.cpp is a massive file, such that
  having all of the unit tests in one file will tend towards disorder.
  Since there will be a lot more tests added to this file, the intention
  is to divide up different types of tests into different test fixtures
  within the same file.

Tree-SHA512: a7dda9c2a9414d4819b4d2911f5637891dc19cecbecfc1463846161d2a78793151927a5ab911c69a5d3013f7668e75a1d78a65667cb9d83910cda439cbe84d62
2017-12-23 11:22:18 +01:00
Martin Ankerl 760af84072 Removed CCheckQueueSpeed benchmark
This benchmark's runtime was rather unpredictive on different machines, not really a useful benchmark.
2017-12-23 11:03:17 +01:00
Martin Ankerl 00721e69f8 Improved microbenchmarking with multiple features.
* inline performance critical code
* Average runtime is specified and used to calculate iterations.
* Console: show median of multiple runs
* plot: show box plot
* filter benchmarks
* specify scaling factor
* ignore src/test and src/bench in command line check script
* number of iterations instead of time
* Replaced runtime in BENCHMARK makro number of iterations.
* Added -? to bench_bitcoin
* Benchmark plotly.js URL, width, height can be customized
* Fixed incorrect precision warning
2017-12-23 11:03:17 +01:00
Wladimir J. van der Laan 9bad8d6472
Merge #11475: [rpc] mempoolinfo should take ::minRelayTxFee into account
149dffd [rpc] mempoolinfo should take ::minRelayTxFee into account (Cristian Mircea Messel)

Pull request description:

  Fixes #6941 following https://github.com/bitcoin/bitcoin/pull/11410#issuecomment-332991078 's suggestion

  This takes care of the mentioned ticket without changing the behavior of https://github.com/bitcoin/bitcoin/pull/11410/files#diff-24efdb00bfbe56b140fb006b562cc70bL629

  By modifying 5a9da37fb3/src/txmempool.cpp (L984) the syncing mempools becomes problematic as per https://github.com/bitcoin/bitcoin/pull/11410#issuecomment-333868390

  ~~Same code causes different tests to fail: https://travis-ci.org/bitcoin/bitcoin/jobs/286128241 https://travis-ci.org/bitcoin/bitcoin/jobs/286128241 . I can't reproduce the problems locally, am I doing something wrong?~~ travis sometimes fails unexpectedly

Tree-SHA512: fd81628da6a3eff51bd09e5342d781bac0710f79d6b330b1df3662756ecaceb2e1682bf9768b5f8edbcba6479a3223dfa6604d37c9e9d37d00d077172da4f6ea
2017-12-23 10:00:24 +01:00
Wladimir J. van der Laan f19ca129ff
Merge #11605: [Wallet] Enable RBF by default in QT
5cbbbd7 [Wallet] Use RBF by default in QT only (Sjors Provoost)

Pull request description:

  ~If there are no objections, this would supersede #11556.~

  Enabling RBF by default avoids the need to explain all possible use cases of RBF.

  This PR does not change the default RPC wallet behavior, as this could break implementations that depend on it and it's not clear what happens when automated services suddenly switch on RBF on a large scale.

  After trying various approaches, we settled on just having QT ignore `-walletrbf`.

  Send screen:
  <img width="388" alt="send" src="https://user-images.githubusercontent.com/10217/34251097-329c8dee-e63f-11e7-9e14-d7f55d2b52cc.png">

  Confirmation screen by default (with RBF):
  <img width="429" alt="rbf yes" src="https://user-images.githubusercontent.com/10217/32442799-f50d54aa-c2fc-11e7-9392-96339d0f1f74.png">

  Confirmation screen without RBF:
  <img width="431" alt="rf no" src="https://user-images.githubusercontent.com/10217/32442793-ef30bc34-c2fc-11e7-8ca2-e86a97175278.png">

Tree-SHA512: 53efb5d277144478143e69dcae8112c1b9c2beb981fdd0fe778592e5f7d5bf838f73d48052ead874586a75b944e8af469b25e5f376c135cf48cc3598e77f5891
2017-12-22 13:15:31 +01:00
Sjors Provoost 5cbbbd7143
[Wallet] Use RBF by default in QT only
GUI wallet uses RBF by default, regardless of -walletrbf.

RPC and debug console in the GUI remain unchanged; they don't
use RBF by default, unless launched with -walletrbf=1.
2017-12-22 09:18:05 +01:00
Wladimir J. van der Laan 711d16ca4a
Merge #11667: Add scripts to dumpwallet RPC
656fde5 Add script birthtime metadata to dump and import wallet (MeshCollider)
1bab9b2 Add script dump note to RPC help text and release notes (MeshCollider)
68c1e00 Add test for importwallet (MeshCollider)
9e1184d Add dumpwallet scripts test (MeshCollider)
ef0c730 Add scripts to importwallet RPC (MeshCollider)
b702ae8 Add CScripts to dumpwallet RPC (MeshCollider)
cdc260a Add GetCScripts to CBasicKeyStore (MeshCollider)

Pull request description:

  As discussed in https://github.com/bitcoin/bitcoin/pull/11289#issuecomment-334600457, adds the CScripts from the wallet to the `dumpwallet` RPC and then allows them to be imported with the `importwallet` RPC. Includes a basic test, and modifies the helptext of the dumpwallet RPC.

  Notes:
  - Reviewers: use `?w=1` to avoid the indentation-only change in commit `Add scripts to importwallet RPC `
  - currently the scripts are followed with `# addr=` comments just as the other keys are, unsure if this might confuse users into thinking all the scripts are for valid P2SH addresses though, but I don't think that should be an issue.
  - there are no birthtimes for scripts, so script imports don't affect rescans
  - `importwallet` imports the CScripts but I'm not sure how to approach specifying whether scripts are for P2SH addresses, BIP173 addresses, etc. whether that matters or not. Otherwise the RPC helptext might just need modification.

  Fixes #11715

Tree-SHA512: 36c55837b3a58b9d3499d4c0c2ae82153d62aa71919e751574651b63a1d2b8ecc83796db4553cc65dad9b5341c3a42ae2fcf4d62598c30af267f8e1461ba8272
2017-12-21 13:03:26 +01:00
MarcoFalke 604e08c83c
Merge #11726: Cleanups + nit fixes for walletdir PR
aac6b3f067 Update files.md for new wallets/ subdirectory (MeshCollider)
b67342906c Cleanups for walletdir PR (MeshCollider)

Pull request description:

  This addresses the remaining nits from https://github.com/bitcoin/bitcoin/pull/11466

  - Updates `doc/files.md` with respect to the new default wallet directory
  - Fixes @promag and @laanwj's error message nit, and Jonas' release notes nit
  - ~Addresses @laanwj's net-specific wallet subdirectory concern in the case that a walletdir is specified~
  - Changes the #includes from "" to <> style after #11651

Tree-SHA512: b86bf5fdc4de54c1b0f65b60a83af3cf82b35d216ce9c0de724803bfba6934796238b6c412659dcc29ae2e3e856d4eb97ae777c80f36f4089d8acecfddefe9aa
2017-12-20 17:37:57 -05:00
Wladimir J. van der Laan 79399c8cd0
Merge #10657: Utils: Improvements to ECDSA key-handling code
63179d0 Scope the ECDSA constant sizes to CPubKey / CKey classes (Jack Grigg)
1ce9f0a Ensure that ECDSA constant sizes are correctly-sized (Jack Grigg)
48abe78 Remove redundant `= 0` initialisations (Jack Grigg)
17fa391 Specify ECDSA constant sizes as constants (Jack Grigg)
e4a1086 Update Debian copyright list (Jack Grigg)
e181dbe Add comments (Jack Grigg)
a3603ac Fix potential overflows in ECDSA DER parsers (Jack Grigg)

Pull request description:

  Mostly trivial, but includes fixes to potential overflows in the ECDSA DER parsers.

  Cherry-picked from Zcash PR https://github.com/zcash/zcash/pull/2335

Tree-SHA512: 8fcbd51b0bd6723e5d33fa5d592f7cb68ed182796a9b837ecc8217991ad69d6c970258617dc00eb378c8caa4cec5d6b304d9d2c066acd40cda98e4da68e0caa4
2017-12-20 18:00:32 +01:00
Wladimir J. van der Laan bc66765144
Merge #11917: Add testnet DNS seed: seed.testnet.bitcoin.sprovoost.nl
f455a24 [net] add seed.testnet.bitcoin.sprovoost.nl to testnet DNS seeds (Sjors Provoost)

Pull request description:

  I tested it myself by:
  * `dig seed.testnet.bitcoin.sprovoost.nl`  (should have propagated by now, but if you only see two records with `A 66.111... ` try again later)
  * deleting the other seeds and all data in `.../testnet3`, recompiling and then starting the node. Log shows `21 addresses found from DNS seeds`.

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

  I'm willing to keep it up and running at least throughout 2018, unless something bad happens.

  About my setup:
  * Amazon EC2 instance in Europe, running Ubuntu 16.04; I use this instance for some other chores, but only port 53 is world reachable (for mainnet I'd probably run a dedicated instance, and perhaps a location I have physical control over)
  * running [sipa/bitcoin-seeder](https://github.com/sipa/bitcoin-seeder) with default settings (and the non-root port redirect)
  * feedback about my domain / DNS setup is welcome, I can provide more details via private email

  I can use guidance on _Any hosting services contracted by the operator are equally expected to uphold these expectations_. Although I assume the requirements for testnet are less strict than for mainnet, in case I want to pursue the latter in the future: what unpleasant things can Amazon, my domain registrar and other intermediaries do? How would I mitigate that?

  Also note that The Netherlands passed some pretty onerous legislation creating uncertainty over what the secret service can compel people like myself to do. However these laws won't take effect before mid 2018, there's probably more interesting targets than myself to go after, and it's easier for them to just monitor all unencrypted P2P traffic everywhere, or monitor some intermediary I depend on.

  Any good tools for monitoring uptime?

Tree-SHA512: 386fe688e5006ab8352d93ab3954fc07dc566876ae002891baa51acfaa5bb113f51b1f5ca08c7394a530b10a2f5008c56d57153af3ed07544a305586dda06b97
2017-12-20 17:04:22 +01:00
Wladimir J. van der Laan d4e404a3af
Merge #11879: [tests] remove redundant univalue_tests.cpp
2862b56 [tests] remove redundant univalue_tests.cpp (John Newbery)

Pull request description:

  univalue unit tests were added in #4730 , and exist at `/src/test/univalue_tests.cpp` (outside the univalue tree). That test was brought into the univalue repository in https://github.com/bitcoin-core/univalue/pull/4 , which was pulled into the github repository in https://github.com/bitcoin/bitcoin/pull/11420.

  That means that the univalue test exists in two places:
  1. `/src/test/univalue_tests.cpp`
  2. `/src/univalue/test/object.cpp`

  (2) is a strict superset of (1). It adds some macros to work around boost not being a univalue dependency, and adds a few extra lines of test.

  Therefore remove `/src/test/univalue_tests.cpp`

Tree-SHA512: 3747b10bbf62e9f12363905488b29945ad559ddca68c5c03d8a362de612a51f408f41a04d3712c6889bfc1632fb1a5fa0d7df0fbf02c322b3981a6d698f501b0
2017-12-20 16:53:02 +01:00
Wladimir J. van der Laan 9ab9963386
Merge #11952: [qa] univalue: Bump subtree
88411e9 Squashed 'src/univalue/' changes from fe805ea74f..07947ff2da (MarcoFalke)

Pull request description:

  Pulls in the test changes to the univalue subtree.

  Beside looking at the code, reviewers should refer to https://github.com/bitcoin/bitcoin/blob/master/contrib/devtools/README.md#git-subtree-checksh on how to verify the subtree pull.

Tree-SHA512: 09493625a573dca1140570326ee90c1bb84e4893e1dab2cdd51bc23ae1fba1e33c43ed771ca9e112ac71b0242e8a8d058071334562c738d502587eadd5a0f114
2017-12-20 16:51:39 +01:00
MeshCollider 656fde53a3 Add script birthtime metadata to dump and import wallet 2017-12-20 20:24:37 +13:00
MeshCollider 1bab9b23af Add script dump note to RPC help text and release notes 2017-12-20 18:47:56 +13:00
MeshCollider ef0c730220 Add scripts to importwallet RPC 2017-12-20 18:47:56 +13:00
MeshCollider b702ae812c Add CScripts to dumpwallet RPC 2017-12-20 18:47:56 +13:00
MeshCollider cdc260afd5 Add GetCScripts to CBasicKeyStore 2017-12-20 18:47:55 +13:00
MarcoFalke fad349c507 univalue: Bump subtree 2017-12-19 16:44:57 -05:00
Matt Corallo 62e7c04fb8 Remove dead feeest-file read code for old versions
0.15.0 introduced a new feeest file format, and support for parsing
old versions was never fully added. We now simply fail to read the
old format, so remove the dead partial-implementation.
2017-12-19 11:19:28 -05:00
Wladimir J. van der Laan cdd6bbf10a
Merge #11273: Ignore old format estimation file
3a3a9f9 Ignore old format estimation file (Murch)

Pull request description:

  The fee estimation data format changed from 0.14.x to 0.15.0, so we should no longer read the old data. H/T @jnewbery, @morcos

  Pending testing.

Tree-SHA512: c8e3824dbdd8f6730133d5ad20b00995e9a63ab54431158a91e2f4d2aba5763b8aa698bce1fffca2713ba3a162e23d8fcd6e3efb9847b015c2e1e8725398150b
2017-12-19 17:09:59 +01:00
Wladimir J. van der Laan 81c89e966e
Merge #11923: Wallet : remove unused fNoncriticalErrors variable from CWalletDB::FindWalletTx
ecf9b25 remove unused fNoncriticalErrors variable from CWalletDB::FindWalletTx (Pierre Rochard)

Pull request description:

  The `CWalletDB::FindWalletTx` method was patterned after `CWalletDB::LoadWallet`, where `fNoncriticalErrors` is used when a tx check fails in `ReadKeyValue`.

  Since `FindWalletTx` is only used by methods which are zapping txs, it makes sense that `ReadKeyValue` is not called and the tx is not checked, so I think that deleting the unused `fNoncriticalErrors` boolean variable and its conditional statement is appropriate.

Tree-SHA512: 0976eae97522719fdaeca1fb3f4a080561e46c06d0b8dc75e14262c6bc242998db3f7057183a230a1d7e4ac5fc348e9059f545b7d718ebbcdf6dcdfc63bcc286
2017-12-19 16:16:39 +01:00
Wladimir J. van der Laan 2971fd030f
Merge #11220: Check specific validation error in miner tests
12781db [Tests] check specific validation error in miner tests (Sjors Provoost)

Pull request description:

  ## Problem

  `BOOST_CHECK_THROW` merely checks that some `std::runtime_error` is
  thrown, but not which one.

  Here's an example of how this can cause a test to pass when a developer
  introduces a consensus bug. The test for the sigops limit assumes
  that `CreateNewBlock` fails with `bad-blk-sigops`. However it can
  also fail with bad-txns-vout-negative, if a naive developer lowers
  `BLOCKSUBSIDY` to `1*COIN`.

  ## Solution

  `BOOST_CHECK_EXCEPTION` allows an additional predicate function. This
  commit uses this for all exceptions that are checked for in
  `miner_tets.cpp`:
  * `bad-blk-sigops`
  * `bad-cb-multiple`
  * `bad-txns-inputs-missingorspent`
  * `block-validation-failed`

  If the function throws a different error, the test will fail. Although the message produced by Boost is a bit [confusing](http://boost.2283326.n4.nabble.com/Test-BOOST-CHECK-EXCEPTION-error-message-still-vague-tt4683257.html#a4683554), it does show which error was actually thrown. Here's what the above `1*COIN` bug would result in:

  <img width="1134" alt="schermafbeelding 2017-09-02 om 23 42 29" src="https://user-images.githubusercontent.com/10217/29998976-815cabce-9038-11e7-9c46-f5f6cfb0ca7d.png">

  ## Other considerations

  A more elegant solution in my opinion would be to subclass `std::runtime_error` for each `INVALID_TRANSACTION` type, but this would involve touching consensus code.

  I put the predicates in `test_bitcoin.h` because I assume they can be reused in other test files. However [serialize_tests.cpp](https://github.com/bitcoin/bitcoin/blob/v0.15.0rc3/src/test/serialize_tests.cpp#L245) also uses `BOOST_CHECK_EXCEPTION` and it defines the predicate in the test file itself.

  Instead of four `IsRejectInvalidReasonX(std::runtime_error const& e)` functions, I'd prefer something reusable like `bool IsRejectInvalidReason(String reason)(std::runtime_error const& e)`, which would be used like `BOOST_CHECK_EXCEPTION(functionThatThrows(), std::runtime_error, IsRejectInvalidReason("bad-blk-sigops")`. I couldn't figure out how to do that in C++.

Tree-SHA512: e364f19b4ac19f910f6e8d6533357f57ccddcbd9d53dcfaf923d424d2b9711446d6f36da193208b35788ca21863eadaa7becd9ad890334d334bccf8c2e63dee1
2017-12-19 13:06:01 +01:00
Wladimir J. van der Laan fee0370fd6
Merge #11178: Add iswitness parameter to decode- and fundrawtransaction RPCs
6f39ac0 Add test for decoderawtransaction bool (MeshCollider)
bbdbe80 Add iswitness parameter to decode- and fundrawtransaction RPCs (MeshCollider)

Pull request description:

  Suggested in https://github.com/bitcoin/bitcoin/pull/10481#issuecomment-325244946, this adds the option to explicitly choose whether a serialized transaction should be decoded as a witness or non-witness transaction rather than relying on the heuristic checks in #10481. The parameter defaults to relying on #10481 if not included, but it overrides that if included.

Tree-SHA512: d4846a5bb7d64dc19c516445488b00af329fc1f4181d9dfdf9f2382a086568edc98250a4ac7594e24a1bc231dfdee53c699b12c8380c355b920a67cc6770b7a9
2017-12-19 09:55:11 +01:00
Pierre Rochard ecf9b25a03 remove unused fNoncriticalErrors variable from CWalletDB::FindWalletTx 2017-12-17 11:01:23 -05:00
Sjors Provoost f455a24da7
[net] add seed.testnet.bitcoin.sprovoost.nl to testnet DNS seeds 2017-12-16 16:48:48 +01:00
Matt Corallo 818075adac Create new mutex for orphans, no cs_main in PLV::BlockConnected
This should (marginally) speed up validationinterface queue
draining by avoiding a cs_main lock in one client.
2017-12-15 15:27:45 -05:00
Wladimir J. van der Laan df71819524
Merge #11886: Clarify getbalance meaning a tiny bit in response to questions.
c79d73d Clarify getbalance meaning a tiny bit in response to questions. (Matt Corallo)

Pull request description:

  Someone was asking why getbalance "*" was more "correct" than getbalance, which should rarely be true...spendzeroconfchange was the issue.

Tree-SHA512: 90201cad1acec5161aee469fb4c6d737a0eb90f8380ac93abf0e41e0f02d120afcc3e2e873e5096d3655bb63bbd16fe99e72452f308d72e69139c7f6bb2d745e
2017-12-15 13:53:07 +01:00
Wladimir J. van der Laan 8585bb8f05
Merge #11616: Update ban-state in case of dirty-state during periodic sweep
57ac471 Call BannedListChanged outside of cs_setBanned lock (Jonas Schnelli)
c853812 Update ban-state in case of dirty-state during periodic sweep (Jonas Schnelli)

Pull request description:

  We do currently not update the UI during periodic ban list sweeps (via dump banlist).
  Fixes #11612

Tree-SHA512: bffbdcc03c63042177bdd511b0a9187c211c2b5011178481e8ee3e43a71eef1e4cd6b72f73672babab142b644f62f8b56f0aac1d26d3f19372b1f8644fec9395
2017-12-15 10:43:34 +01:00
Wladimir J. van der Laan c66adb286a
Merge #10839: Don't use pass by reference to const for cheaply-copied types (bool, char, etc.)
99ba0c3 Don't use pass by reference to const for cheaply-copied types (bool, char, etc.). (practicalswift)

Pull request description:

  Don't use pass by reference to const for cheaply-copied types (`bool`, `char`, etc.).

Tree-SHA512: ccad5e2695dff0b3d6de3e713ff3448f2981168cdac72d73bee10ad346b9919d8d4d588933369e54657a244b8b222fa0bef919bc56d983e1fa64b2004e51b225
2017-12-14 18:28:01 +01:00
Wladimir J. van der Laan 66479c0e61
Merge #11884: Remove unused include in hash.cpp
3f09e03 Remove unused include in hash.cpp (Karl-Johan Alm)

Pull request description:

Tree-SHA512: 543a72656460fba1c5498a0b85c49601d9b0399a4ecc49f4acf4715c258918da729df388e3be724c3161438e903ee16ad3c50626a71483aa6d85ffdbb827742d
2017-12-14 17:01:05 +01:00
Wladimir J. van der Laan 2ae58d5bfb
Merge #11864: Make CWallet::FundTransaction atomic
03a5dc9 [wallet] Make CWallet::FundTransaction atomic (João Barbosa)
95d4450 [wallet] Tidy up CWallet::FundTransaction (João Barbosa)

Pull request description:

  This PR fixes a race for `setLockedCoins` when `lockUnspents` is true. For instance, it should not be possible to use the same unspent in concurrent `fundrawtransaction` calls.

  Now the `cs_main` and `cs_wallet` locks are held during `CreateTransaction` and `LockCoin`(s). Also added some style nits around the change.

Tree-SHA512: ccf383c0c5f6db775655a3e9ccd200c3bd831a83afae2b7c389564c74f7227f5bea86a4775727de2c3603b188f383f8a12d3f9d6d94f7887865c31c94ce95ef6
2017-12-14 10:38:20 +01:00
João Barbosa 03a5dc9c3c [wallet] Make CWallet::FundTransaction atomic 2017-12-14 03:18:29 +00:00
João Barbosa 95d4450a41 [wallet] Tidy up CWallet::FundTransaction 2017-12-14 03:17:58 +00:00
Matt Corallo c79d73dc94 Clarify getbalance meaning a tiny bit in response to questions. 2017-12-13 12:18:33 -05:00
Wladimir J. van der Laan d4991c0cbb
Merge #11877: Improve createrawtransaction functional tests
88af502 test: Add createrawtransaction functional tests (João Barbosa)
27c6199 test: Add multidict to support dictionary with duplicate key (laanwj) (João Barbosa)
320669a rpc: Validate replaceable type in createrawtransaction (João Barbosa)

Pull request description:

  This was motivated by the `Invalid parameter, duplicated address` test.

  Credit to @laanwj for `multidict` implementation.

Tree-SHA512: a87139ae11004b73b467db1e8a072b75e23a0622b173a5668eed383b3575d8abc709817ddd2dfdc53f55afc90750fb61331199ad5de38c1ef6d482f2bc220f74
2017-12-13 17:34:08 +01:00
Wladimir J. van der Laan 68e021e3a3
Merge #11558: Minimal code changes to allow msvc compilation
fbf327b Minimal code changes to allow msvc compilation. (Aaron Clauson)

Pull request description:

  These changes are required to allow the Bitcoin source to build with Microsoft's C++ compiler (#11562 is also required).

  I looked around for a better place for the typedef of ssize_t which is in random.h. The best candidate looks like src/compat.h but I figured including that header in random.h is a bigger change than the typedef. Note that the same typedef is in at least two other places including the OpenSSL and Berkeley DB headers so some of the Bitcoin code already picks it up.

Tree-SHA512: aa6cc6283015e08ab074641f9abdc116c4dc58574dc90f75e7a5af4cc82946d3052370e5cbe855fb6180c00f8dc66997d3724ff0412e4b7417e51b6602154825
2017-12-13 14:05:25 +01:00
Karl-Johan Alm 3f09e03e0f
Remove unused include in hash.cpp 2017-12-13 20:08:49 +09:00
MeshCollider b67342906c Cleanups for walletdir PR 2017-12-13 23:36:43 +13:00
Wladimir J. van der Laan ba2f19504c
Merge #11363: net: Split socket create/connect
3830b6e net: use CreateSocket for binds (Cory Fields)
df3bcf8 net: pass socket closing responsibility up to caller for outgoing connections (Cory Fields)
9e3b2f5 net: Move IsSelectableSocket check into socket creation (Cory Fields)
1729c29 net: split socket creation out of connection (Cory Fields)

Pull request description:

  Requirement for #11227.

  We'll need to create sockets and perform the actual connect in separate steps, so break them up.

  #11227 adds an RAII wrapper around connection attempts, as a belt-and-suspenders in case a CloseSocket is missed.

Tree-SHA512: de675bb718cc56d68893c303b8057ca062c7431eaa17ae7c4829caed119fa3f15b404d8f52aca22a6bca6e73a26fb79e898b335d090ab015bf6456cf417fc694
2017-12-13 05:42:32 +01:00
Cory Fields 3830b6e065 net: use CreateSocket for binds 2017-12-12 15:25:25 -05:00
Cory Fields df3bcf89e4 net: pass socket closing responsibility up to caller for outgoing connections
This allows const references to be passed around, making it clear where the
socket may and may not be invalidated.
2017-12-12 15:25:25 -05:00
Cory Fields 9e3b2f576b net: Move IsSelectableSocket check into socket creation
We use select in ConnectSocketDirectly, so this check needs to happen before
that.

IsSelectableSocket will not be relevant after upcoming changes to remove select.
2017-12-12 15:25:25 -05:00
Cory Fields 1729c29ded net: split socket creation out of connection
Also, check for the correct error during socket creation
2017-12-12 15:25:25 -05:00
Wladimir J. van der Laan ef8ba7d73a
Merge #11870: wallet: Remove unnecessary mempool lock in ReacceptWalletTransactions
5b25293 wallet: Remove unnecessary mempool lock in ReacceptWalletTransactions (João Barbosa)

Pull request description:

Tree-SHA512: 13b922c6c9b5ca95a77742050f449366b80bdd7819c34e7ca09af8a4bd68085f4d0c6e0cde119c403f661499f97f2c465071a8047a7d794268e8d2dfe909e6d5
2017-12-12 20:26:55 +01:00
Wladimir J. van der Laan 22149540f9
Merge #11854: Split up key and script metadata for better type safety
9c8eca7 Split up key and script metadata for better type safety (Russell Yanofsky)

Pull request description:

  Suggested by @TheBlueMatt
  https://github.com/bitcoin/bitcoin/pull/11403#discussion_r155599383

  Combining the maps was probably never a good arrangement but is more
  problematic now in presence of WitnessV0ScriptHash and WitnessV0KeyHash types.

Tree-SHA512: 9263e9c01090fb49221e91d88a88241a9691dda3e92d86041c8e284306a64d3af5e2438249f9dcc3e6e4a5c11c1a89f975a86d55690adf95bf2636f15f99f92a
2017-12-12 19:57:43 +01:00
John Newbery 2862b562cc [tests] remove redundant univalue_tests.cpp 2017-12-12 12:45:53 -05:00
João Barbosa 320669a363 rpc: Validate replaceable type in createrawtransaction 2017-12-12 14:57:03 +00:00
Wladimir J. van der Laan 5d132e8b97
Merge #10574: Remove includes in .cpp files for things the corresponding .h file already included
a720b92 Remove includes in .cpp files for things the corresponding .h file already included (practicalswift)

Pull request description:

  Remove includes in .cpp files for things the corresponding .h file already included.

  Example case:
  * `addrdb.cpp` includes `addrdb.h` and `fs.h`
  * `addrdb.h` includes `fs.h`

  Then remove the direct inclusion of `fs.h` in `addrman.cpp` and rely on the indirect inclusion of `fs.h` via the included `addrdb.h`.

  In line with the header include guideline (see #10575).

Tree-SHA512: 8704b9de3011a4c234db336a39f7d2c139e741cf0f7aef08a5d3e05197e1e18286b863fdab25ae9638af4ff86b3d52e5cab9eed66bfa2476063aa5c79f9b0346
2017-12-12 14:56:25 +01:00
Wladimir J. van der Laan 214046f69b
Merge #10279: Add a CChainState class to validation.cpp to take another step towards clarifying internal interfaces
22fddde Avoid calling GetSerializeSize on each tx in a block if !fTxIndex (Matt Corallo)
2862aca Move some additional variables into CChainState private (Matt Corallo)
fd4d80a Create initial CChainState to hold chain state information (Matt Corallo)
e104f0f Move block writing out of AcceptBlock (Matt Corallo)
50701ba Move txindex/undo data disk location stuff out of ConnectBlock (Matt Corallo)
93a34cf Make DisconnectBlock unaware of where undo data resides on disk (Matt Corallo)

Pull request description:

  CChainState should eventually, essentially, be our exposed "libconsensus", but we're probably a few releases away, so the real goal is to clarify our internal interfaces. The main split was a big step, but validation.cpp is still a somewhat ranomly-mixed bag of functions that are pure functions which validate inputs (which should probably either merge with their callers or move into another file in consensus/), read/write data from disk, manipulate our current chain state (which moves into CChainState), and do mempool transaction validation.

  Obviously this is only a small step, but some effort is made to clean up what functions the functions in CChainState call, and obviously as things are added its easy to keep clear "CChainState::* cannot call anything except via callbacks through CValidationInterface, pure functions, or disk read/write things". Right now there are some glaring violations in mempool callbacks, and general flushing logic needs cleaning up (FlushStateToDisk maybe shouldnt be called, and there should be an API towards setDirtyBlockIndex, but I'll leave that for after @sipa's current changesets land).

Tree-SHA512: 69b8ec191b36b19c9492b4dee74c8057621fb6ec98ad219e8da0b2ed5c3ad711b10b5af9ff1117e8807ccf88918eeeab573be8448baecc9a59f099c53095985b
2017-12-12 14:36:57 +01:00
Wladimir J. van der Laan d48ab83f00
Merge #11831: Always return true if AppInitMain got to the end
07c4838 Always return true if AppInitMain got to the end (Matt Corallo)

Pull request description:

  This should fix a rare zapwallettxes failure on travis, but also
  avoids having init operations (re-adding wallet transactions to
  mempool) running after RPC is free'd.

  I believe this was the failure at https://travis-ci.org/bitcoin/bitcoin/jobs/311747844 (from #11605).

Tree-SHA512: f0fea8c1b9265e2eeda57043d541380a3e58e4d9388fa24628a52fd56324257fcd7df0ca02e8f77f66fadd68d951893bab0f610ed9fd0a89b2ccd6bad1efa351
2017-12-12 10:27:53 +01:00
Wladimir J. van der Laan c0902624b0
Merge #10699: Make all script validation flags backward compatible
01013f5 Simplify tx validation tests (Pieter Wuille)
2dd6f80 Add a test that all flags are softforks (Pieter Wuille)
2851b77 Make all script verification flags softforks (Pieter Wuille)

Pull request description:

  This change makes `SCRIPT_VERIFY_UPGRADABLE_NOPS` not apply to `OP_CHECKLOCKTIMEVERIFY` and `OP_CHECKSEQUENCEVERIFY`. This is a no-op as `UPGRADABLE_NOPS` is only set for mempool transactions, and those always have `SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY` and `SCRIPT_VERIFY_CHECKSEQUENCEVERIFY` set as well. The advantage is that setting more flags now always results in a reduction in acceptable scripts (=softfork).

  This results in a nice and testable property for validation, for which a new test is added.

  This also means that the introduction of a new definition for a NOP or witness version will likely need the following procedure (example OP_NOP8 here)
  * Remove OP_NOP8 from being affected by `SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS`.
  * Add a `SCRIPT_VERIFY_DISCOURAGE_NOP8`, which only applies to `OP_NOP8`.
  * Add a `SCRIPT_VERIFY_NOP8` which implements the new consensus logic.
  * Before activation, add `SCRIPT_VERIFY_DISCOURAGE_NOP8` to the mempool flags.
  * After activation, add `SCRIPT_VERIFY_NOP8` to both the mempool and consensus flags.

Tree-SHA512: d3b4538986ecf646aac9dba13a8d89318baf9e308e258547ca3b99e7c0509747f323edac6b1fea4e87e7d3c01b71193794b41679ae4f86f6e11ed6be3fd62c72
2017-12-12 10:11:00 +01:00
Wladimir J. van der Laan 0e722e8879
Merge #11516: crypto: Add test cases covering the relevant HMAC-SHA{256,512} key length boundaries
a3f5657 Add test cases covering the relevant key length boundaries: 64 bytes +/- 1 byte for HMAC-SHA256 and 128 bytes +/- 1 byte for HMAC-SHA512 (practicalswift)

Pull request description:

  * Add test cases covering the relevant key length boundaries: 64 bytes +/- 1 byte for HMAC-SHA256 and 128 bytes +/- 1 byte for HMAC-SHA512.
  * ~~Avoid creating a one-past-the-end pointer in the case of key length 64 (HMAC-SHA256) and key length 128 (HMAC-SHA512).~~
  * ~~Avoid performing a noop memset call (zero length argument) in the case of key length 64 (HMAC-SHA256) and key length 128 (HMAC-SHA512).~~

Tree-SHA512: 48ff9ab79d41aab97b5b8f6496cc08a39955a07eb424f74ada6440d3b168b6204d3527fa677e175c47e40142f9d62c7456ae162e5a2f5b557e90fb353beef1d0
2017-12-12 09:57:12 +01:00
João Barbosa 5b25293436 wallet: Remove unnecessary mempool lock in ReacceptWalletTransactions 2017-12-11 23:43:31 +00:00
Wladimir J. van der Laan 37ffa16933
Merge #11583: Do not make it trivial for inbound peers to generate log entries
be9f38c Do not make it trivial for inbound peers to generate log entries (Matt Corallo)

Pull request description:

  Based on #11580 because I'm lazy.

  We should generally avoid writing to debug.log unconditionally for
  inbound peers which misbehave (the peer being about to be banned
  being an exception, since they cannot do this twice).

Tree-SHA512: 8e59c8d08d00b1527951b30f4842d010a4c2fc440503ade112baa2c1b9afd0e0d1c5c2df83dde25183a242af45089cf9b9f873b71796771232ffb6c5fc6cc0cc
2017-12-11 17:06:22 +01:00
Wladimir J. van der Laan 8ab6c0b09e
Merge #11839: don't attempt mempool entry for wallet transactions on startup if alr…
6697a70 add test for unconfirmed balance between restarts (Gregory Sanders)
6ba8f30 don't attempt mempool entry for wallet transactions on startup if already in mempool (Gregory Sanders)

Pull request description:

  …eady in mempool

  Mempool loads first, wallet second. Second attempt fails, marking that transaction !fInMempool. Those funds will disappear until confirmation is reached.

Tree-SHA512: 955f0565ec1dc1ba395e0b803a98c07b7cd00c8cac5ec618ed832fed259a856fb7bbbe41310cf6a4e43c0435e09b156109d2a4467d403811dc8379d2caebeede
2017-12-11 16:21:03 +01:00
Gregory Sanders 6ba8f30e7b don't attempt mempool entry for wallet transactions on startup if already in mempool 2017-12-11 09:08:54 -05:00
Wladimir J. van der Laan 59d3dc85b6
Merge #11740: Implement BIP159 NODE_NETWORK_LIMITED (pruned peers) *signaling only*
de74c62 [Doc] Update bip.md, add support for BIP 159 (Jonas Schnelli)
e054d0e [QA] Add node_network_limited test (Jonas Schnelli)
bd09416 Avoid leaking the prune height through getdata (fingerprinting countermeasure) (Jonas Schnelli)
27df193 Always set NODE_NETWORK_LIMITED bit (Jonas Schnelli)
7caba38 Add NODE_NETWORK_LIMITED flags and min block amount constants (Jonas Schnelli)

Pull request description:

  Extracted from #10387.
  Does implement BIP159, but only the signalling part. No connections are made to NODE_NETWORK_LIMITED in this PR.

  The address relay and connection work (the more complicated part) can then be separated (probably in #10387).

Tree-SHA512: e3218eb4789a9320b0f42dc10f62d30c13c49bdef00443fbe653bee22933477adcfc1cf8f6a95269324560b5721203ed41f3c5e2dd8a98ec2791f6a9d8346b1a
2017-12-09 08:38:36 +01:00
Russell Yanofsky 9c8eca7704 Split up key and script metadata for better type safety
Suggested by Matt Corallo <git@bluematt.me>
https://github.com/bitcoin/bitcoin/pull/11403#discussion_r155599383

Combining the maps was probably never a good arrangement but is more
problematic now in presence of WitnessV0ScriptHash and WitnessV0KeyHash types.
2017-12-08 12:50:46 -05:00
Wladimir J. van der Laan 4ef4dfebbc
Merge #11847: Make boost::multi_index comparators const
1ec0c0a Make boost::multi_index comparators const (Suhas Daftuar)

Pull request description:

  This fixes compatibility with boost 1.66.

  Fixes #11837

Tree-SHA512: 3181336fcc159aa7ee70c843d76f2a063e4a401f427c218d7f856a3548ca70eaf8eee9d20abb73be259a5656273d3a65aa748e946e09cf656de5f50e6d4eb880
2017-12-07 18:37:43 +01:00
Wladimir J. van der Laan 80f9dad0b7
Merge #11809: gui: Fix proxy setting options dialog crash
f05d349 gui: Fix proxy setting options dialog crash (Wladimir J. van der Laan)

Pull request description:

  This fixes a crash bug when opening the options dialog.

  - Check the return value of split() to avoid segmentation faults due to   out of bounds when the user manages to enter invalid proxy settings.  This is reported resonably often.

  - Move the default proxy/port to a constant instead of hardcoding magic values.

  - Factor out some common code.

  - Revert #11448 because this proves a more robust replacement, it is no longer necessary and didn't generally solve the issue.

  No attempt is made to do full sanity checking on the proxy, so it can still be rejected by the core with an InitError message.

Tree-SHA512: 72b700b7d6c4d3e3410f0c60e9e4facf93d7c6c1a1b6b23957c48b074a045970f518166952859d1ebca8620062cb70d222670a7310bbd6fe50550ec6d04417b5
2017-12-07 17:40:11 +01:00
Wladimir J. van der Laan 3e50024120
Merge #11838: qa: Add getrawtransaction in_active_chain=False test
fa4c16d qa: Add getrawtransaction in_active_chain=False test (MarcoFalke)

Pull request description:

  #10275 accidentally forgot to add a test for `in_active_chain==False`.

  This adds a test and also removes the special casing of `blockhash.IsNull()`, which makes no sense imo.

Tree-SHA512: 6c51295820b3dcd53b0b48020ab2b8c8f5864cd5061ddab2b35d35d643eb3e60ef95ff20c06c985a2e47f7080e82f27f3e00ee61c85dce627776d5ea6febee8f
2017-12-07 17:37:32 +01:00
Wladimir J. van der Laan f05d349887 gui: Fix proxy setting options dialog crash
This fixes a crash bug when opening the options dialog.

- Check the return value of split() to avoid segmentation faults due to
  out of bounds when the user manages to enter invalid proxy settings.
  This is reported resonably often.

- Move the default proxy/port to a constant instead of hardcoding magic
  values.

- Factor out some common code.

- Revert #11448 because this proves a more robust replacement, it is no
  longer necessary and didn't generally solve the issue.

No attempt is made to do full sanity checking on the proxy, so it can
still be rejected by the core with an InitError message.
2017-12-07 17:34:16 +01:00
Suhas Daftuar 1ec0c0a01c Make boost::multi_index comparators const
This fixes compatibility with boost 1.66
2017-12-07 10:06:38 -05:00
Wladimir J. van der Laan 7630a1fe9a
Merge #11829: Test datadir specified in conf file exists
529b866 Test datadir in conf file exists (MeshCollider)

Pull request description:

  Provoked by Nick ODell's discovery here: https://bitcoin.stackexchange.com/questions/64189/when-running-bitcoind-i-keep-getting-boostfilesystemspace-operation-not-p/64210#64210

  If a custom data directory is specified using `-datadir` argument, its existence is checked before the conf file is loaded. But if the conf file then specifies a different non-existent `datadir`, that isn't tested, and results in esoteric errors like:

      EXCEPTION: N5boost10filesystem16filesystem_errorE
      boost::filesystem::space: Operation not permitted

  This just adds a check for the datadir existence at the end of `ReadConfigFile()`

Tree-SHA512: e488618c40aa356263f94040ae00aa4be98038abef66e8674b01032d22a5553a7fafcb8fe2d1f095865b39fb138c07b7a94415a00ef837573f92f95af065f712
2017-12-07 14:09:09 +01:00
MarcoFalke fa4c16d2e7 qa: Add getrawtransaction in_active_chain=False test 2017-12-06 11:00:08 -05:00
Wladimir J. van der Laan 497d0e014c
Merge #10275: [rpc] Allow fetching tx directly from specified block in getrawtransaction
434526a [test] Add tests for getrawtransaction with block hash. (Karl-Johan Alm)
b167951 [rpc] Allow getrawtransaction to take optional blockhash to fetch transaction from a block directly. (Karl-Johan Alm)
a5f5a2c [rpc] Fix fVerbose parsing (remove excess if cases). (Karl-Johan Alm)

Pull request description:

  [Reviewer hint: use [?w=1](https://github.com/bitcoin/bitcoin/pull/10275/files?w=1) to avoid seeing a bunch of indentation changes.]

  Presuming a user knows the block hash of the block containing a given transaction, this PR allows them to fetch the raw transaction, even without `-txindex`. It also enables support for getting transactions that are in orphaned blocks.

  Note that supplying a block hash will override mempool and txindex support in `GetTransaction`. The rationale behind this is that a transaction may be in multiple places (orphaned blocks) and if the user supplies an explicit block hash it should be adhered to.

  ```Bash
  $ # a41.. is a tx inside an orphan block ..3c6f.. -- first try getting it normally
  $ ./bitcoin-cli getrawtransaction a41e66ee1341aa9fb9475b98cfdc1fe1261faa56c0a49254f33065ec90f7cd79 1
  error code: -5
  error message:
  No such mempool transaction. Use -txindex to enable blockchain transaction queries. Use gettransaction for wallet transactions.
  $ # now try with block hash
  $ ./bitcoin-cli getrawtransaction a41e66ee1341aa9fb9475b98cfdc1fe1261faa56c0a49254f33065ec90f7cd79 1 0000000000000000003c6fe479122bfa4a9187493937af1734e1e5cd9f198ec7
  {
    "hex": "01000000014e7e81144e42f6d65550e59b715d470c9301fd7ac189[...]90488ac00000000",
    "inMainChain": false,
    "txid": "a41e66ee1341aa9fb9475b98cfdc1fe1261faa56c0a49254f33065ec90f7cd79",
    "hash": "a41e66ee1341aa9fb9475b98cfdc1fe1261faa56c0a49254f33065ec90f7cd79",
    "size": 225,
  [...]
  }
  $ # another tx 6c66... in block 462000
  $ ./bitcoin-cli getrawtransaction 6c66b98191e9d6cc671f6817142152ebf6c5cab2ef008397b5a71ac13255a735 1 00000000000000000217f2c12922e321f6d4aa933ce88005a9a493c503054a40
  {
    "hex": "0200000004d157[...]88acaf0c0700",
    "inMainChain": true,
    "txid": "6c66b98191e9d6cc671f6817142152ebf6c5cab2ef008397b5a71ac13255a735",
    "hash": "6c66b98191e9d6cc671f6817142152ebf6c5cab2ef008397b5a71ac13255a735",
    "size": 666,
  [...]
  }
  $
  ```

Tree-SHA512: 279be3818141edd3cc194a9ee65929331920afb30297ab2d6da07293a2d7311afee5c8b00c6457477d9f1f86e86786a9b56878ea3ee19fa2629b829d042d0cda
2017-12-06 12:10:21 +01:00
Jonas Schnelli bd09416524
Avoid leaking the prune height through getdata (fingerprinting countermeasure) 2017-12-05 11:08:34 -10:00
Jonas Schnelli 27df193efd
Always set NODE_NETWORK_LIMITED bit
The current pruning implementation does ensure to always conform to BIP159
2017-12-05 11:03:59 -10:00
Jonas Schnelli 7caba38568
Add NODE_NETWORK_LIMITED flags and min block amount constants 2017-12-05 11:03:59 -10:00
Matt Corallo 07c483895d Always return true if AppInitMain got to the end
This should fix a very rare travis failure in zapwallettxes, but
is also more correct, as you can currently race
ReacceptWalletTransactions with stop RPC calls to get bitcoind to
(IMO) eroneously return a non-0 exit code.
2017-12-05 10:39:44 -05:00
MeshCollider 529b866759 Test datadir in conf file exists 2017-12-06 00:24:06 +13:00
Jonas Schnelli 91eeaa0335
Merge #11556: [Qt] Improved copy for RBF checkbox and tooltip
db0b7373f [Qt] Improved copy: RBF checkbox, tooltip and confirmation screen (Sjors Provoost)

Pull request description:

  Fixes #11344 and replaces #11428.

  **Before**:
  <img width="588" alt="before" src="https://user-images.githubusercontent.com/10217/31984211-3299e81a-b993-11e7-94e9-bf63d2fed4bd.png">

  **After**:
  <img width="578" alt="after" src="https://user-images.githubusercontent.com/10217/31984404-11f839da-b994-11e7-86ad-4c17a7d44b86.png">

Tree-SHA512: 04876b2f2eab53c8d4fd4279e8384fd4869af7e15de7648b2689092f800b6ae9c890c01c26c2f7deffe79a1d70c6440d702cbe420e44fe3ded25c5b83d44ecfa
2017-12-04 21:30:25 -10:00
Karl-Johan Alm b167951677
[rpc] Allow getrawtransaction to take optional blockhash to fetch transaction from a block directly. 2017-12-05 11:03:24 +09:00
Wladimir J. van der Laan 24df9af816
Merge #11781: Add -debuglogfile option
5a7c09a test: Add tests for `-debuglogfile` with subdirs (Anthony Towns)
4158734 doc: Update release notes for `-debuglogfile` (Wladimir J. van der Laan)
2323242 test: Add test for `-debuglogfile` (Wladimir J. van der Laan)
cf5f432 Add `-debuglogfile` option (Wladimir J. van der Laan)

Pull request description:

  This patch adds an option to configure the name and/or directory of the debug log file.

  The user can specify either a relative path, in which case the path is relative to the (network specific) data directory. They can also specify an absolute path to put the log anywhere else in the file system.

  Alternative to #11741 that gets rid of the concept of a "log directory" by specifying the path for the specific kind of log, the debug log. Which happens to be the only kind of log we have at this point*, but a hypothetical new kind of log (say, an audit log) would get a new option. This has more flexibility than specifying a directory which has to contain all of them.

  \* excluding `db.log` which is internally generated by the wallet database library, but that one moves along with `-walletdir`.

Tree-SHA512: 4434d0e598dc23504e5c9e67fdbaef56db4f0fd490f9f54fd503e69d4dda9b5b69c539e1794ed841e72161b7b1dc3374d2f1193dd431b057566750e56fd8f24b
2017-12-04 18:55:17 +01:00
Matt Corallo 22fdddeabb Avoid calling GetSerializeSize on each tx in a block if !fTxIndex 2017-12-04 09:39:21 -05:00
Matt Corallo 2862aca40f Move some additional variables into CChainState private 2017-12-04 09:39:20 -05:00
Matt Corallo fd4d80a2f8 Create initial CChainState to hold chain state information 2017-12-04 09:34:46 -05:00
Matt Corallo e104f0fb7e Move block writing out of AcceptBlock 2017-12-04 09:33:10 -05:00
Matt Corallo 50701ba5fc Move txindex/undo data disk location stuff out of ConnectBlock 2017-12-04 09:33:10 -05:00
Matt Corallo 93a34cfeec Make DisconnectBlock unaware of where undo data resides on disk 2017-12-04 09:33:10 -05:00
Wladimir J. van der Laan 00d25e90db
Merge #11804: [docs] Fixed outdated link with archive.is
bf20a7d [docs] Fixed outdated link with archive.is (Tim Shimmin)

Tree-SHA512: 7d316aa4c462213578a9a1e71b06a459924ed3bb681a0469cc3719b21a871a6350fff4656696057e362561ee10dc10e933fe1328ef454ab7e133ecf05549ec1c
2017-12-01 15:28:53 +01:00
Tim Shimmin bf20a7d640 [docs] Fixed outdated link with archive.is
The listed link is directing to an empty page, at least content-wise. I found the same page on archive.is and linked to that instead.
2017-12-01 15:26:53 +01:00
Wladimir J. van der Laan 0d7e0a3289
Merge #11337: Fix code constness in CBlockIndex::GetAncestor() overloads
b4058ed Fix code constness in CBlockIndex::GetAncestor() overloads (Dan Raviv)

Pull request description:

  Make the non-const overload of `CBlockIndex::GetAncestor()` reuse the const overload implementation instead of the other way around. This way, the constness of the const overload implementation is guaranteed. The other way around, it was possible to implement the non-const overload in a way which mutates the object, and since that implementation would be called even for const objects (due to the reuse), we would get undefined behavior.

Tree-SHA512: 545a8639bc52502ea06dbd924e8fabec6274fa69b43e3b8966a7987ce4dae6fb2498f623730fde7ed0e47478941c7f8baa2e76a12018134ff7c14c0dfa25ba3a
2017-12-01 15:19:07 +01:00
MarcoFalke fbce66a982
Merge #10493: Use range-based for loops (C++11) when looping over map elements
680bc2cbb Use range-based for loops (C++11) when looping over map elements (practicalswift)

Pull request description:

  Before this commit:

  ```c++
  for (std::map<T1, T2>::iterator x = y.begin(); x != y.end(); ++x) {
      T1 z = (*x).first;
      …
  }
  ```

  After this commit:

  ```c++
  for (auto& x : y) {
      T1 z = x.first;
      …
  }
  ```

Tree-SHA512: 954b136b7f5e6df09f39248a6b530fd9baa9ab59d7c2c7eb369fd4afbb591b7a52c92ee25f87f1745f47b41d6828b7abfd395b43daf84a55b4e6a3d45015e3a0
2017-11-30 17:10:05 -05:00
Wladimir J. van der Laan 9e38d35744
Merge #10874: [RPC] getblockchaininfo: Loop through the bip9 soft fork deployments instead of hard coding
e4d0af4 Loop through the bip9 soft fork deployments instead of hard coding (Andrew Chow)

Pull request description:

  Instead of hard coding which deployment statistics should be listed in the `getblockchaininfo` output, loop through the available deployments (except testdummy) when displaying their deployment info.

Tree-SHA512: 87e503bcf5e0fd379940d5e53320b9cbb4b47d647c66246d46f47c09a941f135e6ce1e8b75dad441ed4c22c3f41992dfde7717414be1d71c771d4ff8fe0e1936
2017-11-30 18:19:49 +01:00
Andrew Chow e4d0af4fe1 Loop through the bip9 soft fork deployments instead of hard coding 2017-11-30 12:16:03 -05:00
Wladimir J. van der Laan dd49862a70
Merge #11794: Prefix leveldb debug logging
9b80fc1 Prefix leveldb debug logging (Wladimir J. van der Laan)

Pull request description:

  Add leveldb: prefix to leveldb debug logging lines.
  leveldb debug messages come in various scary flavors such as:

      2017-11-30 08:26:31 leveldb: Recovering log #26
      2017-11-30 08:26:31 leveldb: Level-0 table #28: started
      2017-11-30 08:26:31 leveldb: Level-0 table #28: 597 bytes OK
      2017-11-30 08:26:31 leveldb: Delete type=0 #26
      2017-11-30 08:26:31 leveldb: Delete type=3 #24

  so it's reasonably important to mark them as coming from leveldb internals and not from consensus validation wallet or such.
  This is consistent with the `libevent:` prefix for libevent messages.

  (this only affects `-debug=leveldb` or `-debug=1` otherwise you won't see them in the first place)

Tree-SHA512: 074eba00d39c6378b9e14d03aa2c551b4e3fc7bffdd5a1a0ba2498b44bcc77071d47735be09493286056053f0cca625c5cbaad7ad1ddb9d902d30e7cd316d9d2
2017-11-30 12:56:55 +01:00
Wladimir J. van der Laan 3ff6ff5ec5
Merge #11744: net: Add missing locks in net.{cpp,h}
bfb0c0a Add Clang thread safety analysis annotations (practicalswift)
63f21d2 net: Add missing locks in net.{cpp,h} (practicalswift)

Pull request description:

  Add missing locks in `net.{cpp,h}`:
  * writing variable `nTotalBytesRecv` requires holding mutex `cs_totalBytesRecv` exclusively
  * writing variables `nTotalBytesSent`, `nMaxOutboundTotalBytesSentInCycle` and `nMaxOutboundCycleStartTime` require holding mutex `cs_totalBytesSent` exclusively
  * writing variables `nMaxOutboundTimeframe` and `nMaxOutboundLimit` require holding mutex `cs_totalBytesSent` exclusively
  * writing variable `vAddedNodes` requires holding mutex `cs_vAddedNodes` exclusively

Tree-SHA512: 54a5b4bc6dc6f404dacf403af2ddd7b2214cc0a17d1d32a282def1c6b536105dada56bfabbc8606f56755f2d24874abba09913b51c8d13b0f2b000149551f0b0
2017-11-30 11:52:24 +01:00
Wladimir J. van der Laan cf5f432c69 Add -debuglogfile option
This patch adds an option to configure the name and/or directory of the
debug log.

The user can specify either a relative path, in which case the path
is relative to the data directory. They can also specify an absolute
path to put the log anywhere else in the file system.
2017-11-30 11:16:02 +01:00
Wladimir J. van der Laan 16fff80257
Merge #11783: Fix shutdown in case of errors during initialization
d31e5c1 Fix shutdown in case of errors during initialization (Wladimir J. van der Laan)

Pull request description:

  PR #10286 introduced a few steps which are not robust to early shutdown in initialization.

  Stumbled upon this with #11781, not sure if there are other scenarios that can trigger it, but it's good to harden against this in any case.

  E.g.
  ```
  $ src/bitcoind  -debuglogfile=/dfdf
  Error: Could not open debug log file /dfdf
  Program received signal SIGSEGV, Segmentation fault.
  UnregisterValidationInterface (pwalletIn=0x0) at /.../bitcoin/src/validationinterface.cpp:82
  82          g_signals.m_internals->BlockChecked.disconnect(boost::bind(&CValidationInterface::BlockChecked, pwalletIn, _1, _2));
  (gdb) bt
  #0  UnregisterValidationInterface (pwalletIn=0x0) at /.../bitcoin/src/validationinterface.cpp:82
  #1  0x00005555555a11fc in Shutdown () at /.../bitcoin/src/init.cpp:196
  #2  0x00005555555961cc in AppInit (argc=<optimized out>, argv=<optimized out>) at /.../bitcoin/src/bitcoind.cpp:183
  #3  0x0000555555596249 in main (argc=0, argv=0x555555ecf200) at /.../bitcoin/src/bitcoind.cpp:19
  ```

Tree-SHA512: 7dd9570a9803514a17781bfadf1edde47e96df4e852cce2f423cab422e005fb94d44e777af1a6ea5167b04a4d889e848ae7a61a7e0e94232247ddea32ee70fc8
2017-11-30 11:15:36 +01:00
Wladimir J. van der Laan ef14f2e3ff
Merge #11191: RPC: Improve help text and behavior of RPC-logging.
c60c49b Improve help text and behavior of RPC-logging (Akio Nakamura)

Pull request description:

  1. It is allowed `libevent` logging to be updated during runtime,
    but still described that restriction in the help text.
    So we delete these text.
  2. Add a descrption about the evaluation order of `<include>` and
    `<exclude>` to clarify how debug loggig categories to be set.
  3. Add a description about the available logging category `"all"`
    which is not explained.
  4. Add `"optional"` to the help text of `<include>` and `<exclude>`.
  5. Add missing new lines before `"Argument:"`.
  6. `"0"`,`"1"` are allowed in both array of `<include>` and `<exclude>`.
    `"0"` is **ignored** and `"1"` is treated **same as** `"all"`.
    It is confusing, so forbid them.
  7. It always returns all logging categories with status.
    Fix the help text to match this behavior.

Tree-SHA512: c2142da1a9bf714af8ebc38ac0d82394e2073fc0bd56f136372e3db7b2af3b6746f8d6b0241fe66c1698c208c124deb076be83f07dec0d0a180ad150593af415
2017-11-30 10:12:19 +01:00
Wladimir J. van der Laan 9b80fc1498 Prefix leveldb debug logging
Add leveldb: prefix to leveldb debug logging lines.
leveldb debug messages come in various scary flavors such as:

    2017-11-30 08:26:31 leveldb: Recovering log #26
    2017-11-30 08:26:31 leveldb: Level-0 table #28: started
    2017-11-30 08:26:31 leveldb: Level-0 table #28: 597 bytes OK
    2017-11-30 08:26:31 leveldb: Delete type=0 #26
    2017-11-30 08:26:31 leveldb: Delete type=3 #24

so it's reasonably important to mark them as coming from leveldb
internals and not from consensus validation wallet or such.

(this only affects `-debug=leveldb` or `-debug=1` otherwise you won't
see them in the first place)
2017-11-30 09:29:25 +01:00
Jonas Schnelli 38d31f95d3
Merge #11395: Qt: Enable searching by transaction id
eac2abca0 Qt: Enable searching by transaction id (Luke Dashjr)
c407c61c5 Qt: Avoid invalidating the search filter, when it doesn't really change (Luke Dashjr)
b1f634242 Qt: Rename confusingly-named "address prefix" to "search string" (Luke Dashjr)

Pull request description:

Tree-SHA512: 1c67037d19689fbaff21d15ed7848ac86188e5de34728312e1f9758dada759cab50d913a5bc09e413ecaa3e07557cf253809b95b5637ff79f2e3cf24d86dd3ed
2017-11-29 13:51:16 -10:00
Wladimir J. van der Laan 32c9b570fc
Merge #11753: clarify abortrescan rpc use
8b2c733 clarify abortrescan rpc use (Gregory Sanders)

Pull request description:

  `-rescan` during startup doesn't apply since RPC has not warmed up by that point

Tree-SHA512: 0b6738ed9429ca41edbfa23bb3e2da23bb16fed9e55c1803ab140b2efc49ef3295bb8b7eeb8c24df94204c5b3fb25d0d57cbc8d1be11856a5763c9fde71bceba
2017-11-29 12:19:53 +01:00
Wladimir J. van der Laan 46d1ebfcf8
Merge #11737: Document partial validation in ConnectBlock()
9d811dc Document partial validation in ConnectBlock() (Suhas Daftuar)

Pull request description:

  `ConnectBlock()` relies on validation that happens in `ContextualCheckBlock()` and
  `ContextualCheckBlockHeader()`. This has implications for implementing consensus
  changes and handling software upgrade to ensure that nodes upgrading their
  software end up enforcing all the consensus rules.

Tree-SHA512: 36a252af2221b0e5d5d6f8d5f8b16f8b566ca0db2d56242130a5523302c8757599ac234594a6a946c1689b260d18a32c2c7f8c3831304e78b9832e2ce5ac435a
2017-11-29 12:16:45 +01:00
Wladimir J. van der Laan e97039605e
Merge #11747: Fix: Open files read only if requested
e1a8ec5 Fix: Open files read only if requested (Andras Elso)

Tree-SHA512: 047951bf3fa1272764596d2efed0a541105a6d3057789ba4218cd1bbce8a802cab0feac0ed3d28f6eab6b2e54e294d46f729dd0162d6d209e319d716c0567352
2017-11-29 11:58:42 +01:00
Karl-Johan Alm a5f5a2ce53
[rpc] Fix fVerbose parsing (remove excess if cases). 2017-11-29 17:52:13 +09:00
Wladimir J. van der Laan d31e5c1d0f Fix shutdown in case of errors during initialization
PR #10286 introduced a few steps which are not robust to early shutdown
in initialization.

Stumbled upon this with #11781, not sure if there are other scenarios
that can trigger it, but it's harden against this in any case.
2017-11-28 12:12:05 +01:00
Wladimir J. van der Laan 26efc220a1
Merge #11722: Switched sync.{cpp,h} to std threading primitives.
f7f7e2c threads: add a thread_local autoconf check (Cory Fields)
bba9bd0 Switched sync.{cpp,h} to std threading primitives. (Thomas Snider)

Pull request description:

  Replaced boost threading primitives with the std equivalents.

Tree-SHA512: 72d10f9e48bfcf1db87e4a88bc698ef98eba0b29fe904570391b34a6ea1ffad474b7f192e70e3588a30e448f70f244eb4ddc5f24412a0bde2b564e76274160a5
2017-11-28 08:39:41 +01:00
Cory Fields f7f7e2cd34 threads: add a thread_local autoconf check 2017-11-27 15:01:47 -08:00
Wladimir J. van der Laan a933cb14c7
Merge #11603: Move RPC registration out of AppInitParameterInteraction
abbd230 Move RPC registration out of AppInitParameterInteraction (Russell Yanofsky)

Pull request description:

  Move to AppInitServers. This doesn't have any effects on bitcoin behavior. It was just strange to have this unrelated code in the middle of parameter interaction.

Tree-SHA512: 373e18f2ef8d21999ad36295d69326128a3086044acfc8ed537abd5497c8d3620b9832f7f6aa87c0c0939bb5e0d92be8a3c006b5997e9e6fa20334f5610c89bc
2017-11-23 22:10:30 +01:00
practicalswift bfb0c0a5b7 Add Clang thread safety analysis annotations 2017-11-23 07:59:58 +01:00
sean 3e1ee31043 [Tests] Adding unit tests for GetDifficulty in blockchain.cpp.
blockchain.cpp has low unit test coverage. This commit is intended
to start improving its code coverage to reasonable levels. One or more
follow up commits will complete the task that this commit is starting
(though the usefulness of this commit is not dependent upon later
commits).

Note that these tests were not written based upon a specification of how
GetDifficulty *should* work, but rather how it actually *does* work. As
a result, if there are any bugs in the current GetDifficulty
implementation, these unit tests serve to lock them in rather than
expose them.

-- Why has blockchain.cpp been modified if this is a unit testing change?

Since the existing GetDifficulty function relies on a global variable,
chainActive, it was not suitable for unit testing purposes. Both the
existing GetDifficulty function and the unit tests now call through to
a new, more modular version of GetDifficulty that can work on any chain,
not just chainActive.

-- Why does blockchain_tests.cpp directly include blockchain.cpp instead
of blockchain.h?

While the new GetDifficulty function's signature is arguably better than
the old one's, it still isn't great, and doesn't seem to warrant inclusion
as part of the blockchain.h API, especially since only test code is
directly using it. If a better way of exposing the new GetDifficulty
function to unit tests exists, please mention it and the commit will be
updated accordingly.

-- Why is the test fixture named blockchain_difficulty_tests rather than
blockchain_tests?

The Bitcoin Core policy for naming unit test files is to match the the
file under test ("blockchain" becomes "blockchain_tests"). While this
commit complies with that, blockchain.cpp is a massive file, such that
having all of the unit tests in one file will tend towards disorder.
Since there will be a lot more tests added to this file, the intention
is to divide up different types of tests into different test fixtures
within the same file.
2017-11-22 15:48:14 -08:00
Gregory Sanders 8b2c7330d0 clarify abortrescan rpc use 2017-11-22 14:06:53 -05:00
Andras Elso e1a8ec56c5 Fix: Open files read only if requested 2017-11-21 20:35:06 +01:00
practicalswift d2ea2bcb5c trivial: Fix unsuccessful typo 2017-11-21 19:14:35 +01:00
practicalswift 63f21d27ee net: Add missing locks in net.{cpp,h}
* writing variable 'nTotalBytesRecv' requires holding mutex 'cs_totalBytesRecv' exclusively
* writing variables 'nTotalBytesSent'/'nMaxOutboundTotalBytesSentInCycle'/'nMaxOutboundCycleStartTime' require holding mutex 'cs_totalBytesSent' exclusively
* writing variable 'nMaxOutboundTimeframe'/'nMaxOutboundLimit' require holding mutex 'cs_totalBytesSent' exclusively
* writing variable 'vAddedNodes' requires holding mutex 'cs_vAddedNodes' exclusively
2017-11-21 18:02:57 +01:00
Wladimir J. van der Laan d4267a3ab2
Merge #11738: Fix sendrawtransaction hang when sending a tx already in mempool
d9340ce Fix sendrawtransaction hang when sending a tx already in mempool (Matt Corallo)

Pull request description:

  I assume this is what #11721 actually hit.

Tree-SHA512: 1da4088bbda64c5527233de9ec4d03f9e0c1eacddb2ed3deab3cb99eac0293ee6fb846830f97b5e10e230307b6d7fd18013043173aa4f27ef171d9da626e2c88
2017-11-21 08:51:19 +01:00
MarcoFalke 901ba3e381
Merge #11714: [tests] Test that mempool rejects coinbase transactions
65e91f5ed [tests] Test that mempool rejects coinbase transactions (James O'Beirne)

Pull request description:

  ![selection_063](https://user-images.githubusercontent.com/73197/32978622-b0fa9d70-cbfa-11e7-9a72-1997409e5ba8.png)

  Neither the unit nor functional tests appear to cover rejecting a transaction from acceptance to the mempool on the basis of it being a coinbase. Seems like a decent thing to have a test for.

Tree-SHA512: 53af53c975cad5d7a21c443d71a1c0ced5c70a7799b75bb44d9b7dd6ab2afbcdcaab14571540efeb848f3a1daee5e1dd856530d8f2b50582595219a1c17555ff
2017-11-20 15:19:24 -05:00
Matt Corallo d9340ce912 Fix sendrawtransaction hang when sending a tx already in mempool 2017-11-20 12:18:52 -08:00
Suhas Daftuar 9d811dc18b Document partial validation in ConnectBlock()
ConnectBlock() relies on validation that happens in ContextualCheckBlock() and
ContextualCheckBlockHeader(). This has implications for implementing consensus
changes and handling software upgrade to ensure that nodes upgrading their
software end up enforcing all the consensus rules.
2017-11-20 14:31:15 -05:00
Akio Nakamura c60c49b679 Improve help text and behavior of RPC-logging
A) The changes in behavior are as follows:
1. Introduce logging category "none" as alias of "0" for
   both RPC-logging and bitcoind "-debug" parameter.
2. Same as "0" is given to argument of "-debug",
   if "none" or "0" is given to <include>, all other given logging
   categories are ignored. The same is true for <exclude>.
   (Before this PR, "0" was accepted but just be ignored itself.)

B) The changes in the help text are as follows:
1. Add a descrption about the evaluation order of <include> and
   <exclude> to clarify how debug loggig categories to be set.
2. Delete text that describe restriction about libevent because
   it's already allowed libevent logging to be updated during runtime.
3. Add a description for category "all", "1", "none" and "0".
4. Add "optional" to the help text of <include> and <exclude>.
5. Add missing new lines before "Argument:".
6. This RPC always returns all logging categories with status.
   Fix the help text to match this behavior.
2017-11-20 17:48:39 +09:00
Jonas Schnelli 57ac471a29
Call BannedListChanged outside of cs_setBanned lock 2017-11-19 12:51:44 -10:00
Wladimir J. van der Laan 7293d06413
Merge #11698: [Docs] [Qt] RPC-Console nested commands documentation
c3055bb Add help-console command to Qt debug console (Luke Mlsna)

Pull request description:

  This PR would close issue #9195 by adding documentation for the debug console features (mainly nested commands) which were added in [PR #7783](https://github.com/bitcoin/bitcoin/pull/7783).

  The following changes were made to QT debug console code:
  - Added a line to the initial message text at the top of the debug console:

  > For more information on using this console type **help-console**.

  - Added a pseudo-command `help-console` which is hooked after parsing the request, but before actually executing the RPC thread. It prints the following text to the console as if it were a valid RPC response.

  > This console accepts RPC commands using the standard syntax.
  >    example:    getblockhash 8
  > This console can also accept RPC commands using bracketed syntax.
  >    example:    getblockhash(8)
  > A space or a comma can be used to separate arguments for either syntax.
  >    example:    sendtoaddress \<address\> \<amount\>
  >                    sendtoaddress,\<address\>,\<amount\>
  > Commands may be nested when specified with the bracketed syntax.
  >    example:    getblockinfo(getblockhash(0),true).
  > Result values can be queried with a non-quoted string in brackets.
  >    example:    getblock(getblockhash(0) true)[height]

  This seemed like a reasonably sane way to introduce a fake RPC help command, but

Tree-SHA512: 35d73dcef9c4936b8be99e80978169f117c22b94f4400c91097bf7e0e1489060202dcd738d9debdf4c8a7bd10709e2c19d4f625f19e47c4a034f1d6019c0e0f2
2017-11-19 13:04:43 +01:00
Wladimir J. van der Laan 9cdd2bcf67
Merge #11718: tests: move pwalletMain to wallet test fixture
49bd659 tests: move pwalletMain to wallet test fixture (Wladimir J. van der Laan)

Pull request description:

  Scope the variable instead of using an external global; this is how test fixtures are intended to be used.

  Followup to #11713.

Tree-SHA512: 7d5bda93cdfe1329c8fe39bd72965906e36dad72fbb5d344ebedf26e66b1857510d01a3c2872d7f718fdeb23365e6ba71991aafe68e82781c6767a086b6d1590
2017-11-19 11:21:51 +01:00