Commit Graph

10113 Commits

Author SHA1 Message Date
Wladimir J. van der Laan f088a1bb39
Merge #10303: [bench] Include ms/blk stats in Connect* benchmarks.
a473eff [bench] Replace 0.00(000)1 with MICRO/MILLI #defines in validation.cpp. (Karl-Johan Alm)
5f850b0 [bench] Include ms/blk stats in Connect* benchmarks. (Karl-Johan Alm)

Pull request description:

  Display the average per block runtime for the various benchmarked times in the block connect functions to give an overview of long(er) term time distribution statistics.

Tree-SHA512: 3d6f24f6b9e3dbb448a647e2cda8e7b90ad6a16d4821f49f426a8e1ebc3ce5a0cf0a8cde82213e293affba441615702dfe50822c8c818e282af03bfe383d83e0
2017-08-28 12:13:35 +02:00
Wladimir J. van der Laan df91e11ae1
Merge #11126: Acquire cs_main lock before cs_wallet during wallet initialization
de9a1db Acquire cs_main lock before cs_wallet during wallet initialization (Russell Yanofsky)

Pull request description:

  `CWallet::MarkConflicted` may acquire the `cs_main` lock after `CWalletDB::LoadWallet` acquires the `cs_wallet` lock during wallet initialization. (`CWalletDB::LoadWallet` calls `ReadKeyValue` which calls `CWallet::LoadToWallet` which calls `CWallet::MarkConflicted`). This is the opposite order that `cs_main` and `cs_wallet` locks are acquired in the rest of the code, and so leads to `POTENTIAL DEADLOCK DETECTED` errors if bitcoin is built with `-DDEBUG_LOCKORDER`.

  This commit changes `CWallet::LoadWallet` (which calls `CWalletDB::LoadWallet`) to acquire both locks in the standard order.

  Error was reported by @luke-jr in https://botbot.me/freenode/bitcoin-core-dev/msg/90244330/

Tree-SHA512: 353fe21bc0a4a2828b41876897001a3c414d4b115ee7430925bd391d8bc396fca81661145d00996c1ba1a01516d9acf8b89fb5c3da27092f5f3aa7e37ef26ffa
2017-08-28 10:56:41 +02:00
Wladimir J. van der Laan 9c833f471c
Merge #11145: Fix rounding bug in calculation of minimum change
6af49dd Output a bit more information for fee calculation report. (Alex Morcos)
a54c7b9 Fix rounding errors in calculation of minimum change size (Alex Morcos)

Pull request description:

  Thanks to @juscamarena for reporting this.

  Please backport to 0.15.

  There was a potential rounding error where the fee for the change added to the fee for the original tx could be less than the fee for the tx including change.

  This is fixed in the first commit.  The second commit adds one more snippet of information in the fee calculation report.  I actually realized that there is more information that would be nice to report, but we can add that post 0.15.

  An open question is whether we should be returning failure if the test in line 2885 is hit or just resetting pick_new_inputs and continuing.  Originally I made it a failure to avoid any possible infinite loops.  But the case hit here is an example of where that logic possibly backfired.

Tree-SHA512: efe049781acc1f6a8ad429a689359ac6f7b7c44cdfc9578a866dff4a2f6596e8de474a89d25c704f31ef4f8c89af770e98b75ef06c25419d5a6dfc87247bf274
2017-08-28 10:06:00 +02:00
Wladimir J. van der Laan 745bbdc189
Merge #11161: Remove redundant explicitly defined copy ctors
b426e24 Remove redundant explicitly defined copy ctors (Dan Raviv)

Pull request description:

  CFeeRate and CTxMemPoolEntry have explicitly defined copy ctors which has the same functionality as the implicit default copy ctors which would have been generated otherwise.

  Besides being redundant, it violates the rule of three (see https://en.wikipedia.org/wiki/Rule_of_three_(C%2B%2B_programming) ).
  (Of course, the rule of three doesn't -really- cause a resource management issue here, but the reason for that is exactly that there is no need for an explicit copy ctor in the first place since no resources are being managed).

Tree-SHA512: c9294ebf5d955d230b44c6f0d20822975d44a34471a717d656f8b17181bcd2827f47ba897edf5accd650f5998c58aadc8ab3c91a3f556f1f6de36830ed4069ce
2017-08-28 09:43:49 +02:00
Wladimir J. van der Laan 298251161c
Merge #11138: Compat: Simplify bswap_16 implementation
e40fa98 Simplify bswap_16 implementation (danra)

Pull request description:

  Simplify bswap_16 implementation on platforms which don't already have it defined.
  This has no effect on the generated assembly; it just simplifies the source code.

Tree-SHA512: 1c6ac1d187a2751da75256d12b6b890160d15246dd2c2b6a56748ec43482e3a5a3323be2910f07b42d3dc243a568c7412c26eaa036efec764436e988abd1c3f1
2017-08-28 09:41:57 +02:00
Wladimir J. van der Laan c7229ac36e
Merge #11131: rpc: Write authcookie atomically
82dd719 rpc: Write authcookie atomically (Wladimir J. van der Laan)

Pull request description:

  Use POSIX rename atomicity at the `bitcoind` side to create a working
  cookie atomically:

  - Write `.cookie.tmp`, close file
  - Rename `.cookie.tmp` to `.cookie`

  This avoids clients reading invalid/partial cookies as in #11129. As such, this is an alternative to that PR.

Tree-SHA512: 47fcc1ed2ff3d8fed4b7441e4939f29cc99b57b7a035673c3b55a124a2e49c8a904637a6ff700dd13a184be8c0255707d74781f8e626314916418954e2467e03
2017-08-28 09:40:15 +02:00
Wladimir J. van der Laan 5b8af7b879
Merge #11169: [GUI] Make tabs toolbar no longer have a context menu
e254830 Make tabs toolbar no longer have a context menu (Andrew Chow)

Pull request description:

  Adds a contextMenuPolicy of Qt::PreventContextMenu to prevent the tabs toolbar from showing a context menu that allows it to be hidden.

  Fixes #11168

Tree-SHA512: 8900b3c1a891ead3c9a20dc365b436fa75f97dbe0dfa7e20ee26fd9d09f3fee6eda286b0c075ed89fe1361608ecbdd87c744e37d97a3fba62493a86dedda867b
2017-08-28 09:35:06 +02:00
Dan Raviv b426e24678 Remove redundant explicitly defined copy ctors
CFeeRate and CTxMemPoolEntry have explicitly defined copy ctors which has the same functionality as the implicit default copy ctors which would have been generated otherwise.

Besides being redundant, it violates the rule of three (see https://en.wikipedia.org/wiki/Rule_of_three_(C%2B%2B_programming) ).
(Of course, the rule of three doesn't -really- cause a resource management issue here, but the reason for that is exactly that there is no need for an explicit copy ctor in the first place since no resources are being managed).
CFeeRate has an explicitly defined copy ctor which has the same functionality as the implicit default copy ctor which would h
ave been generated otherwise.
2017-08-28 01:29:48 +03:00
MarcoFalke ede386c219
Merge #11160: Improve versionbits_computeblockversion test code consistency
946638d0a Improve versionbits_computeblockversion test code consistency (danra)

Pull request description:

  In this test, `nTime` is used for all the calls to `Mine()`, each time being set to the correct time beforehand, except for in the last few calls to `Mine()` where `nStartTime` is used directly, even though `nTime` is still set to `nStartTime` beforehand. `nTime` just remains unused for these last few calls to `Mine()`.

  Changed the last few calls to `Mine()` to use `nTime` instead, improving consistency. This also fixes an unused value static analyzer warning about `nTime` being set to a value which is never used.

Tree-SHA512: f17cf1d29fd7097d53c0135d6357ee50943bd81b5ce0be785a37b85d34b5127cd6cc17ef844b519e19c33f2d96f7ababee643b9fba7afb031f444b2cfaeedbfd
2017-08-27 18:23:41 -04:00
MarcoFalke a084767b40
Merge #11155: Trivial: Documentation fixes for CVectorWriter ctors
37c4362f2 Trivial: Documentation fixes for CVectorWriter ctors (danra)

Pull request description:

Tree-SHA512: 13aef27f6b38dc276db6616d13e243a5413acf3a3ece5a52578c07b97a5bc9da337e7e230fcdb91727ec88b199844fd9aa3a88e7d96c911c119c91070a892ba1
2017-08-27 18:17:02 -04:00
danra 946638d0a0 Improve versionbits_computeblockversion test code consistency
In this test, `nTime` is used for all the calls to `Mine()`, each time being set to the correct time beforehand, except for in the last few calls to `Mine()` where `nStartTime` is used directly, even though `nTime` is still set to `nStartTime` beforehand. `nTime` just remains unused for these last few calls to `Mine()`.

Changed the last few calls to `Mine()` to use `nTime` instead, improving consistency. This also fixes an unused value static analyzer warning about `nTime` being set to a value which is never used.
2017-08-28 00:03:18 +03:00
Andrew Chow e2548302f4 Make tabs toolbar no longer have a context menu
Adds a contextMenuPolicy of Qt::PreventContextMenu to prevent the
tabs toolbar from showing a context menu that allows it to be
hidden.
2017-08-27 01:08:19 -04:00
Wladimir J. van der Laan 7fd49d01dc
Merge #11151: Fix header guards using reserved identifiers
bc70ab5 Fix header guards using reserved identifiers (Dan Raviv)

Pull request description:

  Identifiers beginning with an underscore followed immediately by an uppercase letter are reserved.

Tree-SHA512: 32b45e0aef6f6325bc3cbdea399532437490b753621149374df27e1c1eed6739ad1a09ae368e888cab8d01fb757f1b190c45a0854d2861de39a9296f17e29d9e
2017-08-26 12:59:22 +02:00
danra 37c4362f22 Trivial: Documentation fixes for CVectorWriter ctors 2017-08-26 13:20:36 +03:00
Dan Raviv bc70ab5dff Fix header guards using reserved identifiers
Identifiers beginning with an underscore followed immediately by an uppercase letter are reserved.
2017-08-26 02:56:53 +03:00
Alex Morcos 6af49dddea Output a bit more information for fee calculation report. 2017-08-25 14:59:36 -05:00
Alex Morcos a54c7b94f8 Fix rounding errors in calculation of minimum change size 2017-08-25 14:59:35 -05:00
Wladimir J. van der Laan 07c92b98e2
Merge #10976: [MOVEONLY] Move some static functions out of wallet.h/cpp
f01103c MOVEONLY: Init functions wallet/wallet.cpp -> wallet/init.cpp (Russell Yanofsky)
e7fe320 MOVEONLY: Fee functions wallet/wallet.cpp -> wallet/fees.cpp (Russell Yanofsky)
d97fe20 Move some static functions out of wallet.h/cpp (Russell Yanofsky)

Pull request description:

  This just moves some static wallet fee and init functions out of `wallet/wallet.cpp` and into new `wallet/fees.cpp` and `wallet/init.cpp` source files. There is one commit updating declarations and callers, followed by two MOVEONLY commits actually moving the function bodies.

  This change is desirable because wallet.h/cpp are monolithic and hard to navigate, so pulling things out and grouping together pieces of related functionality should improve the organization.

  Another motivation is the wallet process separation work in https://github.com/bitcoin/bitcoin/pull/10973, where (at least initially) parameter parsing and fee estimation are still done in the main process rather than the wallet process, and having functions that run in different processes scrambled up throughout wallet.cpp is unnecessarily confusing.

Tree-SHA512: 6e6982ff82b2ab4e681c043907e2b1801ceb9513394730070f16c46ad338278a863f5b3759aa13db76a259b268b1c919c81f4e339f0796a3cfb990161e8c316d
2017-08-25 21:30:42 +02:00
danra e40fa987e4 Simplify bswap_16 implementation
Simplify bswap_16 implementation on platforms which don't already have it defined.
This has no effect on the generated assembly; it just simplifies the source code.
2017-08-25 19:23:02 +03:00
Wladimir J. van der Laan 82dd7195e1 rpc: Write authcookie atomically
Use POSIX rename atomicity at the `bitcoind` side to create a working
cookie atomically:

- Write `.cookie.tmp`, close file
- Rename `.cookie.tmp` to `.cookie`

This avoids clients reading invalid/partial cookies as in #11129.
2017-08-25 15:37:24 +02:00
MarcoFalke 3f726c99f8
Merge #11112: [developer-notes] By default, declare single-argument constructors "explicit"
f1708ef89 Add recommendation: By default, declare single-argument constructors `explicit` (practicalswift)

Pull request description:

  This is a follow-up to the now merged #10969.

  Add recommendation:

  > By default, declare single-argument constructors `explicit`.
  >
  > - *Rationale*: This is a precaution to avoid unintended conversions that might arise when single-argument constructors are used as implicit conversion functions.
  >

Tree-SHA512: 1ceb1008a7863ebd0f09ba9c06b4e28b3b03265d7381f9d0c8bd4be1663d5d0392de0ecd811027aa27c0d962723674b245b3c165a437942a776f3525db39d36b
2017-08-24 20:59:26 -04:00
MarcoFalke 77fc469fc7
Merge #11108: Changing -txindex requires -reindex, not -reindex-chainstate
cd0ea4874 Changing -txindex requires -reindex, not -reindex-chainstate (Matt Corallo)

Pull request description:

  If there's an 0.15.0rc3, this should go in it.

Tree-SHA512: 857e77f0af9c055a3d1d91f37474ee9e06d6bc8c5ed21b29201b6c386801e7041523949076cdf0daa4d357a5175ce49394d85a1bedfbf13f3e577bdb6da1d6ce
2017-08-24 17:31:05 -04:00
Russell Yanofsky de9a1db2ed Acquire cs_main lock before cs_wallet during wallet initialization
CWallet::MarkConflicted may acquire the cs_main lock after
CWalletDB::LoadWallet acquires the cs_wallet lock during wallet initialization.
(CWalletDB::LoadWallet calls ReadKeyValue which calls CWallet::LoadToWallet
which calls CWallet::MarkConflicted). This is the opposite order that cs_main
and cs_wallet locks are acquired in the rest of the code, and so leads to
POTENTIAL DEADLOCK DETECTED errors if bitcoin is built with -DDEBUG_LOCKORDER.

This commit changes CWallet::LoadWallet (which calls CWalletDB::LoadWallet) to
acquire both locks in the standard order. It also fixes some tests that were
acquiring wallet and main locks out of order and failed with the new locking in
CWallet::LoadWallet.

Error was reported by Luke Dashjr <luke-jr@utopios.org> in
https://botbot.me/freenode/bitcoin-core-dev/msg/90244330/
2017-08-24 14:12:21 -04:00
Joe Harvell 79191f51b5 Add option -stdinrpcpass to allow RPC password to be read from standard input 2017-08-23 12:48:00 -06:00
Wladimir J. van der Laan 31b2612bbf
Merge #10679: Document the non-DER-conformance of one test in tx_valid.json.
ecb11f5 Document the non-strict-DER-conformance of one test in tx_valid.json. (Andreas Schildbach)

Tree-SHA512: 4d5ba4645fbfe8fe3f1baaa5f1a1152cdd2cbf3d901f38d8e7fbd56b16caa6a8a17f2a48c74fb725ce454dd1c870b81b2238e89d0639fcd4eee858554726e996
2017-08-23 12:15:10 +02:00
Andreas Schildbach ecb11f561c Document the non-strict-DER-conformance of one test in tx_valid.json.
In a signature, it contains an ASN1 integer which isn't strict-DER conformant due to excessive 0xff padding:
0xffda47bfc776bcd269da4832626ac332adfca6dd835e8ecd83cd1ebe7d709b0e
2017-08-23 12:13:28 +02:00
practicalswift f1708ef89a Add recommendation: By default, declare single-argument constructors `explicit` 2017-08-22 22:55:19 +02:00
Matt Corallo cd0ea48742 Changing -txindex requires -reindex, not -reindex-chainstate 2017-08-22 13:36:12 -04:00
Wladimir J. van der Laan 3e55f13bfc
Merge #11024: tests: Remove OldSetKeyFromPassphrase/OldEncrypt/OldDecrypt
a897d0e tests: Remove OldSetKeyFromPassphrase/OldEncrypt/OldDecrypt (practicalswift)

Pull request description:

  Reduces the number of non-free:d allocs with four (Δ in use at exit = -928 bytes).

  With this patch applied:

  ```
  $ valgrind --leak-check=full --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite --run_test=wallet_crypto
  …
  ==20243== HEAP SUMMARY:
  ==20243==     in use at exit: 72,704 bytes in 1 blocks
  ==20243==   total heap usage: 53,138 allocs, 53,137 frees, 49,600,420 bytes allocated
  ==20243==
  ==20243== 72,704 bytes in 1 blocks are still reachable in loss record 1 of 1
  ==20243==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==20243==    by 0x6AA5EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==20243==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
  ==20243==    by 0x40107CA: call_init (dl-init.c:30)
  ==20243==    by 0x40107CA: _dl_init (dl-init.c:120)
  ==20243==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
  ==20243==    by 0x2: ???
  ==20243==    by 0xFFF0006A2: ???
  ==20243==    by 0xFFF0006B8: ???
  ==20243==    by 0xFFF0006CF: ???
  ==20243==
  ==20243== LEAK SUMMARY:
  ==20243==    definitely lost: 0 bytes in 0 blocks
  ==20243==    indirectly lost: 0 bytes in 0 blocks
  ==20243==      possibly lost: 0 bytes in 0 blocks
  ==20243==    still reachable: 72,704 bytes in 1 blocks
  ==20243==         suppressed: 0 bytes in 0 blocks
  ```

  Without this patch applied:

  ```
  $ valgrind --leak-check=full --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite --run_test=wallet_crypto
  …
  ==19023== HEAP SUMMARY:
  ==19023==     in use at exit: 73,632 bytes in 5 blocks
  ==19023==   total heap usage: 52,718 allocs, 52,713 frees, 49,502,962 bytes allocated
  ==19023==
  ==19023== 24 bytes in 1 blocks are still reachable in loss record 1 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E5665: lh_insert (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7BB3: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==    by 0x182596: invoke<void (*)()> (callback.hpp:56)
  ==19023==    by 0x182596: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
  ==19023==
  ==19023== 128 bytes in 1 blocks are still reachable in loss record 2 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E5331: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7862: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7B7F: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==
  ==19023== 176 bytes in 1 blocks are still reachable in loss record 3 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E530F: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7862: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7B7F: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==
  ==19023== 600 bytes in 1 blocks are still reachable in loss record 4 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E8745: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==    by 0x182596: invoke<void (*)()> (callback.hpp:56)
  ==19023==    by 0x182596: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
  ==19023==    by 0x596CCB0: ??? (in /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.58.0)
  ==19023==    by 0x594C995: boost::execution_monitor::catch_signals(boost::unit_test::callback0<int> const&) (in /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.58.0)
  ==19023==
  ==19023== 72,704 bytes in 1 blocks are still reachable in loss record 5 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x6AA5EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==19023==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
  ==19023==    by 0x40107CA: call_init (dl-init.c:30)
  ==19023==    by 0x40107CA: _dl_init (dl-init.c:120)
  ==19023==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
  ==19023==    by 0x2: ???
  ==19023==    by 0xFFF0006A2: ???
  ==19023==    by 0xFFF0006B8: ???
  ==19023==    by 0xFFF0006CF: ???
  ==19023==
  ==19023== LEAK SUMMARY:
  ==19023==    definitely lost: 0 bytes in 0 blocks
  ==19023==    indirectly lost: 0 bytes in 0 blocks
  ==19023==      possibly lost: 0 bytes in 0 blocks
  ==19023==    still reachable: 73,632 bytes in 5 blocks
  ==19023==         suppressed: 0 bytes in 0 blocks
  ==19023==
  ==19023== For counts of detected and suppressed errors, rerun with: -v
  ==19023== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
  ```

Tree-SHA512: 38b6552736a5710a42dbad770c490583cfc762acbec716f5db4cf38314f494ea99430713ea407c73b49d867676ced221a282437f3fcfd8346f8f68386f4fc74d
2017-08-22 17:19:23 +02:00
Wladimir J. van der Laan fc5c237d4a
Merge #11007: wallet: Fix potential memory leak when loading a corrupted wallet file
c06755f wallet: Fix memory leak when loading a corrupted wallet file (practicalswift)

Pull request description:

  Fix potential memory leak when loading a corrupted wallet file.

Tree-SHA512: 4b836e4ee1fe4267213bb126af0c1174f964ff015fbe28d0a7e679eab877c275769906b3c08f885763958f6a9b559e1b5e6c7bff1df340bf2dfa2acd57500818
2017-08-22 09:42:43 +02:00
Wladimir J. van der Laan 2ab7c6300f
Merge #10843: Add attribute [[noreturn]] (C++11) to functions that will not return
b82c55a Add attribute [[noreturn]] (C++11) to functions that will not return (practicalswift)

Pull request description:

  Add attribute `[[noreturn]]` (C++11) to functions that will not return.

  Rationale:
  * Reduce the number of false positives/false negatives from static analyzers with regards to things such as unused or unreachable code
  * Potentially enable additional compiler optimizations

Tree-SHA512: 899683fe8b2fcf19bd334352271d368b46b805be9d426aac1808335fd95732d6d7078d3296951b9879196f3f6e3ec0fdb7695d0afdc3fbe4dd78a2ca70e91ff7
2017-08-22 09:38:49 +02:00
Wladimir J. van der Laan 4b65fa5921
Merge #11058: Comments: More comments on functions/globals in standard.h.
360b464 Comments: More comments on functions/globals in standard.h. (Jim Posen)

Pull request description:

  I was confused about what "data carrier" meant, so I wanted to comment the `fAcceptDatacarrier` and `nMaxDatacarrierBytes` fields specifically. Then I figured I'd add docs for the rest of the functions.

Tree-SHA512: e6d0cfe6f4a2ab52ae76f984b1f5d8de371ae938e7832be8b02517d868f1caea62fec8888c917a2bd3d8ef74025de7f00dc96923fa56436dc6b190626652bf29
2017-08-22 09:31:44 +02:00
Wladimir J. van der Laan 7ed57d3d7c
Merge #11050: Avoid treating null RPC arguments different from missing arguments
745d2e3 Clean up getbalance RPC parameter handling (Russell Yanofsky)
fd5d71e Update developer notes after params.size() cleanup (Russell Yanofsky)
e067673 Avoid treating null RPC arguments different from missing arguments (Russell Yanofsky)
e666efc Get rid of redundant RPC params.size() checks (Russell Yanofsky)

Pull request description:

  This is a followup to #10783.

  - The first commit doesn't change behavior at all, just simplifies code.
  - The second commit just changes RPC methods to treat null arguments the same as missing arguments instead of throwing type errors.
  - The third commit updates developer notes after the cleanup.
  - The forth commit does some additional code cleanup in `getbalance`.

  Followup changes that should happen in future PRs:

  - [ ] Replace uses of `.isTrue()` with calls to `.get_bool()` so numbers, objects, and strings cause type errors instead of being interpreted as false. https://github.com/bitcoin/bitcoin/pull/11050#discussion_r133850525
  - [ ] Add braces around if statements. https://github.com/bitcoin/bitcoin/pull/11050#discussion_r133851133
  - [ ] Maybe improve UniValue type error exceptions and eliminate RPCTypeCheck and RPCTypeCheckArgument functions. https://github.com/bitcoin/bitcoin/pull/11050#discussion_r133829303

Tree-SHA512: e72f696011d20acc0778e996659e41f9426bffce387b29ff63bf59ad1163d5146761e4445b2b9b9e069a80596a57c7f4402b75a15d5d20f69f775ae558cf67e9
2017-08-22 09:26:38 +02:00
Wladimir J. van der Laan ea3ac5990d
Merge #11026: Bugfix: Use testnet RequireStandard for -acceptnonstdtxn default
4aa2508 Bugfix: Use testnet RequireStandard for -acceptnonstdtxn default (Luke Dashjr)

Pull request description:

  Fixes a bug introduced in #8855

  `-acceptnonstdtxn` is a valid option only for testnet/regtest (in Core), and the help message reflects that. Currently, however, it is buggy in two ways:

  1. It uses mainnet to get the default value, which doesn't make sense since the option is never available for mainnet, and the only time the option is available, is when the default is the opposite.
  2. It uses the value of "require standard" directly as the default for "accept non-standard transactions", but these concepts are opposites: a negation must be performed to transform one to the other.

  Note the combination of these bugs results in the correct boolean output, but the logic to get there is completely wrong.

Tree-SHA512: 06ce513f59ba31f7ab4b6422a08a17bb37a5652dea4c38a4bbefedd5e2752d17bfccc32a4b0508068fa4783e316bff00a821ef18a24b1a2bb02859995d188fdc
2017-08-22 08:56:33 +02:00
Wladimir J. van der Laan c559884cac
Merge #10809: optim: mark a few classes final
40a0f9f Enable devirtualization opportunities by using the final specifier (C++11) (practicalswift)
9a1675e optim: mark a few classes final (Cory Fields)

Pull request description:

  Using gcc's ```-Wsuggest-final-types``` and lto, I identified a few easy devirtualization wins:

  > wallet/wallet.h:651:7: warning: Declaring type 'struct CWallet' final would enable devirtualization of 26 calls [-Wsuggest-final-types]

  >coins.h:201:7: warning: Declaring type 'struct CCoinsViewCache' final would enable devirtualization of 13 calls [-Wsuggest-final-types]

  >txdb.h:67:7: warning: Declaring type 'struct CCoinsViewDB' final would enable devirtualization of 5 calls [-Wsuggest-final-types]

  >zmq/zmqnotificationinterface.h:16:7: warning: Declaring type 'struct CZMQNotificationInterface' final would enable devirtualization of 4 calls [-Wsuggest-final-types]

  >httpserver.cpp:42:7: warning: Declaring type 'struct HTTPWorkItem' final would enable devirtualization of 2 calls [-Wsuggest-final-types]

Tree-SHA512: 2a825fd27121ccabaacff5cde2fc8a50d1b4cc846374606caa2a71b0cd8fcb0d3c9b5b3fd342d944998610e2168048601278f8a3709cc515191a0bb2d98ba782
2017-08-21 18:25:48 +02:00
Wladimir J. van der Laan 820ddd48a7
Merge #11027: [RPC] Only return hex field once in getrawtransaction
6bbdafc Pass serialization flags and whether to include hex to TxToUniv (Andrew Chow)
e029c6e Only return hex field once in getrawtransaction (Andrew Chow)

Pull request description:

  The hex is already returned in `TxToUniv()`, no need to give it out a second time in getrawtransaction itself.

Tree-SHA512: 270289f2d6dea37f51f5a42db3dae5debdbe83c6b504fccfd3391588da986ed474592c6655d522dc51022d4b08fa90ed1ebb249afe036309f95adfe3652cb262
2017-08-21 08:58:08 +02:00
Jim Posen 360b464a08 Comments: More comments on functions/globals in standard.h. 2017-08-18 14:45:08 -07:00
Wladimir J. van der Laan 262167393d
Merge #10952: [wallet] Remove vchDefaultKey and have better first run detection
e53615b Remove vchDefaultKey and have better first run detection (Andrew Chow)

Pull request description:

  Removes vchDefaultKey which was only used for first run detection. Improves wallet first run detection by checking to see if any keys were read from the database.

  This also fixes a (rather contrived) case where an encrypted non-HD wallet has corruption such that the default key is no longer valid and is loaded into a Core version that supports HD wallets. This causes a runtime exception since a new hd master key is generated as the software believes the wallet file is newly created but cannot add the generated key to the wallet since it is encrypted. I was only able to replicate this error by creating a non-hd wallet, encrypting it, then editing the wallet using `db_dump` and `db_load` before loading the wallet with hd enabled. This problem has been reported by [two](https://bitcointalk.org/index.php?topic=1993244.0) [users](https://bitcointalk.org/index.php?topic=1746976.msg17511261#msg17511261) so it is something that can happen, although that raises the question of "what corrupted the default key".

  ~P.S. I don't know what's up with the whitespace changes. I think my text editor is doing something stupid but I don't think those are important enough to attempt undoing them.~ Undid those

Tree-SHA512: 63b485f356566e8ffa033ad9b7101f7f6b56372b29ec2a43b947b0eeb1ada4c2cfe24740515d013aedd5f51aa1890dfbe499d2c5c062fc1b5d272324728a7d55
2017-08-18 18:56:49 +02:00
Wladimir J. van der Laan 0e5b7486cb
Merge #11044: [wallet] Keypool topup cleanups
67ceff4 [wallet] Add logging to MarkReserveKeysAsUsed (John Newbery)
1221f60 [wallet] Remove keypool_topup_cleanups (John Newbery)

Pull request description:

  A couple of minor cleanups suggested by @ryanofsky here: https://github.com/bitcoin/bitcoin/pull/11022#pullrequestreview-55598940

  Does not affect functionality. Not required for v0.15.

Tree-SHA512: d8d0698fd26ea49a4157e68669d5511095760c3a1ecfa3f917e3f273efbafb55c51a202d677614216eae3f796b6e8d17506b2ec2d4799a94f18981b396e65eec
2017-08-18 17:27:17 +02:00
Wladimir J. van der Laan fc51565cbd
Merge #11039: Avoid second mapWallet lookup
8f2f1e0 wallet: Avoid second mapWallet lookup (João Barbosa)

Pull request description:

  All calls to `mapWallet.count()` have the intent to detect if a `txid` exists and most are followed by a second lookup to retrieve the `CWalletTx`.

  This PR replaces all `mapWallet.count()` calls with `mapWallet.find()` to avoid the second lookup.

Tree-SHA512: 96b7de7f5520ebf789a1aec1949a4e9c74e13683869cee012f717e5be8e51097d068e2347a36e89097c9a89f1ed1a1529db71760dac9b572e36a3e9ac1155f29
2017-08-18 16:25:59 +02:00
Wladimir J. van der Laan 9e00a625b4
Merge #11066: Document the preference of nullptr over NULL or (void*)0
bea8e9e Document the preference of nullptr over NULL or (void*)0 (practicalswift)

Pull request description:

  Document the preference of `nullptr` over `NULL` or `(void*)0`.

  After this commit:

  ```
  $ git grep "[^A-Za-z_]NULL[^A-Za-z_]" | grep -vE '(leveldb|univalue|secp256k1|torcontrol|NULL certificates|ctaes|release-notes|patches|configure.ac|developer-notes)'
  $
  ```

  Some context:
  * `NULL → nullptr` was handled in the recently merged PR #10483
  * `0 → nullptr` was handled in the recently merged PR #10645

Tree-SHA512: f863096aa4eb21705910f89713ca9cc0d83c6df2147e3d3530c3e1589b96f6c68de8755dcf37d8ce99ebda3cfb69805e00eab13bf65424aaf16170e9dda3958a
2017-08-18 15:24:07 +02:00
Wladimir J. van der Laan 9f60b3707d
Merge #11081: Add length check for CExtKey deserialization (jonasschnelli, guidovranken)
07685d1 Add length check for CExtKey deserialization (Jonas Schnelli)

Pull request description:

  Fix a potential overwrite or uninitialised data issue.
  That code part is currently unused (at least in Bitcoin Core).
  We already do the same check `CExtPubKey`.

  Reported by @guidovranken

Tree-SHA512: 069ac5335248cf890491bc019537d3b0f7481428a4b240c5cd28ee89b56f4c9f45d947dd626fe89b2fae58472b6dbef57ed909876efe9963e2d72380d17cff12
2017-08-18 11:28:15 +02:00
Wladimir J. van der Laan f3558834db
Merge #11083: Fix combinerawtransaction RPC help result section
f9ca0fe Fix combinerawtransaction RPC help result section (Jonas Nick)

Pull request description:

  Without this PR it looks like the RPC would return something like a dictionary. But it just returns the transaction in hex.

Tree-SHA512: 565571fbb60cb805f81198cf0eab9ecdc04b62aff58c56145449235cd7c21215f4a1d7a5694d01c1a815fe0e787e5b790d24b71e2f9cc595cda16462ab680b8d
2017-08-18 09:52:48 +02:00
practicalswift bea8e9e66e Document the preference of nullptr over NULL or (void*)0 2017-08-18 09:51:00 +02:00
Wladimir J. van der Laan dbf6bd6ea0
Merge #11071: Use static_assert(…, …) (C++11) instead of assert(…) where appropriate
d1e6f91 Prefer compile-time checking over run-time checking (practicalswift)

Pull request description:

  Use `static_assert(…, …)` instead of `assert(…)` where appropriate.

Tree-SHA512: 63b6e50916bcef2195a73f93476bd69657ed9a8eea0bc4382933f478a6df639632c23c076df401fea648142adcb308bb2e6be35cc3dabca30daf7649b790f436
2017-08-18 09:46:22 +02:00
Jonas Nick f9ca0fe44e Fix combinerawtransaction RPC help result section 2017-08-17 19:35:30 -07:00
Jonas Schnelli 07685d1bc1
Add length check for CExtKey deserialization 2017-08-17 21:54:23 +02:00
Andrew Chow 6bbdafcdc4 Pass serialization flags and whether to include hex to TxToUniv 2017-08-17 10:42:51 -07:00
practicalswift d1e6f91f85 Prefer compile-time checking over run-time checking 2017-08-17 00:42:32 +02:00
John Newbery 67ceff4039 [wallet] Add logging to MarkReserveKeysAsUsed 2017-08-16 17:23:20 -04:00