Commit graph

10144 commits

Author SHA1 Message Date
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
John Newbery 1221f60c94 [wallet] Remove keypool_topup_cleanups
Unused function. Mostly reverts c25d90f125

c25d90f... was merged as part of PR 11022 but is not required.
2017-08-16 17:22:49 -04:00
practicalswift 64fb0ac016 Declare single-argument (non-converting) constructors "explicit"
In order to avoid unintended implicit conversions.
2017-08-16 16:33:25 +02:00
MarcoFalke 22e301a3d5
Merge #10901: Fix constness of ArgsManager methods
a622a1768 Fix constness of ArgsManager methods (João Barbosa)

Pull request description:

  Make `cs_args` mutex mutable so that const methods can acquire it.

  There's also tiny performance improvement by avoiding two map lookups when retrieving an argument value.

Tree-SHA512: ece58469745f2743b4b643242b51889a3d9c5b76492ed70bb74d4e5b378fff59da79fc129e499da779bf9f488c9435dda17ad1f3a804c1c30f56af422389e8bd
2017-08-16 16:09:27 +02:00
practicalswift 36d326e8b0 Use nullptr instead of zero (0) as the null pointer constant 2017-08-16 10:24:18 +02:00
MarcoFalke a46a671e25
Merge #10957: Avoid returning a BIP9Stats object with uninitialized values
3eb53b867 Avoid returning a BIP9Stats object with uninitialized values (practicalswift)

Pull request description:

  Uninitialized data potentially used in `rpc/blockchain.cpp`:

  ```
  static UniValue BIP9SoftForkDesc(const Consensus::Params& consensusParams, Consensus::DeploymentPos id)
  {
      ...
      const ThresholdState thresholdState = VersionBitsTipState(consensusParams, id);
      ...
      if (THRESHOLD_STARTED == thresholdState)
      {
          UniValue statsUV(UniValue::VOBJ);
          BIP9Stats statsStruct = VersionBitsTipStatistics(consensusParams, id);
          statsUV.push_back(Pair("period", statsStruct.period));
          statsUV.push_back(Pair("threshold", statsStruct.threshold));
          statsUV.push_back(Pair("elapsed", statsStruct.elapsed));
          statsUV.push_back(Pair("count", statsStruct.count));
          statsUV.push_back(Pair("possible", statsStruct.possible));
          rv.push_back(Pair("statistics", statsUV));
      }
      ...
      return rv;
  }
  ```

  Friendly ping @pinheadmz :-)

Tree-SHA512: cc1debe11d81157b9fa8e6064bfec199524cd1e2d0230ff35f45d97ecabbc664df8423edb1c9e4ba3daf19bbd51ab87bb50e5e5cd279be1d2aa1f7d8b300f148
2017-08-16 02:45:19 +02:00
MarcoFalke 655970d9c6
Merge #10965: Replace deprecated throw() with noexcept specifier (C++11)
986255026 Use the noexcept specifier (C++11) instead of deprecated throw() (practicalswift)

Pull request description:

  Use the `noexcept` specifier (C++11) instead of deprecated `throw()`.

Tree-SHA512: cf9b6b18f61f2f59bbeceb2e43b5cd07a60f5e569c8def05c410cb72326d597c80cb731059969ef89fa5fddaae1242225886e6109fcb535c4ad62d56ebcdf1ea
2017-08-16 02:29:18 +02:00
MarcoFalke b6a48914c5
Merge #9964: Add const to methods that do not modify the object for which it is called
6e8c48dc5 Add const to methods that do not modify the object for which it is called (practicalswift)

Pull request description:

Tree-SHA512: a6888111ba16fb796e320e60806e1a77d36f545989b5405dc7319992291800109eab0b8e8c286b784778f41f1ff5289e7cb6b4afd7aec77f385fbcafc02cffc1
2017-08-16 02:09:49 +02:00
MarcoFalke 7db65c363a
Merge #11011: [Trivial] Add a comment on the use of prevector in script.
08f71c29e [Trivial] Add a comment on the use of prevector in script. (Gregory Maxwell)

Pull request description:

Tree-SHA512: 020981516e67e576685eb9a8532178fb97d1780af409fc86d869cd05c293c0c823c26e838cf544d18610f5a3f479ce3e47d2ccb95fb1c4e55fe9e7ceb354f20b
2017-08-16 01:29:09 +02:00
MarcoFalke 4fb2586661
Merge #10956: Fix typos
9d5e98ff8 Fix typos. (practicalswift)

Pull request description:

  Fix some typos not covered by #10705.

Tree-SHA512: f06e9541f6ae13ef5d6731399b61795997b21a8816abeb1749c93e99a5c47354e6cbd4a3d145f4dc6ef8a13db179799a3121ecbb7288abf3e8d81cdf81500d37
2017-08-16 00:37:18 +02:00
MarcoFalke d7be7b39fa
Merge #10705: Trivial: spelling fixes
f42fc1d50 doc: spelling fixes (klemens)

Pull request description:

  patch contains some spelling fixes ( just in comments ) as found by a bot ( http://www.misfix.org, https://github.com/ka7/misspell_fixer ).

Tree-SHA512: ba6046cfcd81b0783420daae7d776be92dd7b85a593e212f8f1b4403aca9b1b6af12cef7080d4ea5ed4a14952fd25e4300109a59c414e08f5395cdb9947bb750
2017-08-16 00:30:12 +02:00
klemens f42fc1d508 doc: spelling fixes 2017-08-16 00:24:39 +02:00
Andrew Chow e53615b443 Remove vchDefaultKey and have better first run detection
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 will now also check for a valid defaultkey for backwards
compatibility reasons and to check for any corruption.

Keys will stil be generated on the first one, but there won't be
any shown in the address book as was previously done.
2017-08-15 15:05:53 -07:00
Russell Yanofsky 745d2e315f Clean up getbalance RPC parameter handling
Only change in behavior is that unsupported combinations of parameters now
trigger more specific error messages instead of the vague "JSON value is not a
string as expected" error.
2017-08-15 15:47:27 -04:00
Jonas Schnelli ae47724687
Merge #11017: [wallet] Close DB on error.
03bc719a8 [wallet] Close DB on error. (Karl-Johan Alm)

Pull request description:

  This PR intends to plug some leaks. It specifically implements adherence to the requirement in BDB to close a handle which failed to open (https://docs.oracle.com/cd/E17276_01/html/api_reference/C/dbopen.html):

  > The `DB->open()` method returns a non-zero error value on failure and 0 on success. If `DB->open()` fails, the `DB->close()` method must be called to discard the DB handle.

Tree-SHA512: cc1f2b925ef3fd6de785f62108fbc79454443397f80707762acbc56757841d2c32b69c0234f87805571aa40c486da31f315ca4c607a2c7d1c97c82a01301e2a6
2017-08-15 21:24:21 +02:00
Jonas Schnelli 64e66bb262
Merge #10964: Pass SendCoinsRecipient (208 bytes) by reference
d3d946a29 Pass SendCoinsRecipient (208 bytes) by const reference (practicalswift)

Pull request description:

  Pass `SendCoinsRecipient` (208 bytes) by reference.

  Avoid passing big parameters by value.

Tree-SHA512: 504791f1b1c73badbc276db13b83e39695298d7d82a9db0e48d54e7ef02f1a8d276b0adfdece1ba1130cc214e2f0fa9a3100b5359d0ca0fe96558d3c9a786e6e
2017-08-15 20:43:45 +02:00
Wladimir J. van der Laan 3841aaf059
Merge #11008: Enable disablesafemode by default.
f4c3d2c Enable disablesafemode by default. (Gregory Maxwell)

Pull request description:

  Safemode is almost useless as is-- it only triggers in limited
   cases most of which aren't even concerning. There have been
   several proposals to remove it. But as a simpler, safer, and
   more flexible first case, simply deactivate it by default.

  Anyone who wants it can re-enable and know what they've signed up for.

Tree-SHA512: f5409a3e81514c32db8eb27c7563ef85e25e56e5fc2a59eac2c30b10ec54087d982c1d3b702bedf9f3133c1f272f23805582a0f468350ba18d8b5a02bedd6401
2017-08-15 17:47:55 +02:00
Russell Yanofsky e067673f4e Avoid treating null RPC arguments different from missing arguments
This changes RPC methods to treat null arguments the same as missing arguments,
instead of throwing type errors. Specifically:

- `getbalance` method now returns the wallet balance when the `account` param
  is null instead of throwing a type error (same as when parameter is missing).
  It is still an error to supply `minconf` or `watchonly` options when the
  account is null.

- `addnode` and `setban` methods now return help text instead of type errors if
  `command` params are null (same as when params are missing).

- `sendrawtransaction`, `setaccount`, `movecmd`, `sendfrom`,
  `addmultisigaddress`, `listaccounts`, `lockunspent` methods accept null
  default values where missing values were previously allowed, and treat them
  the same.
2017-08-14 19:44:02 -04:00
Russell Yanofsky e666efcdba Get rid of redundant RPC params.size() checks
No change in behavior.
2017-08-14 19:38:18 -04:00
João Barbosa 8f2f1e0458 wallet: Avoid second mapWallet lookup 2017-08-14 23:06:06 +01:00
practicalswift c06755f5cf wallet: Fix memory leak when loading a corrupted wallet file 2017-08-14 17:54:35 +02:00
practicalswift a897d0e37a tests: Remove OldSetKeyFromPassphrase/OldEncrypt/OldDecrypt 2017-08-14 17:52:06 +02:00
Russell Yanofsky f01103c1e0 MOVEONLY: Init functions wallet/wallet.cpp -> wallet/init.cpp 2017-08-14 11:19:38 -04:00
Russell Yanofsky e7fe3208a8 MOVEONLY: Fee functions wallet/wallet.cpp -> wallet/fees.cpp 2017-08-14 11:19:38 -04:00
Russell Yanofsky d97fe2016c Move some static functions out of wallet.h/cpp
This commit just moves a few function declarations and updates callers.
Function bodies are moved in two followup MOVEONLY commits.

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 proximate 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.
2017-08-14 11:19:38 -04:00
Marko Bencun fcbde9091e remove unused gArgs wrappers 2017-08-14 17:02:36 +02:00
Marko Bencun bb81e17355 scripted-diff: stop using the gArgs wrappers
They were temporary additions to ease the transition.

-BEGIN VERIFY SCRIPT-
find src/ -name "*.cpp" ! -wholename "src/util.h" ! -wholename "src/util.cpp" | xargs perl -i -pe 's/(?<!\.)(ParseParameters|ReadConfigFile|IsArgSet|(Soft|Force)?(Get|Set)(|Bool|)Arg(s)?)\(/gArgs.\1(/g'
-END VERIFY SCRIPT-
2017-08-14 17:02:10 +02:00
Wladimir J. van der Laan ce74799a3c
Merge #10483: scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL
90d4d89 scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL (practicalswift)

Pull request description:

  Since C++11 the macro `NULL` may be:
  * an integer literal with value zero, or
  * a prvalue of type `std::nullptr_t`

  By using the C++11 keyword `nullptr` we are guaranteed a prvalue of type `std::nullptr_t`.

  For a more thorough discussion, see "A name for the null pointer: nullptr" (Sutter &
  Stroustrup), http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf

  With this patch applied there are no `NULL` macro usages left in the repo:

  ```
  $ git grep NULL -- "*.cpp" "*.h" | egrep -v '(/univalue/|/secp256k1/|/leveldb/|_NULL|NULLDUMMY|torcontrol.*NULL|NULL cert)' | wc -l
  0
  ```

  The road towards `nullptr` (C++11) is split into two PRs:
  * `NULL` → `nullptr` is handled in PR #10483 (scripted, this PR)
  * `0` → `nullptr` is handled in PR #10645 (manual)

Tree-SHA512: 3c395d66f2ad724a8e6fed74b93634de8bfc0c0eafac94e64e5194c939499fefd6e68f047de3083ad0b4eff37df9a8a3a76349aa17d55eabbd8e0412f140a297
2017-08-14 16:30:59 +02:00
Wladimir J. van der Laan 0e5cff6f2b
Merge #11012: Make sure to clean up mapBlockSource if we've already seen the block
3f8fa7f Make sure to clean up mapBlockSource if we've already seen the block (Cory Fields)

Pull request description:

  Otherwise we may leave them dangling.

  Credit TheBlueMatt.

Tree-SHA512: 8be77e08ebfc4f5b206d5ee7cfbe87f92c1eb5bc2b412471993658fe210306789aaf0f3d1454c635508a7d8effede2cf5ac144d622b0157b872733d9661d65c3
2017-08-14 16:19:35 +02:00
Wladimir J. van der Laan 6bdf4b3c7c
Merge #11028: Avoid masking of difficulty adjustment errors by checkpoints
85c82b5 Avoid masking of difficulty adjustment errors by checkpoints (Pieter Wuille)

Pull request description:

  Currently difficulty adjustment violations are not reported for chains that branch off before the last checkpoint. Change this by moving the checkpoint check after the difficulty check.

Tree-SHA512: 33666f2c3459151b28c42041a463779e6df18f61d3dd5b1879a0af4e5b199ef74d1e33e06af68bebfdfb211569ad5fb56556bfebe9d63b5688d910ea211b839a
2017-08-14 16:12:55 +02:00
Wladimir J. van der Laan 653a46dd91
Merge #11022: Basic keypool topup
d34957e [wallet] [tests] Add keypool topup functional test (Jonas Schnelli)
095142d [wallet] keypool mark-used and topup (John Newbery)
c25d90f [wallet] Add HasUnusedKeys() helper (John Newbery)
f2123e3 [wallet] Cache keyid -> keypool id mappings (John Newbery)
83f1ec3 [wallet] Don't hold cs_LastBlockFile while calling setBestChain (John Newbery)
2376bfc [wallet] [moveonly] Move LoadKeyPool to cpp (Matt Corallo)
cab8557 [wallet] [moveonly] Move CAffectedKeysVisitor (Jonas Schnelli)

Pull request description:

  This PR contains the first part of #10882 :

  - if a key from the keypool is used, mark all keys up to that key as used, and then try to top up the keypool
  - top up the keypool on startup

  Notably, it does not stop the node or prevent the best block from advancing if the keypool drops below a threshold (which means that transactions may be missed and funds lost if restoring from an old HD wallet backup).

Tree-SHA512: ac681fefeaf7ec2aab2fa1da93d12273ea80bd05eb48d7b3b551ea6e5d975dd97ba7de52b7fba52993823280ac4079cc36cf78a27dac708107ebf8fb6326142b
2017-08-14 16:08:44 +02:00
Gregory Maxwell 08f71c29ea [Trivial] Add a comment on the use of prevector in script. 2017-08-12 16:32:58 +00:00
MarcoFalke 2c811e08db
Merge #10765: Tests: address placement should be deterministic by default
c5ebddd11 Tests: address placement should be deterministic by default (René Nyffenegger)

Pull request description:

  Better version of wrong and closed pull request https://github.com/bitcoin/bitcoin/pull/10764

Tree-SHA512: dfda6ea4a9dd0f4c8b96212ad43a716ff1dddf115cd2712a2a7e42c97fc9494079c746906b39d880a9827c05d2b75c728afd4ca4519ce4d365f0dae0c4aec24c
2017-08-11 17:45:47 +02:00
Felix Weis 86279464b4 [RPC] trivial: gettxout no longer shows version of tx
Since the switch to a per-txout chainstate db in #10195, the tx version information is no longer stored. Updated `gettxout` rpc help text accordingly.
2017-08-11 12:16:55 +08:00
Andrew Chow e029c6e709 Only return hex field once in getrawtransaction
The hex is already returned in TxToUniv, no need to give it out a
second independent time in getrawtransaction itself.
2017-08-10 15:58:25 -07:00
Pieter Wuille 85c82b50d1 Avoid masking of difficulty adjustment errors by checkpoints
Currently difficulty adjustment violations are not reported for
chains that branch off before the last checkpoint. Change this
by moving the checkpoint check after the difficulty check.
2017-08-10 15:39:36 -07:00
Luke Dashjr 4aa25089b4 Bugfix: Use testnet RequireStandard for -acceptnonstdtxn default 2017-08-10 21:35:43 +00:00
John Newbery 095142d1f9 [wallet] keypool mark-used and topup
This commit adds basic keypool mark-used and topup:

- try to topup the keypool on initial load
- if a key in the keypool is used, mark all keys before that as used and
try to top up
2017-08-10 13:44:02 -04:00
MarcoFalke e526ca6284
Merge #10835: Rename member field according to the style guide
4d4fb33fc Rename member field according to the style guide. (Pavel Janík)

Pull request description:

  After #10193, approx. five instances of this warning are printed when compiling with `-Wshadow`:

  ```
  In file included from txmempool.cpp:14:
  ./reverse_iterator.h:20:22: warning: declaration shadows a field of 'reverse_range<T>' [-Wshadow]
      reverse_range(T &x) : x(x) {}
                       ^
  ./reverse_iterator.h:17:8: note: previous declaration is here
      T &x;
         ^
  1 warning generated.
  ```

Tree-SHA512: 6c07c2ed6f4f232a3a8bdcdd6057040967c74552fd29d80f42e8a453b95baf203c410aa31dccc08ff2e765cbba02b1a282f6ea7804955f09b31ab20ef383792e
2017-08-09 12:42:10 +02:00
Wladimir J. van der Laan 67f6f1c2d5
qt: Periodic translations update
Tree-SHA512: f967af98ba40908f3ba1286659a7ffedd1319d8d7d5c8d658f266897cb61ea28bace3f20f8ec77b83a69ac311c7e65467e40c3ee8b320a88768afa15e8c802cc
2017-08-09 12:04:41 +02:00
MarcoFalke ecd21357f1
Merge #10963: [bench] Restore format state of cout after printing with std::fixed/setprecision
fd05132e5 Restore default format state of cout after printing with std::fixed/setprecision (practicalswift)

Pull request description:

  Restore default format state of `std::cout` after printing with `std::fixed`/`std::setprecision`.

Tree-SHA512: 445b5b42aff58e2350939e8febc9b4a6fff478616abfe831aec42bee906cefac7a153c93d506407fb213d04dae9c7afbb5bfd344be63ca0f40ae39b331a4144f
2017-08-09 11:52:19 +02:00
practicalswift 1bcd44223c Remove the virtual specifier for functions with the override specifier
`override` guarantees that the function is virtual (in addition
to that the function is overriding a virtual function from a base
class).
2017-08-09 10:44:59 +02:00
Karl-Johan Alm 03bc719a85
[wallet] Close DB on error. 2017-08-09 17:28:29 +09:00
Cory Fields 3f8fa7f58b Make sure to clean up mapBlockSource if we've already seen the block
Credit TheBlueMatt
2017-08-08 21:45:18 -04:00
Gregory Maxwell f4c3d2c9da Enable disablesafemode by default.
Safemode is almost useless as is-- it only triggers in limited
 cases most of which aren't even concerning. There have been
 several proposals to remove it. But as a simpler, safer, and
 more flexible first case, simply deactivate it by default.

Anyone who wants it can re-enable and know what they've signed up for.
2017-08-08 20:14:25 +00:00
practicalswift 9d5e98ff80 Fix typos. 2017-08-08 17:12:57 +02:00
Wladimir J. van der Laan 2507fd5556
Merge #10998: Fix upgrade cancel warnings
861f9a2 Skip remainder of init if upgrade is cancelled (Matt Corallo)

Pull request description:

  Based on #10919.
  Without this, if you cancel upgrade, you get a needless error:
  ERROR: VerifyDB(): *** irrecoverable inconsistency in block data at

Tree-SHA512: aa47665682c6605ada376f1c100ce17cf8c4312427929eb2e75306f2199b47cbcdb4e0d98d5efcfefff03947b2c0fcbd3aab487a4ed14d50607df685c91a03d0
2017-08-08 11:58:31 +02:00
Wladimir J. van der Laan 4268426b45
Merge #11002: [wallet] return correct error code from resendwallettransaction
055d95f [wallet] return correct error code from resendwallettransaction (John Newbery)

Pull request description:

  New code in #10995 uses `RPC_INVALID_REQUEST`. According to the comment in rpc/protocol.h:
  ```
  // RPC_INVALID_REQUEST is internally mapped to HTTP_BAD_REQUEST (400).
  // It should not be used for application-layer errors.
  ```
  Change the returned error code to `RPC_WALLET_ERROR`

  #11000 will need to be updated to test for the correct error code.

Tree-SHA512: 0201b3a2091adf17ad301825da5bd29f0ea7e284b5394cbef80483fc293a558acc849f74a0780bb8501acab324fc722e41ae049cffec7afb76884e26df4b809e
2017-08-08 11:41:29 +02:00
Wladimir J. van der Laan 627c3c0e49
Merge #10999: Fix amounts formatting in decoderawtransaction
ce07638 doc: Add comment to use ValueFromAmount/AmountFromValue for JSON, not utilmoneystr (Wladimir J. van der Laan)
ec05c50 rpc: Use ValueFromAmount instead of FormatMoney in TxToUniv (Wladimir J. van der Laan)
46347ad rpc: Move ValueFromAmount to core_write (Wladimir J. van der Laan)
dac3782 doc: Correct AmountFromValue/ValueFromAmount names (Wladimir J. van der Laan)

Pull request description:

  With this, the amounts returned in `decoderawtransaction` will be padded to 8 digits like anywhere else in the API.

  This is accomplished by using `ValueFromAmount` in `TxToUniv`, instead of `FormatMoney` which it currently (mistakingly) uses. The `FormatMoney` function is only for debugging/logging use!

  To avoid dependency issues, `ValueFromAmount` is moved to `core_write.cpp`, where it also fits better. I don't move `AmountFromValue` to `core_read.cpp` at the same time, as this would have more impact due to the RPCError dependency there.

  (n.b.: large number of changed files is solely due to the util_tests JSONs needing update)

Tree-SHA512: 10fc2d27d33a77dbcb57aa7eccd4f53110c05d38eb7df6d40f10f14c08fad4274472e93af75aa59fe68ad0720fdf0930f0108124abef518e0dd162b3d2b2b292
2017-08-08 11:27:29 +02:00
John Newbery 055d95f842 [wallet] return correct error code from resendwallettransaction 2017-08-07 15:50:01 -04:00
Matt Corallo 861f9a28bc Skip remainder of init if upgrade is cancelled 2017-08-07 08:31:41 -07:00
Wladimir J. van der Laan 318392ca7c
Merge #10301: Check if sys/random.h is required for getentropy.
ee2d10a Check if sys/random.h is required for getentropy on OSX. (James Hilliard)

Pull request description:

  This should check and include sys/random.h if required for osx as mentioned [here](https://github.com/bitcoin/bitcoin/pull/9821#issuecomment-290936636).

Tree-SHA512: e9491f67f2e8b2e6bcdbcbb8063295e844d5627daf5336e3e17b4a8027d888fa65a08e4580a745abdc35ffd8d86b4fc7434daaac172c4a06ab7566a2ed0bfb92
2017-08-07 17:24:55 +02:00
Wladimir J. van der Laan ce076383a8 doc: Add comment to use ValueFromAmount/AmountFromValue for JSON, not utilmoneystr 2017-08-07 17:10:42 +02:00
Wladimir J. van der Laan ec05c508c6 rpc: Use ValueFromAmount instead of FormatMoney in TxToUniv
With this, the amounts returned in `decoderawtransaction` will be
padded to 8 digits like anywhwere else in the API.
2017-08-07 17:01:21 +02:00
Wladimir J. van der Laan 46347add43 rpc: Move ValueFromAmount to core_write
This is necessary because core_write has to write amounts in
TxToUniv, and mistakingly uses FormatMoney for that
(which is only for debugging).

We don't move AmountFromValue at the same time, as
this is more challenging due to the RPCError depencency
there.
2017-08-07 17:01:21 +02:00
Wladimir J. van der Laan fa64636948
Merge #10995: Fix resendwallettransactions assert failure if -walletbroadcast=0
01699fb Fix resendwallettransactions assert failure if -walletbroadcast=0 (Matt Corallo)

Pull request description:

  This fixes #10981 in my preferred way.

Tree-SHA512: 2e43d3ac78d13c5d59db23a82c76c722cc3344767a8237617080e489296d27a98bb1b3bd469b2c9b289b57a9da3709c90448d7a23bcc2e1dfb791c4fd16be015
2017-08-07 09:06:06 +02:00
Wladimir J. van der Laan c1c671feb1
Merge #10919: Fix more init bugs.
e7539f8 Fix some broken init-time prints/constants (Matt Corallo)
13ab353 Check for empty coinsview instead of just-reset coinsview in init (Matt Corallo)
fce3f4f Fix resume-of-reindex-after-restart (Matt Corallo)
efac91e Always wait for threadGroup to exit in bitcoind shutdown (Matt Corallo)

Pull request description:

  This is a follow-on to #10758 to help move 10758 along. The first fixes a regression in master that was partially fixed in 10758, the second I'm not sure if its a regression or not, but its clearly a bug that should be fixed.

Tree-SHA512: aca7b97a97dca66e1a218a33cc6f4aa002292ff1bb0af64e35b81fbaa91b9504f2605375808b43e93a63fc73634ad079b30ef6c9f4ba338d3b5f72d816dfeaff
2017-08-07 09:04:19 +02:00
Wladimir J. van der Laan c8b62c7de3
Merge #10982: Disconnect network service bits 6 and 8 until Aug 1, 2018
1de73f4 Disconnect network service bits 6 and 8 until Aug 1, 2018 (Matt Corallo)

Pull request description:

  Immediately disconnect peers that use service bits 6 and 8 until August 1st, 2018
  These bits have been used as a flag to indicate that a node is running incompatible
  consensus rules instead of changing the network magic, so we're stuck disconnecting
  based on the service bits, at least for a while.

  Staying connected to nodes on other networks only prevents both sides from reaching consensus quickly, wastes network resources on both sides, etc.

  Didn't add constants to protocol.h as the code there notes that "service bits should be allocated via the BIP process".

Tree-SHA512: 2d887774fcf20357019ffc2a8398464c76c1cff2c4e448c92bd5f391d630312301977fea841e0534df6641c7c5547605a5aad82859c59c4bd68be865e6d5a4c6
2017-08-07 08:49:56 +02:00
practicalswift 90d4d89230 scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL
-BEGIN VERIFY SCRIPT-
sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h
sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp
sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp
sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp
sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp
sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp
-END VERIFY SCRIPT-
2017-08-07 07:36:37 +02:00
Matt Corallo 01699fb283 Fix resendwallettransactions assert failure if -walletbroadcast=0 2017-08-06 21:40:56 -04:00
Matt Corallo 1de73f4e19 Disconnect network service bits 6 and 8 until Aug 1, 2018
These have been used to indicate incompatible consensus rules
instead of changing network magic, so we're stuck disconnecting them.
2017-08-06 11:48:19 -04:00
Wladimir J. van der Laan a9dd111441
Merge #10988: qt: Increase BLOCK_CHAIN_SIZE constants
1967d2a qt: Increase BLOCK_CHAIN_SIZE constants (Wladimir J. van der Laan)

Pull request description:

  - Increase `BLOCK_CHAIN_SIZE` from 120GB to 150GB
  - Increase `CHAIN_STATE_SIZE` from 2GB to 4GB

  I took the local sizes of the blocks and chainstate directory, and added a bit extra to accomodate the near future (15GB for the chain and 1GB for the chainstate).

Tree-SHA512: 76ec7770bd3a30380b0224a0f307cdad14c8227ef726dd55738cebe9d894430865aff11e05a793fd3e60d8fe019dbb392f574c1fb63ec746618b4460ed64bd0c
2017-08-05 13:36:44 +02:00
Wladimir J. van der Laan 02f4c4a42e
Merge #10977: [net] Fix use of uninitialized value in getnetworkinfo(const JSONRPCRequest&)
11dd29b [net] Fix use of uninitialized value in getnetworkinfo(const JSONRPCRequest& request) (practicalswift)

Pull request description:

  When running `test_bitcoin` under Valgrind I found the following issue:

  ```
  $ valgrind src/test/test_bitcoin
  ...
  ==10465== Use of uninitialised value of size 8
  ==10465==    at 0x6D09B61: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==10465==    by 0x6D0B1BB: std::ostreambuf_iterator<char, std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::_M_insert_int<unsigned long>(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, unsigned long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==10465==    by 0x6D0B36C: std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, unsigned long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==10465==    by 0x6D17699: std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==10465==    by 0x4CAAD7: operator<< (ostream:171)
  ==10465==    by 0x4CAAD7: formatValue<ServiceFlags> (tinyformat.h:345)
  ==10465==    by 0x4CAAD7: void tinyformat::detail::FormatArg::formatImpl<ServiceFlags>(std::ostream&, char const*, char const*, int, void const*) (tinyformat.h:523)
  ==10465==    by 0x1924D4: format (tinyformat.h:510)
  ==10465==    by 0x1924D4: tinyformat::detail::formatImpl(std::ostream&, char const*, tinyformat::detail::FormatArg const*, int) (tinyformat.h:803)
  ==10465==    by 0x553A55: vformat (tinyformat.h:947)
  ==10465==    by 0x553A55: format<ServiceFlags> (tinyformat.h:957)
  ==10465==    by 0x553A55: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > tinyformat::format<ServiceFlags>(char const*, ServiceFlags const&) (tinyformat.h:966)
  ==10465==    by 0x54C952: getnetworkinfo(JSONRPCRequest const&) (net.cpp:462)
  ==10465==    by 0x28EDB5: CallRPC(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (rpc_tests.cpp:31)
  ==10465==    by 0x293947: rpc_tests::rpc_togglenetwork::test_method() (rpc_tests.cpp:88)
  ==10465==    by 0x2950E5: rpc_tests::rpc_togglenetwork_invoker() (rpc_tests.cpp:84)
  ==10465==    by 0x182496: invoke<void (*)()> (callback.hpp:56)
  ==10465==    by 0x182496: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
  ...
  ```

  The read of the uninitialized variable `nLocalServices` is triggered by `g_connman->GetLocalServices()` in `getnetworkinfo(const JSONRPCRequest& request)` (`net.cpp:462`):

  ```c++
  UniValue getnetworkinfo(const JSONRPCRequest& request)
  {
  ...
      if(g_connman)
          obj.push_back(Pair("localservices", strprintf("%016x", g_connman->GetLocalServices())));
  ...
  }
  ```

  The reason for the uninitialized `nLocalServices` is that `CConnman::Start(...)` is not called
  by the tests, and hence the initialization normally performed by `CConnman::Start(...)` is
  not done.

  This commit adds a method `Init(const Options& connOptions)` which is called by both the
  constructor and `CConnman::Start(...)`. This method initializes `nLocalServices` and the other
  relevant values from the supplied `Options` object.

Tree-SHA512: d8742363acffd03b2ee081cc56840275569e17edc6fa4bb1dee4a5971ffe4b8ab1d2fe7b68f98a086bf133b7ec46f4e471243ca08b45bf82356e8c831a5a5f21
2017-08-05 13:23:19 +02:00
Wladimir J. van der Laan 2361208424
Merge #10986: Update chain transaction statistics
b1973d6 Update chain transaction statistics (Pieter Wuille)

Pull request description:

Tree-SHA512: f906173f4d602210f4a3e3d33eb2551158e353089a3d0b46dba93e6c6fbcb8bc785839be2917a60abe288e5728949e24bca355cbbe7600dc5a7ed30a873fff5a
2017-08-05 13:14:44 +02:00
Wladimir J. van der Laan 1967d2a4da qt: Increase BLOCK_CHAIN_SIZE constants
- Increase `BLOCK_CHAIN_SIZE` from 120GB to 150GB
- Increase `CHAIN_STATE_SIZE` from 2GB to 4GB

I took the local sizes of the blocks and chainstate directory, and added
a bit extra to accomodate the near future (15GB for the chain and 1GB
for the chainstate).
2017-08-05 08:42:43 +02:00
John Newbery c25d90f125 [wallet] Add HasUnusedKeys() helper 2017-08-04 16:42:53 -04:00
John Newbery f2123e3a7b [wallet] Cache keyid -> keypool id mappings 2017-08-04 11:08:39 -04:00
Ferdinando M. Ametrano ce3baa193f changed regtest RPCport to 18443 to avoid conflict with testnet 18332 2017-08-04 10:27:41 +02:00
Pieter Wuille 8842d1a5d4 Add undocumented -forcecompactdb to force LevelDB compactions 2017-08-03 23:42:26 -07:00
Pieter Wuille b1973d6181 Update chain transaction statistics 2017-08-03 16:39:58 -07:00
Wladimir J. van der Laan 2e857bb619
Merge #10942: Eliminate fee overpaying edge case when subtracting fee from recipients
49d903e Eliminate fee overpaying edge case when subtracting fee from recipients (Alex Morcos)

Pull request description:

  I'm not sure if this is the cause of the issue in #10034 , but this was a known edge case.  I just didn't realize how simple the fix is.

  Could use a couple more eyes to make sure nothing silly can go wrong here, but if we all agree it's this simple, we can add this as another 0.15 bug fix.

Tree-SHA512: db1dd1e83363a3c231267b626d3a388893ee70ba1972056fe2c339c5c9e4fbfd30f7fe837c30cc7be884d454797fd4c619b9d631a8d5eeb55cdb07402a83acb3
2017-08-03 12:26:12 +02:00
John Newbery 83f1ec33ce [wallet] Don't hold cs_LastBlockFile while calling setBestChain
cs_LastBlockFile shouldn't be held while calling wallet functions.
2017-08-02 17:31:35 -04:00
Matt Corallo 2376bfcf24 [wallet] [moveonly] Move LoadKeyPool to cpp 2017-08-02 17:31:35 -04:00
Jonas Schnelli cab8557e35 [wallet] [moveonly] Move CAffectedKeysVisitor 2017-08-02 17:31:35 -04:00