Commit graph

12032 commits

Author SHA1 Message Date
Pieter Wuille b25a4c2284
Merge #13072: Update createmultisig RPC to support segwit
f40b3b82df [tests] functional test for createmultisig RPC (Anthony Towns)
b9024fdda3 segwit support for createmultisig RPC (Anthony Towns)
d58055d25f Move AddAndGetDestinationForScript from wallet to outputype module (Anthony Towns)
9a44db2e46 Add outputtype module (Anthony Towns)

Pull request description:

  Adds an "address_type" parameter that accepts "legacy", "p2sh-segwit", and "bech32" to choose the type of address created. Defaults to "legacy" rather than the value of the `-address-type` option for backwards compatibility.

  As part of implementing this, OutputType is moved from wallet into its own module, and `AddAndGetDestinationForScript` is changed to apply to a `CKeyStore` rather than a wallet, and to invoke `keystore.AddCScript(script)` itself rather than expecting the caller to have done that.

  Fixes #12502

Tree-SHA512: a08c1cfa89976e4fd7d29caa90919ebd34a446354d17abb862e99f2ee60ed9bc19d8a21a18547c51dc3812cb9fbed86af0bef2f1e971f62bf95cade4a7d86237
2018-07-13 20:31:13 -07:00
Pieter Wuille 1329ef1f00
Merge #13651: [moveonly] Extract CWallet::MarkInputsDirty, and privatize AddToWalletIfInvolvingMe
17e6aa8e33 Privatize CWallet::AddToWalletIfInvolvingMe (Ben Woosley)
b7f5650942 Extract CWallet::MarkInputsDirty (Ben Woosley)

Pull request description:

  Thus reducing code and surface area of CWallet.

Tree-SHA512: 31a99acc77ef3438ef9b95d60030972b707bd69d6e7b1498a5f776b219d9aabc83464f75bfec7bad5cb635d0b2d686c389914e5cc57a4bb0b93c47bd82ca608c
2018-07-13 20:24:37 -07:00
Pieter Wuille 9a1ad2c5cb
Merge #11658: During IBD, when doing pruning, prune 10% extra to avoid pruning again soon after
ac51a26bdc During IBD, when doing pruning, prune 10% extra to avoid pruning again soon after (Luke Dashjr)

Pull request description:

  Pruning forces a chainstate flush, which can defeat the dbcache and harm performance significantly.

  Alternative to #11359

Tree-SHA512: 631e4e8f94f5699e98a2eff07204aa2b3b2325b2d92e8236b8c8d6a6730737a346e0ad86024e705f5a665b25e873ab0970ce7396740328a437c060f99e9ba4d9
2018-07-13 20:16:41 -07:00
Pieter Wuille 1e90862f5d
Merge #13417: [net] Tighten scope in net_processing
3339ba28e9 Make g_enable_bip61 a member variable of PeerLogicValidation (Jesse Cohen)
6690a28606 Restrict as much as possible in net_processing to translation unit (Jesse Cohen)
1d4df02b7e [move-only] Move things only referenced in net_processing out of header file (Jesse Cohen)
02bbc05310 Rescope g_enable_bip61 to net_processing (Jesse Cohen)

Pull request description:

  As part of a larger effort to decouple net_processing and validation a bit, these are a bunch of simple scope cleanups. I've moved things out of the header file that are only referenced in net_processing and added static (or anonymous namespace) modifiers to everything possible in net_processing.

  There are a handful of functions which could be static except that they are exposed for the sake of unit testing - these are explicitly commented. There has been some discussion of a compile time annotation, but no conclusion has been reached on that yet.

  This is somewhat related to other prs #12934 #13413 #13407 and will be followed by prs that reduce reliance on cs_main to synchronize data structures which are translation unit local to net_processing

Tree-SHA512: 46c9660ee4e06653feb42ba92189565b0aea17aac2375c20747c0d091054c63829cbf66d2daddf65682b58ce1d6922e23aefea051a7f2c8abbb6db253a609082
2018-07-13 20:10:55 -07:00
Pieter Wuille ad552a54c5
Merge #13566: Fix get balance
702ae1e21a [RPC] [wallet] allow getbalance to use min_conf and watch_only without accounts. (John Newbery)
cf15761f6d [wallet] GetBalance can take a min_depth argument. (John Newbery)
0f3d6e9ab7 [wallet] factor out GetAvailableWatchOnlyBalance() (John Newbery)
7110c830f8 [wallet] deduplicate GetAvailableCredit logic (John Newbery)
ef7bc8893c [wallet] Factor out GetWatchOnlyBalance() (John Newbery)
4279da4785 [wallet] GetBalance can take an isminefilter filter. (John Newbery)

Pull request description:

  #12953 inadvertently removed the functionality to call `getbalance "*" <int> <bool>` to get the wallet's balance with either minconfs or include_watchonly.

  This restores that functionality (when `-deprecatedrpc=accounts`), and also makes it possible to call ``getbalance minconf=<int> include_watchonly=<bool>` when accounts are not being used.

Tree-SHA512: 67e84de9291ed6d34b23c626f4dc5988ba0ae6c99708d02b87dd3aaad3f4b6baa6202a66cc2dadd30dd993a39de8036ee920fcaa8cbb1c5dfe606e6fac183344
2018-07-13 19:46:31 -07:00
Pieter Wuille d6b2235ca4
Merge #13630: Drop unused pindexRet arg to CMerkleTx::GetDepthInMainChain
d6f39b6c64 Drop unused pindexRet arg to CMerkleTx::GetDepthInMainChain (Ben Woosley)

Pull request description:

Tree-SHA512: 5f064a47e71113f90f296ab36dae92173ff3fc632ab4e1e85dc71d556cb9239d15939b1e542f4292dab93d336795b7f2e4ae64f6984303c852df8d24f54ccebe
2018-07-13 19:33:41 -07:00
Andrew Chow 8b5ef27937 SignPSBTInput wrapper function
The SignPSBTInput function takes a PSBTInput, SignatureData, SigningProvider,
and other data necessary for signing. It fills the SignatureData with data from
the PSBTInput, retrieves the UTXO from the PSBTInput, signs and finalizes the
input if possible, and then extracts the results from the SignatureData and
puts them back into the PSBTInput.
2018-07-13 14:27:31 -07:00
Andrew Chow 58a8e28918 Refactor transaction creation and transaction funding logic
In preparation for more create transaction and fund transcation RPCs,
refactor the transaction creation and funding logic into separate
functions.
2018-07-13 14:27:31 -07:00
Andrew Chow e9d86a43ad Methods for interacting with PSBT structs
Added methods which move data to/from SignaturData objects to
PSBTInput and PSBTOutput objects.

Added sanity checks for PSBTs as a whole which are done immediately
after deserialization.

Added Merge methods to merge a PSBT into another one.
2018-07-13 14:27:31 -07:00
Andrew Chow 12bcc64f27 Add pubkeys and whether input was witness to SignatureData
Stores pubkeys in SignatureData and retrieves them when using GetPubKey().

Stores whether the signatures in a SignatureData are for a witness input.
2018-07-13 14:27:31 -07:00
Andrew Chow 41c607f09b Implement PSBT Structures and un/serialization methods per BIP 174 2018-07-13 14:27:31 -07:00
Thomas Kerin 417b6c1d29 bitcoinconsensus: invalid flags should be set to bitcoinconsensus_error type, add test cases covering bitcoinconsensus error codes 2018-07-13 22:13:10 +01:00
Ben Woosley 17e6aa8e33
Privatize CWallet::AddToWalletIfInvolvingMe
And document in the header.
2018-07-13 16:18:14 -04:00
Ben Woosley b7f5650942
Extract CWallet::MarkInputsDirty
To avoid repeated implementations.
2018-07-13 16:18:13 -04:00
Jonas Schnelli 619cd29393
Merge #12944: [wallet] ScanforWalletTransactions should mark input txns as dirty
3c292cc19 ScanforWalletTransactions should mark input txns as dirty (Gregory Sanders)

Pull request description:

  I'm hitting a corner case in my mainnet wallet where I load a restore a wallet, call `rescanblockchain` from RPC, and it's "double counting" an output I've sent to myself since currently it never marks input transactions as dirty. This is fixed by a restart of the wallet.

  Note that this only happens with keys with birthdate *after* the blocks containing the spent funds which gets scanned on startup, so it's hard to test without a set seed function.

Tree-SHA512: ee1fa152bb054b57ab4c734e355df10d241181e0372c81d583be61678fffbabe5ae60b09b05dc1bbbcfb4838df9d8538791d4c1d80a09b84d78ad2f50dcb0a61
2018-07-13 20:34:43 +01:00
Ben Woosley 93de2891fa
wallet: assert to ensure accuracy of CMerkleTx::GetBlocksToMaturity
According to my understanding, it should not be possible for coinbase
transactions to be conflicting, thus it should not be possible for
GetDepthInMainChain to return a negative result. If it did, this would
also result in innacurate results for GetBlocksToMaturity due to the
math therein. asserting ensures accuracy.
2018-07-13 12:41:45 -04:00
Ben Woosley 89e70f9d7f
Fix that CWallet::AbandonTransaction would only traverse one level
Prior to this change, it would mark only the first layer of
child transactions abandoned, due to always following the input hashTx
rather than the current now tx.
2018-07-13 11:16:08 -04:00
Ben Woosley 5617840392
Drop dead code from Stacks
Stacks is local to this file, and only used in DataFromTransaction, so
it's easy to confirm this code is unused.
2018-07-12 18:44:33 -04:00
Jonas Schnelli 4704e5f074
[QA] add createwallet disableprivatekey test 2018-07-12 20:32:07 +01:00
Jonas Schnelli c7b8f343e9
[Qt] Disable creating receive addresses when private keys are disabled 2018-07-12 20:32:07 +01:00
Jonas Schnelli 2f15c2bc20
Add disable privatekeys option to createwallet 2018-07-12 20:32:07 +01:00
Jonas Schnelli cebefba085
Add option to disable private keys during internal wallet creation 2018-07-12 20:31:57 +01:00
Jonas Schnelli 9048575511
Add FindScriptPubKey() to search the UTXO set 2018-07-12 20:10:05 +01:00
Wladimir J. van der Laan dcb154e5aa
Merge #13177: GCC-7 and glibc-2.27 back compat code
253f592909 Add stdin, stdout, stderr to ignored export list (Chun Kuan Lee)
fc6a9f2ab1 Use IN6ADDR_ANY_INIT instead of in6addr_any (Cory Fields)
908c1d7745 GCC-7 and glibc-2.27 compat code (Chun Kuan Lee)

Pull request description:

  The `__divmoddi4` code was modified from https://github.com/gcc-mirror/gcc/blob/master/libgcc/libgcc2.c . I manually find the older glibc version of log2f by objdump, use `.symver` to specify the certain version.

Tree-SHA512: e8d875652003618c73e019ccc420e7a25d46f4eaff1c7a1a6bfc1770b3b46f074b368b2cb14df541b5ab124cca41dede4e28fe863a670589b834ef6b8713f9c4
2018-07-12 17:46:29 +02:00
Wladimir J. van der Laan 9b638c7ce1
Merge #13627: Free keystore.h from file scope level type aliases
d0b9405f96 Refactors `keystore.h` type aliases. (251)

Pull request description:

  This pull request frees `keystore.h` from type alias declarations that have been declared at file scope level.

  `keystore.h` has various type aliases that have been declared ~3 - 6 years ago at file scope level, which can either be encapsulated or removed.

  Where type alias declarations are encapsulated at the appropriate scope and access level, C++11's `using` notation is used in favor of the `typedef` notation.

Tree-SHA512: 1395cdc63e0c7ff5a1b1721675ad4416f71f507e999bd4ba019f03457cbfc08877848f10a8db7f5ccd2cd5ca3f5a291c986616f7703172fb6d79fba7447ffba8
2018-07-12 14:37:28 +02:00
MarcoFalke d3dae3ddf9
Merge #13145: Use common getPath method to create temp directory in tests.
075429a482 Use common SetDataDir method to create temp directory in tests. (winder)

Pull request description:

  Took a stab at #12574

  Created a `getPath` method which can be used with the `TestingSetup` fixture to create a temp directory. Updated tests using temp directories to use this method.

  I tried setting up a `BOOST_GLOBAL_FIXTURE` to create a truly global path for all tests but was getting linker errors when including `boost/test/unit_test.hpp` in `test_bitcoin.cpp`. Even if I had gotten the linking to work, it looks like `make check` invokes the test binary a bunch of times, so it may not have worked anyway.

Tree-SHA512: b51d0f5fada5d652ccc9362596cf98a742aa47f5daf94f189b5f034d8c035c85d095377befdcff7fb4247154d5160e8c500d70f554a2158e2c185a9d24f694f1
2018-07-12 07:47:53 -04:00
Jonas Schnelli 9995a602a6
Add facility to store wallet flags (64 bits) 2018-07-12 10:30:21 +01:00
winder 075429a482 Use common SetDataDir method to create temp directory in tests. 2018-07-11 23:44:12 -04:00
251 d0b9405f96 Refactors keystore.h type aliases.
This squashed commit either encapsulates type alias declarations at the appropriate scope; or removes type aliases that are not used.

The encapsulated type aliases are declared using C++11's `using` notation in favor of the `typedef` notation.
2018-07-12 00:48:49 +02:00
MarcoFalke 5ba77df15d
Merge #13114: wallet/keystore: Add Clang thread safety annotations for variables guarded by cs_KeyStore
968b76f77c Add missing cs_KeyStore lock (practicalswift)
4bcd5bb87d Add locking annotations for variables guarded by cs_KeyStore (practicalswift)

Pull request description:

  * Add Clang thread safety annotations for variables guarded by `cs_KeyStore`
  * Add missing `cs_KeyStore` lock

Tree-SHA512: 7d93513c2da0cd564b9f1e75aa5156a454a4133eb845020fde8872e685dd5758353e93c33364aeea4a812c08353a810494e503a5ce160cc5be0af5af4bb2e6d7
2018-07-11 15:09:24 -04:00
Wladimir J. van der Laan e538a952d5
Merge #13622: Remove mapRequest tracking that just effects Qt display.
beef7ec4be Remove useless mapRequest tracking that just effects Qt display. (Matt Corallo)

Pull request description:

  I thought we had removed this a long time ago, TBH, its really
  confusing feedback to users that we display whether a tx was
  broadcast to immediate neighbor nodes, given that has little
  indication of whether the tx propagated very far.

Tree-SHA512: c9d0808fb60146919bb78d0860ec2193601966c944887eaae7837408422f7e85dfdb306407a613200cdd4726aec66da18df618ebc6a8cfe8650bf08d4a8dc155
2018-07-11 16:36:15 +02:00
MarcoFalke fa4bf92be9
Remove dead service bits code 2018-07-11 10:32:25 -04:00
Wladimir J. van der Laan acc68bc631
Merge #13586: refactor: add benchmarks to bech32::Encode/Decode
189cf35f3e Add simple bech32 benchmarks (Karl-Johan Alm)

Pull request description:

  This PR adds benchmarks to `Encode()`/`Decode()`.

  The benchmark commit is duplicated in #13632.

Tree-SHA512: 102a193e4af58c9cb23c66d3dc7e174aa6328edab0ed74f92deb7804db5c3d0601807b3e25a5472b5c72d6113cde0dbc9976315644671a8f14ecf349967dbaaa
2018-07-11 11:44:10 +02:00
Ben Woosley d6f39b6c64
Drop unused pindexRet arg to CMerkleTx::GetDepthInMainChain 2018-07-11 00:22:10 -04:00
practicalswift bd9d0690dc Remove unused argument to WitnessSigOps(...) 2018-07-10 18:12:57 +02:00
practicalswift d1d7cfebd2 Remove unused argument to DefaultOptions(...) 2018-07-10 18:12:57 +02:00
practicalswift 05dbb0c042 Remove unused argument to ThreadHTTP(...) 2018-07-10 18:12:57 +02:00
Wladimir J. van der Laan fad42e8c4a
Merge #13547: Make signrawtransaction* give an error when amount is needed but missing
685d1d8115 [tests] Check signrawtransaction* errors on missing prevtx info (Anthony Towns)
a3b065b51f Error on missing amount in signrawtransaction* (Anthony Towns)

Pull request description:

  Signatures using segregated witness commit to the amount being spent, so that value must be passed into signrawtransactionwithkey and signrawtransactionwithwallet. This ensures an error is issued if that doesn't happen, rather than just assuming the value is 0 and producing a signature that is almost certainly invalid.

  Based on Ben Woosley's #12458, Fixes: #12429.

Tree-SHA512: 8e2ff89d5bcf79548e569210af0d850028bc98d86c149b92207c9300ab1d63664a7e2b222c1be403a15941aa5cf36ccc3c0d570ee1c1466f3496b4fe06c17e11
2018-07-10 17:04:11 +02:00
MarcoFalke b05ded1764
Merge #13565: test: Fix AreInputsStandard test to reference the proper scriptPubKey
f95989b3ed Fix AreInputsStandard test to reference the proper scriptPubKey (Ben Woosley)

Pull request description:

  This value doesn't affect the outcome of the test, because the values are
  properly set on line 351 (https://github.com/bitcoin/bitcoin/pull/13565/files#diff-b7061098b41bd31ef5db043705441133R351), but this makes the test values internally coherent.

Tree-SHA512: 5a5fda843475abd91f6c366315536d3573e70420d7c6abeebd74a54939d4de774c33faad4560d1fd4b2c35006224d9e7b3a8c925fe9926013586fd1f7aa886cc
2018-07-10 10:23:11 -04:00
Wladimir J. van der Laan c05c93c5d8
Merge #13118: RPCAuth Detection in Logs
dae0d13bbb RPCAuth Detection in Logs (Linrono)

Pull request description:

  This adds a log entry for when RPCAuth is detected.
  This keeps everything working as it currently is. I suppose it could be added as a nested if to also stop the creation of the cookie file if this would be wanted.

Tree-SHA512: 61a893b2e06ae5e7db2ddedc63819d34047fad0df764184b1b2b3f49016581e6bbf2c94a59374ca2c300190cd4e827f01da286aad5a4cc8fe5140e258b1cf8c4
2018-07-10 16:19:30 +02:00
Jesse Cohen 3339ba28e9 Make g_enable_bip61 a member variable of PeerLogicValidation 2018-07-09 21:09:58 -04:00
Matt Corallo beef7ec4be Remove useless mapRequest tracking that just effects Qt display.
I thought we had removed this a long time ago, TBH, its really
confusing feedback to users that we display whether a tx was
broadcast to immediate neighbor nodes, given that has little
indication of whether the tx propagated very far.
2018-07-09 20:06:39 -04:00
Wladimir J. van der Laan b641f60425
Merge #13481: doc: Rewrite some validation docs as lock annotations
fa324a8b15 doc: Rewrite some validation doc as lock annotations (MarcoFalke)

Pull request description:

  #13402 added some lock annotations in comments. This pull removes them and adds clang-readable locking annotations instead.

Tree-SHA512: 2d392efa8ac4978830a9df08b2009e69d6f1ac031f62be2275ae8d7c7e483331c7f8d458d865443af907a7af27a592421c6cca6b2df3f2877e0f369b9198f383
2018-07-09 21:53:48 +02:00
Wladimir J. van der Laan 3a3eabef40
Merge #13386: SHA256 implementations based on Intel SHA Extensions
66b2cf1ccf Use immintrin.h everywhere for intrinsics (Pieter Wuille)
4c935e2eee Add SHA256 implementation using using Intel SHA intrinsics (Pieter Wuille)
268400d318 [Refactor] CPU feature detection logic for SHA256 (Pieter Wuille)

Pull request description:

  Based on #13191.

  This adds SHA256 implementations that use Intel's SHA Extension instructions (using intrinsics). This needs GCC 4.9 or Clang 3.4.

  In addition to #13191, two extra implementations are provided:
  * (a) A variable-length SHA256 implementation using SHA extensions.
  * (b) A 2-way 64-byte input double-SHA256 implementation using SHA extensions.

  Benchmarks for 9001-element Merkle tree root computation on an AMD Ryzen 1800X system:
  * Using generic C++ code (pre-#10821): 6.1ms
  * Using SSE4 (master, #10821): 4.6ms
  * Using 4-way SSE4 specialized for 64-byte inputs (#13191): 2.8ms
  * Using 8-way AVX2 specialized for 64-byte inputs (#13191): 2.1ms
  * Using 2-way SHA-NI specialized for 64-byte inputs (this PR): 0.56ms

  Benchmarks for 32-byte SHA256 on the same system:
  * Using SSE4 (master, #10821): 190ns
  * Using SHA-NI (this PR): 53ns

  Benchmarks for 1000000-byte SHA256 on the same system:
  * Using SSE4 (master, #10821): 2.5ms
  * Using SHA-NI (this PR): 0.51ms

Tree-SHA512: 2b319e33b22579f815d91f9daf7994a5e1e799c4f73c13e15070dd54ba71f3f6438ccf77ae9cbd1ce76f972d9cbeb5f0edfea3d86f101bbc1055db70e42743b7
2018-07-09 21:17:18 +02:00
Wladimir J. van der Laan 7e74c54fed
Merge #13452: rpc: have verifytxoutproof check the number of txns in proof structure
d280617bf5 [qa] Add a test for merkle proof malleation (Suhas Daftuar)
ed82f17000 have verifytxoutproof check the number of txns in proof structure (Gregory Sanders)

Pull request description:

  Recent publication of a weakness in Bitcoin's merkle tree construction demonstrates many SPV applications vulnerable to an expensive to pull off yet still plausible attack: https://bitslog.wordpress.com/2018/06/09/leaf-node-weakness-in-bitcoin-merkle-tree-design/

  This change would at least allow `verifytxoutproof` to properly validate that the proof matches a known block, with known number of transactions any time after the full block is processed. This should neuter the attack entirely.

  The negative is that a header-only processed block/future syncing mode would cause this to fail until the node has imported the data required.

  related: #13451

  `importprunedfunds` needs this check as well. Can expand it to cover this if people like the idea.

Tree-SHA512: 0682ec2b622a38b29f3f635323e0a8b6fc071e8a6fd134c954579926ee7b516e642966bafa667016744ce49c16e19b24dbc8801f982a36ad0a6a4aff6d93f82b
2018-07-09 20:25:50 +02:00
Wladimir J. van der Laan 453ae5ec9f
Merge #13603: bitcoin-tx: Stricter check for valid integers
57889e688d bitcoin-tx: Stricter check for valid integers (Daniel Kraft)

Pull request description:

  Just calling `atoi` to convert strings to integers does not check for valid integers very thoroughly; in particular, it just ignores everything starting from the first non-numeral character.  Even a string like "foo" is fine and silently returns 0.

  This meant that `bitcoin-tx` would not fail if such a string was passed in various places where an integer is expected (like the `locktime` or an input/output index); this means that it would, for instance, silently accept a typo and interpret it in an unexpected way.

  In this change, we use `ParseInt64` for parsing strings to integers, which actually verifies that the full string is valid as number.  New tests in the `bitcoin-util-test` cover the new error paths.

  This fixes #13599.

Tree-SHA512: 146a0af275e9f57784e5d0582d3defbac35551b54b6b7232f8a0b20db04aa611125e52aa4512ef2f8ed2cafc2a12fe586f9d10ed66d641cff090288f279b1988
2018-07-09 20:08:15 +02:00
Wladimir J. van der Laan a247594e75
Merge #13570: RPC: Add new "getzmqnotifications" method
161e8d40a4 RPC: Add new getzmqnotifications method. (Daniel Kraft)
caac39b0ac Make ZMQ notification interface instance global. (Daniel Kraft)

Pull request description:

  This adds a new RPC method `getzmqnotifications`, which returns information about all active ZMQ notification endpoints.  This is useful for software that layers on top of bitcoind, so it can verify that ZeroMQ is enabled and also figure out where it should listen.

  See #13526.

Tree-SHA512: edce722925741c84ddbf7b3a879fc9db1907e5269d0d97138fe724035d93ee541c2118c24fa92f4197403f380d0e25c2fda5ca6c62d526792ea749cf527a99a0
2018-07-09 17:21:03 +02:00
Wladimir J. van der Laan 17e9106c86
Merge #13614: doc: Update command line help for -printtoconsole and -debuglogfile (satwo)
5e362c0cf0 Fix command line help for -printtoconsole and -debuglogfile (Samuel B. Atwood)

Pull request description:

  This is a rebased version of #13589 with the changes to the 0.16.x release notes removed.

  > #13004 changed the default behavior for printtoconsole but this has not been reflected in the command line help.

  > This fixes the description of -printtoconsole to reflect this change, and also provides the user with missing information on how to explicitly disable logging to debug.log.

  > At present I have made the latter update to two separate places (-printtoconsole and -debuglogfile) because a user looking for information on how to disable logging is probably going to look in the "Debugging/Testing Options" section. Moving -debuglogfile from the "General" options category to the "Debugging/Testing" section could potentially remove the need for this redundancy but may be out of the scope of this PR.

Tree-SHA512: 7461d59a1864039d5a9dfcce765a1169df882f51a4ca50a6066416c0803821cd821be07be534e0bd57f0a22c0b45adb881a93abbe91962bc37d2d228f35ee712
2018-07-09 17:03:12 +02:00
Wladimir J. van der Laan 172f984f59
Merge #13615: net: Remove unused interrupt from SendMessages
4b6ab02122 Remove unused argument to ProcessGetBlockData(...) (practicalswift)
c469ecf22e net: Remove unused interrupt from SendMessages (fanquake)

Pull request description:

  Discussed very briefly with cfields.

  Includes 65b4400 from #13554 as it's a similar refactor.

Tree-SHA512: 45cd64208a5c8164242db74e6687e9344ea592bab5e7f9ba8e1bb449057fc908ec9d8b8523748a68426e4a4304e3388a138cd834698b39837b2149b72beefdc9
2018-07-09 16:50:09 +02:00
Anthony Towns b9024fdda3 segwit support for createmultisig RPC 2018-07-10 00:07:58 +10:00
Anthony Towns d58055d25f Move AddAndGetDestinationForScript from wallet to outputype module
Makes AddAndGetDestinationForScript use a generic CKeyStore rather than
the wallet, and makes it always add the script to the keystore, rather
than only adding related (redeem) scripts.
2018-07-10 00:06:19 +10:00
Wladimir J. van der Laan b55f0c31d4
Merge #13611: [bugfix] Use __cpuid_count for gnu C to avoid gitian build fail.
63c16ed507 Use __cpuid_count for gnu C to avoid gitian build fail. (Chun Kuan Lee)

Pull request description:

  Fixes #13538

Tree-SHA512: 161ae4db022288ae8631a166eaea2d08cf2c90bcd27218a094a754276de30b92ca9cfb5a79aa899c5a9d0534c5d7261037e7e915e1b92bc7067ab1539dc2b51e
2018-07-09 15:55:32 +02:00
Anthony Towns 9a44db2e46 Add outputtype module
Moves OutputType into its own module
2018-07-09 22:21:15 +10:00
practicalswift 4b6ab02122
Remove unused argument to ProcessGetBlockData(...) 2018-07-08 21:27:12 +08:00
fanquake c469ecf22e
net: Remove unused interrupt from SendMessages 2018-07-08 21:27:12 +08:00
Samuel B. Atwood 5e362c0cf0
Fix command line help for -printtoconsole and -debuglogfile
#13004 changed the default behavior for printtoconsole but this has not been reflected in the command line help.

This fixes the description of -printtoconsole to reflect this change, and also provides the user with missing information on how to explicitly disable logging to debug.log.

At present I have made the latter update to two separate places (-printtoconsole and -debuglogfile) because a user looking for information on how to disable logging is probably going to look in the "Debugging/Testing Options" section. Moving -debuglogfile from the "General" options category to the "Debugging/Testing" section could potentially remove the need for this redundancy but may be out of the scope of this PR.
2018-07-08 21:12:31 +08:00
MarcoFalke 88a15ebc8d
Merge #13564: [wallet] loadwallet shouldn't create new wallets.
ea65182f03 [wallet] loadwallet shouldn't create new wallets. (John Newbery)

Pull request description:

  A bug in the initial implementation of loadwallet meant that if the
  arguement was a directory that didn't contain a wallet.dat file, a new
  wallet would be created in that directory. Fix that so that if a
  directory is passed in, it must contain a wallet.dat file.

  Bug reported by promag (João Barbosa).

Tree-SHA512: 0a59fa8a33fde51a88544ad288b00e4995284fe16424f643076aaba42b8244fff362145217650ee53d518dfab7efbed4237632c34cdd3dcbbecaa9ecaab5fd7b
2018-07-07 06:07:41 -11:00
Chun Kuan Lee 63c16ed507 Use __cpuid_count for gnu C to avoid gitian build fail. 2018-07-07 16:01:43 +00:00
Daniel Kraft 57889e688d bitcoin-tx: Stricter check for valid integers
Just calling atoi to convert strings to integers does not check for
valid integers very thoroughly; in particular, it just ignores
everything starting from the first non-numeral character.  Even a string
like "foo" is fine and silently returns 0.

This meant that bitcoin-tx would not fail if such a string was passed in
various places where an integer is expected (like the locktime or an
input/output index); this means that it would, for instance, silently
accept a typo and interpret it in an unexpected way.

In this change, we use ParseInt64 for parsing strings to integers,
which actually verifies that the full string is valid as number.
New tests in the bitcoin-util-test cover the new error paths.
2018-07-07 14:25:09 +02:00
MarcoFalke 0212187fc6
Merge #13598: bench: fix incorrect behaviour in prevector.cpp
1fc605a8ae fix bench/prevector.cpp (Akio Nakamura)

Pull request description:

  This patch intends to fix some incorrect action of bench/prevector.cpp.

  1. PrevectorClear()
  2nd call of ```clear()``` should to operate t1 instead of t0.
  This patch changes t0 to t1.

  2. PREVECTOR_TEST()
  PREVECTOR_TEST macro should to call both
  ```PrevectorXX<nontrivial_t>(state)``` and ```PrevectorXX<trivial_t>(state)```
  by specific ```"name"``` which given by parameter instead of calling
  ```PrevectorResize<>()``` regardless of ```"name"```.
  This patch changes ```"PrevectorResize<"``` of this macro to
  ```"Prevector ## name<"```.

Tree-SHA512: d0498c6d627d7e96fc8ccfb329ca0be2641535b1ce1923d9b1fc720825f9bf4d7281dc8d5ae929038e37b3e625189af9807cb62e6d20933d73832a6dff4b5596
2018-07-05 19:59:35 -11:00
Wladimir J. van der Laan 287e4edc2f
Merge #12788: [build] Tune wildcards for LIBSECP256K1 target
98b181323 [build] Tune wildcards for LIBSECP256K1 target (Karl-Johan Alm)

Pull request description:

  Automake would think the target was out of date every time because e.g. '.deps' was updated.

  Note: I am assuming that secp256k1 depends on `*.h`, `*.c`, ~~and `libsecp256k1-config.h`~~ (it's `.h` so already included), aside from pre-existing `include/*`. If there are other files that would require a rebuild of the `LIBSECP256K1` target, they should probably be added.

  It would be neat if you could exclude specific files, rather than split it up like this, but it doesn't seem possible (https://www.gnu.org/software/make/manual/html_node/Wildcard-Function.html#Wildcard-Function)

  Should probably note this:
  ```Bash
  $ V=1 make check VERBOSE=1
  Making check in src
  make[1]: Entering directory '/home/user/workspace/bitcoin/src'
  make[2]: Entering directory '/home/user/workspace/bitcoin/src'
  make  -C secp256k1 libsecp256k1.la
  make[3]: Entering directory '/home/user/workspace/bitcoin/src/secp256k1'
  make[3]: 'libsecp256k1.la' is up to date.
  make[3]: Leaving directory '/home/user/workspace/bitcoin/src/secp256k1'
  make  check-TESTS check-local
  make[3]: Entering directory '/home/user/workspace/bitcoin/src'
  make[4]: Entering directory '/home/user/workspace/bitcoin/src'
  make  -C secp256k1 libsecp256k1.la
  make[5]: Entering directory '/home/user/workspace/bitcoin/src/secp256k1'
  make[5]: 'libsecp256k1.la' is up to date.
  make[5]: Leaving directory '/home/user/workspace/bitcoin/src/secp256k1'
  PASS: test/test_bitcoin.exe
  ```

Tree-SHA512: 62b133c76e882788dae0c14208a9f5acdbd731c2e7a248f9e01f488b8ec13f9d637d7ad0d63e18d324bb4e088f1836a936649b0fb97bee679eaadedbeed5c981
2018-07-05 19:39:42 +02:00
Wladimir J. van der Laan 062738cf69
Merge #13096: [Policy] Fix MAX_STANDARD_TX_WEIGHT check
2f1a30c63 Fix MAX_STANDARD_TX_WEIGHT check (Johnson Lau)

Pull request description:

  As suggested by the constant name and its comment in policy.h, a transaction with a weight of exactly MAX_STANDARD_TX_WEIGHT should be allowed. Users could be confused.

Tree-SHA512: af417de1c6a2e6796ebbb39aa0caad8764302ded155cb1bbfbe457e4567c199cc53256189832b17d4aeec369e190b3edd4c6116d5f0b8cf0ede6dfb4ed83bdd3
2018-07-05 18:40:58 +02:00
Wladimir J. van der Laan c9eb8d1c55
Merge #13577: logging: avoid nStart may be used uninitialized in AppInitMain warning
2dcd7b4ec logging: avoid nStart may be used uninitialized in AppInitMain warning (mruddy)

Pull request description:

  Was getting the following compiler warning:

  ```
  init.cpp: In function ‘bool AppInitMain()’:
  init.cpp:1616:60: warning: ‘nStart’ may be used uninitialized in this function [-Wmaybe-uninitialized]
           LogPrintf(" block index %15dms\n", GetTimeMillis() - nStart);
  ```

  It's ok without this PR, but this PR renames `nStart` to `load_block_index_start_time`, makes it `const`, and also reduces the scope of the variable.

  The logging line is moved such that the the time spent will be logged even if a shutdown is requested while the index is being loaded.

  Having the log message output even when a shutdown is requested may be how this was intended to work before anyways. That could explain the leading space, as such a log message now looks like:
  ```
  2018-06-30T11:34:05Z [0%]...[16%]...[33%]...[50%]... block index           25750ms
  2018-06-30T11:34:17Z Shutdown requested. Exiting.
  ```

Tree-SHA512: 967048afbc31f2ce8f80ae7d33fee0bdcbe94550cf2b5b662087e2a7cff14a8bf43d909b30f930660c184ec6c3c7e1302a84e3e54fc1723f7412827f4bf2c518
2018-07-05 18:12:21 +02:00
Wladimir J. van der Laan 028b0d963c
Merge #13425: Moving final scriptSig construction from CombineSignatures to ProduceSignature (PSBT signer logic)
b81560029 Remove CombineSignatures and replace tests (Andrew Chow)
ed94c8b55 Replace CombineSignatures with ProduceSignature (Andrew Chow)
0422beb9b Make SignatureData able to store signatures and scripts (Andrew Chow)
b6edb4f5e Inline Sign1 and SignN (Andrew Chow)

Pull request description:

  Currently CombineSignatures is used to create the final scriptSig or an input. However ProduceSignature is capable of doing this itself. Using both CombineSignatures and ProduceSignature results in code duplication which is unnecessary.

  To move the scriptSig construction to ProduceSignatures, the SignatureData class contains two maps to hold pubkeys mapped to signatures, and script ids mapped to scripts. DataFromTransaction is extended to be able to extract signatures, their public keys, and scripts from existing ScriptSigs.

  The SignaureData are then passed down to SignStep which can use the aforementioned maps to get the signatures, pubkeys, and scripts that it needs, falling back to the actual SigningProvider and SignatureCreator if the data are not available in the SignatureData.

  Additionally, Sign1 and SignN have been removed and their functionality inlined into SignStep since Sign1 is really just a wrapper around CreateSig.

  Since ProduceSignature can produce the final scriptSig or scriptWitness by using SignatureData which has extracted data from the transaction, CombineSignatures is unnecessary as ProduceSignature is able to replicate all of CombineSignatures' functionality.

  This also furthers BIP 174 support and begins moving towards a BIP 174 style backend.

  The tests have also been updated to use the new combining methodology.

Tree-SHA512: 78cd58a4ebe37f79229bd5eee2958a0bb45cd7f36d0e993eee13ff685b3665dd76ef2dfd5f47d34678995bb587f5594100ee5f6c09b1c69ee96d3684d470d01e
2018-07-05 17:18:50 +02:00
Wladimir J. van der Laan 40334c71d6
Merge #13580: build: Detect if char equals int8_t
49d1f4cdd Detect if char equals int8_t (Chun Kuan Lee)

Pull request description:

  Probably fixes #13576. I'm not able to test this. @stacepellegrino, can you test this?

Tree-SHA512: b750e00e11e6b6f6341fec668ec2254cc101c8ebdd4878f320d6cb3b07cf326761146e4ceff0b6405b7e503ff64c093a8274bd524a097e2c49382dc296972c4f
2018-07-05 13:34:15 +02:00
Akio Nakamura 1fc605a8ae fix bench/prevector.cpp
1. PrevectorClear()
2nd call of clear() should to operate t1 instead of t0.
This patch changes t0 to t1.

2. PREVECTOR_TEST()
PREVECTOR_TEST macro should to call both
PrevectorXX<nontrivial_t>(state) and PrevectorXX<trivial_t>(state)
by specific "name" which given by parameter instead of calling
PrevectorResize<>() regardless of "name".
This patch changes "PrevectorResize<" of this macro to
"Prevector ## name<".
2018-07-05 20:04:48 +09:00
Daniel Kraft 161e8d40a4 RPC: Add new getzmqnotifications method.
This adds a new RPC method "getzmqnotifications", which returns
information about all active ZMQ notification endpoints.  This is useful
for software that layers on top of bitcoind, so it can verify that
ZeroMQ is enabled and also figure out where it should listen.

See https://github.com/bitcoin/bitcoin/issues/13526.
2018-07-05 08:02:22 +02:00
Wladimir J. van der Laan b77c38e06c
Merge #13588: Docs: Improve doc of options addnode, connect, seednode
b330c3001 Docs: Improve doc of options addnode, connect, seednode (wodry)

Pull request description:

  Just clarify that options `addnode`, `connect` and `seednode` can be specified multiple times.

Tree-SHA512: ed149cabe7fc1d40f2fb6ad8b643656e0ec49cfae1834c157c89170eac1241efa3c5683d97266ff921f5229f28d732c9f7ee030e7902d9a79db1e0c8716fa3db
2018-07-04 15:57:40 +02:00
Wladimir J. van der Laan 79e677950b
Merge #13235: Break circular dependency: init -> * -> init by extracting shutdown.h
1fabd59e7 Break circular dependency: init -> * -> init by extracting shutdown.h (Ben Woosley)
e62fdfeea Drop unused init.h includes (Ben Woosley)

Pull request description:

  Most includers just wanted to react to pending shutdown.

  This isolates access to `fRequestShutdown` and limits access to the shutdown api functions, including the new `CancelShutdown` for setting it to `false`.

Tree-SHA512: df42f75dfbba163576710e9a67cf1228531fd99d70a2f187bfba0bcc476d6749cf88180a97e66a81bb5b6c3c7f0917de7402d26039ba7b644cb7509b02f7e267
2018-07-04 15:34:03 +02:00
Wladimir J. van der Laan 5c05dd6285
Merge #13575: Refactor: Rename NET_TOR to NET_ONION
07c493f2d scripted-diff: Replace NET_TOR with NET_ONION (wodry)

Pull request description:

  This is a follow-up to #13532, where @promag already asked if this renaming would make sense.

  If network shall be named _Onion_ instead of _Tor_ (like in the option `onlynet`), renaming the network enum NET_TOR to NET_ONION maybe would make sense and be stringent.

  Change was produced with the following script:

  ```
  #!/bin/bash

  for file in $(grep --exclude-dir='.git' --files-with-matches --binary-files=without-match --recursive NET_TOR bitcoin/)
  do
      sed --in-place --expression='s/NET_TOR/NET_ONION/g' $file
  done
  ```

  _Tor_ is used at many other places in the code, though.

Tree-SHA512: 4ffdeca8115031465eb64e1c76694fb77b5900c4ea465d3c13d9b6b75a1eb04c45913f83cdc8bdbef28936aeec4655f1d4905b3b98407da3263632a2128a8d23
2018-07-04 12:00:55 +02:00
Wladimir J. van der Laan 61a044a86a
Merge #13491: Improve handling of INVALID in IsMine
bb582a59c Add P2WSH destination helper and use it instead of manual hashing (Pieter Wuille)
eaba1c111 Add additional unit tests for invalid IsMine combinations (Pieter Wuille)
e6b9730c4 Do not expose invalidity from IsMine (Pieter Wuille)

Pull request description:

  This improves the handling of INVALID in IsMine:
  * Extra INVALID conditions were added to `IsMine` (following https://github.com/bitcoin/bitcoin/pull/13142/files#r185349057), but these were untested. Add unit tests for them.
  * In https://github.com/bitcoin/bitcoin/pull/13142#issuecomment-386396975 it was suggested to merge `isInvalid` into the return status. This PR takes a different approach, and removes the `isInvalid` entirely. It was only ever used inside tests, as normal users of IsMine don't care about the reason for non-mine-ness, only whether it is or not. As the unit tests are extensive enough, it seems sufficient to have a black box text (with tests for both compressed and uncompressed keys).

  Some addition code simplification is done as well.

Tree-SHA512: 3267f8846f3fa4e994f57504b155b0e1bbdf13808c4c04dab7c6886c2c0b88716169cee9c5b350513297e0ca2a00812e3401acf30ac9cde5d892f9fb59ad7fef
2018-07-04 11:36:42 +02:00
Wladimir J. van der Laan b9ded733c1
Merge #13568: Trivial: Remove double semicolon from wallet.cpp and misc.cpp
1336d9cb3 Delete double semicolon in wallet.cpp and misc.cpp (Matteo Sumberaz)

Pull request description:

Tree-SHA512: 86a65df8fdcf8b909ebdebbc510ed57df7c089707a6967c9714c653049eed5d193203443446659c8bbec3f64c12770466455ebedaf5d68cb2869561a477fcfd7
2018-07-04 11:28:05 +02:00
Andrew Chow b815600295 Remove CombineSignatures and replace tests
Removes CombineSignatures and replaces its use in tests with
ProduceSignature to test the same behavior for ProduceSignature.
2018-07-03 17:19:23 -07:00
Andrew Chow ed94c8b556 Replace CombineSignatures with ProduceSignature
Instead of using CombineSignatures to create the final scriptSig or
scriptWitness of an input, use ProduceSignature itself.

To allow for ProduceSignature to place signatures, pubkeys, and scripts
that it does not know about, we pass down the SignatureData to SignStep
which pulls out the information that it needs from the SignatureData.
2018-07-03 17:19:23 -07:00
Andrew Chow 0422beb9bd Make SignatureData able to store signatures and scripts
In addition to having the scriptSig and scriptWitness, have SignatureData
also be able to store just the signatures (pubkeys mapped to sigs) and
scripts (script ids mapped to scripts).

Also have DataFromTransaction be able to extract signatures and scripts
from the scriptSig and scriptWitness of an input to put them in SignatureData.

Adds a new SignatureChecker which takes a SignatureData and puts pubkeys
and signatures into it when it successfully verifies a signature.

Adds a new field in SignatureData which stores whether the SignatureData
was complete. This allows us to also update the scriptSig and
scriptWitness to the final one when updating a SignatureData with another
one.
2018-07-03 17:18:52 -07:00
Karl-Johan Alm 189cf35f3e
Add simple bech32 benchmarks 2018-07-03 12:19:14 +09:00
wodry b330c3001c Docs: Improve doc of options addnode, connect, seednode 2018-07-02 20:15:17 +02:00
wodry 07c493f2d1 scripted-diff: Replace NET_TOR with NET_ONION
-BEGIN VERIFY SCRIPT-

sed --in-place'' --expression='s/NET_TOR/NET_ONION/g' $(git grep -I --files-with-matches 'NET_TOR')

-END VERIFY SCRIPT-

The --in-place'' hack is required for sed on macOS to edit files in-place without passing a backup extension.
2018-07-02 16:41:13 +02:00
Matteo Sumberaz 1336d9cb3b Delete double semicolon in wallet.cpp and misc.cpp 2018-07-02 10:10:27 +02:00
Chun Kuan Lee 49d1f4cdde Detect if char equals int8_t 2018-07-01 15:37:28 +00:00
MarcoFalke 954f4a9c7c
Merge #13431: validation: count blocks correctly for check level < 3
f618ebc4e4 validation: count blocks correctly for check level < 3 (Karl-Johan Alm)

Pull request description:

  As noted in https://github.com/bitcoin/bitcoin/pull/13428#issuecomment-396129295 there is a bug where if check level < 3, the resulting count for blocks is wrong, because `pindexState` is never updated.

  Post-commit `./bitcoin-cli verifychain 1 3`:
  ```

  2018-06-11T07:12:28Z Verifying last 3 blocks at level 1
  2018-06-11T07:12:28Z [0%]...[33%]...[66%]...[99%]...[DONE].
  2018-06-11T07:12:28Z No coin database inconsistencies in last 3 blocks (0 transactions)
  ```

  Pre-commit `./bitcoin-cli verifychain 1 3`:
  ```
  2018-06-11T07:13:34Z Verifying last 3 blocks at level 1
  2018-06-11T07:13:34Z [0%]...[33%]...[66%]...[99%]...[DONE].
  2018-06-11T07:13:34Z No coin database inconsistencies in last 0 blocks (0 transactions)
  ```

Tree-SHA512: 3d82ed26665162c9615fb0e6e91a46ed4d229a5e6797c6c420e6b0bf1be6e5e02401c6e9a93b7a5aec503a2650d8c20d1b45fe300a922379e4cef8ee26e18d96
2018-06-30 22:07:32 -11:00
Jonas Schnelli 10ffca7429
Merge #13537: GUI: Peer table: Visualize inbound/outbound state for every row
4132ad3bf Show symbol for inbound/outbound in peer table (wodry)

Pull request description:

  Fixes #13483

  The address in the network peer table is prefixed with an up-arrow symbolizing an outbound connection, or an down-array symbolizing an inbound connection. See screenshot.

  The user has an easy visual confirmation about the connection direction state. I really like it :)
  Impact to columns sorting is grouping by inbound/outbound first, which in my opinion is an advantage, too.
  ![bildschirmfoto](https://user-images.githubusercontent.com/8447873/41862752-13803eb2-78a5-11e8-9126-a52385f5ec19.png)

Tree-SHA512: d355f679d34c3006743c06750be5f36a083c1a8376da8f5f35045fcd9df964153409946fdde5007734f23bd692c91355962dc42df31122cdcf88e4affce8bc0e
2018-07-01 10:27:43 +02:00
mruddy 2dcd7b4ec7 logging: avoid nStart may be used uninitialized in AppInitMain warning 2018-06-30 07:25:25 -04:00
Andrew Chow b6edb4f5e6 Inline Sign1 and SignN
Sign1 and SignN are kind of redundant so remove them and inline their
behavior into SignStep
2018-06-29 17:32:32 -07:00
John Newbery 702ae1e21a [RPC] [wallet] allow getbalance to use min_conf and watch_only without accounts. 2018-06-29 15:54:24 -04:00
Daniel Kraft caac39b0ac Make ZMQ notification interface instance global.
This moves the used instance of CZMQNotificationInterface from a static
variable in init.cpp to a globally-accessible one declared in
zmq/zmqnotificationinterface.h.  The variable is also renamed to
g_zmq_notification_interface, to be consistent with other globals.

We need this to implement a new RPC method "getzmqnotifications" (see
https://github.com/bitcoin/bitcoin/issues/13526) in a follow up.
2018-06-29 15:16:31 +02:00
MarcoFalke f3c9c40aeb
Merge #13545: tests: Fix test case streams_serializedata_xor. Remove Boost dependency.
962d8eed5b Remove boost dependency (boost/assign/std/vector.hpp) (practicalswift)
c6fd0df4ef Fix incorrect tests (practicalswift)

Pull request description:

  * Fix test case `streams_serializedata_xor`.
  * Remove Boost dependency.

Tree-SHA512: 609c4ced1b6a8b86f6a37e4220535f1b3c9f2e80949cd034ecc069a94c55c05cd514f2e132fe7f715161ee29811a0fadb6903635c507411d8dc3e7efe864edeb
2018-06-30 00:29:59 +14:00
John Newbery cf15761f6d [wallet] GetBalance can take a min_depth argument. 2018-06-28 17:56:59 -04:00
John Newbery 0f3d6e9ab7 [wallet] factor out GetAvailableWatchOnlyBalance() 2018-06-28 17:56:59 -04:00
John Newbery 7110c830f8 [wallet] deduplicate GetAvailableCredit logic 2018-06-28 17:56:57 -04:00
John Newbery ef7bc8893c [wallet] Factor out GetWatchOnlyBalance() 2018-06-28 17:50:40 -04:00
John Newbery 4279da4785 [wallet] GetBalance can take an isminefilter filter.
GetBalance() can now take an ismine filter, which is passed down to
GetAvailableCredit. This allows GetBalance to be used to get watch-only
balances.
2018-06-28 17:50:36 -04:00
MarcoFalke b330f3fdd5
Merge #13563: bench: Simplify CoinSelection
c2e4fc84ec bench: Simplify CoinSelection (João Barbosa)

Pull request description:

  Closes #13549.

  As pointed by @MarcoFalke:
   - `SelectCoinsMinConf` should always succeed as there are enough coins in the wallet.
   - Removed creating the coins in the wallet.

Tree-SHA512: 965c363bcaf0ca7a1dec35b5cf4866abcf190c53eb7012dc4aeb4d29830f13a7465644bfb5a47f6ea3eaa86e4d4a57fe41e7b2593bf5094b76a551c4c71625bb
2018-06-29 10:08:54 +14:00
Ben Woosley f95989b3ed
Fix AreInputsStandard test to reference the proper scriptPubKey
This value doesn't affect the outcome of the test, because the values are
properly set on line 351, but this makes the test values internally coherent.
2018-06-28 14:41:23 -04:00
John Newbery ea65182f03 [wallet] loadwallet shouldn't create new wallets.
A bug in the initial implementation of loadwallet meant that if the
arguement was a directory that didn't contain a wallet.dat file, a new
wallet would be created in that directory. Fix that so that if a
directory is passed in, it must contain a wallet.dat file.

Bug reported by promag (João Barbosa).
2018-06-28 13:37:44 -04:00
João Barbosa c2e4fc84ec bench: Simplify CoinSelection 2018-06-28 14:28:42 +01:00
practicalswift ea49e06c82 tests: Fix incorrect documentation for test case cuckoocache_hit_rate_ok 2018-06-27 19:04:26 +02:00
Anthony Towns a3b065b51f Error on missing amount in signrawtransaction*
Signatures using segregated witness commit to the amount being spent,
so that value must be passed into signrawtransactionwithkey and
signrawtransactionwithwallet. This ensures an error is issued if that
doesn't happen, rather than just assuming the value is 0 and producing
a signature that is almost certainly invalid.
2018-06-28 02:06:33 +10:00
practicalswift 962d8eed5b Remove boost dependency (boost/assign/std/vector.hpp) 2018-06-27 17:45:18 +02:00
practicalswift c6fd0df4ef Fix incorrect tests 2018-06-27 16:59:23 +02:00
MarcoFalke d96bdd7830
Merge #12882: tests: Make test_bitcoin pass under ThreadSanitzer (clang). Fix lock-order-inversion (potential deadlock).
9fdf05d70c tests: Fix lock-order-inversion (potential deadlock) in DoS_tests. Reported by TSAN. (practicalswift)

Pull request description:

  Fix lock-order-inversion (potential deadlock) in `DoS_tests`. Reported by Clang's TSAN.

  Makes `src/test/test_bitcoin` pass also when compiled with TreadSanitizer (`./configure --with-sanitizers=thread` with `clang`).

Tree-SHA512: 41403bb7b6e26bdf1b830b5699e27c637d522bae1799d2a19ed4b68b21b2555438b42170d8b1189613beb32a69b76a65175d29a83f5f4e493896c3d0d94ae26d
2018-06-28 00:30:07 +14:00
MarcoFalke c655b2c2df
Merge #13503: Document FreeBSD quirk. Fix FreeBSD build: Use std::min<int>(...) to allow for compilation under certain FreeBSD versions.
629a47a154 Document FreeBSD quirk. Fix FreeBSD build. (practicalswift)

Pull request description:

  * Document FreeBSD quirk.
  * Fix FreeBSD build: Cast to `int` to allow `std::min` to work under FreeBSD.

  Context: https://github.com/bitcoin/bitcoin/pull/9598#issuecomment-398353904

Tree-SHA512: 5ca7a5fa9e1f3efae241b9be64c9b019ec713c11dcc3edaaed383477ea48ac0dc82549ffebbe9069e8c3f6eff30acd6e4542b4aa31d307f022f4f51e5851a82c
2018-06-27 04:39:47 -04:00
Wladimir J. van der Laan 7209fec190
Merge #13532: Log warning when deprecated network name 'tor' is used
9f8c54b1b5 Log warning message when deprecated network name 'tor' is used (e.g. option onlynet=tor) (wodry)

Pull request description:

  As @laanwj mentioned [here](https://github.com/bitcoin/bitcoin/pull/13418#discussion_r197645385), using option `onlynet=tor` is deprecated.

  I think it would be good to give the user a depcreaction warning feedback, so users can switch to `onlynet=onion` so there is a perspective for removing the deprecated `tor` in the future to decrease confusion.

  Currently, users maybe just wonder that they can use a undocumented option, or they are not aware that they use a deprecated option.

  Alternatively for the log warning message, I think at least this deprecetaion should be documented in the source code in a comment for readers of the source code.

Tree-SHA512: f4889793cdd62a0a13353e13994ed50ca7d367fa9da9897ce909f86cf0b0ce6151b3c484c8e514b8ac332949c6bbc71001e06e918248a1089f73756bd4840602
2018-06-27 07:55:38 +02:00
Pieter Wuille 01f909828d
Merge #13418: Docs: More precise explanation of parameter onlynet
2454a8558a Docs: More precise explanation of parameter "onlynet" (wodry)

Pull request description:

  See issue #13378

Tree-SHA512: d51e81e4ef7fe084c3c9accf3433760fb34c02d149bb2d7006545fecdf68ecd4a5c5bfd0585fd5caff2f034eb96c7da80e85cb04c0ff3edb4c9c65ab56eb2847
2018-06-26 16:59:35 -07:00
Pieter Wuille f54f3738c8
Merge #13498: [wallet] Fixups from account API deprecation
df10f07db1 [wallet] Don't use accounts when checking balance in sendmany (John Newbery)
e209184101 [wallet] deprecate sendfrom RPC method. (John Newbery)

Pull request description:

  A couple of fixups from the accounts API deprecation PR (#12953):

  - properly deprecate `sendfrom`
  - don't use accounts when calculating balance in `sendmany` (unless the `-deprecatedrpc=accounts` flag is being used)

Tree-SHA512: 1befde055067438c4c3391bbff1aaed0e6249efd708c567db3f1faad40a0f28e64f95e5bad0679ae826d24a0239e4bc8a1c392dc93e2e7502343a7f6b1d1845c
2018-06-26 16:46:49 -07:00
wodry 2454a8558a Docs: More precise explanation of parameter "onlynet" 2018-06-26 21:31:23 +02:00
wodry 4132ad3bfa Show symbol for inbound/outbound in peer table 2018-06-26 19:39:12 +02:00
Pieter Wuille 66b2cf1ccf Use immintrin.h everywhere for intrinsics 2018-06-26 10:11:08 -07:00
Pieter Wuille 4c935e2eee Add SHA256 implementation using using Intel SHA intrinsics 2018-06-26 10:11:08 -07:00
MarcoFalke ee02debb25
Merge #13531: doc: Clarify that mempool txiter is const_iterator
faca0a8625 doc: Clarify that mempool txiter is const_iterator (MarcoFalke)

Pull request description:

  `iterator` and `const_iterator` are the same type for multi indexed transaction sets, but `const_iterator` should be preferred for documentation purposes.

Tree-SHA512: 83e8af36d15aa1e9fc59b3c2279504fd6f6ea3188dc43e36dec279ee0613ff07947d7143fd112bade7868b0dba59ecab3fd246cbde82e376ef965b646d9f8c4d
2018-06-26 07:05:05 -04:00
Wladimir J. van der Laan 452bb90c71
Merge #13507: RPC: Fix parameter count check for importpubkey
3f72d04e29 Fix parameter count check for importpubkey. (Kristaps Kaupe)

Pull request description:

  Found this while working on #13464. Parameter count check for `importpubkey` was wrong.

Tree-SHA512: aba41b666c6493379f320be5e3e438a6cad1a96429102ff4428c092c48f29c2eead2195792c0b018296f20e1c42eb091dd5b9886c42cecbb1f0d03d5def14705
2018-06-25 20:43:30 +02:00
MarcoFalke baf3a3ab0c
Merge #13536: [qt] coincontrol: Remove unused qt4 workaround
faa2cf685a [qt] coincontrol: Remove unused qt4 workaround (MarcoFalke)

Pull request description:

  This reverts 55eade9d46 since it is no longer required.

Tree-SHA512: ec523d505b410ab72ce9fdee86dfcfe96011472fb386744bb585169724270426ee65da2b527ae47928d604e1f21f54aa2b4b82f9a9d3fbfea1a6516478d81d11
2018-06-25 13:14:49 -04:00
MarcoFalke b877c39477
Merge #13528: qt: Move BitcoinGUI initializers to class, fix initializer order warning
bb3de15ad8 qt: Move BitcoinGUI initializers to class, fix initializer order warning (Wladimir J. van der Laan)

Pull request description:

  - C++11-ize the code (move initializers to class, change `0` to `nullptr` where appropriate)
  - Make sure `m_wallet_selector` is initialized
  - And fix the following warning:

      bitcoin/src/qt/bitcoingui.cpp:122:5: warning: field 'spinnerFrame' will be initialized after field 'm_wallet_selector_label' [-Wreorder]
          spinnerFrame(0),

Tree-SHA512: b81c8d4ac31b712c8dfaf941ba43b235eb466eb5528535d69d68c26d8706d2a658581513a413050e5dee08b72a4e7fc08bd8936ef5beb052059d2467eaeff84b
2018-06-25 13:12:53 -04:00
Wladimir J. van der Laan bb3de15ad8 qt: Move BitcoinGUI initializers to class, fix initializer order warning
- C++11-ize the code (move initializers to class, change 0 to `nullptr` where appropriate)
- Make sure `m_wallet_selector` is initialized
- And fix the following warning:

    bitcoin/src/qt/bitcoingui.cpp:122:5⚠️ field 'spinnerFrame' will be initialized after field 'm_wallet_selector_label' [-Wreorder]
        spinnerFrame(0),
2018-06-25 16:57:41 +02:00
MarcoFalke faa2cf685a
[qt] coincontrol: Remove unused qt4 workaround 2018-06-25 09:32:01 -04:00
Ben Woosley 1fabd59e7e
Break circular dependency: init -> * -> init by extracting shutdown.h
Most includers just wanted to react to pending shutdown.

This isolates access to `fRequestShutdown` and limits access to the shutdown
api functions, including the new `AbortShutdown` for setting it to `false`.

Note I originally called `AbortShutdown` `CancelShutdown` but that name was
already taken by winuser.h
https://travis-ci.org/bitcoin/bitcoin/jobs/386913329

This change also triggered a build error in bench. Fixing it required moving LIBBITCOIN_SERVER after LIBBITCOIN_WALLET in bench_bench_bitcoin_LDADD To make
server definitions in src/net.cpp available to wallet methods in
src/wallet/wallet.cpp. Specifically, solving:

  libbitcoin_wallet.a(libbitcoin_wallet_a-wallet.o): In function `CWalletTx::RelayWalletTransaction(CConnman*)':
  wallet.cpp:(.text+0x3f0e): undefined reference to `CConnman::NodeFullyConnected(CNode const*)'
  collect2: error: ld returned 1 exit status

https://travis-ci.org/bitcoin/bitcoin/jobs/392133581

Need for remaining init.h includes confirmed via a thorough search with a more
specific regex:
  \bInterrupt\(\)|\bShutdown\(\)|\bInitLogging\(\)|\bInitParameterInteraction\(\)|\bAppInitBasicSetup\(\)|\bAppInitParameterInteraction\(\)|\bAppInitSanityChecks\(\)|\bAppInitLockDataDirectory\(\)|\bAppInitMain\(\)|\bSetupServerArgs\(\)|\bLicenseInfo\(\)|g_wallet_init_interface|init.h
2018-06-25 00:08:49 -04:00
Ben Woosley e62fdfeeab
Drop unused init.h includes
These were entirely unused, as based on successful compilation
and a grep for:
  \bStartShutdown\(\)|\bShutdownRequested\(\)|\bInterrupt\(\)|\bShutdown\(\)|\bInitLogging\(\)|\bInitParameterInteraction\(\)|\bAppInitBasicSetup\(\)|\bAppInitParameterInteraction\(\)|\bAppInitSanityChecks\(\)|\bAppInitLockDataDirectory\(\)|\bAppInitMain\(\)|\bSetupServerArgs\(\)|\bLicenseInfo\(\)|g_wallet_init_interface|init.h
2018-06-25 00:08:00 -04:00
wodry 9f8c54b1b5 Log warning message when deprecated network name 'tor' is used (e.g. option onlynet=tor) 2018-06-24 22:09:01 +02:00
MarcoFalke faca0a8625
doc: Clarify that mempool txiter is const_iterator 2018-06-24 15:49:09 -04:00
Pieter Wuille 268400d318 [Refactor] CPU feature detection logic for SHA256 2018-06-24 10:51:07 -07:00
Wladimir J. van der Laan cec84c2f1a bench: Add missing pow.h header
Fix a build error introduced in #13219.

```
.../bitcoin/src/bench/block_assemble.cpp:42:13:error: use of undeclared identifier 'CheckProofOfWork'
    while (!CheckProofOfWork(block->GetHash(), block->nBits, Params().GetConsensus())) {
```
2018-06-24 19:25:03 +02:00
Wladimir J. van der Laan 868cf431be
Merge #13160: wallet: Unlock spent outputs
fd9b3a7182 test: Output should be unlocked when spent (João Barbosa)
54c3bb4cf8 wallet: Unlock spent outputs (João Barbosa)

Pull request description:

  Fixes #12738.

Tree-SHA512: 2c1694727aea0c658d07566c7d11d7afe91218053f84d568fac97413348fa5a977243d6cdeebd1c6550816489e35cb3a31667c8354d9b350de99f979d641d605
2018-06-24 18:52:30 +02:00
Wladimir J. van der Laan 08516e0e65
Merge #13219: bench: Add block assemble benchmark
fa0fc1bc7e bench: Add block assemble benchmark (MarcoFalke)

Pull request description:

Tree-SHA512: 614da28020b76154f4cb17752df226466d2d7da7a81f31812e10ca5b94987c7f5abab62b2f45a3a958663bd8cbf2191f3f23e497215196ad7a775f0ea8fb6116
2018-06-24 18:49:23 +02:00
Wladimir J. van der Laan 66e1a08d6f
Merge #13486: build: Move rpc/util.cpp from libbitcoin-util to libbitcoin-server
471a4992d4 Move rpc/util.cpp from libbitcoin-util to libbitcoin-server (Chun Kuan Lee)

Pull request description:

  The functions in `rpc/util.cpp` would call functions in `script/standard.cpp` which in libbitcoin-common. This could cause problem if the linker does not strip out unused function while linking `bitcoin-cli`.

Tree-SHA512: 2f8335c880eeb00a29a359d5398a93d9f2909094b8febf2ad0a1e01388d077634fb5e72a638671bae8de89e1936c234d3f47ff445f1e456de723389bdc22d089
2018-06-24 16:54:24 +02:00
Wladimir J. van der Laan 31145a3d7c
Merge #13480: Avoid copies in range-for loops and add a warning to detect them
d92204c900 build: add warning to detect hidden copies in range-for loops (Cory Fields)
466e16e0e8 cleanup: avoid hidden copies in range-for loops (Cory Fields)

Pull request description:

  Following-up on #13241, which was itself a follow-up of #12169.

  See title. Fixing these would otherwise be a continuous process, adding the warning should keep them from cropping up.

  Note that the warning seems to be Clang-only for now.

Tree-SHA512: ccfb769c3128b3f92c95715abcf21ee2496fe2aa384f80efead1529a28eeb56b98995b531b49a089f8142601389e63f7bb935963d724eacde4f5e1b4a024934b
2018-06-24 16:36:40 +02:00
Wladimir J. van der Laan dc53f7f251
Merge #13458: gui: Drop qt4 support
af6ac3b677 doc: Remove mention of Qt4 from build docs (Wladimir J. van der Laan)
462c71f71b test: Update travis to not test Qt4 anymore (Wladimir J. van der Laan)
907f73bbc5 gui: Remove QT_VERSION fallbacks for Qt < 5 (Wladimir J. van der Laan)
bad068ad9f build: Build system changes to support only Qt5 (Wladimir J. van der Laan)

Pull request description:

  Implements #8263.

  Qt4.x has been EOL since 2015, and at least Gentoo has, or is going to drop support for it. I wouldn't be surprised if other Linux distributions follow.

  This removes Qt4 detection from the build system, as well as removes all Qt4 fallbacks from the code. Turns out there's more than I expected: this is going to make maintenance of the GUI code, as well as adding new features significantly easier.

  (I know there's still some references left to qt4 in RPM and Debian build script, but I don't have the knowledge how to fix them)

Tree-SHA512: d495924fd4dda6f6566ba44ee96be7cbe62e69ba1ca993b80a8449f78da852b7f1bd3e8200d57cfa1d72233c340eeff4596fb0032ecbddc715d99aea63817d3f
2018-06-24 16:02:37 +02:00
Wladimir J. van der Laan 5eca4e86d4
Merge #13471: For AVX2 code, also check for AVX, XSAVE, and OS support
32d153fa36 For AVX2 code, also check for AVX, XSAVE, and OS support (Pieter Wuille)

Pull request description:

  Fixes #12903.

Tree-SHA512: 01e71efb5d3a43c49a145a5b1dc4fe7d0a491e1e78479e7df830a2aaac57c3dcfc316e28984c695206c76f93b68e4350fc037ca36756ca579b7070e39c835da2
2018-06-24 15:31:33 +02:00
MarcoFalke faa24441ec
policy: Remove promiscuousmempoolflags 2018-06-23 17:02:52 -04:00
lmanners 793290f940 Net: Fixed a race condition when disabling the network.
This change addresses a race condition where setnetworkactive=false wouldn't always disconnect all peers.

Before this change, the following could happen:
1. Thread A -- Begins connecting to a node.
2. Thread B -- Sets kNetworkActive=false and disconnects connected nodes.
3. Thread A -- Finishes connecting and adds node to list of connected nodes.

The node that was connected from Thread A remains connected and active,
even though kNetworkActive=false.

To fix the race, disconnections when kNetworkActive=false are now handled in the main network loop.

fixes #13038
2018-06-21 19:24:48 +02:00
Jonas Schnelli 000abbb6b0
Merge #13111: Add unloadwallet RPC
fe65bdec2 bugfix: Delete walletView in WalletFrame::removeWallet (João Barbosa)
0b82bac76 bugfix: Remove dangling wallet env instance (João Barbosa)
0ee77b207 ui: Support wallets unloaded dynamically (João Barbosa)
9f9b50d5f doc: Add release notes for unloadwallet RPC (João Barbosa)
ccbf7ae74 test: Wallet methods are disabled when no wallet is loaded (João Barbosa)
4940a20a4 test: Add functional tests for unloadwallet RPC (João Barbosa)
6608c369b rpc: Add unloadwallet RPC (João Barbosa)
537efe19e rpc: Extract GetWalletNameFromJSONRPCRequest from GetWalletForJSONRPCRequest (João Barbosa)

Pull request description:

  This patch adds wallet unload feature via RPC. It also adds UI support for unloaded wallets.

Tree-SHA512: 7c7f9f32f7a2266d2df574aa6b95f993c3dc82736f93304562122beb8756fb28cd22d03866b48f493c747441f22d30e196b098dec435cc25e035633f090351ea
2018-06-21 16:24:31 +02:00
practicalswift 629a47a154 Document FreeBSD quirk. Fix FreeBSD build. 2018-06-21 09:27:24 +02:00
Jesse Cohen 6690a28606
Restrict as much as possible in net_processing to translation unit
Mark everything else static or in an anonymous namespace.
2018-06-20 17:27:59 -04:00
João Barbosa fe65bdec23 bugfix: Delete walletView in WalletFrame::removeWallet 2018-06-20 14:15:12 +01:00
Kristaps Kaupe 3f72d04e29 Fix parameter count check for importpubkey. 2018-06-20 00:34:38 +03:00
Jonas Schnelli 3a03d2a33f
Qt: load wallet in UI after possible init aborts 2018-06-19 21:33:13 +02:00
Jesse Cohen 1d4df02b7e [move-only] Move things only referenced in net_processing out of header file 2018-06-19 13:02:27 -04:00
Jesse Cohen 02bbc05310 Rescope g_enable_bip61 to net_processing 2018-06-19 13:02:26 -04:00
Jonas Schnelli 3f398d7a17
Merge #13439: rpc: Avoid "duplicate" return value for invalid submitblock
f74894480 Only set fNewBlock to true in AcceptBlock when we write to disk (Matt Corallo)
fa6e49731 rpc: Avoid "duplicate" return value for invalid submitblock (MarcoFalke)

Pull request description:

  This is #13395 with one more commit tacked on. MarcoFalke got tired of dealing with the stupidity of fixing a return code with too many rounds of review (not that I blame him). Honestly we should probably have no return whatsoever, but for now, this fixes it (as well as nLastBlockTime for eviction purposes).

  Original description:

  When `submitblock` of an invalid block, the return value should not be `"duplicate"`.

  This is only seen when the header was previously found (denoted by the incorrectly named boolean `fBlockPresent`). Fix this bug by removing `fBlockPresent`.

Tree-SHA512: 0ce3092655d5d904b4c8c5ff7479f73ce387144a738f20472b8af132564005c6db5594ae366e589508f6258506ee7a28b1c7995a83a8328b334f99316006bf2d
2018-06-19 09:25:17 +02:00
Andrew Chow cd3f4aa808 Decouple wallet version from client version
Instead of comparing version numbers in the wallet to the client
version number, compare them to the latest supported wallet version
in the client. This allows for wallet version numbers to be unrelated
to the client version number.
2018-06-18 15:21:32 -07:00
Pieter Wuille 32d153fa36 For AVX2 code, also check for AVX, XSAVE, and OS support 2018-06-18 14:55:54 -07:00
John Newbery df10f07db1 [wallet] Don't use accounts when checking balance in sendmany 2018-06-18 12:33:16 -04:00
John Newbery e209184101 [wallet] deprecate sendfrom RPC method. 2018-06-18 12:33:15 -04:00
MarcoFalke fa324a8b15
doc: Rewrite some validation doc as lock annotations 2018-06-18 11:43:29 -04:00
João Barbosa 0b82bac76d bugfix: Remove dangling wallet env instance 2018-06-18 16:35:39 +01:00
João Barbosa 0ee77b2077 ui: Support wallets unloaded dynamically 2018-06-18 16:35:29 +01:00
João Barbosa ccbf7ae749 test: Wallet methods are disabled when no wallet is loaded 2018-06-18 16:35:17 +01:00
João Barbosa 6608c369b1 rpc: Add unloadwallet RPC 2018-06-18 16:35:17 +01:00
Wladimir J. van der Laan 0882406854
Merge #13437: wallet: Erase wtxOrderd wtx pointer on removeprunedfunds
faa18ca046 wallet: Erase wtxOrderd wtx pointer on removeprunedfunds (MarcoFalke)

Pull request description:

  This prevents segfaults, when reading from the freed memory.

Tree-SHA512: 04f8190dea7901cf1cc298d5db98c83b02858f27114c5ef4da738accd176d6647d6b81f3dc39f3d5912b1a981cf0599370fd391c4154ffbde97afc1fac389123
2018-06-18 17:34:20 +02:00
Wladimir J. van der Laan ac3224c8ee
Merge #13412: Make ReceivedBlockTransactions return void
fafa270328 Make ReceivedBlockTransactions return void (MarcoFalke)

Pull request description:

  Instead of always returning `bool{true}` and forcing the caller to handle the return code, make it void and remove "a bunch" of dead code at the call sites.

Tree-SHA512: 10e41461c0516c0441d8b8eedcf6385874355c224b9e9d65e89addb142b4cf3e3be2d4ca0a7f2bd95c76aecdaa8537b6bd2d25631bf804bc42863ad5e84fa271
2018-06-18 17:18:55 +02:00
Wladimir J. van der Laan 450055bdbd
Merge #13438: Improve coverage of SHA256 SelfTest code
1e1eb6367f Improve coverage of SHA256 SelfTest code (Pieter Wuille)

Pull request description:

  The existing SelfTest code does not cover the specialized double-SHA256-for-64-byte-inputs transforms added in #13191. Fix this.

Tree-SHA512: 593c7ee5dc9e77fc4c89e0a7753a63529b0d3d32ddbc015ae3895b52be77bee8a80bf16b754b30a22c01625a68db83fb77fa945a543143542bebb5b0f017ec5b
2018-06-18 15:34:37 +02:00
Wladimir J. van der Laan 2d071f5a70
Merge #13443: Removed unused == operator from CMutableTransaction.
55771b7c6a Removed unused == operator from CMutableTransaction. (lucash.dev@gmail.com)

Pull request description:

  This removes the unused == operator from `CMutableTransaction`.

  The motivation is that unused code has a cost but offers no benefit (in general), while also adding the risk of introducing silent bugs. On top of that this particular code is quite inefficient, unnecessarily calculating the hash (it could, say, compare serializations). So if anyone ever needs to use a == comparison on `CMutableTransaction`, they'd be better of having to reimplement it (and add tests) than relying on code that's not being maintained.

  Note: after this, trying to use the == operator on CMutableTransactions results in a compilation error:
  ```
  ./primitives/transaction.h:405:15: error: invalid operands to binary expression ('CMutableTransaction' and
        'CMutableTransaction')
  ```

Tree-SHA512: a565af563e09d99347b6fe419f6d48c750b1377295af293a3e0c3c0d815e58aede8d7058987a68d66cfa7ed023e5d3285b12afabd17d0ff9cf11322ba3ce20fe
2018-06-18 15:31:16 +02:00
Wladimir J. van der Laan 45c00f8416
Merge #13454: Make sure LC_ALL=C is set in all shell scripts
47776a958b Add linter: Make sure all shell scripts opt out of locale dependence using "export LC_ALL=C" (practicalswift)
3352da8da1 Add "export LC_ALL=C" to all shell scripts (practicalswift)

Pull request description:

  ~~Make sure `LC_ALL=C` is set when using `grep` range expressions.~~

  Make sure `LC_ALL=C` is set in all shell scripts.

  From the `grep(1)` documentation:

  > Within a bracket expression, a range expression consists of two characters separated by a hyphen. It matches any single character that sorts between the two characters, inclusive, using the locale's collating sequence and character set. For example, in the default C locale, `[a-d]` is equivalent to `[abcd]`. Many  locales sort characters in dictionary order, and in these locales `[a-d]` is typically not equivalent to `[abcd]`; it might be equivalent to `[aBbCcDd]`, for example. To obtain the traditional interpretation of bracket expressions, you can use the C locale by setting the `LC_ALL` environment variable to the value C.

  Context: [Locale issue found when reviewing #13450](https://github.com/bitcoin/bitcoin/pull/13450/files#r194877736)

Tree-SHA512: fd74d2612998f9b49ef9be24410e505d8c842716f84d085157fc7f9799d40e8a7b4969de783afcf99b7fae4f91bbb4559651f7dd6578a6a081a50bdea29f0909
2018-06-18 13:18:12 +02:00
Wladimir J. van der Laan af6ac3b677 doc: Remove mention of Qt4 from build docs 2018-06-18 12:22:14 +02:00
Wladimir J. van der Laan 907f73bbc5 gui: Remove QT_VERSION fallbacks for Qt < 5
There were surprisingly many `#ifdef` fallbacks for Qt 4.

Remiving them simplifies maintenance, as well as adding new GUI
functionality.
2018-06-18 12:22:11 +02:00
Chun Kuan Lee 471a4992d4 Move rpc/util.cpp from libbitcoin-util to libbitcoin-server 2018-06-18 02:55:47 +00:00
Pieter Wuille bb582a59c7 Add P2WSH destination helper and use it instead of manual hashing 2018-06-17 19:44:50 -07:00
Pieter Wuille eaba1c111e Add additional unit tests for invalid IsMine combinations 2018-06-17 17:39:42 -07:00
Pieter Wuille e6b9730c49 Do not expose invalidity from IsMine 2018-06-17 16:28:04 -07:00
Cory Fields 466e16e0e8 cleanup: avoid hidden copies in range-for loops 2018-06-15 13:40:00 -04:00
MarcoFalke be27048a18
Merge #13241: scripted-diff: Avoid temporary copies when looping over std::map
9b72c988a0 scripted-diff: Avoid temporary copies when looping over std::map (Ben Woosley)

Pull request description:

  The ::value_type of the std::map/std::multimap/std::unordered_map containers is
  std::pair<const Key, T>. Dropping the const results in an unnecessary copy,
  for example in C++11 range-based loops.

  For this I started with a more general scripted diff, then narrowed it down
  based on the inspection showing that all actual map/multimap/unordered_map
  variables used in loops start with m or have map in the name.

Tree-SHA512: b656d66b69ffa1eb954124aa8ae2bc5436ca50262abefa93bdda55cfcdaffc5ff90cd40539051a2bd06355ba69ddf245265cc8764eebff66d761b3aec06155a9
2018-06-15 12:32:39 -04:00
MarcoFalke 43fa3554b7
Merge #13402: Document validationinterace callback blocking deadlock potential.
25bc9615b7 Document validationinterace callback blocking deadlock potential. (Matt Corallo)

Pull request description:

  From the branches-I've-had-lying-around-and-forgot-to-PR department...

  This is a comment-only PR, but the comments point out an API quirk that isn't exactly trivial. None of our use-cases right now hit this, but if we were to call SyncWithValidationInterfaceQueue (eg to limit queue depth) in ATMP, I'm pretty sure we'd hit a deadlock there.

Tree-SHA512: 889dd8fc9eb15d1f2aa5ca467e783bc8f07bc543b166b032741795b0db7a0df11a2846d3cb7c69bafa8d1acf970021001b742f52be06725a932813230c5b4a7b
2018-06-15 09:58:26 -04:00
Karl-Johan Alm f618ebc4e4
validation: count blocks correctly for check level < 3 2018-06-15 13:27:18 +09:00
MarcoFalke 2b770080a4
Merge #13422: Drop ParseHashUV in favor of calling ParseHashStr
abd2678ac1 Drop ParseHashUV in favor of calling ParseHashStr (Ben Woosley)

Pull request description:

  The one existing call already validates `get_str` will pass via `checkObject`:
  https://github.com/bitcoin/bitcoin/pull/13422/files#diff-8fe4d6985ee4acf8bfc1ed8db1e83cb5L586

  Split from #13420

Tree-SHA512: 35dfa8c28d0c3ceac7a6de7f4eb4a44d912f4c31f5d21c9438f899566ca2b34851f1a58c3417355e55d0c33abb97385f4a47e034bfc8e3cdbbf5f73813ca0582
2018-06-14 21:34:41 -04:00
Wladimir J. van der Laan cc7cbd756a
Merge #13451: rpc: expose CBlockIndex::nTx in getblock(header)
86edf4a2a5 expose CBlockIndex::nTx in getblock(header) (Gregory Sanders)

Pull request description:

  Recent publication of a weakness in Bitcoin's merkle tree construction demonstrates many SPV applications vulnerable to an expensive to pull off yet still plausible attack: https://bitslog.wordpress.com/2018/06/09/leaf-node-weakness-in-bitcoin-merkle-tree-design/

  Including the coinbase in the txoutproof seems the most effective fix, however results in a significant efficiency downgrade. Transactors will not even know a priori what the size of their proof will be within a couple orders of magnitude, unless they use the mid-state of SHA2 as detailed in the blog post.

  Some applications, like Elements blockchain platform that take SPV-style proofs have optional access to a bitcoind to verify these proofs of inclusion and check depth in the chain. Returning `CBlockIndex::nTx` would allow an extremely easy and compact way of checking the depth of the tree, with no additional overhead to the codebase, and works with pruned nodes.

  `getblockheader` is arguably not the place for it, but as mentioned before, is a natural workflow for us checking depth of a block in a possibly pruned node.

  We should also ensure that `verifytxoutproof` ends up validating this depth fact as well, but left this for another PR.

Tree-SHA512: af4cf48e704c6088f8da06a477fda1aaa6f8770cee9b876c4465d1075966d6a95831a88817673fe5a0d6bbcdc1ffcbc1892e2be0d838c60fc6958d33eacdcc14
2018-06-14 19:40:02 +02:00
Gregory Sanders 3c292cc190 ScanforWalletTransactions should mark input txns as dirty 2018-06-14 09:57:34 -04:00
Gregory Sanders ed82f17000 have verifytxoutproof check the number of txns in proof structure 2018-06-14 09:54:41 -04:00
practicalswift 3352da8da1 Add "export LC_ALL=C" to all shell scripts 2018-06-14 15:27:52 +02:00
MarcoFalke 4a7e64fc85
Merge #13441: Prevent shared conf files from failing with different available options in different binaries
c2dfbb4a97 Add unavailable options to hidden options category (Andrew Chow)

Pull request description:

  From IRC:

  ```
  <ossifrage> FYI, bitcoin-qt from the head I built today won't start if you have "daemon=0" in the config file, so you can't use the same config for either bitcoind or bitcoin-qt
  <ossifrage> Seems like bitcoin-qt should ignore this option?
  <provoostenator> ossifrage: probably caused by 13112. Another problem is disablewallet=1 will prevent a launch if you compile bitcoind without wallet. It probably needs to be relaxed slightly.
  ```

  Adds all of the options that are unavailable due to compiling options to the hidden category so that shared config files do not break with the alternative binaries.

Tree-SHA512: 1ef43f5f7ad46ecc2865d22ee683ef22831e8f131ec99b732bb36d90381f7964bf64829595e993c2d435823fe4425a20323c8e65307cf2463a9e40b8049ab559
2018-06-13 13:49:18 -04:00
Wladimir J. van der Laan b2221381e7
Merge #13457: tests: Drop variadic macro
faf52f953b tests: Drop variadic macro (MarcoFalke)

Pull request description:

  The C++11 constructor of `std::vector` that takes an initializer list, is not `explicit`. Thus, the macro is not required and can be dropped.

  Hopefully fixes #13456

Tree-SHA512: 4095ed205f88138a7cd5b14790cc426899966f622a924a9b3f7de646a0d801a48ffb8921da760f1f93d5481298477c8a64dbec291381bb9aa77b075bdd2659f2
2018-06-13 19:25:42 +02:00
Gregory Sanders 86edf4a2a5 expose CBlockIndex::nTx in getblock(header) 2018-06-13 10:20:50 -04:00
MarcoFalke faf52f953b
tests: Drop variadic macro 2018-06-13 09:58:54 -04:00
Wladimir J. van der Laan caabdea627
Merge #13428: validation: check the specified number of blocks (off-by-one)
f6f8026e40 validation: check the specified number of blocks (off-by-one) (Karl-Johan Alm)

Pull request description:

  ```
  echeveria | 2018-06-11 02:03:03.384975 Verifying last 3 blocks at level 3
  echeveria | 2018-06-11 02:03:23.676793 No coin database inconsistencies in last 4 blocks (6564 transactions)
  echeveria | off by one?
  sipa      | echeveria: possibly!
  kallewoof | Looks like it checks one more block than suggested. `if (pindex->nHeight < chainActive.Height()-nCheckDepth) break;` should probably be `<=`.
  sipa      | kallewoof: agree
  ```

  Post-commit:
  ```
  2018-06-11T05:24:02Z Verifying last 6 blocks at level 3
  2018-06-11T05:24:02Z [0%]...[16%]...[33%]...[50%]...[66%]...[83%]...[99%]...[DONE].
  2018-06-11T05:25:07Z No coin database inconsistencies in last 6 blocks (7258 transactions)
  ```

  Pre-commit:
  ```
  2018-06-11T05:27:11Z Verifying last 6 blocks at level 3
  2018-06-11T05:27:11Z [0%]...[16%]...[33%]...[50%]...[66%]...[83%]...[99%]...[DONE].
  2018-06-11T05:27:12Z No coin database inconsistencies in last 7 blocks (9832 transactions)
  ```

Tree-SHA512: 6e68dc4ba74232518c2ba8ea624d65893534f3619d43ccdf0b9c65992f25b68cb52cf54fa35e6e3d092d1eee5c9a8887057828895f1acdafc0ebb48f683fffdc
2018-06-13 15:42:32 +02:00
Andrew Chow c2dfbb4a97 Add unavailable options to hidden options category
Options that are not available (but known in the source code) will
cause an error if they are specified.
Make these options "available" by adding them to the hidden options
category to prevent conf files from failing when shared between binaries
that have different options available.
2018-06-12 14:33:35 -07:00
practicalswift 9fdf05d70c tests: Fix lock-order-inversion (potential deadlock) in DoS_tests. Reported by TSAN.
Makes `src/test/test_bitcoin --run_test=DoS_tests` pass also when
compiled with TreadSanitizer (`./configure --with-sanitizers=thread`).
2018-06-12 21:45:46 +02:00
Pieter Wuille 1e1eb6367f Improve coverage of SHA256 SelfTest code 2018-06-12 12:10:13 -07:00
Wladimir J. van der Laan a607d23ae8
Merge #13393: Enable double-SHA256-for-64-byte code on 32-bit x86
57ba401abc Enable double-SHA256-for-64-byte code on 32-bit x86 (Pieter Wuille)

Pull request description:

  The SSE4 and AVX2 double-SHA256-for-64-byte input code from #13191 compiles fine on 32-bit x86 systems, but the autodetection logic in sha256.cpp doesn't enable it. Fix this.

  Note that these instruction sets are only available on CPUs that support 64-bit mode as well, so it is only beneficial in the (perhaps unlikely) scenario where a 64-bit CPU is running a 32-bit Bitcoin Core binary.

Tree-SHA512: 39d5963c1ba8c33932549d5fe98bd184932689a40aeba95043eca31dd6824f566197c546b60905555eccaf407408a5f0f200247bb0907450d309b0a70b245102
2018-06-12 18:52:26 +02:00
Wladimir J. van der Laan ca2a23387b
Merge #13120: policy: Treat segwit as always active
fa7a6cf1b3 policy: Treat segwit as always active (MarcoFalke)

Pull request description:

  Now that segwit is active for a long time, there is no need to reject transactions with the reason that segwit hasn't activated.

  Strictly speaking, this is a bug fix, because with the release of 0.16, we create segwit transactions in our wallet by default without checking if they are allowed by local policy.

  More broadly, this simplifies the code as if "premature witness" was always set to true with the corresponding command line args.

Tree-SHA512: 484c26aa3a66faba6b41e8554a91a29bfc15fbf6caae3d5363a3966283143189c4bd5333a610b0669c1238f75620691264e73f6b9f1161cdacf7574d946436da
2018-06-12 17:20:34 +02:00
João Barbosa 537efe19e6 rpc: Extract GetWalletNameFromJSONRPCRequest from GetWalletForJSONRPCRequest 2018-06-12 16:11:28 +01:00
MarcoFalke b22115d9a3
Merge #13312: docs: Add a note about the source code filename naming convention
e56771365b Do not use uppercase characters in source code filenames (practicalswift)
419a1983ca docs: Add a note about the source code filename naming convention (practicalswift)

Pull request description:

  Add a note about the source code filename naming convention.

Tree-SHA512: 8d329bd9e19bcd26e74b0862fb0bc2369b46095dbd3e69d34859908632763abd7c3d00ccc44ee059772ad4bae4460c2bcc1c0e22fd9d8876d57e5fcd346cea4b
2018-06-12 08:02:20 -04:00
Karl-Johan Alm 98b1813230
[build] Tune wildcards for LIBSECP256K1 target
Automake would think the target was out of date every time because e.g. '.deps' was updated.
2018-06-12 16:05:20 +09:00
Matt Corallo f74894480d Only set fNewBlock to true in AcceptBlock when we write to disk
The only affect this should have is fixing the return code in
submitblock in cases where a block fails ContextualCheckBlock and
not setting nLastBlockTime on peers that provide blocks which fail
ContextualCheckBlock (which is only used in eviction and cosmetic).
2018-06-11 17:21:13 -04:00
Ben Woosley 9b72c988a0
scripted-diff: Avoid temporary copies when looping over std::map
The ::value_type of the std::map/std::multimap/std::unordered_map containers is
std::pair<const Key, T>. Dropping the const results in an unnecessary copy,
for example in C++11 range-based loops.

For this I started with a more general scripted diff, then narrowed it down
based on the inspection showing that all actual map/multimap/unordered_map
variables used in loops start with m or have map in the name.

-BEGIN VERIFY SCRIPT-
sed -i -E 's/for \(([^<]*)std::pair<([^c])(.+) : m/for (\1std::pair<const \2\3 : m/' src/*.cpp src/**/*.cpp
sed -i -E 's/for \(([^<]*)std::pair<([^c])(.+) : (.*)map/for (\1std::pair<const \2\3 : \4map/' src/*.cpp src/**/*.cpp
-END VERIFY SCRIPT-
2018-06-11 13:12:55 -07:00
MarcoFalke fa6e49731b
rpc: Avoid "duplicate" return value for invalid submitblock 2018-06-11 15:08:50 -04:00
Wladimir J. van der Laan 7c32b414b6
Merge #13230: Simplify include analysis by enforcing the developer guide's include syntax
16e3cd380a Clarify include recommendation (practicalswift)
6d10f43738 Enforce the use of bracket syntax includes ("#include <foo.h>") (practicalswift)
906bee8e5f Use bracket syntax includes ("#include <foo.h>") (practicalswift)

Pull request description:

  When analysing includes in the project it is often assumed that the preferred bracket include syntax (`#include <foo.h>`) mentioned in `developer-docs.md` is used consistently. @sipa:s excellent circular dependencies script [`circular-dependencies.py`](50c69b7801/contrib/devtools/circular-dependencies.py) (#13228) is an example of a script making this reasonable assumption.

  This PR enables automatic Travis checking of the include syntax making sure that the bracket syntax includes (`#include <foo.h>`) is used consistently.

Tree-SHA512: a414921aabe8e487ebed42f3f1cbd02fecd1add385065c1f2244cd602c31889e61fea5a801507ec501ef9bd309b05d3c999f915cec1c2b44f085bb0d2835c182
2018-06-11 20:24:58 +02:00
MarcoFalke faa18ca046
wallet: Erase wtxOrderd wtx pointer on removeprunedfunds 2018-06-11 14:06:59 -04:00
Wladimir J. van der Laan 43ae5ee9e4
Merge #12634: [refactor] Make TransactionWithinChainLimit more flexible
f77e1d34fd test: Add MempoolAncestryTests (Karl-Johan Alm)
a08d76bcfe mempool: Calculate descendant maximum thoroughly (Karl-Johan Alm)
6d3568371e wallet: Switch to using ancestor/descendant limits (Karl-Johan Alm)
6888195b06 wallet: Strictly greater than for ancestor caps (Karl-Johan Alm)
322b12ac4e Remove deprecated TransactionWithinChainLimit (Karl-Johan Alm)
4784751547 Switch to GetTransactionAncestry() in OutputEligibleForSpending (Karl-Johan Alm)
475a385a80 Add GetTransactionAncestry to CTxMemPool for general purpose chain limit checking (Karl-Johan Alm)
46847d69d2 mempool: Fix max descendants check (Karl-Johan Alm)
b9ef21dd72 mempool: Add explicit max_descendants (Karl-Johan Alm)

Pull request description:

  Currently, `TransactionWithinChainLimit` is restricted to single-output use, and needs to be called every time for different limits. If it is replaced with a chain limit value calculator, that can be called once and reused, and is generally more flexible (see e.g. #12257).

  Update: this PR now corrects usage of max ancestors / max descendants, including calculating the correct max descendant value, as advertised for the two limits.

  ~~This change also makes `nMaxAncestors` signed, as the replacement method will return `-1` for "not in the mempool", which is different from "0", which means "no ancestors/descendants in mempool".~~

  ~~This is a subset of #12257.~~

Tree-SHA512: aa59c849360542362b3126c0e29d44d3d58f11898e277d38c034dc4b86a5b4500f77ac61767599ce878c876b5c446fec9c02699797eb2fa41e530ec863a00cf9
2018-06-11 16:25:46 +02:00
Wladimir J. van der Laan 3f0f39415b
Merge #13060: [wallet] [rpc] Remove getlabeladdress RPC
67e0e04140 [wallet] [docs] Update release notes for removing `getlabeladdress` (John Newbery)
81608178cf [wallet] [rpc] Remove getlabeladdress RPC (John Newbery)

Pull request description:

  labels are associated with addresses (rather than addresses being
  associated with labels, as was the case with accounts). The
  getlabeladdress does not make sense in this model, so remove it.

  getaccountaddress is still supported for one release as the accounts
  API is deprecated.

Tree-SHA512: 7f45d0456248ebcc4e54dd34e2578a09a8ea8e4fceda75238ccea9d731dc99a3f3c0519b18a9739de17d2e6e59c9c2259ba67c9ae2e3cb2a40ddb14b9193fe29
2018-06-11 15:21:24 +02:00
Wladimir J. van der Laan 26c93edf1d
Merge #13294: Fix compiler warnings emitted when compiling under stock OpenBSD 6.3
a426098572 Fix compiler warnings emitted when compiling under stock OpenBSD 6.3 (practicalswift)

Pull request description:

  Fix compiler warnings emitted when compiling under stock OpenBSD 6.3 (OpenBSD clang version 5.0.1, based on LLVM 5.0.1):

  ```
  random.cpp:182:13: warning: unused function 'GetDevURandom' [-Wunused-function]
  static void GetDevURandom(unsigned char *ent32)
              ^

  txmempool.cpp:707:45: warning: comparison of integers of different signs: 'uint64_t' (aka 'unsigned long long') and 'long long' [-Wsign-compare]
          assert(it->GetSizeWithDescendants() >= childSizes + it->GetTxSize());
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ```

Tree-SHA512: da2ae86218054b10659ea694179433700ac91de8022e06007348168ed5adc3d8c4ad3b32a3fc5783a2cdf1ca7425aff586b839200dd3b226ebff72a7df15f120
2018-06-11 15:06:49 +02:00
Wladimir J. van der Laan 70a03c635b
Merge #13408: crypto: cleanup sha256 build
f68049dd87 crypto: cleanup sha256 build (Cory Fields)

Pull request description:

  Requested by @sipa in #13386.

  Rather than appending all possible cpu variants to all targets, create a convenience variable that encompasses all.

Tree-SHA512: 8e9ab2185515672b79bb7925afa4f3fbfe921bfcbe61456833d15457de4feba95290de17514344ce42ee81cc38b252476cd0c29432ac48c737c2225ed515a4bd
2018-06-11 14:44:37 +02:00
Wladimir J. van der Laan 6e249e4678
Merge #13043: [qt] OptionsDialog: add prune setting
cbede7dbfd [qt] OptionsDialog: add prune setting (Sjors Provoost)

Pull request description:

  The default suggested value is 2 GB. Minimum is 1 GB (550 MB rounded up).

  When the user toggles this setting, a strong warning appears that undoing requires re-downloading the chain:

  <img width="478" alt="schermafbeelding 2018-05-15 om 12 35 24" src="https://user-images.githubusercontent.com/10217/40051858-7939cc20-583c-11e8-9120-327a75376732.png">

  Tooltip points out that actual disk usage can be higher. It's a bit vague on the "advanced features", because I'm assuming anyone who needs to use `-rescan` and `-txindex` will read the documentation, and a more detailed text would needlessly confuse everyone else.

  <img width="450" alt="schermafbeelding 2018-05-15 om 12 33 51" src="https://user-images.githubusercontent.com/10217/40051791-49d6156a-583c-11e8-97b9-7de6dfd8c481.png">

  The UI uses gigabytes for readability and easy of use. There is also no manual pruning UI (`prune=1`). The user will have to use `bitcoin.conf` for those things.

  Fixes #6461. When combined with #13029 the user, after pruning their node, can safely reset settings and/or use bitcoind without having to edit `bitcoin.conf`. However I don't think that's an essential prerequisite.

Tree-SHA512: e17aff276d7235fbd40796adb6431d430620788a753ee13bc064abd35d2edc4280a3d3cddc18e42b4e00edff13ed18fd4f2a966c6f0b43b689afd13673e0c4bf
2018-06-11 14:21:24 +02:00
Karl-Johan Alm f77e1d34fd
test: Add MempoolAncestryTests 2018-06-11 19:09:44 +09:00
Karl-Johan Alm a08d76bcfe
mempool: Calculate descendant maximum thoroughly 2018-06-11 19:09:44 +09:00
Karl-Johan Alm 6d3568371e
wallet: Switch to using ancestor/descendant limits
Instead of combining the -limitancestorcount and -limitdescendantcount into a nMaxChainLength, this commit uses each one separately in the coin eligibility filters.
2018-06-11 19:04:56 +09:00
Karl-Johan Alm 6888195b06
wallet: Strictly greater than for ancestor caps 2018-06-11 19:04:56 +09:00
Karl-Johan Alm 322b12ac4e
Remove deprecated TransactionWithinChainLimit 2018-06-11 19:04:56 +09:00
Karl-Johan Alm 4784751547
Switch to GetTransactionAncestry() in OutputEligibleForSpending 2018-06-11 19:04:55 +09:00
Karl-Johan Alm 475a385a80
Add GetTransactionAncestry to CTxMemPool for general purpose chain limit checking 2018-06-11 19:04:55 +09:00
Karl-Johan Alm 46847d69d2
mempool: Fix max descendants check
The chain limits check for max descendants would check the descendants of the transaction itself even though the description for -limitdescendantcount says 'any ancestor'. This commit corrects the descendant count check by finding the top parent transaction in the mempool and comparing against that.
2018-06-11 19:04:55 +09:00
Karl-Johan Alm b9ef21dd72
mempool: Add explicit max_descendants
TransactionWithinChainLimits would take a 'limit' and check it against ascendants and descendants. This is changed to take an explicit
max ancestors and max descendants value, and to test the corresponding value against its corresponding max.
2018-06-11 19:04:55 +09:00
Karl-Johan Alm f6f8026e40
validation: check the specified number of blocks (off-by-one) 2018-06-11 14:16:51 +09:00