Commit graph

10552 commits

Author SHA1 Message Date
Matt Corallo 932f118e6a Accept unrequested blocks with work equal to our tip
This is a simple change that makes our accept requirements the
same as our request requirements, (ever so slightly) further
decoupling our consensus logic from our FindNextBlocksToDownload
logic in net_processing.
2017-10-31 13:36:06 -04:00
Matt Corallo 3d9c70ca0f Stop always storing blocks from whitelisted peers
There is no reason to wish to store blocks on disk always just
because a peer is whitelisted. This appears to be a historical
quirk to avoid breaking things when the accept limits were added.
2017-10-31 13:36:06 -04:00
practicalswift 3ab545d7f8 addrman: Add missing lock in Clear() (CAddrMan)
The variable vRandom is guarded by the mutex cs.
2017-10-31 10:34:00 +01:00
Matt Corallo 3788a8479b Do not send (potentially) invalid headers in response to getheaders
Nowhere else in the protocol do we send headers which are for
blocks we have not fully validated except in response to getheaders
messages with a null locator. On my public node I have not seen any
such request (whether for an invalid block or not) in at least two
years of debug.log output, indicating that this should have minimal
impact.
2017-10-30 18:59:07 -04:00
practicalswift 2530bf27b7 net: Add missing lock in ProcessHeadersMessage(...)
Reading the variable mapBlockIndex requires holding the mutex cs_main.

The new "Disconnect outbound peers relaying invalid headers" code
added in commit 37886d5e2f and merged
as part of #11568 two days ago did not lock cs_main prior to accessing
mapBlockIndex.
2017-10-30 20:00:17 +01:00
Wladimir J. van der Laan bb9ab0fccf
Merge #11541: Build: Fix Automake warnings when running autogen.sh
cc5c39d [Build] Add AM_OBJCXXFLAGS and QT_PIE_FLAGS to OBJCXXFLAGS to future-proof darwin targets (fanquake)
f8c6697 Fix automake warnings when running autogen.sh (Evan Klitzke)

Pull request description:

  Adjusted @eklitzke's commit to completely remove GZIP_ENV.
  Added a commit to address OBJCXXFLAGS.
  Rebased on master.
  Relevant info from @theuni & #11013 below.

  --------
  GZIP_ENV was indeed added for determinism, but gitian exports this as needed, so it's not really necessary. I'd rather just remove it.

  The mm.o rule was added to support XCode 4.2's ancient version of automake. That's irrelevant now, so it makes sense to remove that too.

  All darwin targets are PIE by default, so we don't technically need the flags, but I'd be more comfortable if we hooked up the OBJCXXFLAGS in case future ones are added.

  --------

  The second commit addresses the last point, but could probably use a better commit message.
  These warnings are removed from autogen output:
  ```
  Makefile.am:12: warning: user variable 'GZIP_ENV' defined here ...
  /usr/local/Cellar/automake/1.15.1/share/automake-1.15/am/distdir.am: ... overrides Automake variable 'GZIP_ENV' defined here
  src/Makefile.am: installing 'build-aux/depcomp'
  src/Makefile.am:503: warning: user target '.mm.o' defined here ...
  /usr/local/Cellar/automake/1.15.1/share/automake-1.15/am/depend2.am: ... overrides Automake target '.mm.o' defined here
  ```

Tree-SHA512: bd59df5f6d3aafe35d5e36925bfe61cc71e774583a0438d7dd946c9e7ecf6e59d42f90a58b8cfef0faa404c81050338ad4cefe721b4a949af881e73b6ab254d4
2017-10-29 18:28:21 +01:00
fanquake 60b98f8e14
[Util] Update tinyformat.h
Updates `tinyformat.h` to commit c42f/tinyformat@689695c upstream.
2017-10-29 21:12:12 +08:00
Pieter Wuille ba216b5fa6
Merge #11568: Disconnect outbound peers on invalid chains
37886d5e2 Disconnect outbound peers relaying invalid headers (Suhas Daftuar)
4637f1852 moveonly: factor out headers processing into separate function (Suhas Daftuar)

Pull request description:

  Alternate to #11446.

  Disconnect outbound (non-manual) peers that serve us block headers that are already known to be invalid, but exempt compact block announcements from such disconnects.

  We restrict disconnection to outbound peers that are using up an outbound connection slot, because we rely on those peers to give us connectivity to the honest network (our inbound peers are not chosen by us and hence could all be from an attacker/sybil).  Maintaining connectivity to peers that serve us invalid headers is sometimes desirable, eg after a soft-fork, to protect unupgraded software from being partitioned off the honest network, so we prefer to only disconnect when necessary.

  Compact block announcements are exempted from this logic to comply with BIP 152, which explicitly permits nodes to relay compact blocks before fully validating them.

Tree-SHA512: 3ea88e4ccc1184f292a85b17f800d401d2c3806fefc7ad5429d05d6872c53acfa5751e3df83ce6b9c0060ab289511ed70ae1323d140ccc5b12e3c8da6de49936
2017-10-28 11:19:38 -07:00
Wladimir J. van der Laan b5545d8df9
Merge #10409: [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest
fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift)

Pull request description:

  The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`.

  The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`.

Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
2017-10-28 16:22:20 +02:00
Suhas Daftuar 37886d5e2f Disconnect outbound peers relaying invalid headers 2017-10-27 16:29:12 -04:00
Suhas Daftuar 4637f18522 moveonly: factor out headers processing into separate function
ProcessMessages will now return earlier when processing headers
messages, rather than continuing on (and do nothing).
2017-10-26 16:37:06 -04:00
Wladimir J. van der Laan d93fa261f0
Merge #11490: Disconnect from outbound peers with bad headers chains
e065249 Add unit test for outbound peer eviction (Suhas Daftuar)
5a6d00c Permit disconnection of outbound peers on bad/slow chains (Suhas Daftuar)
c60fd71 Disconnecting from bad outbound peers in IBD (Suhas Daftuar)

Pull request description:

  The first commit will disconnect an outbound peer that serves us a headers chain with insufficient work while we're in IBD.

  The second commit introduces a way to disconnect outbound peers whose chains fall out of sync with ours:

  For a given outbound peer, we check whether their best known block (which is known from the blocks they announce to us) has at least as much work as our tip.  If it doesn't, we set a 20 minute timeout, and if we still haven't heard about a block with as much work as our tip had when we set the timeout, then we send a single getheaders message, and wait 2 more minutes.  If after two minutes their best known block has insufficient work, we disconnect that peer.

  We protect 4 of our outbound peers (who provide some "good" headers chains, ie a chain with at least as much work as our tip at some point) from being subject to this logic, to prevent excessive network topology changes as a result of this algorithm, while still ensuring that we have a reasonable number of nodes not known to be on bogus chains.

  We also don't require our peers to be on the same chain as us, to prevent accidental partitioning of the network in the event of a chain split.  Note that if our peers are ever on a more work chain than our tip, then we will download and validate it, and then either reorg to it, or learn of a consensus incompatibility with that peer and disconnect.  This PR is designed to protect against peers that are on a less work chain which we may never try to download and validate.

Tree-SHA512: 2e0169a1dd8a7fb95980573ac4a201924bffdd724c19afcab5efcef076fdbe1f2cec7dc5f5d7e0a6327216f56d3828884f73642e00c8534b56ec2bb4c854a656
2017-10-26 21:53:41 +02:00
Suhas Daftuar e065249c01 Add unit test for outbound peer eviction 2017-10-26 13:51:06 -04:00
Suhas Daftuar 5a6d00c6de Permit disconnection of outbound peers on bad/slow chains
Currently we have no rotation of outbound peers.  If an outbound peer
stops serving us blocks, or is on a consensus-incompatible chain with
less work than our tip (but otherwise valid headers), then we will never
disconnect that peer, even though that peer is using one of our 8
outbound connection slots.  Because we rely on our outbound peers to
find an honest node in order to reach consensus, allowing an
incompatible peer to occupy one of those slots is undesirable,
particularly if it is possible for all such slots to be occupied by such
peers.

Protect against this by always checking to see if a peer's best known
block has less work than our tip, and if so, set a 20 minute timeout --
if the peer is still not known to have caught up to a chain with as much
work as ours after 20 minutes, then send a single getheaders message,
wait 2 more minutes, and if a better header hasn't been received by then,
disconnect that peer.

Note:

- we do not require that our peer sync to the same tip as ours, just an
equal or greater work tip.  (Doing otherwise would risk partitioning the
network in the event of a chain split, and is also unnecessary.)

- we pick 4 of our outbound peers and do not subject them to this logic,
to be more conservative. We don't wish to permit temporary network
issues (or an attacker) to excessively disrupt network topology.
2017-10-26 13:43:53 -04:00
Suhas Daftuar c60fd71a65 Disconnecting from bad outbound peers in IBD
When in IBD, we'd like to use all our outbound peers to help us
sync the chain.  Disconnect any outbound peers whose headers have
insufficient work.
2017-10-26 13:43:53 -04:00
John Newbery 11413646be [trivial] (whitespace only) fix getblockchaininfo alignment 2017-10-26 12:11:13 -04:00
John Newbery bd9c18171d [rpc] Add initialblockdownload to getblockchaininfo 2017-10-26 12:11:09 -04:00
Russell Yanofsky 659b2061c4 Make listsinceblock refuse unknown block hash
Change suggested by Cory Fields <cory-nospam-@coryfields.com> who noticed
listsinceblock would ignore invalid block hashes causing it to return a
completely unfiltered list of transactions.
2017-10-26 07:10:59 -04:00
practicalswift fd3a2f3130 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest 2017-10-25 22:08:10 +02:00
Matt Corallo a6f33ea77d Sanity-check script sizes in bitcoin-tx 2017-10-24 14:11:52 -04:00
Jonas Schnelli 6157e8ce39
Merge #11499: [Qt] Add upload and download info to the peerlist (debug menu)
6b1891e2c Add Sent and Received information to the debug menu peer list (Aaron Golliver)
8e4aa35ff move human-readable byte formatting to guiutil (Aaron Golliver)

Pull request description:

  Makes the peer list display how much you've uploaded/downloaded from each peer.

  Here's a screenshot ~~[outdated](https://i.imgur.com/MhPbItp.png)~~, [current](https://i.imgur.com/K1htrVv.png) of how it looks. You can now sort to see who are the peers you've uploaded the most too.

  I also moved `RPCConsole::FormatBytes` to `guiutil::formatBytes` so I could use it in the peerlist

Tree-SHA512: 8845ef406e4cbe7f981879a78c063542ce90f50f45c8fa3514ba3e6e1164b4c70bb2093c4e1cac268aef0328b7b63545bc1dfa435c227f28fdb4cb0a596800f5
2017-10-22 15:33:11 -10:00
fanquake cc5c39ddca
[Build] Add AM_OBJCXXFLAGS and QT_PIE_FLAGS to OBJCXXFLAGS to future-proof darwin targets 2017-10-21 12:13:25 +08:00
Evan Klitzke f8c66972dd
Fix automake warnings when running autogen.sh 2017-10-21 12:05:36 +08:00
Suhas Daftuar 01b52cedd4 Add comment explaining forced processing of compact blocks 2017-10-19 20:52:30 -04:00
Suhas Daftuar ce8cd7a7da Don't process unrequested, low-work blocks
A peer could try to waste our resources by sending us unrequested blocks with
low work, eg to fill up our disk.  Since
e2652002b6 we no longer request blocks until we
know we're on a chain with more than nMinimumChainWork (our anti-DoS
threshold), but we would still process unrequested blocks that had more work
than our tip.  This commit fixes that behavior.
2017-10-19 20:33:45 -04:00
Wladimir J. van der Laan ff92fbf247
Merge #11529: Avoid slow transaction search with txindex enabled
7a5f930 Avoid slow transaction search with txindex enabled (João Barbosa)

Pull request description:

  This is an alternative to #11507 where a slow search is not attempted (in any case) if `txindex` is enabled.

Tree-SHA512: e680621781a9241c0513ddd79d23b0b42f3ccec8a63ed1c926b35c43321c81c39a1028770397dd5070501dcf644d897026a2bd68a161a4b435f19227c1bbca48
2017-10-19 20:04:57 +02:00
João Barbosa 7a5f9303a9 Avoid slow transaction search with txindex enabled 2017-10-19 16:01:45 +01:00
Russell Yanofsky 478a89c1ef Avoid opening copied wallet databases simultaneously
Make sure wallet databases have unique fileids. If they don't, throw an error.
BDB caches do not work properly when more than one open database has the same
fileid, because values written to one database may show up in reads to other
databases.

Bitcoin will never create different databases with the same fileid, but users
can create them by manually copying database files.

BDB caching bug was reported by Chris Moore <dooglus@gmail.com>
https://github.com/bitcoin/bitcoin/issues/11429

Fixes #11429
2017-10-19 09:01:43 -04:00
Andreas Schildbach 132d3225f3 Remove my testnet DNS seed as I currently don't have the capacity to keep it up to date. 2017-10-19 12:47:19 +02:00
MeshCollider c098c58196 Wrap dumpwallet warning and note scripts aren't dumped 2017-10-19 22:02:13 +13:00
Thomas Snider ff35de8f03 [ui] Add toggle for unblinding password fields 2017-10-18 13:22:30 -07:00
Wladimir J. van der Laan 937613d215
Merge #11467: Fix typos. Use nullptr instead of NULL.
0aacfa4 Remove accidental stray semicolon (practicalswift)
68feb49 Use nullptr instead of NULL (practicalswift)
c6b07fd Fix a vs. an typo (practicalswift)

Pull request description:

  Minor cleanups:
  * Typo: Fix a vs. an typo
  * Typo: Remove accidental stray semicolon (only remaining instance in repo)
  * Correctness/consistency: Use `nullptr` instead of `NULL` (only remaining instance in repo)

Tree-SHA512: 47142e557da9d3fa0b532c46edeb7f356a1f6dc5973e60b0e496badff3581ff696eade542d49da777ac7f2e895129cc8487ccdb1984ff828434fa86f9a56dad0
2017-10-18 17:01:43 +02:00
Wladimir J. van der Laan 50d72b3570
Merge #11495: [trivial] Make namespace explicit for is_regular_file
f4c4e38 [trivial] Make namespace explicit for is_regular_file (John Newbery)

Pull request description:

  is_regular_file resolves using argument dependent lookup. Make the
  namespace explicit so it's obvious where the function is defined.

  For those not familiar with argument dependent lookups:

  - http://en.cppreference.com/w/cpp/language/adl
  - https://en.wikipedia.org/wiki/Argument-dependent_name_lookup

  Thanks to C++ guru @ryanofsky for pointing this out to me.

Tree-SHA512: 919f1818081a8f90c5751181f87e13b06d90f8aec0ab873100434e55c85cca6e0e288ecc7f135e19e9b5dba7952e96b6393864b7840e20b69dd40e92a157928b
2017-10-18 16:35:19 +02:00
Wladimir J. van der Laan a1d78b59fc
Merge #11006: Improve shutdown process
793667a Improve shutdown process (João Barbosa)

Pull request description:

  Improve the shutdown time by not having to wait up to 2 seconds.

  Here is a comparison running `wallet.py` function tests before this PR:
  ```
  2017-08-08 03:25:20.881000 TestFramework (INFO): Initializing test directory /var/folders/1v/8_69hby54nj2k3n6fywt44x80000gn/T/testq_ramjjr
  2017-08-08 03:25:23.853000 TestFramework (INFO): Mining blocks...
  2017-08-08 03:25:24.132000 TestFramework (INFO): test getmemoryinfo
  2017-08-08 03:25:24.559000 TestFramework (INFO): test gettxout
  2017-08-08 03:25:59.858000 TestFramework (INFO): check -rescan
  2017-08-08 03:26:07.735000 TestFramework (INFO): check -reindex
  2017-08-08 03:26:15.751000 TestFramework (INFO): check -zapwallettxes=1
  2017-08-08 03:26:24.105000 TestFramework (INFO): check -zapwallettxes=2
  2017-08-08 03:26:36.694000 TestFramework (INFO): Stopping nodes
  2017-08-08 03:26:43.599000 TestFramework (INFO): Cleaning up
  2017-08-08 03:26:43.612000 TestFramework (INFO): Tests successful
  ```
  After:
  ```
  2017-08-08 03:24:04.319000 TestFramework (INFO): Initializing test directory /var/folders/1v/8_69hby54nj2k3n6fywt44x80000gn/T/testoqeyi50_
  2017-08-08 03:24:07.035000 TestFramework (INFO): Mining blocks...
  2017-08-08 03:24:07.317000 TestFramework (INFO): test getmemoryinfo
  2017-08-08 03:24:07.763000 TestFramework (INFO): test gettxout
  2017-08-08 03:24:25.715000 TestFramework (INFO): check -rescan
  2017-08-08 03:24:27.792000 TestFramework (INFO): check -reindex
  2017-08-08 03:24:29.797000 TestFramework (INFO): check -zapwallettxes=1
  2017-08-08 03:24:32.207000 TestFramework (INFO): check -zapwallettxes=2
  2017-08-08 03:24:36.812000 TestFramework (INFO): Stopping nodes
  2017-08-08 03:24:37.915000 TestFramework (INFO): Cleaning up
  2017-08-08 03:24:37.927000 TestFramework (INFO): Tests successful
  ```
  This largely improves the time spent in Travis (under evaluation).

Tree-SHA512: 023012fb3f8a380addf5995a4bf865862fed712cdd1a648d82a710e6566bc3bd34b6c49f9f06d6cc6bd81ca859da50d30d7f786c816e702549ab642e3476426f
2017-10-18 16:06:27 +02:00
Wladimir J. van der Laan b645f368f2
Merge #11492: [wallet] Fix leak in CDB constructor
7104de8 [wallet] Fix leak in CDB constructor (João Barbosa)

Pull request description:

  First commit fixes a minor leak.
  Second commit improves the constructor in the failure cases.

Tree-SHA512: 5165413d60ed9fc28203c9fe128adbba03a9ea9e9aa3734d9ea2522dafd815ba0fb8b90fd0809dbc06eb3ad360e7764de01dadf653ade3350fe86f6b8f04bc90
2017-10-18 15:39:43 +02:00
Wladimir J. van der Laan ffa5159cef
Merge #11508: Fix crash via division by zero assertion
207408b Fix crash via division by zero assertion (Jonas Schnelli)

Pull request description:

  Replaces the newly added `assert` for a devision by zero protection by a control structure. Floating point division by zero is defined by the floating point standard and results in +inf or -inf.

  Introduced in #11133
  Reported by @mzhou, fixes #11501

Tree-SHA512: ac9b4efa3ba52a2aa246fb11170128c4aaf829fd491b649524c85069c6ed33ae612e761809aea9d9a44bdea29a417b3f3a558226495094b5070a42a56b2ac77e
2017-10-18 15:22:54 +02:00
Pieter Wuille 26fee4f6bd
Merge #11062: [mempool] Mark mempool import fails that were found in mempool as 'already there'
258d33b41 [mempool] Mark unaccepted txs present in mempool as 'already there'. (Karl-Johan Alm)

Pull request description:

  I was investigating the reasons for failed imports in mempool and noticed that `LoadMempool()` and `pwallet->postInitProcess()` (for all wallets) are executed concurrently. The wallet will end up importing transactions that `LoadMempool()` later tries to import; the latter will fail due to the tx already being in the mempool.

  This PR changes the log message, adding an additional "already there" entry. For transactions not accepted into mempool, a check if they are in the mempool is done first, and if found, they are counted as 'already there', otherwise counted as 'failed'.

  Also slight rewording for consistency (successes, failed, expired, ... -> succeeded, failed, expired).

Tree-SHA512: 1a6134a25260917f2768365e0dfd8b278fe3f8287cab38bb028b7de3d517718a2d37696186dc7a23ceab338cc755fbbe7d45358ee94e573610fddd2a0620d6e5
2017-10-18 02:37:46 -07:00
MarcoFalke 808c84f89d
Merge #11483: Fix importmulti bug when importing an already imported key
a44a21517 Fix importmulti bug when importing an already imported key (Pedro Branco)

Pull request description:

  This PR fixes a bug in `importmulti` RPC call where it returns an invalid response when importing an already imported key.

  Before:
  ```sh
  ❯ bitcoin-cli -regtest importmulti '[{ "keys": ["cNcMUunXhVK1dXJ5riixtpYSxPXZnUAMGS4vpzwChdKmYY3Rz99v"], "scriptPubKey": { "address": "n4YZAf4WE2XF3t4BfeYS2nHAhb8CVx91BR" }, "timestamp": 1507655239 }]'
  [{ "success": true }]

  ❯ bitcoin-cli -regtest importmulti '[{ "keys": ["cNcMUunXhVK1dXJ5riixtpYSxPXZnUAMGS4vpzwChdKmYY3Rz99v"], "scriptPubKey": { "address": "n4YZAf4WE2XF3t4BfeYS2nHAhb8CVx91BR" }, "timestamp": 1507655239 }]' '{ "rescan": false }'
  [ false ]

  ❯ bitcoin-cli -regtest importmulti '[{ "keys": ["cNcMUunXhVK1dXJ5riixtpYSxPXZnUAMGS4vpzwChdKmYY3Rz99v"], "scriptPubKey": { "address": "n4YZAf4WE2XF3t4BfeYS2nHAhb8CVx91BR" }, "timestamp": 1507655239 }]' '{ "rescan": true }'
  error code: -1
  error message:
  JSON value is not a boolean as expected
  ```

  After this fix:
  ```sh
  ❯ bitcoin-cli -rpcuser=u -rpcpassword=p -regtest importmulti '[{ "keys": ["cNcMUunXhVK1dXJ5riixtpYSxPXZnUAMGS4vpzwChdKmYY3Rz99v"], "scriptPubKey": { "address": "n4YZAf4WE2XF3t4BfeYS2nHAhb8CVx91BR" }, "timestamp": 1507655139 }]'
  [{ "success": true }]

  ❯ bitcoin-cli -rpcuser=u -rpcpassword=p -regtest importmulti '[{ "keys": ["cNcMUunXhVK1dXJ5riixtpYSxPXZnUAMGS4vpzwChdKmYY3Rz99v"], "scriptPubKey": { "address": "n4YZAf4WE2XF3t4BfeYS2nHAhb8CVx91BR" }, "timestamp": 1507655139 }]'
  [{ "success": false, "error": { "code": -4, "message": "The wallet already contains the private key for this address or script" } }]
  ```

Tree-SHA512: 4acebdfb7d0ebd7cd48e943b93ed1cec072db1ace5c42b3f5cc225603764b6e804e4b823b0710965826aafc2f0c615c53d5aefcfdb9bc9c379f5221b798a318c
2017-10-17 21:40:54 +02:00
Aaron Golliver 6b1891e2c0 Add Sent and Received information to the debug menu peer list 2017-10-16 20:58:23 -07:00
Aaron Golliver 8e4aa35ffb move human-readable byte formatting to guiutil 2017-10-16 20:58:23 -07:00
donaloconnor b296bf1496 Init: Remove redundant exit(EXIT_FAILURE) instances and replace with return false 2017-10-16 22:16:36 +01:00
Jonas Schnelli 207408b088
Fix crash via division by zero assertion 2017-10-15 22:44:01 -07:00
Jonas Schnelli 2c66cea2d1
Merge #11496: [Trivial] Add missing comma from rescanblockchain example
43f76f6ac Add missing comma from rescanblockchain (MeshCollider)

Pull request description:

  #7061 forgot a comma in the HelpExampleRpc() for the rescanblockchain RPC, giving an incorrect example command output:
  > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "rescanblockchain", "params": [100000 120000] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

  Was just missed during nit-fixing. This is a trivial fix to add that comma in.

Tree-SHA512: b808f32674af585a1ddb78b25621dff0387dbad79c97d65ff61d8a9a12a94e4b8ecf03eda3f281fe439bddb6c0703c39104dbb279f1718949abd930faaa9042f
2017-10-15 21:56:17 -07:00
Pieter Wuille 6ab0e4cf49
Merge #10672: Avoid division by zero in the case of a corrupt estimates file
fe862c5ad Avoid division by zero in the case of a corrupt estimates file (practicalswift)

Pull request description:

  Avoid division by zero in the case of a corrupt estimates file.

Tree-SHA512: 285cb0d566f239d260880026a930a7412d86e31ea3819d5371a36364a241dc76164e68c1da6da8369345fa6037ca0abc5ab82d245058c085d5f1fd50111fba48
2017-10-14 16:58:13 -07:00
João Barbosa 7104de8b1f [wallet] Fix leak in CDB constructor
Now using a std::unique_ptr, the Db instance is correctly released
when CDB initialization fails.
The internal CDB state and mapFileUseCount are only mutated when
the CDB initialization succeeds.
2017-10-14 23:59:46 +01:00
MeshCollider a38bfbc51d Add wallet backup text to import*, add* and dumpwallet RPCs 2017-10-14 13:57:11 +13:00
MeshCollider 43f76f6acd Add missing comma from rescanblockchain 2017-10-14 12:34:04 +13:00
Matt Corallo 89f03120a0 Remove redundant pwallet nullptr check 2017-10-13 19:30:15 -04:00
Matt Corallo 3ea8b75281 Give ZMQ consistent order with UpdatedBlockTip on scheduler thread
Note that UpdatedBlockTip is also used in net_processing to
announce new blocks to peers. As this may need additional review,
this change is included in its own commit.
2017-10-13 19:30:15 -04:00
Matt Corallo cb06edf938 Fix wallet RPC race by waiting for callbacks in sendrawtransaction 2017-10-13 19:30:15 -04:00
Matt Corallo e545dedf72 Also call other wallet notify callbacks in scheduler thread
This runs Block{Connected,Disconnected}, SetBestChain, Inventory,
and TransactionAddedToMempool on the background scheduler thread.

Of those, only BlockConnected is used outside of Wallet/ZMQ, and
is used only for orphan transaction removal in net_processing,
something which does not need to be synchronous with anything
else.

This partially reverts #9583, re-enabling some of the gains from
 #7946. This does not, however, re-enable the gains achieved by
repeatedly releasing cs_main between each transaction processed.
2017-10-13 19:30:15 -04:00
Matt Corallo 17220d6325 Use callbacks to cache whether wallet transactions are in mempool
This avoid calling out to mempool state during coin selection,
balance calculation, etc. In the next commit we ensure all wallet
callbacks from CValidationInterface happen in the same queue,
serialized with each other. This helps to avoid re-introducing one
of the issues described in #9584 [1] by further disconnecting
wallet from current chain/mempool state.

Thanks to @morcos for the suggestion to do this.

Note that there are several race conditions introduced here:

 * If a user calls sendrawtransaction from RPC, adding a
   transaction which is "trusted" (ie from them) and pays them
   change, it may not be immediately used by coin selection until
   the notification callbacks finish running. No such race is
   introduced in normal transaction-sending RPCs as this case is
   explicitly handled.

 * Until Block{Connected,Disconnected} and
   TransactionAddedToMempool calls also run in the CSceduler
   background thread, there is a race where
   TransactionAddedToMempool might be called after a
   Block{Connected,Disconnected} call happens.

 * Wallet will write a new best chain from the SetBestChain
   callback prior to having processed the transaction from that
   block.

[1] "you could go to select coins, need to use 0-conf change, but
such 0-conf change may have been included in a block who's
callbacks have not yet been processed - resulting in thinking they
are not in mempool and, thus, not selectable."
2017-10-13 19:30:14 -04:00
Matt Corallo 5d67a7868d Add calls to CWallet::BlockUntilSyncedToCurrentChain() in RPCs
This prevents the wallet-RPCs-return-stale-info issue from being
re-introduced when new-block callbacks no longer happen in the
block-connection cs_main lock
2017-10-13 19:29:54 -04:00
Matt Corallo 5ee3172636 Add CWallet::BlockUntilSyncedToCurrentChain()
This blocks until the wallet has synced up to the current height.
2017-10-13 19:29:54 -04:00
Matt Corallo 0b2f42d737 Add CallFunctionInQueue to wait on validation interface queue drain 2017-10-13 19:29:54 -04:00
Matt Corallo 2b4b34503f Add ability to assert a lock is not held in DEBUG_LOCKORDER 2017-10-13 19:29:54 -04:00
Matt Corallo 0343676ce3 Call TransactionRemovedFromMempool in the CScheduler thread
This is both good practice (we want to move all such callbacks
into a background thread eventually) and prevents a lock inversion
when we go to use this in wallet (mempool.cs->cs_wallet and
cs_wallet->mempool.cs would otherwise both be used).
2017-10-13 19:29:54 -04:00
Matt Corallo a7d3936de8 Add a CValidationInterface::TransactionRemovedFromMempool
This is currently unused, but will by used by wallet to cache when
transactions are in the mempool, obviating the need for calls to
mempool from CWalletTx::InMempool()
2017-10-13 19:29:54 -04:00
Pieter Wuille 326a5652e0
Merge #11456: Replace relevant services logic with a function suite.
15f5d3b17 Switch DNSSeed-needed metric to any-automatic-nodes, not services (Matt Corallo)
5ee88b4bd Clarify docs for requirements/handling of addnode/connect nodes (Matt Corallo)
57edc0b0c Rename fAddnode to a more-descriptive "manual_connection" (Matt Corallo)
44407100f Replace relevant services logic with a function suite. (Matt Corallo)

Pull request description:

  This was mostly written as a way to clean things up so that the NETWORK_LIMITED PR (#10387) can be simplified a ton, but its also a nice standalone cleanup that will also require a bit of review because it tweaks a lot of stuff across net. The new functions are fine in protocol.h right now since they're straight-forward, but after NETWORK_LIMITED will really want to move elsewhere after @theuni moves the nServices-based selection to addrman from connman.

  Adds HasAllRelevantServices and GetRelevantServices, which check
  for NETWORK|WITNESS.

  This changes the following:
   * Removes nRelevantServices from CConnman, disconnecting it a bit
     more from protocol-level logic.
   * Replaces our sometimes-connect-to-!WITNESS-nodes logic with
     simply always requiring WITNESS|NETWORK for outbound non-feeler
     connections (feelers still only require NETWORK).
   * This has the added benefit of removing nServicesExpected from
     CNode - instead letting net_processing's VERSION message
     handling simply check HasAllRelevantServices.
   * This implies we believe WITNESS nodes to continue to be a
     significant majority of nodes on the network, but also because
     we cannot sync properly from !WITNESS nodes, it is strange to
     continue using our valuable outbound slots on them.
   * In order to prevent this change from preventing connection to
     -connect= nodes which have !WITNESS, -connect nodes are now
     given the "addnode" flag. This also allows outbound connections
     to !NODE_NETWORK nodes for -connect nodes (which was already true
     of addnodes).
   * Has the (somewhat unintended) consequence of changing one of the
     eviction metrics from the same
     sometimes-connect-to-!WITNESS-nodes metric to requiring
     HasRelevantServices.

  This should make NODE_NETWORK_LIMITED much simpler to implement.

Tree-SHA512: 90606896c86cc5da14c77843b16674a6a012065e7b583d76d1c47a18215358abefcbab44ff4fab3fadcd39aa9a42d4740c6dc8874a58033bdfc8ad3fb5c649fc
2017-10-13 15:31:19 -07:00
Jonas Schnelli 8c2de827e9
Merge #7061: [Wallet] Add RPC call "rescanblockchain <startheight> <stopheight>"
7a91ceb5e [QA] Add RPC based rescan test (Jonas Schnelli)
c77170fbd [Wallet] add rescanblockchain <start_height> <stop_height> RPC command (Jonas Schnelli)

Pull request description:

  A RPC rescan command is much more flexible for the following reasons:
  * You can define the start and end-height
  * It can be called during runtime
  * It can work in multiwallet environment

Tree-SHA512: df67177bad6ad1d08e5a621f095564524fa3eb87204c2048ef7265e77013e4b1b29f991708f807002329a507a254f35e79a4ed28a2d18d4b3da7a75d57ce0ea5
2017-10-13 15:23:22 -07:00
John Newbery f4c4e38884 [trivial] Make namespace explicit for is_regular_file
is_regular_file resolves using argument dependent lookup. Make the
namespace explicit so it's obvious where the function is defined.
2017-10-13 17:23:52 -04:00
Matt Corallo 15f5d3b172 Switch DNSSeed-needed metric to any-automatic-nodes, not services 2017-10-13 13:29:25 -04:00
Matt Corallo 5ee88b4bde Clarify docs for requirements/handling of addnode/connect nodes 2017-10-13 13:29:25 -04:00
Matt Corallo 57edc0b0c8 Rename fAddnode to a more-descriptive "manual_connection" 2017-10-13 13:25:58 -04:00
Matt Corallo 44407100ff Replace relevant services logic with a function suite.
Adds HasAllRelevantServices and GetRelevantServices, which check
for NETWORK|WITNESS.

This changes the following:
 * Removes nRelevantServices from CConnman, disconnecting it a bit
   more from protocol-level logic.
 * Replaces our sometimes-connect-to-!WITNESS-nodes logic with
   simply always requiring WITNESS|NETWORK for outbound non-feeler
   connections (feelers still only require NETWORK).
 * This has the added benefit of removing nServicesExpected from
   CNode - instead letting net_processing's VERSION message
   handling simply check HasAllRelevantServices.
 * This implies we believe WITNESS nodes to continue to be a
   significant majority of nodes on the network, but also because
   we cannot sync properly from !WITNESS nodes, it is strange to
   continue using our valuable outbound slots on them.
 * In order to prevent this change from preventing connection to
   -connect= nodes which have !WITNESS, -connect nodes are now
   given the "addnode" flag. This also allows outbound connections
   to !NODE_NETWORK nodes for -connect nodes (which was already true
   of addnodes).
 * Has the (somewhat unintended) consequence of changing one of the
   eviction metrics from the same
   sometimes-connect-to-!WITNESS-nodes metric to requiring
   HasRelevantServices.

This should make NODE_NETWORK_LIMITED much simpler to implement.
2017-10-13 13:25:57 -04:00
practicalswift fe862c5ad4 Avoid division by zero in the case of a corrupt estimates file 2017-10-13 08:41:45 +02:00
Pieter Wuille 424be03305
Merge #10099: Slightly Improve Unit Tests for Checkqueue
8c2f4b888 Expose more parallelism with relaxed atomics (suggested in #9938). Fix a test to check the exclusive or of two properties rather than just or. (Jeremy Rubin)

Pull request description:

  This PR is in response to #10026 and some feedback on #9938.

  ~Locally, all the checkqueue tests ran 3.2X faster on my machine. The worst offender, `test_CheckQueue_Correct_Random` ran 3.4X faster.~

  1. ~Removes `GetRand()` and replaces it with a single deterministic FastRandomContext instance.~ #10321 replicated this

  1. Exposes more parallelism with relaxed atomics, increasing chance of catching a bug. This does not change performance on my machine.

  1. Makes one test case more restrictive (xor instead of or, see #9938).

Tree-SHA512: a59dfbee0273c713525a130dfedc1c7ff26f50c2aaca1e94ef5d759b1d6ea6338ffbd97f863b9f6209750d8a788a15fa8ae1bf26774ed2473c520811337e6b00
2017-10-12 15:32:50 -07:00
Wladimir J. van der Laan 470c730e3f
Merge #10898: Fix invalid checks (NULL checks after dereference, redundant checks, etc.)
76fed83 Avoid NULL pointer dereference when _walletModel is NULL (which is valid) (practicalswift)
4971a9a Use two boolean literals instead of re-using variable (practicalswift)
b5fb339 Remove duplicate uriParts.size() > 0 check (practicalswift)
7466991 Remove redundant check (!ecc is always true) (practicalswift)
55224af Remove redundant NULL checks after new (practicalswift)

Pull request description:

  Contains:
  * Remove redundant `NULL` checks after throwing `new`
  * Remove redundant check (`!ecc` is always true)
  * Remove duplicate `uriParts.size() > 0` check
  * Use two boolean literals instead of re-using variable

Tree-SHA512: 30e9af8a9d5c8184836f8267b492aeb4e26eca171a3be08f634b3f39b3055b9fa9f06623f6c69b294ca13bf99743f7645cfac2b25e014ff74687bd085a997895
2017-10-12 23:55:50 +02:00
Jonas Schnelli c77170fbdb
[Wallet] add rescanblockchain <start_height> <stop_height> RPC command 2017-10-12 11:59:21 -07:00
Eelis 28f8b66577 Diagnose unsuitable outputs in lockunspent().
Fixes #2667.
2017-10-12 15:56:32 +02:00
Wladimir J. van der Laan f74459dba6
Merge #11277: Fix uninitialized URI in batch RPC requests
4526d21 Add test for multiwallet batch RPC calls (Russell Yanofsky)
74182f2 Add missing batch rpc calls to python coverage logs (Russell Yanofsky)
505530c Add missing multiwallet rpc calls to python coverage logs (Russell Yanofsky)
9f67646 Make AuthServiceProxy._batch method usable (Russell Yanofsky)
e02007a Limit AuthServiceProxyWrapper.__getattr__ wrapping (Russell Yanofsky)
edafc71 Fix uninitialized URI in batch RPC requests (Russell Yanofsky)

Pull request description:

  This fixes "Wallet file not specified" errors when making batch wallet RPC calls with more than one wallet loaded. This issue was reported by @NicolasDorier in https://github.com/bitcoin/bitcoin/issues/11257

  Request URI is not used for anything except multiwallet request dispatching, so this change has no other effect.

Tree-SHA512: b3907af48a6323f864bb045ee2fa56b604188b835025ef82ba3d81673244c04228d796323cec208a676e7cd578a95ec7c7ba1e84d0158b93844d5dda8f6589b9
2017-10-12 14:54:26 +02:00
Wladimir J. van der Laan 3bb77ebee6
Merge #11073: Remove dead store in ecdsa_signature_parse_der_lax.
bfebc0b Remove dead store in ecdsa_signature_parse_der_lax. (Eelis)

Pull request description:

  This was one of the issues found by Clang's static analyzer (#9573).

Tree-SHA512: 3674c56ccdc750bfe42e41d56b1f2058b6921c5354f7e757f6af10a759c5be75e23d6c7932a4524b9a24da308f426803b11deffbfcf09a5898a4204ee61d16d2
2017-10-12 13:41:12 +02:00
Wladimir J. van der Laan a865b38bf3
Merge #11133: Document assumptions that are being made to avoid division by zero
55509f1 Document assumptions that are being made to avoid division by zero (practicalswift)

Pull request description:

  Document assumptions (via `assert(…)`:s) that are being made to avoid division by zero.

  Rationale:
  * Make it clear to human reviewers and non-human static analyzers that what might look like potential division by zero cases are written the way they are intentionally (these cases are currently flagged by various static analyzers).

Tree-SHA512: bbb67b1370afd8f39bda35f9e3a20f4325f017d94cc1bfac3b0d36c9f34c2d95a9efe11efe44db29fb4aadd25d8276d8f0e03c8806ac64f0d21d821912e13b8e
2017-10-12 13:40:16 +02:00
Wladimir J. van der Laan 892809309c
Merge #11420: Bump univalue subtree and fix json formatting in tests
619bb05 Squashed 'src/univalue/' changes from 16a1f7f6e..fe805ea74 (MarcoFalke)

Pull request description:

  The subtree-merge commit also fixes the whitespace for failing tests, such that bisect doesn't break.

  Finally, the bump also includes the changes that accidentally modified our subtree, such that the subtree check should work fine now:

  ```sh
  ./contrib/devtools/git-subtree-check.sh src/univalue

Tree-SHA512: 3009d1e52b6f41ef89ecc8a000649f08e44395538703f294995a6e913e3fbfb7813d6bd31fdb4acb6127fd4af99c095bf980a12f1f026bb27cacc66e1487cd1e
2017-10-11 18:23:20 +02:00
Pedro Branco a44a215177 Fix importmulti bug when importing an already imported key 2017-10-11 17:20:42 +01:00
Wladimir J. van der Laan fef65c4f5e
Merge #11113: [net] Ignore getheaders requests for very old side blocks
eff4bd8 [test] P2P functional test for certain fingerprinting protections (Jim Posen)
a2be3b6 [net] Ignore getheaders requests for very old side blocks (Jim Posen)

Pull request description:

  Sending a getheaders message with an empty locator and a stop hash is a request for a single header by hash. The node will respond with headers for blocks not in the main chain as well as those in the main chain. To avoid fingerprinting, the node should, however, ignore requests for headers on side branches that are too old. This replicates the logic that currently exists for `getdata` requests for blocks.

Tree-SHA512: e04ef61e2b73945be6ec5977b3c5680b6dc3667246f8bfb67afae1ecaba900c0b49b18bbbb74869f7a37ef70b6ed99e78ebe0ea0a1569369fad9e447d720ffc4
2017-10-11 10:54:05 +02:00
Wladimir J. van der Laan 0e3a411351
Merge #8498: Near-Bugfix: Optimization: Minimize the number of times it is checked that no money...
4e955c5 Near-Bugfix: Reestablish consensus check removed in 8d7849b (Jorge Timón)
3e8c916 Introduce CheckInputsAndUpdateCoins static wrapper in txmempool.cpp (Jorge Timón)
832e074 Optimization: Minimize the number of times it is checked that no money is created (Jorge Timón)
3f0ee3e Proper indentation for CheckTxInputs and other minor fixes (Jorge Timón)

Pull request description:

  ...is created by individual transactions to 2 places (but call only once in each):

  - ConnectBlock ( before calculated fees per txs twice )
  - AcceptToMemoryPoolWorker ( before called CheckTxInputs 4 times and calculated
     fees per tx one extra time )

  Also call tx.GetValueOut() only once per call of CheckTxInputs (instead of 2)

  For more motivation:

  ~~https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L1493~~
  https://github.com/jtimon/bitcoin/compare/0.13-consensus-inputs...jtimon:0.13-consensus-inputs-comments

  EDIT: partially replaces #6445

  Near-Bugfix as pointed out in https://github.com/bitcoin/bitcoin/pull/8498#discussion_r124346132

Tree-SHA512: c71188e7c7c2425c9170ed7b803896755a92fd22f43b136eedaa6e554106696f0b10271d0ef0d0127c1eaafbc31d12eb19143df4f1b6882feecedf6ef05ea346
2017-10-11 10:45:22 +02:00
Tomas van der Wansem 5d465e3962 Ensure backupwallet fails when attempting to backup to source file
Previous behaviour was to destroy the wallet (to zero-length)
2017-10-10 14:49:47 +02:00
Wladimir J. van der Laan 5a9da37fb3
Merge #11469: fix typo in comment of chain.cpp
f902e40 fix typo in comment of chain.cpp (Johannes Kanig)

Pull request description:

Tree-SHA512: 1af049bd75f244febc2c249f7b743b481ed6ce935f1f5265881f57064d69e0f055b9334dae765132348125a5e688f99b07a255de7deacf37ac57d1e6966b5e4b
2017-10-10 09:00:34 +02:00
Johannes Kanig f902e40c76 fix typo in comment of chain.cpp 2017-10-09 19:14:47 +02:00
MarcoFalke 92eadc3950
Merge #11465: rpc: Update named args documentation for importprivkey
aa57590d7 Update importprivkey named args documentation (Dusty Williams)

Pull request description:

  Addresses issue #11462 by updating the documentation for the importprivkey arguments to the correct names, and updates the functional test importprunedfunds.py to use named arguments when calling importprivkey.

Tree-SHA512: 64e14bf89c8c6eec9c37f6ec0c9fc0012fdb035d9ec32cd652110c75abaa922ec5c7523d6ec5098c8a7b42124159b5e330e070974eb79b8b92816f8d61074523
2017-10-09 19:09:45 +02:00
Wladimir J. van der Laan 3a93270c55
Merge #11367: [rpc] getblockchaininfo: add size_on_disk, prune_target_size
b7dfc6c [rpc] getblockchaininfo: add size_on_disk, prune_target_size, automatic_pruning (Daniel Edgecumbe)

Pull request description:

Tree-SHA512: c255c27d6c922434d203ffdefda0dd3dddbd765b6a9cce5f80f5af5cb0b1c11c8aff6f4d00e96a326701d0bc81aace2f216fd1985675aa979f76c16f564a6cf6
2017-10-09 17:04:18 +02:00
Wladimir J. van der Laan da0478e6e5
Merge #10961: Improve readability of DecodeBase58Check(...)
c6a995e Improve readability of DecodeBase58Check(...) (practicalswift)

Pull request description:

  Use the more readable form ...

  ```c++
  &vchRet[vchRet.size() - 4]
  ```

  ... instead of ...

  ```c++
  &v.end()[-n]
  ```

  Has the added benefit of eliminating a spurious static analyzer warning about improper use of negative values.

Tree-SHA512: 5895310c189e9322082c28f34342ff9a6c238e2cae3f204521111c8a7981bc555af60b42de082c91608c1125dfc244a65c4faf929249a067a51435e2be74cb39
2017-10-09 16:41:06 +02:00
Wladimir J. van der Laan d473e6ddc5
Merge #11448: [gui] reset addrProxy/addrSeparateProxyTor if colon char missing
ce2418f [gui] reset addrProxy/addrSeparateProxyTor if colon char missing (Cristian Mircea Messel)

Pull request description:

  If addrProxy or addrSeparateProxyTor do not have a colon in the string
  somewhere in the QSettings storage, then attempting to open the options
  dialog will cause the entire program to crash.

  Fixes #11209

Tree-SHA512: 2d9e6987cf05af3f41033290b61d00920f7fe4a65bea7efd96ed417a8ca7866d248f091e09947cc8aad3a6a4aa8b7777211cfff7f379a62188be50df2c46d4b2
2017-10-09 16:10:32 +02:00
practicalswift 68feb49105 Use nullptr instead of NULL 2017-10-09 14:26:53 +02:00
Dusty Williams aa57590d7c Update importprivkey named args documentation
Fixes #11462. Updated documentation for importprivkey function to use the correct name for the first argument.
Also updates a call to importprivkey to use named args in functional test.
2017-10-09 07:40:42 -04:00
practicalswift c6b07fddcf Fix a vs. an typo 2017-10-09 10:37:40 +02:00
Jonas Schnelli dd9bb253c3
Fix code style in keystore.cpp/crypter.cpp 2017-10-06 20:56:43 -07:00
Wladimir J. van der Laan 17f2acedbe
Merge #9572: Skip witness sighash cache for non-segwit transactions
0da49b5 Skip precompute sighash for transactions without witness (Johnson Lau)

Pull request description:

  This saves unnecessary hash caching for non-segwit transactions, but I am not sure if the difference is noticeable.

Tree-SHA512: 5cd733a729a52a45781510b3572b26e76837a94155caa14311c6d23a27a12e9613ff278dfc2592e21f640202782f22c5ad00fca85c4de5efacaa617c48ccb08d
2017-10-05 19:49:42 +02:00
Wladimir J. van der Laan 9e8ef9d991
Merge #10440: [tests] Add libFuzzer support
f3ba869 [tests] Add libFuzzer support. (practicalswift)

Pull request description:

  Add `libFuzzer` support.

  As discussed in [issue #10364](https://github.com/bitcoin/bitcoin/issues/10364#issuecomment-300000902).

  See http://llvm.org/docs/LibFuzzer.html#fuzzer-usage for usage instructions.

Tree-SHA512: 32562a3a43eb07e79989d55eeb0bfe94e2cff060da8ff0cb50c2f838ef19f2fd583a3dc89074a6442bd3e395185d309371325ed9a0ef50065431d5ea7f099772
2017-10-05 18:07:50 +02:00
MarcoFalke e93fff1463
Merge #11107: Fix races in AppInitMain and others with lock and atomic bools
c626dcb50 Make fUseCrypto atomic (MeshCollider)
731065b11 Consistent parameter names in txdb.h (MeshCollider)
35aeabec6 Make fReindex atomic to avoid race (MeshCollider)
58d91af59 Fix race for mapBlockIndex in AppInitMain (MeshCollider)

Pull request description:

  Fixes https://github.com/bitcoin/bitcoin/issues/11106

  Also makes fReindex atomic as suggested in @TheBlueMatt comment below, and makes fUseCrypto atomic as suggested in 10916

  d291e7635b just renames the parameters in the txdb header file to make them consistent with those used in the cpp file, noticed it when looking for uses of fReindex

Tree-SHA512: b378aa7289fd505b76565cd4d48dcdc04ac5540283ea1c80442170b0f13cb6df771b1a94dd54b7fec3478a7b4668c224ec9d795f16937782724c5d020edd3a42
2017-10-05 15:03:36 +02:00
Jonas Schnelli 208fda69b3
CCrypter: move relevant implementation out of the header 2017-10-04 20:32:09 -07:00
Jonas Schnelli 3155fd23f2
CKeystore: move relevant implementation out of the header 2017-10-04 20:32:04 -07:00
Wladimir J. van der Laan 167cef8082
Merge #11435: build: Make "make clean" remove all files created when running "make check"
f35d033 build: Make "make clean" remove all files created when running "make check" (practicalswift)

Pull request description:

  Make `make clean` remove all files created when running `make check`. More specifically: remove also `obj/build.h` and `bench/data/block413567.raw.h` as part of `make clean`.

  Before this patch:

  ```bash
  $ git clone https://github.com/bitcoin/bitcoin.git
  $ cd bitcoin/
  $ ./autogen.sh
  $ ./configure
  $ cp -r ../bitcoin ../bitcoin-before-make
  $ make check
  $ make clean
  $ cp -r ../bitcoin ../bitcoin-after-make-and-make-clean
  $ cd ..
  $ diff -rq bitcoin-before-make/ bitcoin-after-make-and-make-clean/ | grep -E "^Only in bitcoin-after-make-and-make-clean/" | grep -v dirstamp
  Only in bitcoin-after-make-and-make-clean/src/bench/data: block413567.raw.h
  Only in bitcoin-after-make-and-make-clean/src/obj: build.h
  $
  ```

  After this patch:

  ```bash
  $ git clone https://github.com/bitcoin/bitcoin.git
  $ cd bitcoin/
  $ ./autogen.sh
  $ ./configure
  $ cp -r ../bitcoin ../bitcoin-before-make
  $ make check
  $ make clean
  $ cp -r ../bitcoin ../bitcoin-after-make-and-make-clean
  $ cd ..
  $ diff -rq bitcoin-before-make/ bitcoin-after-make-and-make-clean/ | grep -E "^Only in bitcoin-after-make-and-make-clean/" | grep -v dirstamp
  $
  ```

Tree-SHA512: 953e8423485ffd415f0ade6abe0b4c407454f67c332140ef019d89db425bb4a831327b3f634b8d69b17325dcfc6e3ac72dc2ba1ce5462158eecc3c05645e93ba
2017-10-04 15:35:41 +02:00
Wladimir J. van der Laan 74123eabdd
Merge #11440: Fix validationinterface build on super old boost/clang
96c2ce9 Fix validationinterface build on super old boost/clang (Matt Corallo)

Pull request description:

  This should fix all the non-dependancy issues for termux builds.
  See Github issue #11388.

Tree-SHA512: ff0918fa76a6d4639a6c5b5e045ef053ce1d93eb0b1fe94c5fdfcc4d5e54e1118eeb09676ffd8f6d1acd630a63656944c6274ee3dbd7c09b7129c30647dbf4f9
2017-10-04 15:02:41 +02:00
Wladimir J. van der Laan 7f11ef2608
Merge #9937: rpc: Prevent dumpwallet from overwriting files
0cd9273 rpc: Prevent `dumpwallet` from overwriting files (Wladimir J. van der Laan)

Pull request description:

  Prevent arbitrary files from being overwritten by `dumpwallet`. There have been reports that users have overwritten wallet files this way. It may also avoid other security issues.

  Fixes #9934. Adds mention to release notes and adds a test.

Tree-SHA512: 268c98636d40924d793b55a685a0b419bafd834ad369edaec08227ebe26ed4470ddea73008d1c4beb10ea445db1b0bb8e3546ba8fc2d1a411ebd4a0de8ce9120
2017-10-04 15:01:24 +02:00
practicalswift f35d033369 build: Make "make clean" remove all files created when running "make check"
More specifically: remove also obj/build.h and bench/data/block413567.raw.h.

Before this patch:

```
$ diff -rq bitcoin-before-make/ bitcoin-after-make-and-make-clean/ | grep -E "^Only in bitcoin-after-make-and-make-clean/" | grep -v dirstamp
Only in bitcoin-after-make-and-make-clean/src/bench/data: block413567.raw.h
Only in bitcoin-after-make-and-make-clean/src/obj: build.h
$
```

After this patch:

```
$ diff -rq bitcoin-before-make/ bitcoin-after-make-and-make-clean/ | grep -E "^Only in bitcoin-after-make-and-make-clean/" | grep -v dirstamp
$
```
2017-10-04 14:54:41 +02:00
Wladimir J. van der Laan a1f7f18709
Merge #10939: [init] Check non-emptiness of -blocknotify command prior to executing
cffe85f Skip sys::system(...) call in case of empty command (practicalswift)
6fb8f5f Check that -blocknotify command is non-empty before executing (practicalswift)

Pull request description:

  Check that `-blocknotify` command is non-empty before executing.

  To make the `BlockNotifyCallback(...)` (`-blocknotify`) behaviour consistent with that of:
  * `AlertNotify(...)` (`-alertnotify`)
  * `AddToWallet(...)` (`-walletnotify`)

Tree-SHA512: 18272166793a5a8b9cc2a727bfbcea53d38c329a55bc975c02db601329d608a61c20e026ce4b616193ecd3810dca4d3e2cb3bf773898a51872008a8dba96763e
2017-10-04 14:54:09 +02:00
Wladimir J. van der Laan e12522dfda
Merge #11406: Add state message print to AcceptBlock failure message.
6643b80 Add state message print to AcceptBlock failure message. (Matt Corallo)

Pull request description:

  This should make it easier to debug issues where the CheckBlock at
  the top of ProcessNewBlock fails (which does not print, in contrast
  to AcceptBlock, which always prints).

  This was motivated by #11371 which appears to be exactly such a case, and is not debuggable from the information provided. Not sure how much this would have helped in that case, but it is kinda weird that we can reject a block without ever printing why.

Tree-SHA512: 7a1c2c76080b810212da885c38e091609e409c62918cc326bb36a1096e09b2ae7e26fd4bdaefd79863d2894e2823e463005700a524940f177a59ef09f589b2f1
2017-10-04 14:35:43 +02:00
MarcoFalke 9ccafb1d7b
Merge #11421: Merge current secp256k1 subtree
fd86f998f Squashed 'src/secp256k1/' changes from 84973d393..0b7024185 (MarcoFalke)

Pull request description:

  The subtree should now match upstream again. Check with:

  ```sh
  ./contrib/devtools/git-subtree-check.sh src/secp256k1
  ```

  The changes are only documentation/refactoring related.

Tree-SHA512: 43e8a95bcbfefef9e19ec38a92d2d57fdd4a16ddf726e036d36a0d806eb6f35b45b40ee69f980430e107895ec8725b5de4e36456b026214675e0b19630bb6fe9
2017-10-04 12:35:15 +02:00
Cristian Mircea Messel ce2418fa4c [gui] reset addrProxy/addrSeparateProxyTor if colon char missing
If addrProxy or addrSeparateProxyTor do not have a colon in the string
somewhere in the QSettings storage, then attempting to open the options
dialog will cause the entire program to crash.
2017-10-04 01:09:12 +03:00
MarcoFalke b4a509a3f8
Merge #11433: qa: Restore bitcoin-util-test py2 compatibility
fafff1220 qa: Restore bitcoin-util-test py2 compatibility (MarcoFalke)

Pull request description:

  Currently `./configure && make check` will look for python3, then python2. As long as we support python2 (and use it as fallback), `make check` should run fine with both python2 and python3.

  Fixes #11352 by @Zenitur

Tree-SHA512: a335ebdd224328d6f924fe52a9b97de196926476c9ee04ce3280743ea93bcae355eb2d5d4bed4050c01b2e904105595eac7db2eaa9307207581caa0a98ebcc0b
2017-10-03 21:25:00 +02:00
Russell Yanofsky edafc718ad Fix uninitialized URI in batch RPC requests
This fixes "Wallet file not specified" errors when making batch wallet RPC
calls with more than one wallet loaded. This issue was reported by
NicolasDorier <nicolas.dorier@gmail.com>
https://github.com/bitcoin/bitcoin/issues/11257

Request URI is not used for anything except multiwallet request dispatching, so
this change has no other effects.

Fixes #11257
2017-10-03 15:25:00 -04:00
Jim Posen a2be3b66b5 [net] Ignore getheaders requests for very old side blocks
Sending a getheaders message with an empty locator and a stop hash
is a request for a single header by hash. The node will respond with
headers for blocks not in the main chain as well as those in the main
chain. To avoid fingerprinting, the node should, however, ignore
requests for headers on side branches that are too old.
2017-10-03 10:28:00 -07:00
MarcoFalke dbc4ae0396
Merge #11293: Deduplicate CMerkleBlock construction code, add test coverage
46ce223d1 Add tests for CMerkleBlock usage with txids specified (James O'Beirne)
5ab586f90 Consolidate CMerkleBlock constructor into a single method (James O'Beirne)

Pull request description:

  What started as a simple task to add test coverage ended up giving way to a light refactoring. This consolidates the mostly-identical `CMerkleBlock` constructors into one (using C++11 constructor delegation) and adds coverage for the by-txids construction case.

  ### Before

  ![selection_006](https://user-images.githubusercontent.com/73197/30242104-0f381fe4-9545-11e7-9617-83b87fce0456.png)

  ### After

  ![selection_008](https://user-images.githubusercontent.com/73197/30242107-1425dfaa-9545-11e7-9e6b-2c3432517dd1.png)

Tree-SHA512: eed84ed3e8bfc43473077b575c8252759a857e37275e4b36ca7cc2c17a65895e5f494bfd9d4aeab09fc6e98fc6a9c641ac7ecc0ddbeefe01a9e4308e7909e529
2017-10-03 14:27:39 +02:00
Matt Corallo 96c2ce9d34 Fix validationinterface build on super old boost/clang
This should fix all the non-dependancy issues for termux builds.
See Github issue #11388.
2017-10-02 18:24:59 -04:00
MarcoFalke f199b8a33d
Merge #11365: [Tests] Add Qt GUI tests to Overview and ReceiveCoin Page
634e38ca7 [Tests] Add Qt GUI tests to Overview and ReceiveCoin Page (Anditto Heristyo)

Pull request description:

  I've added some Qt wallet tests based on #9974, namely the input & buttons on ReceiveCoin.

Tree-SHA512: f4223827145e35c2abee83a6ca777498bebcff3825fece10fbb1dbfd1f6bb017d3f2c0521662854b4407cdeee9c6a527269ab9cc28e0dc85c11b668155fcd195
2017-10-02 21:19:43 +02:00
practicalswift 76fed838f3 Avoid NULL pointer dereference when _walletModel is NULL (which is valid) 2017-10-02 17:20:08 +02:00
practicalswift 4971a9a3c9 Use two boolean literals instead of re-using variable 2017-10-02 15:47:44 +02:00
practicalswift b5fb33943f Remove duplicate uriParts.size() > 0 check 2017-10-02 15:47:44 +02:00
practicalswift 7466991670 Remove redundant check (!ecc is always true) 2017-10-02 15:47:43 +02:00
practicalswift 55224af6bd Remove redundant NULL checks after new 2017-10-02 15:47:43 +02:00
Wladimir J. van der Laan 90926db238
Merge #11021: [rpc] fix getchaintxstats()
07704c1 Add some tests for getchaintxstats (Akio Nakamura)
3336676 Fix getchaintxstats() (Akio Nakamura)

Pull request description:

  1. calculate nblocks more adaptive.
    -> set default nblocks to min (blocks for 1 month, target block's height - 1)
    -> before PR: if not specify nblocks-parameter, illegal parameter error will happen when target block height is below nblocks.
  2. correct error message.
    -> nblocks accepts [1 .. block's height -1] . so add a word "-1".
  3. add check 0-divide.
    -> if nTimeDiff = 0 then use UniValue(UniValue::VNULL) and returns {... "txrate": null} .
    -> before PR: if nTimeDiff = 0 then returns {... "txrate":} and bitcoin-cli cannot handle the response.

Tree-SHA512: e1962ce7bb05a5bc7dec03eb04a8e7578f50fdb68927fcfc0a2232905ef4d679293eee148ebe0866682d209a8c458d21fbe71715e7311adb81f37089aae1ed93
2017-10-02 15:22:41 +02:00
Wladimir J. van der Laan 339da9ca41
Merge #11411: script: Change SignatureHash input index check to an assert.
5ddf560 script: Change SignatureHash input index check to an assert. (Jim Posen)

Pull request description:

  In the SignatureHash function, the input index must refer to a valid index. This is not enforced equally in the segwit/non-segwit branches and should be an assertion rather than returning a error hash.

Tree-SHA512: a775fc9e9bd9835c0ab36368aa45ab3d53e38f31fd4d2b8684a77ee6028c854c363df038681a59358b30138957573ad63b71d4a722c16e0830fb4fa72669ef39
2017-10-02 15:10:40 +02:00
Wladimir J. van der Laan c5c77bdcc6
Merge #11193: [Qt] Terminate string *pszExePath after readlink and without using memset
3a4401a [Qt] Terminate string *pszExePath after readlink and without using memset (practicalswift)

Pull request description:

  Terminate string `*pszExePath` after `readlink` and before passing to operator `<<`.

  * `ssize_t readlink(const char *pathname, char *buf, size_t bufsiz)` does not append a null byte to `buf`.
  * Operator `<<` expects a null-terminated string.

Tree-SHA512: fc18844bb23059fead8db0cb9b4b4ba6188f58e3f19ab4719c2737cc5dd6df23ae7d4804ef2820d39b334204a48ee3de1d202c272bcd156e60761af2fcb9349d
2017-10-02 15:04:43 +02:00
Wladimir J. van der Laan 058c0f996b
Merge #11432: Remove unused fTry from push_lock
92848e5 Remove unused fTry from push_lock (João Barbosa)

Pull request description:

  After #9674 (618ee92) the `fTry` argument in `push_lock` is no longer needed.

Tree-SHA512: a461f2ca9e590a9dfcc7814d9852d85f03712cb4735176b8b2db0e8dc731597c2a515650998ca7d53cf5a0c48b408a974a0704897036c6ed74788fc24c5e73ae
2017-10-02 14:54:49 +02:00
Wladimir J. van der Laan 10bee0dd4f
Merge #11284: Fix invalid memory access in CScript::operator+= (guidovranken, ajtowns)
d601f16 Fix invalid memory access in CScript::operator+= (Anthony Towns)

Pull request description:

  This is a fix for #11114 -- invoking "s += s" gets turned into "s.insert(s.end(), s.begin(), s.end())" which can result in an invalid memory access is s.capacity() < 2*s.size() (because s gets resized and possibly moved, so s.begin() and s.end() become invalid references when reading the values to be appended).

  The fix is straightforward: reserve enough space in advance, so that insert() doesn't need to resize and thus its arguments remain valid.

  A simple test case is added as well; though you probably need to run it via valgrind to actually catch the problem when it's not fixed...

Tree-SHA512: 4720d0c17463fdc43b344c45fe603423d20b30d48da1b9d85eeedc505d7f34db1ed5495ef1556459ae962a94717e3c6e8fc441763771901efea210d01322b7ef
2017-10-02 14:46:47 +02:00
Wladimir J. van der Laan c641ccac5b
Merge #11422: qa: Verify DBWrapper iterators are taking snapshots
bb8376b Verify DBWrapper iterators are taking snapshots (Matt Corallo)

Pull request description:

  The LevelDB docs seem to indicate that an iterator will not take
  snapshots (even providing instructions on how to do so yourself).
  In several of the places we use them, we assume snapshots to have
  been taken.

  In order to make sure LevelDB doesn't change out from under us
  (and to prevent the next person who reads the docs from having the
  same fright I did), verify that snapshots are taken in our tests.

Tree-SHA512: 54f24dabc294962e9c20882f61809604421a661208d1568bb107102248603e8e7c12e929ccb0812a73d4e4f23fea61f1b48e7cc24da5a7260f1d14d89ba88cd6
2017-10-02 14:40:48 +02:00
MarcoFalke fafff1220c qa: Restore bitcoin-util-test py2 compatibility 2017-10-01 11:22:07 +02:00
João Barbosa 92848e5058 Remove unused fTry from push_lock 2017-09-30 22:43:55 +01:00
Matt Corallo bb8376bbc3 Verify DBWrapper iterators are taking snapshots
The LevelDB docs seem to indicate that an iterator will not take
snapshots (even providing instructions on how to do so yourself).
In several of the places we use them, we assume snapshots to have
been taken.

In order to make sure LevelDB doesn't change out from under us
(and to prevent the next person who reads the docs from having the
same fright I did), verify that snapshots are taken in our tests.
2017-09-30 14:17:51 -04:00
MarcoFalke e542728cde
Merge #11303: Fix estimatesmartfee rounding display issue
1789e4675 Force explicit double -> int conversion for CFeeRate constructor (Matt Corallo)
53a6590f4 Make float <-> int casts explicit outside of test, qt, CFeeRate (Matt Corallo)
0b1b9148c Remove countMaskInv caching in bench framework (Matt Corallo)

Pull request description:

  This fixes an issue where estimatesmartfee which matches at the min relay fee will return 999 sat/byte instead of 1000 sat/byte due to a float rounding issue. I went ahead and made all float <-> int conversion outside of test/qt explicit (test only had one or two more, Qt had quite a few, including many in the Qt headers themselves) and added overloads to CFeeRate to force callers to do an explicit round themselves. Easy to test with -Wfloat-conversion.

Tree-SHA512: 66087b08e5dfca67506da54ae057c2f9d86184415e8fa4fa0199e38839e06a3ce96c836fcb7593b7d960065f5240c594ff3a0cfa14333ac528421f5aeac835c9
2017-09-30 18:07:55 +02:00
Pieter Wuille 38c201f47c
Merge #11418: Add error string for CLEANSTACK script violation
cee28fbc3 Add error string for CLEANSTACK script violation, preventing an "unknown error" if the CLEANSTACK error condition is set. (Mark Friedenbach)

Pull request description:

  This prevents an unhelpful "unknown error" from being printed in test logs if the CLEANSTACK error condition is set.

Tree-SHA512: cd6764e930184aef3d662e40c67f2ea8aea8552a26d33a567d0315a19d707a82aa2afad9f48ecbb731aa5b77fbbfbd7a6a3a989fdb1424a1181350052ff2a9b5
2017-09-29 15:05:42 -07:00
Daniel Edgecumbe b7dfc6c4b8 [rpc] getblockchaininfo: add size_on_disk, prune_target_size, automatic_pruning
Fix pruneheight help text.
Move fPruneMode block to match output ordering with help text.
Add functional tests for new fields in getblockchaininfo.
2017-09-29 19:40:50 +01:00
MarcoFalke 999968e416 Bump secp256k1 subtree 2017-09-29 16:02:39 +02:00
MarcoFalke fd86f998fc Squashed 'src/secp256k1/' changes from 84973d393..0b7024185
0b7024185 Merge #474: Fix header guards using reserved identifiers
ab1f89f00 Merge #478: Fixed multiple typos
8c7ea22d5 Fixed multiple typos
abe2d3e84 Fix header guards using reserved identifiers
f532bdc9f Merge #459: Add pubkey prefix constants to include/secp256k1.h
cac7c5559 Merge #470: Fix wnaf_const documentation
768514bac Fix wnaf_const documentation with respect to return value and number of words set
b8c26a399 Merge #458: Fix typo in API documentation
817fb2013 Merge #440: Fix typos
12230f90e Merge #468: Remove redundant conditional expression
2e1ccdca0 Remove redundant conditional expression
bc61b91ac add pubkey prefix constants to include/secp256k1.h
b0452e664 Fix typo in API documentation
4c0f32ed5 Fix typo: "Agressive" → "Aggressive"
73aca8364 Fix typo: "exectured" → "executed"

git-subtree-dir: src/secp256k1
git-subtree-split: 0b7024185045a49a1a6a4c5615bf31c94f63d9c4
2017-09-29 16:00:20 +02:00
MarcoFalke 93d20a734d
Merge #11309: Minor cleanups for AcceptToMemoryPool
bf64c3cb3 Ignore transactions added to mempool during a reorg for fee estimation purposes. (Alex Morcos)
04f78ab5b Do not reject based on mempool min fee when bypass_limits is set. (Alex Morcos)
fd849e1b0 Change AcceptToMemoryPool function signature (Alex Morcos)

Pull request description:

  First commit just removes default arguments from `AcceptToMemoryPool` and consolidates two arguments, it does not change behavior.

  Second commit finally fixes the fact that we're not meant to reject based on mempool min fee when adding a transaction from a disconnected block during a reorg as mentioned [here](https://github.com/bitcoin/bitcoin/pull/9602#issue-202197849)

  Third commit makes fee estimation ignore transactions added from a disconnected block during a reorg. I think this was another source of fee estimates returning estimates below 1000 sat/kB as in #11303.

Tree-SHA512: 30925ca8b341915bb214f1d2590b36b7931f2e125b7660150e38ae70338f00db5aa7f1608546dddb181446924177eb7cf62ea8bd2583068acc074d6c3f86bc0c
2017-09-29 15:07:57 +02:00
MarcoFalke faaeeb0d3e Bump univalue and fix json formatting in tests
This merge commit bumps the univalue subtree and also updates the whitespace
for some failing tests.
2017-09-29 14:35:46 +02:00
Mark Friedenbach cee28fbc3f Add error string for CLEANSTACK script violation, preventing an "unknown error" if the CLEANSTACK error condition is set. 2017-09-29 01:48:43 -07:00
Wladimir J. van der Laan 0ec9c91623
Merge #11417: Correct typo in comments
6f33d8c Correct typo in comments (Johnson Lau)

Pull request description:

  I think this is a search and replace mistake

Tree-SHA512: a83e081b817f1607496bfdcee47593d45d75cbe72effe944cdb5494b49a341eeeebdeb954f6db59dfa1ddfa350a117a4b26c754725a3459be78f2a1a093c6fde
2017-09-29 10:20:31 +02:00
Wladimir J. van der Laan aa624b61c9
Merge #11167: Full BIP173 (Bech32) support
8213838 [Qt] tolerate BIP173/bech32 addresses during input validation (Jonas Schnelli)
06eaca6 [RPC] Wallet: test importing of native witness scripts (NicolasDorier)
fd0041a Use BIP173 addresses in segwit.py test (Pieter Wuille)
e278f12 Support BIP173 in addwitnessaddress (Pieter Wuille)
c091b99 Implement BIP173 addresses and tests (Pieter Wuille)
bd355b8 Add regtest testing to base58_tests (Pieter Wuille)
6565c55 Convert base58_tests from type/payload to scriptPubKey comparison (Pieter Wuille)
8fd2267 Import Bech32 C++ reference code & tests (Pieter Wuille)
1e46ebd Implement {Encode,Decode}Destination without CBitcoinAddress (Pieter Wuille)

Pull request description:

  Builds on top of #11117.

  This adds support for:
  * Creating BIP173 addresses for testing (through `addwitnessaddress`, though by default it still produces P2SH versions)
  * Sending to BIP173 addresses (including non-v0 ones)
  * Analysing BIP173 addresses (through `validateaddress`)

  It includes a reformatted version of the [C++ Bech32 reference code](https://github.com/sipa/bech32/tree/master/ref/c%2B%2B) and an independent implementation of the address encoding/decoding logic (integrated with CTxDestination). All BIP173 test vectors are included.

  Not included (and intended for other PRs):
  * Full wallet support for SegWit (which would include automatically adding witness scripts to the wallet during automatic keypool topup, SegWit change outputs, ...) [see #11403]
  * Splitting base58.cpp and tests/base58_tests.cpp up into base58-specific code, and "address encoding"-code [see #11372]
  * Error locating in UI for BIP173 addresses.

Tree-SHA512: 238031185fd07f3ac873c586043970cc2db91bf7735c3c168cb33a3db39a7bda81d4891b649685bb17ef90dc63af0328e7705d8cd3e8dafd6c4d3c08fb230341
2017-09-29 10:18:45 +02:00
Johnson Lau 6f33d8c791 Correct typo in comments 2017-09-29 14:50:30 +08:00
Jonas Schnelli 8213838db2 [Qt] tolerate BIP173/bech32 addresses during input validation
This eases the during-type validation to allow Bech32 chars.
Once the focus has been lost, the address will be properly verified through IsValidDestinationString
2017-09-28 17:29:04 -07:00
Pieter Wuille e278f12ca7 Support BIP173 in addwitnessaddress 2017-09-28 16:24:33 -07:00
Pieter Wuille c091b99379 Implement BIP173 addresses and tests 2017-09-28 16:24:30 -07:00
Pieter Wuille bd355b8db9 Add regtest testing to base58_tests 2017-09-28 16:04:11 -07:00
Pieter Wuille 6565c5501c Convert base58_tests from type/payload to scriptPubKey comparison 2017-09-28 16:04:11 -07:00
Pieter Wuille 8fd2267053 Import Bech32 C++ reference code & tests
This includes a reformatted version of the Bech32 reference code
(see https://github.com/sipa/bech32/tree/master/ref/c%2B%2B), with
extra documentation.
2017-09-28 16:02:16 -07:00
Wladimir J. van der Laan 9d31ed2e69
Merge #10663: net: split resolve out of connect
b887676 net: remove now-unused functions (Cory Fields)
45fd754 net: remove now-superfluous numeric resolve (Cory Fields)
2416dd7 net: separate resolving and conecting (Cory Fields)

Pull request description:

  This is a greatly simplified version of #10285, which only aims to address async resolving.

  It essentially breaks up two wrapper functions for things only used in one place (ConnectSocketDirectly/ConnectThroughProxy) in favor of calling them directly. This allows us to fully handle resolves before attempting a connection, as is necessary for async connections.

  As a bonus, I believe the logic is now much easier to follow than before.

Tree-SHA512: f03f618107379edf3efe2a9f3e3677e8f075017ab140a0b4fdc3b8263e6beff148d55256263ab10bc2125ef089ca68e0d8e865beeae176f1eca544e769c976d3
2017-09-28 17:05:47 +02:00
Wladimir J. van der Laan 9a8e9167f2
Merge #10858: [RPC] Add "errors" field to getblockchaininfo and unify "errors" field in get*info RPCs
395cef7 Change getmininginfo errors field to warnings (Andrew Chow)
8502b20 Unify help text for GetWarnings output in get*info RPCs (Andrew Chow)
f77f0e4 Add warnings field to getblockchaininfo (Andrew Chow)

Pull request description:

  The `getblockchaininfo` output does not contain the `errors` field which the `getinfo`, `getmininginfo`, and `getnetworkinfo` RPCs have. It should have it as the errors pertain to the blockchain. This PR adds that field.

  This PR also unifies the help text for the `errors` field and its output position so that all of the `get*info` commands are consistent.

  `getnetworkinfo`'s `errors` field is named `warnings`. I did not change this even though it is inconsistent since this naming has been in use for a long time.

Tree-SHA512: 385ab6acfee67fc8816f4d51ab2bd7a623264c7973906dfbab0a171f199e9db16fde19093a5bc3dfbdd4ff5f19d2186b646eb6b3bae0a4d7c9add43650a4a9d9
2017-09-28 16:39:15 +02:00
Wladimir J. van der Laan c9a4aa8a0e
Merge #10871: Handle getinfo in bitcoin-cli w/ -getinfo (revival of #8843)
5e69a43 Add test for bitcoin-cli -getinfo (John Newbery)
3826253 rpc: Handle `getinfo` locally in bitcoin-cli w/ `-getinfo` (Wladimir J. van der Laan)

Pull request description:

  Since @laanwj doesn't want to maintain these changes anymore, I will.

  This PR is a revival of #8843. I have addressed @jnewbery's comments.

  Regarding atomicity, I don't think that is a concern here. This is explicitly a new API and those who use it will know that this is different and that it is not atomic.

Tree-SHA512: 9664ed13a5557bda8c43f34d6527669a641f260b7830e592409b28c845258fc7e0fdd85dd42bfa88c103fea3ecdfede5f81e3d91870e2accba81c6d6de6b21ff
2017-09-28 08:33:36 +02:00
Jonas Schnelli d90a00eabe
Merge #11397: net: Improve and document SOCKS code
22f816ef4 net: Improve and document SOCKS code (Wladimir J. van der Laan)

Pull request description:

  Make the SOCKS code more consistent, and document the constants used.

Tree-SHA512: 1bb04fcd6aacb6bfd2c54989d8298c892036466a895efb88be36fbace041af67c964ae0f5fb76c96f813f20a040109de4e0aac49a20844640e4d7633fcb22f25
2017-09-27 20:09:59 -07:00
Jim Posen 5ddf56045a script: Change SignatureHash input index check to an assert.
In the SignatureHash function, the input index must refer to a valid
index. This is not enforced equally in the segwit/non-segwit branches
and should be an assertion rather than returning a error hash.
2017-09-27 19:49:18 -07:00
Wladimir J. van der Laan 382625318d rpc: Handle getinfo locally in bitcoin-cli w/ -getinfo
This adds the infrastructure `BaseRequestHandler` class that takes care
of converting bitcoin-cli arguments into a JSON-RPC request object, and
converting the reply into a JSON object that can be shown as result.

This is subsequently used to handle the `-getinfo` option, which sends
a JSON-RPC batch request to the RPC server with
`["getnetworkinfo", "getblockchaininfo", "getwalletinfo"]`,
and after reply combines the result into what looks like a `getinfo`
result.

There have been some requests for a client-side `getinfo` and this
is my PoC of how to do it. If this is considered a good idea
some of the logic could be moved up to rpcclient.cpp and
used in the GUI console as well.

Extra-Author: Andrew Chow <achow101@gmail.com>
2017-09-27 21:53:07 -04:00
Andrew Chow 395cef7601 Change getmininginfo errors field to warnings
Changes the errors field to warnings. To maintain compatibility,
the errors field is deprecated and enabled by starting bitcoind with
-deprecatedrpc=getmininginfo
2017-09-27 11:27:26 -04:00
Andrew Chow 8502b20852 Unify help text for GetWarnings output in get*info RPCs 2017-09-27 11:27:26 -04:00
Andrew Chow f77f0e4825 Add warnings field to getblockchaininfo 2017-09-27 11:27:26 -04:00
MarcoFalke ef8340d25f
Merge #11031: [rpc] deprecate estimatefee
048e0c3e2 [rpc] [tests] Add deprecated RPC test (Cristian Mircea Messel)
d4cdbd6fb [rpc] Deprecate estimatefee RPC (John Newbery)

Pull request description:

  Deprecates estimatefee in v0.16, for final removal in v0.17.

  This commit introduces a phased removal of RPC methods. RPC method is
  disabled by default in version x, but can be enabled by using the
  `-deprecatedrpc=<methodname>` argument. RPC method is removed entirely in version
  (x+1).

  This gives users fair warning that an RPC is to be removed, and time to change client software if necessary. Deprecation warnings in RPC return values or release notes are easily ignored.

  This is a more generic version of the approach I tried to use in #10841, which too late to make it into v0.15.

Tree-SHA512: 9695a600e84b812974387333e4a6805d18972da30befb754e9e4da77cd9815d00c5cc2ee0b0350bdbbdb5fdc6ba47789f8b2c6f5b15c8cd5a1deefcc4832da30
2017-09-27 14:38:13 +02:00
MarcoFalke 69c7ecef40
Merge #11408: Trivial: Fix parameter name typo in ErasePurpose walletdb method
603efe9fc Fix parameter name typo in ErasePurpose walletdb method. (Pierre Rochard)

Pull request description:

  The header file has the correct method signature and the one usage in CWallet::DelAddressBook is correctly passing in EncodeDestination(address)

Tree-SHA512: ee0808a74111fd23a1c47ba5ab51de151fdd33a01d92895671e562ac184cbcb33180a3ff26c22e5717595592097b9fa33deca9878d89ce8d34687f09cfadfcf0
2017-09-27 14:23:39 +02:00
Pierre Rochard 603efe9fc4 Fix parameter name typo in ErasePurpose walletdb method. 2017-09-26 18:02:09 -04:00