Commit graph

11537 commits

Author SHA1 Message Date
Ben Woosley 5b35b92768
Break circular dependency: chain -> pow -> chain
chain.h does not actually depend on the methods defined in pow.h, just its
include of consensus/params.h, which is standalone and can be included instead.

Confirmed by inspection and successful build.
2018-05-14 18:36:39 -07:00
MarcoFalke 81c533c6f4
Merge #13158: [Qt]: Improve sendcoinsdialog readability
f08a385590 [qt]: changes sendcoinsdialog's box layout for improved readability. (marcoagner)

Pull request description:

  I'm addressing two (probably duplicate) issues: https://github.com/bitcoin/bitcoin/issues/11606 and https://github.com/bitcoin/bitcoin/issues/10613.

  Some points worth noting:

  - I've tried to balance the proposed changes on both issues without going too far and remaining a bit conservative. It will be easier to improve based on suggestions where necessary.

  - I preferred to maintain a layout that doesn't ask for an address truncation because, in my view, this wallet should be conservative on this.

  - I didn't follow the idea of aligning the amounts to the right for finding it more natural (and minimalist) to read the information without having to map alignments. Additionally, that approach seems to need more `<hr />`'s (or similar) in order to help the user to map information, which ended up cluttering the box too much (specially with multiple recipients). Thus, I preferred to just give some more space between recipients. Let me know if there are better ideas on this.

  Visually, I went from this (current):
  ![screenshot from 2018-05-03 15-11-30](https://user-images.githubusercontent.com/5016303/39581859-16abec82-4edc-11e8-86d3-eb722f8a7ed6.png)

  To this:
  ![screenshot from 2018-05-03 15-15-41](https://user-images.githubusercontent.com/5016303/39582066-96856adc-4edc-11e8-804c-468aec44cc8d.png)

  As a side note, while doing this, I thought about a better way to show fees and found there's already a PR on this (https://github.com/bitcoin/bitcoin/pull/12189) and thought it is

Tree-SHA512: e94b740fab6c1babd853a97be65c3b6f86ec174c975a926fde66b147f7a47e0cf0fa10f7255ba92aaba68c76a80dde8c688008179a34705a9799bf24d3c5cd46
2018-05-14 17:07:26 -04:00
MarcoFalke c5870ab689
Merge #12963: Fix Clang Static Analyzer warnings
159c32d1f1 Add assertion to guide static analyzers. Clang Static Analyzer needs this guidance. (practicalswift)
fd447a6efe Fix dead stores. Values were stored but never read. Limit scope. (practicalswift)

Pull request description:

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

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

Tree-SHA512: 83dbec821f45217637316bee978e7543f2d2caeb7f7b0b3aec107fede0fff8baa756da8f6b761ae0d38537740839ac9752f6689109c38a4b05c0c041aaa3a1fb
2018-05-14 10:45:24 -04:00
Wladimir J. van der Laan 682698970d
Merge #13197: util: warn about ignored recursive -includeconf calls
2352aa9 test: Ensure that recursive -includeconf produces appropriate warnings (Karl-Johan Alm)
c5bcc7d util: warn about recursive -includeconf arguments in configuration files (Karl-Johan Alm)

Pull request description:

  This is a follow-up PR to #10267, and addresses https://github.com/bitcoin/bitcoin/pull/10267#issuecomment-387546144.

  ~~I am adding extra work for @jnewbery in #12755 here -- maybe I should just rebase on top of that, but not sure what the appropriate approach is here.~~

Tree-SHA512: 87f0c32436b70424e33616ffb88d7cb699f90d6a583a10237e224b28fc936d6a9df95536c8c52ee8546b3942da92b2a357e61bf87e00d1462bc10d46d3bee352
2018-05-14 16:39:07 +02:00
MarcoFalke 0264836695
Merge #11689: mempool: Fix missing locking in CTxMemPool::check(…) and CTxMemPool::setSanityCheck(…)
47782b49e6 Add Clang thread safety analysis annotations (practicalswift)
0e2dfa8a65 Fix missing locking in CTxMemPool::setSanityCheck(double dFrequency) (practicalswift)
6bc5b7100b Fix missing locking in CTxMemPool::check(const CCoinsViewCache *pcoins) (practicalswift)

Pull request description:

  Fix missing locking in `CTxMemPool::check(const CCoinsViewCache *pcoins)`:
  * reading variable `mapTx` requires holding mutex `cs`
  * reading variable `mapNextTx` requires holding mutex `cs`
  * reading variable `nCheckFrequency` requires holding mutex `cs`

  Fix missing locking in `CTxMemPool::setSanityCheck(double dFrequency)`:
  * writing variable `nCheckFrequency` requires holding mutex `cs`

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

Pull request description:

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

Tree-SHA512: d59723598e918143f36408b4f49d31138b5d8968ba191472f6a207a63af147627f21e48fd6cc1606dd901d8a58183271e65ea4346a380db3c09e404764a28063
2018-05-14 09:56:47 -04:00
Wladimir J. van der Laan cb088b1461
Merge #13005: Make --enable-debug to pick better options
9e49db2 Make --enable-debug to pick better options (Evan Klitzke)

Pull request description:

  Cherry-picked (and rebased) 94189645e67f364c4445d62e2b00c282d885cbbf from the "up for grabs" PR: "[build] Make --enable-debug pick better options" (#12695).

  See previous review in #12695.

Tree-SHA512: a93cdadcf13e2ef8519acb1ce4f41ce95057a388347bb0a86a5c164dc7d0b0d14d4bb2a466082d5a100b8d50de65c605c40abaed555e8ea77c99e28800a34439
2018-05-14 15:33:03 +02:00
MarcoFalke 0dec5b5af4
Merge #13081: wallet: Add compile time checking for cs_wallet runtime locking assertions
66b0b1b2a6 Add compile time checking for all cs_wallet runtime locking assertions (practicalswift)

Pull request description:

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

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

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

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

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

Pull request description:

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

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

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

Tree-SHA512: b809b318e5014ec47d023dc3dc40826b9706bfb211fa08bc2d29f36971b96caa10ad48d9a3f96c03933be46fa4ff7e00e952ac77bfffb6563767fb08aa4f23d6
2018-05-14 15:06:48 +02:00
practicalswift 66b0b1b2a6 Add compile time checking for all cs_wallet runtime locking assertions 2018-05-14 14:57:25 +02:00
MarcoFalke ea7d6553bc
Merge #13116: Add Clang thread safety annotations for variables guarded by cs_{rpcWarmup,nTimeOffset,warnings}
8499f15e67 Add Clang thread safety annotations for variables guarded by cs_warnings (practicalswift)
cf13ad23d4 Add Clang thread safety annotations for variables guarded by cs_nTimeOffset (practicalswift)
012dec0347 Add Clang thread safety annotations for variables guarded by cs_rpcWarmup (practicalswift)

Pull request description:

  Add Clang thread safety annotations for variables guarded by `cs_{rpcWarmup,nTimeOffset,warnings}`.

Tree-SHA512: 8e0a4b9e36a4450bd75ad32c21d813bb572aaaa5b4a4cbdcbf4678e58ade6265c0b275352391168930a63fcbd09caa3b76e74595a7b14646054c52870c46d007
2018-05-14 08:46:54 -04:00
Wladimir J. van der Laan e03c0db08f
Merge #12560: [wallet] Upgrade path for non-HD wallets to HD
a8da482 Bump wallet version for pre split keypool (Andrew Chow)
dfcd9f3 Use a keypool of presplit keys after upgrading to hd chain split (Andrew Chow)
5c50e93 Allow -upgradewallet to upgradewallets to HD (Andrew Chow)
2bcf2b5 Test sethdseed (Andrew Chow)
b5ba01a Add 'sethdseed' RPC to initialize or replace HD seed (Chris Moore)
dd3c07a Separate HaveKey function that checks whether a key is in a keystore (Andrew Chow)

Pull request description:

  Revival/rebase of #11085

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

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

  I have also add some tests for this.

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

Tree-SHA512: e56c792e150590429ac4a1061e8d6f7b20cca06366e184eb9bbade4cd6ae82699a28fe84f87031eadba97ad2c1606517a105f00fb7b45779c979243020071adb
2018-05-14 11:17:29 +02:00
Pieter Wuille 418ae49ee1
Merge #13199: Bugfix: ensure consistency of m_failed_blocks after reconsiderblock
11fa6bb66e Bugfix: ensure consistency of m_failed_blocks after reconsiderblock (Suhas Daftuar)

Pull request description:

  This was introduced in 015a5258ad and could cause a node to crash (due to assertion failure) when using the `reconsiderblock` rpc.

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

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

Since upgradewallet is effectively run during a first run, all of the
first run initial setup stuff is combined with the upgrade to HD
2018-05-12 13:15:21 -04:00
Chris Moore b5ba01a187 Add 'sethdseed' RPC to initialize or replace HD seed 2018-05-12 13:15:21 -04:00
Wladimir J. van der Laan 6af005c3eb
Merge #11423: [Policy] Several transaction standardness rules
364bae5 qa: Pad scriptPubKeys to get minimum sized txs (MarcoFalke)
7485488 Policy to reject extremely small transactions (Johnson Lau)
0f8719b Add transaction tests for constant scriptCode (Johnson Lau)
9dabfe4 Add constant scriptCode policy in non-segwit scripts (Johnson Lau)

Pull request description:

  This disables `OP_CODESEPARATOR` in non-segwit scripts (even in an unexecuted branch), and makes a positive `FindAndDelete` result invalid. This ensures that the `scriptCode` serialized in `SignatureHash` is always the same as the script passing to the `EvalScript`.

Tree-SHA512: a0552cb920294d130251c48053fa2ff1fbdd26332e62b52147d918837852750f0ce35ce2cd1cbdb86588943312f8154ccb4925e850dbb7c2254bc353070cd5f8
2018-05-12 17:39:46 +02:00
Karl-Johan Alm c5bcc7dbe9
util: warn about recursive -includeconf arguments in configuration files
Since -includeconf cannot be used recursively, the user would not see feedback that an -includeconf
in an -includeconf'd file was silently ignored.
2018-05-10 11:02:20 +09:00
Andrew Chow 4d4185a4f0 Make gArgs aware of the arguments
gArgs knows what the available arguments are and their help. Getting
the help message is moved to gArgs and HelpMessage() is removed
2018-05-09 12:21:05 -04:00
Wladimir J. van der Laan 08c1caf863
Merge #13185: Bugfix: the end of a reorged chain is invalid when connect fails
a2f678d Bugfix: the end of a reorged chain is invalid when connect fails (Pieter Wuille)

Pull request description:

  Introduced in 4e0eed88ac

  When an invalid block is found during a reorg, we know the last of the blocks in the was-to-be-connected chain is invalid, but not necessarily the first. As `vpIndexToConnect` is ordered in decreasing height, the end of the reorg is the front of the vector, and not the back.

  This only affected the warning system.

Tree-SHA512: ddf749f8a78083811a5a17152723f545c1463768d09dc9832ec3682e803a3c106fb768de9fa91c03aa95e644d4e41361a7e4ee791940fd7d51cdefea90de31fc
2018-05-09 17:10:53 +02:00
Suhas Daftuar 11fa6bb66e Bugfix: ensure consistency of m_failed_blocks after reconsiderblock 2018-05-09 10:40:33 -04:00
Tim Ruffing b6f0b4d859
wallet: Improve logging when BerkeleyDB environment fails to close 2018-05-09 15:23:16 +02:00
Wladimir J. van der Laan 7b966d9e6e
Merge #10267: New -includeconf argument for including external configuration files
25b7ab9 doc: Add release notes for -includeconf (Karl-Johan Alm)
0f0badd test: Test includeconf parameter. (Karl-Johan Alm)
629ff8c -includeconf=<path> support in config handler, for including external configuration files (Karl-Johan Alm)

Pull request description:

  Fixes: #10071.

  Done:
  - adds `-includeconf=<path>`, where `<path>` is relative to `datadir` or to the path of the file being read, if in a file
  - protects against circular includes
  - updates help docs

  ~~~Thoughts:~~~
  - ~~~I am not sure how to test this in a neat manner. Feedback on this would be nice. Will dig/think though.~~~

Tree-SHA512: cb31f1b2f69fbc0890d264948eb2e501ac05cf12f5e06a5942f9c1539eb15ea8dc3cae817f4073aecb2fcc21d0386747f14f89d990772003a76e2a6d25642553
2018-05-09 06:36:54 +02:00
marcoagner f08a385590 [qt]: changes sendcoinsdialog's box layout for improved readability.
[qt]: extracts html tags from translator.

[qt]: removes missed tr() call.
2018-05-08 21:19:12 +01:00
Pieter Wuille a2f678d355 Bugfix: the end of a reorged chain is invalid when connect fails
Introduced in 4e0eed88ac

When an invalid block is found during a reorg, we know the last of the blocks in
the was-to-be-connected chain is invalid, but not necessarily the first. As
vpIndexToConnect is ordered in decreasing height, the end of the reorg is the
front of the vector, and not the back.

This only affected the warning system.
2018-05-07 11:18:30 -07:00
David A. Harding f30e9be4c1
RPC Docs: gettxout*: clarify bestblock and unspent counts 2018-05-07 11:48:58 -04:00
Jonas Schnelli 5778d44aa8
Merge #13079: Fix rescanblockchain rpc to properly report progress
16be13345 Fix rescanblockchain rpc to property report progress (Ben Woosley)

Pull request description:

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

Tree-SHA512: 5ebed0c56fae4ccfe613ff1d7082cb6da5a86635a8993ed3af70b500a4ea43074121aea9219b2f0321fbfeb7efcb964bdc2199297a64ca0fa85d9d07aa637d40
2018-05-07 15:03:38 +02:00
Wladimir J. van der Laan 57aae632e2
Merge #13131: Add Windows shutdown handler
ddebde7 Add Windows shutdown handler (Chun Kuan Lee)

Pull request description:

  Exit properly when clicked the red X of Windows Console

Tree-SHA512: f030edd08868390662b42abfa1dc6bd702166c6c19f5b1f8e7482e202451e79fb6f37ea672c26c2eb0d32c367bfca86160fbee624696c53828f280b7070be6a0
2018-05-07 14:33:03 +02:00
Wladimir J. van der Laan bd83704ec6
Merge #13149: Handle unsuccessful fseek(...):s
20ce5af Print a log message if we fail to shrink the debug log file (practicalswift)
29c9bdc Handle unsuccessful fseek(...):s (practicalswift)

Pull request description:

  Handle unsuccessful `fseek(...)`:s.

  **Note to reviewers:** What is the most appropriate course of actions for each of these unsuccessful `fseek(...)`:s?

Tree-SHA512: 5b3d82dbdd15d434d3f08dcb4df62888da4df8541d2586f56a4e529083005f6782c39e10645acd1ec403da83061bbfd8dbf2dddc66e09268d410ad0918c61876
2018-05-07 13:39:19 +02:00
Jonas Schnelli 6a01a50f49
Merge #13180: Fix re-declared scoped enum as unscoped (Causes issues with some compilers)
43f3dec00 Remove enum specifier (to avoid re-declare scoped enum as unscoped) (donaloconnor)

Pull request description:

  MSVC fails to compile with the changes made in #10742

  The problem is enum types were changed to scoped (`enum class`) but in some places `enum` as an unscoped is used.

  This is a very simple fix and I've tested it.

  Edit: Had to remove enum altogether - `enum class` doesn't compile on clang.

Tree-SHA512: 13e21666243585a133c74c81249a1fa4098d6b7aa3cda06be871fa017c0ad9bb7b0725f801160b9d31678448d668718197941fd84702ebdef15128c27d92cd70
2018-05-07 13:28:33 +02:00
Wladimir J. van der Laan a174702bad
Merge #13162: [net] Don't incorrectly log that REJECT messages are unknown.
fad63eb [logging] Don't incorrectly log that REJECT messages are unknown. (John Newbery)

Pull request description:

  Reject messages are logged to debug.log if NET debug logging is enabled.

  Because of the way the `ProcessMessages()` function is structured,
  processing for REJECT messages will also drop through to the default
  branch and incorrectly log `Unknown command "reject" from peer-?`. Fix
  that by exiting from `ProcessMessages()` early.

  without this PR:
  ```
  2018-05-03T17:37:00.930600Z received: reject (21 bytes) peer=0
  2018-05-03T17:37:00.930620Z Reject message code 16: spammy spam
  2018-05-03T17:37:00.930656Z Unknown command "reject" from peer=0
  ```
  with this PR:
  ```
  2018-05-03T17:35:04.751246Z received: reject (21 bytes) peer=0
  2018-05-03T17:35:04.751274Z Reject message code 16: spammy spam
  ```

Tree-SHA512: 5c84c98433ab99e0db2dd481f9c2db6f87ff0d39022ff317a791737e918714bbcb4a23e81118212ed8e594ebcf098ab7f52f7fd5e21ebc3f07b1efb279b9b30b
2018-05-07 12:49:11 +02:00
donaloconnor 43f3dec009 Remove enum specifier (to avoid re-declare scoped enum as unscoped) 2018-05-06 22:50:39 +01:00
practicalswift 47782b49e6 Add Clang thread safety analysis annotations 2018-05-05 16:51:22 +02:00
practicalswift 0e2dfa8a65 Fix missing locking in CTxMemPool::setSanityCheck(double dFrequency)
* writing variable 'nCheckFrequency' requires holding mutex 'cs'
2018-05-05 16:50:58 +02:00
practicalswift 6bc5b7100b Fix missing locking in CTxMemPool::check(const CCoinsViewCache *pcoins)
* reading variable 'mapTx' requires holding mutex 'cs'
* reading variable 'mapNextTx' requires holding mutex 'cs'
* reading variable 'nCheckFrequency' requires holding mutex 'cs'
2018-05-05 16:50:58 +02:00
practicalswift cbba1d2da4 Add compile time checking for all ::mempool.cs runtime locking assertions 2018-05-05 08:11:05 +02:00
Andrew Chow dd3c07acce Separate HaveKey function that checks whether a key is in a keystore 2018-05-05 00:43:04 -04:00
Johnson Lau 7485488e90 Policy to reject extremely small transactions
A transaction with 1 segwit input and 1 P2WPHK output has non-witness size of 82 bytes. Anything smaller than this have unnecessary malloc overhead and are not relayed/mined.
2018-05-05 04:26:13 +08:00
Johnson Lau 0f8719bb03 Add transaction tests for constant scriptCode
Tests showing that CONST_SCRIPTCODE is applied only to non-segwit transactions
2018-05-05 04:26:13 +08:00
Johnson Lau 9dabfe49c0 Add constant scriptCode policy in non-segwit scripts
This disables OP_CODESEPARATOR in non-segwit scripts (even in an unexecuted branch), and makes a positive FindAndDelete result invalid. This ensures that the scriptCode serialized in SignatureHash() is always the same as the script passing to the EvalScript.
2018-05-05 04:26:12 +08:00
practicalswift c3f34d06be Make it clear which functions that are intended to be translation unit local
Do not share functions that are meant to be translation unit local with
other translation units. Use internal linkage for those consistently.
2018-05-03 21:47:40 +02:00
John Newbery fad63ebe0f [logging] Don't incorrectly log that REJECT messages are unknown.
Reject messages are logged to debug.log if NET debug logging is enabled.

Because of the way the `ProcessMessages()` function is structured,
processing for REJECT messages will also drop through to the default
branch and incorrectly log `Unknown command "reject" from peer-?`. Fix
that by exiting from `ProcessMessages()` early.

without this PR:
```
2018-05-03T17:37:00.930600Z received: reject (21 bytes) peer=0
2018-05-03T17:37:00.930620Z Reject message code 16: spammy spam
2018-05-03T17:37:00.930656Z Unknown command "reject" from peer=0
```
with this PR:
```
2018-05-03T17:35:04.751246Z received: reject (21 bytes) peer=0
2018-05-03T17:35:04.751274Z Reject message code 16: spammy spam
```
2018-05-03 13:41:03 -04:00
Ben Woosley 16be13345e
Fix rescanblockchain rpc to property report progress
CWallet::ScanForWalletTransactions did not previously take into account
pindexStop when calculating progress.

Renamed progress vars to progress_*.

rescanblockchain is the only rpc that uses this parameter.
2018-05-03 13:18:10 -04:00
Tim Ruffing 264c643809
wallet: Reset BerkeleyDB handle after connection fails
According to the BerkeleyDB docs, the DbEnv handle may not be accessed
after close() has been called. This change ensures that we create a new
handle after close() is called. This avoids a segfault when the first
connection attempt fails and then a second connection attempt tries to
call open() on the already closed DbEnv handle.
2018-05-03 19:15:11 +02:00
practicalswift 20ce5af4c6 Print a log message if we fail to shrink the debug log file 2018-05-03 15:44:04 +02:00
Wladimir J. van der Laan 7eb7076f70
Merge #12639: Reduce cs_main lock in listunspent
a59dac3 refactor: Avoid extra lookups of mapAddressBook in listunspent RPC (João Barbosa)
d76962e rpc: Reduce cs_main lock in listunspent (João Barbosa)

Pull request description:

  On my system, where the wallet has 10000 unspents, the `cs_main` lock duration changed from 191ms to 36ms. The loop that generates the response takes around 155ms. So, the lock duration is reduced to around 20%.

Tree-SHA512: ddaae591f39da59a9d1a8e9ffe773d857687789476f566ca273d310ad531da6dacff80cac69f3334c601c251ac7c5ed4136656c725aa3d611c6bbf734111946e
2018-05-03 15:37:41 +02:00
Wladimir J. van der Laan b62b437acd
Merge #13148: logging: Fix potential use-after-free in LogPrintStr(...)
0bd4cd3 logging: remove unused return value from LogPrintStr (practicalswift)
76f344d logging: Fix potential use-after-free in LogPrintStr(...) (practicalswift)

Pull request description:

  Fix potential use-after-free in `LogPrintStr(...)`.

  `freopen(…)` frees `m_fileout`.

Tree-SHA512: ceee1f659c10a21525aa648377afeea0a37016339f5269dea54850ba3b475aa316f4931081655717b65f981598fdc9d79a1e79e55f7084c242eeb7bf372bc4b6
2018-05-03 12:53:57 +02:00
Wladimir J. van der Laan 11adab39e6
Merge #13154: Trivial: s/SetBestChain/ChainStateFlushed in comments after #13106
21f5680 Trivial: s/SetBestChain/ChainStateFlushed in comments after #13106 (Russell Yanofsky)

Pull request description:

Tree-SHA512: 373896dd73c3ba202739433b22320a4b7ea6dc80ef84547b4ed72c7ae0d6746b109c8b1879359c43374d1816fe384cc31b24b87879ddefe993887140c2f0df9c
2018-05-03 12:40:08 +02:00
João Barbosa a59dac35ab refactor: Avoid extra lookups of mapAddressBook in listunspent RPC 2018-05-03 11:32:57 +01:00