Commit graph

10879 commits

Author SHA1 Message Date
Cory Fields 96dbd381cf net: initialize socket to avoid closing random fd's 2018-02-01 11:31:27 -05:00
Wladimir J. van der Laan 10847fe2d8
qt: Periodic translations update
Pull 0.16 translations before forking, to avoid having to do it twice.

Tree-SHA512: 9c093885f03783e0f64718985c5f9d385d2a8592e2acc87d922ca973d07c756a6b7fff585388094f0e1b673c41e792ce918c1f594b45e82a262acd93e1b91a8e
2018-01-30 13:43:26 +01:00
Wladimir J. van der Laan 3448907a68
Merge #12266: Move scheduler/threadGroup into common-init instead of per-app
082a61c Move scheduler/threadGroup into common-init instead of per-app (Matt Corallo)

Pull request description:

  This resolves #12229 which pointed out a shutdown deadlock due to
  scheduler/checkqueue having been shut down while network message
  processing is still running.

Tree-SHA512: 0c0a76113996b164b0610d3b8c40b396f3e384d165bf098768e31fe3701b00763d0d810ef24702387e2e936fefb9fb900a6225f7417bb0175b585f365d542660
2018-01-30 13:04:30 +01:00
Wladimir J. van der Laan 7936446268
Merge #12276: Remove duplicate mapWallet lookups
039425c [wallet] Remove duplicate mapWallet lookups (João Barbosa)

Pull request description:

Tree-SHA512: 8075925d2adb64737c691e988d74a37bc326711aaee2c37327361679c051f219fa500e14cbcdb6a169352bcdbab160e11df4276b2657e19e12908ee2d4444d30
2018-01-30 10:16:31 +01:00
Wladimir J. van der Laan 288deacdbe
Merge #12278: Add special error for genesis coinbase to getrawtransaction
ee11121 Add special error for genesis coinbase to gettransaction (MeshCollider)

Pull request description:

  Suggested by sipa here: https://botbot.me/freenode/bitcoin-core-dev/2018-01-23/?msg=96069825&page=2

  Just adds a special error message for the genesis block coinbase transaction when using `getrawtransaction`

Tree-SHA512: cd102c7983ec5457b299bff4b6db747d339fda157933a3ac54aec26b1e48b115aa68c1c9e6cb7a916f15c7786273ab558b2b20ab9768544d211e0ae9d1480e34
2018-01-30 09:59:28 +01:00
João Barbosa 5bdbbdc096 Refactor HaveKeys to early return on false result 2018-01-29 23:45:25 +00:00
MeshCollider ee11121229 Add special error for genesis coinbase to gettransaction 2018-01-30 11:36:25 +13:00
MarcoFalke 9d9c4185fa
Merge #12293: [rpc] Mention that HD is enabled if hdmasterkeyid is present
c6b6385651 [rpc] Mention that HD is enabled if hdmasterkeyid is present (fanquake)

Pull request description:

  Also adds optional flag.

  Replaces #12042

Tree-SHA512: 6aded2cf36799f697eacbe4f51dff7c8110281092ca3c4fd73e26f57d788ec95a4fcbaf6976ef144e64f2e52759dbe241ac218a95e5ca2233cae1b98bfa5872e
2018-01-29 15:27:56 -05:00
Wladimir J. van der Laan c0ae864ef5
Merge #11577: Fix warnings (-Wsign-compare) when building with DEBUG_ADDRMAN
6eddd43 Fix warnings when building with DEBUG_ADDRMAN (practicalswift)

Pull request description:

  Fix warnings when building with `DEBUG_ADDRMAN`.

  Warnings prior to this commit:

  ```
  addrman.cpp:390:24: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (vRandom.size() != nTried + nNew)
          ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~
  addrman.cpp:411:52: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare]
          if (info.nRandomPos < 0 || info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
                                     ~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
  addrman.cpp:419:25: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (setTried.size() != nTried)
          ~~~~~~~~~~~~~~~ ^  ~~~~~~
  addrman.cpp:421:23: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
      if (mapNew.size() != nNew)
          ~~~~~~~~~~~~~ ^  ~~~~
  4 warnings generated.
  ```

Tree-SHA512: 0316faecfe95066d2c9a0b6b3960086e43824f21a67086a895ea45fbce1327f8d6df5945fe923c2dbe4efce430bc1384d515d317c3930d97d24965e507cf734d
2018-01-29 14:26:26 +01:00
Wladimir J. van der Laan f3c7062b7b
Merge #12159: Use the character based overload for std::string::find.
a73aab7 Use the character based overload for std::string::find. (Alin Rus)

Pull request description:

  std::string::find has a character based overload as can be seen here
  (4th oveload): http://www.cplusplus.com/reference/string/string/find/

  Use that instead of constantly allocating temporary strings.

Tree-SHA512: dc7684b1551e6d779eb989e9a74363f9b978059a7c0f3db09d01744c7e6452961f9e671173265e71efff27afbcb80c0fe2c11b6dff2290e54a49193fa25a5679
2018-01-29 14:08:09 +01:00
fanquake c6b6385651
[rpc] Mention that HD is enabled if hdmasterkeyid is present 2018-01-29 21:00:27 +08:00
Wladimir J. van der Laan 9220426280
Merge #12108: [Refactor] Remove unused fQuit var from checkqueue.h
30ded3e [Refactor] Remove unused fQuit var from checkqueue.h (donaloconnor)

Pull request description:

  As per PR title, this var is no longer required

  Tested by doing a successful compile.

Tree-SHA512: 845e5e0a250cb99e353e8584e9af2df44d97683174e8caa1069bd192b72ab622063765f29676272aecaef87596d72c63ae628404e2f42555136ec2c26d419f2d
2018-01-29 13:21:50 +01:00
Wladimir J. van der Laan 000ac4fd01
Merge #12197: Log debug build status and warn when running benchmarks
34328b4 Use PACKAGE_NAME instead of hardcoding application name in log message (Wladimir J. van der Laan)
0c74e2e Log debug build status and warn when running benchmarks (Wladimir J. van der Laan)

Pull request description:

  Log whether the starting instance of bitcoin core is a debug or release build (--enable-debug).

  Also warn when running the benchmarks with a debug build, to prevent mistakes comparing debug to non-debug results.

Tree-SHA512: f612dcb7d0a8435016cff0df8aef4942144dfb88be8a00df45cc8830d2aba4b167f6d397b83f8f57d57685888babd04ba88d4dac5a202d3dbd91bcbea3708ef0
2018-01-29 11:12:16 +01:00
João Barbosa 039425cf4f [wallet] Remove duplicate mapWallet lookups 2018-01-28 17:25:16 +00:00
practicalswift 1340eda3b7 Fix typos 2018-01-28 13:21:25 +01:00
Suhas Daftuar 669c9433cf Avoid leaking prioritization information when relaying transactions 2018-01-25 18:02:24 -05:00
Suhas Daftuar e868b22917 fee estimator: avoid sorting mempool on shutdown 2018-01-25 18:02:24 -05:00
Wladimir J. van der Laan a8c344b913 Update chainTxData for 0.16
Another part of the release process.
2018-01-25 19:17:53 +01:00
Wladimir J. van der Laan 2ae7cf8ef5
Merge #12269: Update defaultAssumeValid to block 506067
bde8bcd Update defaultAssumeValid according to release-process.md. (Gregory Maxwell)

Pull request description:

  Update defaultAssumeValid according to release-process.md.
  Updated for block 506067 (0000000000000000005214481d2d96f898e3d5416e43359c145944a909d242e0).

Tree-SHA512: 38e6440a11609e56df816e295ceff697d29830a1d85009f920250320c474f8b04a182635b2f1ab44f54d0cdb8b4e4378336a788400e513d7482514434e53b3ff
2018-01-25 19:05:53 +01:00
Wladimir J. van der Laan 16bac24f60
Merge #12262: net: Hardcoded seed update
1e90544 net: Update hardcoded seeds (Wladimir J. van der Laan)
55f52bd contrib: Update ATTERN_AGENT to include 0.15.x (Wladimir J. van der Laan)

Pull request description:

  Update the hardcoded node addresses, after changing the pattern to include 0.15.x.

Tree-SHA512: 58b997393d77dcee3dcaffba0c6f185ca46c24d766b33d3a8c9d9efe5dd2e01f086b894a23e185120eee5054697e409b64736e53ca8e42b2315f82355c5f5d5c
2018-01-25 19:05:23 +01:00
Matt Corallo 082a61c69d Move scheduler/threadGroup into common-init instead of per-app
This resolves #12229 which pointed out a shutdown deadlock due to
scheduler/checkqueue having been shut down while network message
processing is still running.
2018-01-25 11:35:34 -05:00
Gregory Maxwell bde8bcd8ad Update defaultAssumeValid according to release-process.md.
Updated for block 506067 (0000000000000000005214481d2d96f898e3d5416e43359c145944a909d242e0).
2018-01-25 15:35:30 +00:00
MarcoFalke f359afcc41
Merge #12261: qt: Bump BLOCK_CHAIN_SIZE to 200GB
ba490d2460 qt: Bump BLOCK_CHAIN_SIZE to 200GB (Wladimir J. van der Laan)

Pull request description:

  Part of the release process for 0.16.

  Value is open for discussion, my blocks/ directory is 163GB but this leaves some slack.

Tree-SHA512: 4dff81740992bf9de90427934afeb223ea5216f5682c9f07cb5c47aea33980a4c682fe3fd43c3dfa2c4d66ad0e7434dbce6cb252e56d63b36df605e12af9b10a
2018-01-24 14:40:37 -05:00
Jonas Schnelli 7abb0f0929
Merge #12194: Add change type option to fundrawtransaction
16f6f59dc [qa] Test fundrawtransaction with change_type option (João Barbosa)
536ddeb17 [rpc] Add change_type option to fundrawtransaction (João Barbosa)
31dbd5af4 [wallet] Add change type to CCoinControl (João Barbosa)

Pull request description:

  Adds a new option `change_type` to `fundrawtransaction` RPC. This is useful to override the node `-changetype` argument.

  The new option is exclusive to `changeAddress` option, setting both raises a RPC error.

  See also #11403, #12119.

Tree-SHA512: 654686444f6125e37015a62f167064d54ec335701534988447be4687fa5ef9c7980a8a07cc0a03fff6ea6c4c1abf0f77a8843d535c4f3fe0bf93f968a4e676e6
2018-01-24 09:09:30 -10:00
Jonas Schnelli eadb2dacc3
Merge #12213: Add address type option to addmultisigaddress
f523c6bec [qa] Use address type in addmultisigaddress to avoid addwitnessaddress (João Barbosa)
886a92f25 [rpc] Add address type option to addmultisigaddress (João Barbosa)

Pull request description:

  Adds the option `address_type` to `addmultisigaddress` and `createmultisg` RPC. This also allows to avoid `addwitnessaddress` to obtain an `p2sh-segwit` or `bech32` multsig address.

  Related to #12210 as this reduces `addwitnessaddress` usage.

Tree-SHA512: 8f8f85dfcff66bb6c7e1e9865e37c285dead1d6dadb9672a89b92fa209d03cc35817ca1d656588c6c2146b728daaf7540b851929b640294653c62836cbefe7ee
2018-01-24 09:00:51 -10:00
Wladimir J. van der Laan 1e90544153 net: Update hardcoded seeds
Update the hardcoded node addresses, after bumping the pattern in last
commit.
2018-01-24 17:35:43 +01:00
MarcoFalke fa7ecbf9f8
initwallet: Do not translate highly technical addresstype help 2018-01-24 11:30:44 -05:00
Wladimir J. van der Laan ba490d2460 qt: Bump BLOCK_CHAIN_SIZE to 200GB
Part of the release process for 0.16.

Value is open for discussion, my blocks/ directory is 163GB but this
leaves some slack.
2018-01-24 17:17:55 +01:00
João Barbosa 536ddeb173 [rpc] Add change_type option to fundrawtransaction 2018-01-24 16:00:50 +00:00
João Barbosa 31dbd5af48 [wallet] Add change type to CCoinControl 2018-01-24 15:52:05 +00:00
Wladimir J. van der Laan 6e3fe93609
qt: Update translation source file
Tree-SHA512: d16e6fd179c74203c9ce2dae717fe1d71b501ee6e397f10c6d0ec6fad9bdad256d9f383781d1f375c82d309d76547edf5ec10bdecabc21db4339b68c326e208e
2018-01-24 16:38:11 +01:00
Wladimir J. van der Laan e37ca2be91
Merge #12250: Make CKey::Load references const
04ededf Make CKey::Load references const (Russell Yanofsky)

Pull request description:

  No change in behavior, this just prevents CKey::Load arguments from looking
  like outputs.

Tree-SHA512: 6d93bce109318e88ddd5c21ad626571344707ae0e6d46e898c76fd95a7afd1c32202a6b3dfab47d6a787c84dfcbb35343cdec898bcf8f668574aa224f2eed977
2018-01-24 16:33:33 +01:00
João Barbosa 886a92f25f [rpc] Add address type option to addmultisigaddress 2018-01-24 14:45:07 +00:00
Wladimir J. van der Laan 95941396ff
Merge #12119: [wallet] use P2WPKH change output if any destination is P2WPKH or P2WSH
596c446 [wallet] use P2WPKH change output if any destination is P2WPKH or P2WSH (Sjors Provoost)

Pull request description:

  If `-changetype` is not explicitly set, then regardless of `-addresstype`, the wallet will use a ~`bech32` change address~ `P2WPKH` change output if any destination is `P2WPKH` or `P2WSH`.

  This seems more intuitive to me and more in line with the spirit of [BIP-69](https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki).

  When combined with #11991 a QT user could opt to use `bech32` exclusively without having to figure out how to launch with `-changetype=bech32`, although so would #11937.

Tree-SHA512: 9238d3ccd1f3be8dfdd43444ccf45d6bdc6584ced3172a3045f3ecfec4a7cc8999db0cdb76ae49236492a84e6dbf3a1fdf18544d3eaf6d518e1f8bd241db33e7
2018-01-24 15:22:42 +01:00
Wladimir J. van der Laan 69ec021969
Merge #11415: [RPC] Disallow using addresses in createmultisig
1df206f Disallow using addresses in createmultisig (Andrew Chow)

Pull request description:

  This PR should be the last part of #7965.

  This PR makes createmultisig only accept public keys and marks the old functionality of accepting addresses as deprecated.

  It also splits `_createmultisig_redeemscript` into two functions, `_createmultisig_getpubkeys` and `_createmultisig_getaddr_pubkeys`. `_createmultisig_getpubkeys` retrieves public keys from the RPC parameters and `_createmultisig_getaddr_pubkeys` retrieves addresses' public keys from the wallet. `_createmultisig_getaddr_pubkeys` requires the wallet and is only used by `addwitnessaddress` (except when `createmultisig` is used in deprecated mode).

  `addwitnessaddress`'s API is also changed. Instead of returning just an address, it now returns the same thing as `createmultisig`: a JSON object with two fields, address and redeemscript.

Tree-SHA512: a5796e41935ad5e47d8165ff996a8b20d5112b5fc1a06a6d3c7f5513c13e7628a4fd37ec30fde05d8b15abfed51bc250710140f6834b13f64d0a0e47a3817969
2018-01-24 14:03:40 +01:00
Wladimir J. van der Laan 6e89de5ba7
Merge #11512: Use GetDesireableServiceFlags in seeds, dnsseeds, fixing static seed adding
2b839ab Update chainparams comment for more info on service bits per dnsseed (Matt Corallo)
62e7642 Fall back to oneshot for DNS Seeds which don't support filtering. (Matt Corallo)
51ae766 Use GetDesireableServiceFlags in static seeds, document this. (Matt Corallo)
fb6f6b1 bluematt's testnet-seed now supports x9 (and is just a static list) (Matt Corallo)

Pull request description:

  4440710 broke inserting entries into addrman from dnsseeds which
  did not support service bits, as well as static seeds. Static seeds
  were already being filtered by UA for 0.13.1+ (ie NODE_WITNESS), so
  simply changing the default service bits to include NODE_WITNESS
  (and updating docs appropriately) is sufficient. For DNS Seeds, not
  supporting NODE_WITNESS is no longer useful, so instead use
  non-filtering seeds as oneshot hosts irrespective of named proxy.

  I've set my testnet-seed to also support x9, though because it is simply a static host, it may be useful to leave the support off so that it is used as a oneshot to get addresses from a live node instead. I'm fine with either.

Tree-SHA512: 3f17d4d2b0b84d876981c962d2b44cb0c8f95f52c56a48c6b35fd882f6d7a40805f320ec452985a1c0b34aebddb1922709156c3ceccd1b9f8363fd7cb537d21d
2018-01-24 13:07:05 +01:00
Wladimir J. van der Laan 8470e64724
Merge #11281: Avoid permanent cs_main/cs_wallet lock during RescanFromTime
7f81250 Mention that other RPC calls report keys as "imported" while txns are still missing (Jonas Schnelli)
ccd8ef6 Reduce cs_main lock in ReadBlockFromDisk, only read GetBlockPos under the lock (Jonas Schnelli)
bc356b4 Make sure WalletRescanReserver has successfully reserved the rescan (Jonas Schnelli)
dbf8556 Add RAII wallet rescan reserver (Jonas Schnelli)
8d0b610 Avoid pemanent cs_main/cs_wallet lock during wallet rescans (Jonas Schnelli)

Pull request description:

  Right now, we are holding `cs_main`/`cs_wallet` during the whole rescan process (which can take a couple of hours).
  This was probably only done because of laziness and it is an important show-stopper for #11200 (GUI rescan abort).

Tree-SHA512: 0fc3f82d0ee9b2f013e6bacba8d59f7334306660cd676cd64c47bb305c4cb7c7a36219d6a6f76023b74e5fe87f3ab9fc7fd2439e939f71aef653fddb0a1e23b1
2018-01-24 12:56:23 +01:00
Wladimir J. van der Laan d3a185a33b net: Move misbehaving logging to net logging category
This moves the error messages for misbehavior (when available) into the
line that reports the misbehavior, as well as moves the logging to the
`net` category.

This is a continuation of #11583 and avoids serious-looking errors due
to misbehaving peers.

To do this, Misbehaving() gains an optional `message` argument.

E.g. change:

    2018-01-18 16:02:27 Misbehaving: x.x.x.x:62174 peer=164603 (80 -> 100) BAN THRESHOLD EXCEEDED
    2018-01-18 16:02:27 ERROR: non-continuous headers sequence

to

    2018-01-18 16:02:27 Misbehaving: x.x.x.x:62174 peer=164603 (80 -> 100) BAN THRESHOLD EXCEEDED: non-continuous headers sequence
2018-01-24 12:18:29 +01:00
Jonas Schnelli 7f812502b7
Mention that other RPC calls report keys as "imported" while txns are still missing 2018-01-23 20:24:53 -10:00
Jonas Schnelli ccd8ef65f9
Reduce cs_main lock in ReadBlockFromDisk, only read GetBlockPos under the lock 2018-01-23 20:24:53 -10:00
Jonas Schnelli bc356b4268
Make sure WalletRescanReserver has successfully reserved the rescan 2018-01-23 20:24:18 -10:00
Jonas Schnelli dbf8556b4d
Add RAII wallet rescan reserver 2018-01-23 20:23:57 -10:00
Jonas Schnelli 8d0b610fe8
Avoid pemanent cs_main/cs_wallet lock during wallet rescans 2018-01-23 20:22:33 -10:00
Russell Yanofsky 04ededf001 Make CKey::Load references const
No change in behavior, this just prevents CKey::Load arguments from looking
like outputs.
2018-01-23 13:16:56 -05:00
Sjors Provoost 596c44633f
[wallet] use P2WPKH change output if any destination is P2WPKH or P2WSH
Only if -changetype is not set and -addresstype is not "legacy".
2018-01-23 17:56:15 +01:00
Matt Corallo 2b839abd3e Update chainparams comment for more info on service bits per dnsseed 2018-01-19 12:41:28 -10:00
Matt Corallo 62e764219b Fall back to oneshot for DNS Seeds which don't support filtering.
This allows us to not have to update the chainparams whenever a
DNS Seed changes its filtering support, as well fixes a bug
introduced in 44407100f where returned nodes will never be
attempted.
2018-01-19 12:41:28 -10:00
Matt Corallo 51ae7660b8 Use GetDesireableServiceFlags in static seeds, document this.
44407100f broke inserting entries into addrman from static seeds
(as well as dnsseeds which did not support service bits). Static
seeds were already being filtered by UA for 0.13.1+ (ie
NODE_WITNESS), so simply changing the default service bits to
include NODE_WITNESS (and updating docs appropriately) is
sufficient.

For DNS Seeds, we will later fix by falling back to oneshot if a
seed does not support filtering.
2018-01-19 12:40:05 -10:00
Suhas Daftuar 09754063e0 Correct mempool mapTx comment 2018-01-19 09:58:21 -05:00
Wladimir J. van der Laan 34328b4980 Use PACKAGE_NAME instead of hardcoding application name in log message 2018-01-19 11:15:01 +01:00
Russell Yanofsky ec527c6c88 Don't allow relative -walletdir paths
Also warn if bitcoind is configured to use a relative -datadir path.

Specifying paths relative to the current working directory in a daemon process
can be dangerous, because files can fail to be located even if the
configuration doesn't change, but the daemon is started up differently.

Specifying a relative -datadir now adds a warning to the debug log. It would
not be backwards-compatible to forbid relative -datadir paths entirely, and it
could also be also inconvenient for command line testing.

Specifying a relative -walletdir now results in a startup error. But since the
-walletdir option is new in 0.16.0, there should be no compatibility issues.
Another reason not to use working directory paths for -walletdir specifically
is that the default -walletdir is a "wallets" subdirectory inside the datadir,
so it could be surprising that setting -walletdir manually would choose a
directory rooted in a completely different location.
2018-01-18 15:09:27 -05:00
Jonas Schnelli 10d10d7fad
Merge #12211: Avoid potential null dereference in ReceiveCoinsDialog constructor
cc90a4f46 Avoid potential null dereference in ReceiveCoinsDialog constructor (Russell Yanofsky)

Pull request description:

  Not a bug in practice because current `WalletModel::getDefaultAddressType()` implementation does not dereference its `this` pointer.

  Encountered issue while rebasing #10244 after #11991 was merged.

Tree-SHA512: d76afc410d4a436ec62936196fdac1af89c221d8c0d6e73349024afe55bbf8820f843177a8fe8210aa8021d45a17a0ecd9b6f693381e3edb234d9897cece29d7
2018-01-18 09:46:58 -10:00
Wladimir J. van der Laan 898f560b55
Merge #12206: qa: Sync with validationinterface queue in sync_mempools
fa1e69e qa: Sync with validationinterface queue in sync_mempools (MarcoFalke)

Pull request description:

  Commit e545dedf72 moved `TransactionAddedToMempool` to the background scheduler thread. Thus, adding a transaction to the mempool will no longer add it to the wallet immediately. Functional tests, that `sync_mempools` and then call into wallet rpcs will race against the scheduler thread.

  Fix that race by flushing the scheduler queue.

  Fixes #12205; Fixes #12171;
  References #9584;

Tree-SHA512: 14d99cff9c4756de9fad412f04e6d8e25bb9a0938f24ed8348de79df5b4ee67763dac5214b1a69e77e60787d81ee642976d1482b1b5637edfc4892a238ed22af
2018-01-18 15:05:40 +01:00
Wladimir J. van der Laan cdf3e03a72 wallet: Deprecate addwitnessaddress
Now that segwit is natively supported by the wallet, deprecate the hack `addwitnessaddress`.
2018-01-18 10:24:18 +01:00
MarcoFalke fa1e69e52b qa: Sync with validationinterface queue in sync_mempools 2018-01-17 16:44:32 -05:00
Russell Yanofsky cc90a4f46b Avoid potential null dereference in ReceiveCoinsDialog constructor
Not a bug in practice because current WalletModel::getDefaultAddressType()
implementation does not dereference its `this` pointer.
2018-01-17 13:23:26 -05:00
Wladimir J. van der Laan c7978be899
Merge #12101: Clamp walletpassphrase timeout to 2^30 seconds and check its bounds
134cdc7 Test walletpassphrase timeout bounds and clamping (Andrew Chow)
0b63e3c Clamp walletpassphrase timeout to 2^(30) seconds and check its bounds (Andrew Chow)

Pull request description:

  Fixes #12100

  Makes the timeout be clamped to 2^30 seconds to avoid the issue with sign flipping with large timeout values and thus relocking the wallet instantly. Unlocking for at most ~34 years should be sufficient.

  Also checks that the timeout is not negative to avoid instant relocks.

Tree-SHA512: 426922f08c54e323d259e25dcdbebc2cd560708a65111ce6051493a7e7c61e79d9da1ea4026cc0d68807d728f5d7c0d7c58168c6ef4167b94cf6c2877af88794
2018-01-17 12:15:59 +01:00
Wladimir J. van der Laan adce1de9a6
Merge #12198: rpc: Add deprecation error for getinfo
49e5f3f rpc: Add deprecation error for `getinfo` (Wladimir J. van der Laan)

Pull request description:

  Add a short informative deprecation message when users use `getinfo`, that points them to the new calls
   here to get the different information fields.
  This is meant to be temporary, for one release only.

Tree-SHA512: 4fccd8853762d0740d051d9e74cdea5ad6f8d5c0ba67d69e8dd2ac8a1538d8270c1a1fab755d9f052ff3b3677753b09138c8c5ca0bc92d156de90413cd5c1814
2018-01-17 12:08:59 +01:00
Wladimir J. van der Laan 49e5f3ff7e rpc: Add deprecation error for getinfo
Add a short informative deprecation message when users use `getinfo`,
that points them to the new calls where to get the different information fields.
2018-01-17 10:06:13 +01:00
Jonas Schnelli 062c8b69f4
Merge #11991: [qt] Receive: checkbox for bech32 address
63ac8907c [qt] receive tab: bech32 address opt-in checkbox (Sjors Provoost)

Pull request description:

  <img width="647" alt="schermafbeelding 2018-01-12 om 18 34 48" src="https://user-images.githubusercontent.com/10217/34887691-a6a796fe-f7c7-11e7-8b89-87ce07c61ce3.png">

  Checkbox does what you would expect. Press tab from the amount field to get there.

  It's unchecked by default.

  When launched with `-addresstype=bech32` it's checked by default. When launched with `-addresstype=legacy` it unchecked and disabled.

  The change in `receivecoinsdialog.ui` is smaller than it looks, due to the way git handles XML diffs. I had to add a horizontal spacer to make it look decent, see https://github.com/bitcoin/bitcoin/issues/11950#issuecomment-352870909. This causes column numbers to change in the rest of the grid.

  I recommend testing on at least one other OS than OSX to be on the safe side.

Tree-SHA512: ec4b733b796d9a94278a5d8040a69d9574ef50021e68f94f61f2da75d1bb57f39272cbc9f1f7d34f733a19640daf666a23844fcd132f83bfdaf327d9d1d6f105
2018-01-16 20:48:38 -10:00
Sjors Provoost 63ac8907ce
[qt] receive tab: bech32 address opt-in checkbox
When launched with -adresstype=legacy the checkbox will be hidden.
2018-01-16 20:11:40 +00:00
MarcoFalke cad504bf4c
Merge #12177: trivial: fix address_type help text of getnewaddress and getrawchangeaddress
5f911c5cc2 trivial: fix address_type help text of getnewaddress and getrawchangeaddress (mruddy)

Pull request description:

  "p2sh" in the help messages should have been "p2sh-segwit".

  The messages before this patch:

  `help getnewaddress`
  "address_type"   (string, optional) The address type to use. Options are "legacy", "**p2sh**", and "bech32". Default is set by -addresstype.

  `help getrawchangeaddress`
  "address_type"           (string, optional) The address type to use. Options are "legacy", "**p2sh**", and "bech32". Default is set by -changetype.

Tree-SHA512: 6dfc0bebe577995f5521b83a12854045ac3eda4e65c9b92fc581da4ee68ab1218e05af82f2154bb2640a0813c5f79e010cd9e5ada449494c8831b3757bda854c
2018-01-16 08:03:48 -05:00
Wladimir J. van der Laan 0c74e2e890 Log debug build status and warn when running benchmarks
Log whether the starting instance of bitcoin core is a debug or release
build (--enable-debug).

Also warn when running the benchmarks with a debug build, to prevent
mistakes comparing debug to non-debug results.
2018-01-16 11:48:33 +01:00
MeshCollider 2f3bd47d44 Abstract directory locking into util.cpp 2018-01-16 19:05:46 +13:00
MeshCollider 5260a4aca1 Make .walletlock distinct from .lock 2018-01-16 19:05:46 +13:00
MeshCollider 64226de908 Generalise walletdir lock error message for correctness 2018-01-16 19:05:45 +13:00
MeshCollider e60cb99c58 Add a lock to the wallet directory 2018-01-16 19:02:57 +13:00
Wladimir J. van der Laan bbc91b7699
Merge #12173: [Qt] Use flexible font size for QRCode image address
59f9e2a Use flexible font size for QRCode image address (Jonas Schnelli)

Pull request description:

  Bech32 addresses are currently cut off in the QRCode image in the GUI receive tab.
  This adds a simple font size calculation logic that "must" (down to 4pt) fix into the given image width.

  Examples OSX HiDPI:
  <img width="332" alt="bildschirmfoto 2018-01-12 um 11 25 40" src="https://user-images.githubusercontent.com/178464/34896144-c0c65d76-f78c-11e7-93e1-94dc8e203269.png">
  <img width="322" alt="bildschirmfoto 2018-01-12 um 11 25 46" src="https://user-images.githubusercontent.com/178464/34896145-c0edfe1c-f78c-11e7-8c09-c15155e2160e.png">

  Examples Ubuntu non HIDPI:
  <img width="314" alt="bildschirmfoto 2018-01-12 um 11 27 51" src="https://user-images.githubusercontent.com/178464/34896151-c88347f4-f78c-11e7-8a03-df8049dcfed6.png">
  <img width="322" alt="bildschirmfoto 2018-01-12 um 11 27 42" src="https://user-images.githubusercontent.com/178464/34896152-c8bb881c-f78c-11e7-89d2-6f04ec608a19.png">

Tree-SHA512: d749763fb748b146f77fd8d88fb7d29b07a46cde0b0f303a4006ae9cc3521b3c2e8ab43b828e243514109379898b198552e17b8f316c5a869b0cc8246b054b86
2018-01-15 23:33:43 +01:00
Jonas Schnelli 59f9e2aaf3
Use flexible font size for QRCode image address 2018-01-15 09:33:46 -10:00
Wladimir J. van der Laan 44080a90a2
Merge #12118: Sort mempool by min(feerate, ancestor_feerate)
0a22a52 Use mempool's ancestor sort in transaction selection (Suhas Daftuar)
7abfa53 Add test for new ancestor feerate sort behavior (Suhas Daftuar)
9a51319 Sort mempool by min(feerate, ancestor_feerate) (Suhas Daftuar)
6773f92 Refactor CompareTxMemPoolEntryByDescendantScore (Suhas Daftuar)

Pull request description:

  This more closely approximates the desirability of a given transaction for
  mining, and should result in less re-sorting when transactions get removed from
  the mempool after being mined.

  I measured this as approximately a 5% speedup in removeForBlock.

Tree-SHA512: ffa36b567c5dfe3e8908c545a459b6a5ec0de26e7dc81b1050dd235cac9046564b4409a3f8c5ba97bd8b30526e8fec8f78480a912e317979467f32305c3dd37b
2018-01-15 15:36:35 +01:00
Wladimir J. van der Laan 9501dc27b3
Merge #12127: Remove unused mempool index
8e617e3 Remove unused mempool index (Suhas Daftuar)

Pull request description:

  We haven't used the "mining_score" index since 0.12, so remove it.

Tree-SHA512: ae37b8663194986eaeecfc2bbeca7ecb4ae6f0d8384515fa218cbc939a580d4b9f7f997c5297c3f1b3c3a0651edb092f373ac9a4808aaec30d38cb99d5f3ed70
2018-01-15 09:57:24 +01:00
Suhas Daftuar 0a22a52918 Use mempool's ancestor sort in transaction selection
Transaction selection for mining tracks ancestor feerates that are
modified based on transactions that have already been selected.  This
commit de-duplicates the code so that the ancestor feerate sorting used
by the mempool can also be directly applied to the miner.
2018-01-13 15:57:30 -05:00
mruddy 5f911c5cc2 trivial: fix address_type help text of getnewaddress and getrawchangeaddress 2018-01-13 10:49:46 -05:00
Suhas Daftuar 7abfa538b5 Add test for new ancestor feerate sort behavior 2018-01-12 12:40:55 -05:00
Jan Sarenik 648bdc8cc0 Trivial: Fix #include sys/fcntl.h to just fcntl.h (without sys/)
http://pubs.opengroup.org/onlinepubs/009695399/functions/fcntl.html
http://man7.org/linux/man-pages/man2/fcntl.2.html
2018-01-12 11:22:54 +00:00
Andrew Chow 0b63e3c7b2 Clamp walletpassphrase timeout to 2^(30) seconds and check its bounds
Clamps the timeout of walletpassphrase to 2^(30) seconds, which is
~34 years. Any number greater than that will be forced to be
2^(30). This avoids the sign flipping problem with large values which
can result in a negative time used.

Also perform bounds checks to ensure that the timeout is positive
to avoid immediate relocking of the wallet.
2018-01-11 23:57:38 -05:00
Alin Rus a73aab7cd8 Use the character based overload for std::string::find.
std::string::find has a character based overload as can be seen here
(4th oveload): http://www.cplusplus.com/reference/string/string/find/

Use that instead of constantly allocating temporary strings.
2018-01-11 21:40:51 +01:00
Andrew Chow 1df206f854 Disallow using addresses in createmultisig
Make createmultisig only accept public keys with the old functionality
marked as deprecated.

Splits _createmultisig_redeemscript into two functions, one for
getting public keys from UniValue and one for getting addresses
from UniValue and then their respective public keys. The one for
retrieving address's public keys is located in rpcwallet.cpp

Changes addwitnessaddress's output to be a JSON object with
two fields, address and redeemscript.

Adds a test to deprecated_rpc.py for testing the deprecation.

Update the tests to use addwitnessaddress or give only public keys
to createmultisig. Anything that used addwitnessaddress was also
updated to reflect the new API.
2018-01-11 14:13:24 -05:00
MarcoFalke 0910cbe4ef
Merge #12082: Adding test case for SINGLE|ANYONECANPAY hash type in tx_valid.json
18be3ab139 Adding test case for SINGLE|ANYONECANPAY hash type in tx_valid.json (Chris Stewart)

Pull request description:

  We are missing a test vector for SINGLE|ANYONECANPAY inside of tx_valid.json. This addresses the issue #12060

Tree-SHA512: e3526113477dbf575c4a844cf489dcfa2c037c6d928af6f97413edc1a8d29cdf2143da96471cdfd3de08bf5ed178117ed67926fd70fd42ca391ac0bb0d08f3fd
2018-01-11 12:36:45 -05:00
Russell Yanofsky f765bb3788 Fix ListCoins test failure due to unset g_address_type, g_change_type
New global variables were introduced in #11403 and not setting them causes:

    test_bitcoin: wallet/wallet.cpp:4199: CTxDestination GetDestinationForKey(const CPubKey&, OutputType): Assertion `false' failed.
    unknown location(0): fatal error in "ListCoins": signal: SIGABRT (application abort requested)

It's possible to reproduce the failure reliably by running:

    src/test/test_bitcoin --log_level=test_suite --run_test=wallet_tests/ListCoins

Failures happen nondeterministically because boost test framework doesn't run
tests in a specified order, and tests that run previously can set the global
variables and mask the bug.
2018-01-11 07:56:11 -05:00
Jonas Schnelli d889c036cd
Merge #11403: SegWit wallet support
b224a47a1 Add address_types test (Pieter Wuille)
7ee54fd7c Support downgrading after recovered keypool witness keys (Pieter Wuille)
940a21932 SegWit wallet support (Pieter Wuille)
f37c64e47 Implicitly know about P2WPKH redeemscripts (Pieter Wuille)
57273f2b3 [test] Serialize CTransaction with witness by default (Pieter Wuille)
cf2c0b6f5 Support P2WPKH and P2SH-P2WPKH in dumpprivkey (Pieter Wuille)
37c03d3e0 Support P2WPKH addresses in create/addmultisig (Pieter Wuille)
3eaa003c8 Extend validateaddress information for P2SH-embedded witness (Pieter Wuille)
30a27dc5b Expose method to find key for a single-key destination (Pieter Wuille)
985c79552 Improve witness destination types and use them more (Pieter Wuille)
cbe197470 [refactor] GetAccount{PubKey,Address} -> GetAccountDestination (Pieter Wuille)
0c8ea6380 Abstract out IsSolvable from Witnessifier (Pieter Wuille)

Pull request description:

  This implements a minimum viable implementation of SegWit wallet support, based on top of #11389, and includes part of the functionality from #11089.

  Two new configuration options are added:
  * `-addresstype`, with options `legacy`, `p2sh`, and `bech32`. It controls what kind of addresses are produced by `getnewaddress`, `getaccountaddress`, and `createmultisigaddress`.
  * `-changetype`, with the same options, and by default equal to `-addresstype`, that controls what kind of change is used.

  All wallet private and public keys can be used for any type of address. Support for address types dependent on different derivation paths will need a major overhaul of how our internal detection of outputs work. I expect that that will happen for a next major version.

  The above also applies to imported keys, as having a distinction there but not for normal operations is a disaster for testing, and probably for comprehension of users. This has some ugly effects, like needing to associate the provided label to `importprivkey` with each style address for the corresponding key.

  To deal with witness outputs requiring a corresponding redeemscript in wallet, three approaches are used:
  * All SegWit addresses created through `getnewaddress` or multisig RPCs explicitly get their redeemscripts added to the wallet file. This means that downgrading after creating a witness address will work, as long as the wallet file is up to date.
  * All SegWit keys in the wallet get an _implicit_ redeemscript added, without it being written to the file. This means recovery of an old backup will work, as long as you use new software.
  * All keypool keys that are seen used in transactions explicitly get their redeemscripts added to the wallet files. This means that downgrading after recovering from a backup that includes a witness address will work.

  These approaches correspond to solutions 3a, 1a, and 5a respectively from https://gist.github.com/sipa/125cfa1615946d0c3f3eec2ad7f250a2. As argued there, there is no full solution for dealing with the case where you both downgrade and restore a backup, so that's also not implemented.

  `dumpwallet`, `importwallet`, `importmulti`, `signmessage` and `verifymessage` don't work with SegWit addresses yet. They're remaining TODOs, for this PR or a follow-up. Because of that, several tests unexpectedly run with `-addresstype=legacy` for now.

Tree-SHA512: d425dbe517c0422061ab8dacdc3a6ae47da071450932ed992c79559d922dff7b2574a31a8c94feccd3761c1dffb6422c50055e6dca8e3cf94a169bc95e39e959
2018-01-10 20:55:41 -10:00
Pieter Wuille 7ee54fd7c7 Support downgrading after recovered keypool witness keys 2018-01-09 15:35:31 -08:00
Pieter Wuille 940a21932b SegWit wallet support
This introduces two command line flags (-addresstype and -changetype) which control
the type of addresses/outputs created by the GUI and RPCs. Certain RPCs allow
overriding these (`getnewaddress` and `getrawchangeaddress`). Supported types
are "legacy" (P2PKH and P2SH-multisig), "p2sh-segwit" (P2SH-P2WPKH and P2SH-P2WSH-multisig),
and "bech32" (P2WPKH and P2WSH-multisig).

A few utility functions are added to the wallet to construct different address type
and to add the necessary entries to the wallet file to be compatible with earlier
versions (see `CWallet::LearnRelatedScripts`, `GetDestinationForKey`,
`GetAllDestinationsForKey`, `CWallet::AddAndGetDestinationForScript`).
2018-01-09 15:35:31 -08:00
Pieter Wuille f37c64e477 Implicitly know about P2WPKH redeemscripts
Make CKeyStore automatically known about the redeemscripts necessary for P2SH-P2WPKH
(and due to the extra checks in IsMine, also P2WPKH) spending.
2018-01-09 15:35:27 -08:00
Pieter Wuille cf2c0b6f5c Support P2WPKH and P2SH-P2WPKH in dumpprivkey 2018-01-09 15:27:55 -08:00
Pieter Wuille 37c03d3e05 Support P2WPKH addresses in create/addmultisig 2018-01-09 15:27:51 -08:00
Suhas Daftuar 9a51319578 Sort mempool by min(feerate, ancestor_feerate)
This more closely approximates the desirability of a given transaction for
mining.
2018-01-09 12:27:57 -05:00
Suhas Daftuar 6773f92b30 Refactor CompareTxMemPoolEntryByDescendantScore 2018-01-09 11:53:40 -05:00
Suhas Daftuar 8e617e3708 Remove unused mempool index 2018-01-09 08:59:21 -05:00
donaloconnor 30ded3e3d8 [Refactor] Remove unused fQuit var from checkqueue.h 2018-01-07 20:44:21 +00:00
Pieter Wuille b3ecb7bab6
Merge #10677: RPC Docs: addmultisigaddress is intended for non-watchonly addresses
73041c3c99 RPC Docs: addmultisigaddress is intended for non-watchonly addresses (Gregory Sanders)

Pull request description:

  Spent a couple hours debugging why my p2sh watchonly funds were not appearing in various accounting calls when address was imported via `addmultisigaddress`.

Tree-SHA512: 0673e276e5ca8cdc4c9357bd835a29bd5a994520a78179600944932c700917142930288bf179f5e89b0874beaf1a88bd70129f3a297a46df42a10bab847017bb
2018-01-06 02:54:33 -08:00
251 8a93543419 Replaces numbered place marker %2 with %1.
Replaces numbered place marker %2 with %1, because the QString::arg() member function is called once on the string used to create the QString object.
2018-01-04 20:57:22 +01:00
MarcoFalke ddff3447f2
Merge #11997: [tests] util_tests.cpp: actually check ignored args
c99a3c32c8 [tests] util_tests.cpp: actually check ignored args (Anthony Towns)

Pull request description:

  An array with 7 elements was setup for checking argument parsing, but
  was passed to ParseParamaeters with argc=5, meaning the interpretation
  of the last two arguments was never actually checked.

Tree-SHA512: 7b81fde49742e524f1bb67e2ec084f5909ae36125f237f0210df4587c62e5a5a8f277f13543f0a85ad145c4bb80d62339a7d50d7ed41659df318c8198ea7f428
2018-01-04 05:08:13 -09:00
Wladimir J. van der Laan a9a49e6e7e
Merge #12001: [RPC] Adding ::minRelayTxFee amount to getmempoolinfo and updating help
aad3090 [rpc] Adding ::minRelayTxFee amount to getmempoolinfo and updating mempoolminfee help description (Jeff Rade)

Pull request description:

  These are RPC document changes from #11475 which is now merged.  Took into consideration comments from #11475 and #6941 for this PR.

  Biggest change here is when calling `getmempoolinfo`, will now show the `minrelaytxfee` in the JSON reponse (see below):

  ```
  $ bitcoin-cli getmempoolinfo
  {
    "size": 50,
    "bytes": 13102,
    "usage": 70480,
    "maxmempool": 300000000,
    "mempoolminfee": 0.00001000,
    "minrelaytxfee": 0.00001000
  }
  ```

  Fixes #8953

Tree-SHA512: 5ca583961365ee1cfe6e0d19afb0b41d542e179efee3b3c5f3fcf7d3ebca9cc3eedfd1434a0da40c5eed84fba98b35646fda201e6e61c689b58bee9cbea44b9e
2018-01-04 09:22:53 +01:00
Jonas Schnelli eeb6d5271d
Merge #12035: [qt] change µBTC to bits
ebcee1de2 bips: add bip176 (Bits Denomination) (William Casarin)
275b2eeed [qt] change µBTC to bits (William Casarin)

Pull request description:

  Now that we have bip176, change "µBTC" to the more colloquial "bits"

Tree-SHA512: eba5e5f89c392728a4f0a3bd81a9779a117b8d72a490390fd031d4e7cc56c2bfee0016aba7ef9535903e8cf2262ce46497283424e378906d0e3bf5b0d2d981c7
2018-01-03 22:16:13 -10:00
Jonas Schnelli a1136f0cb4
Merge #12074: [qt] Optimizes boolean expression model && model->haveWatchOnly()
6dda059bd [qt] Simplifies boolean expression model && model->haveWatchOnly() (251)

Pull request description:

  This PR optimizes the boolean expression `model && model->haveWatchOnly()` to `model->haveWatchOnly()`.

  The boolean expression can be optimized because the method `TransactionView::exportClicked` already guards against a potential dereferenced null pointer by returning early if `model` is null.
  63a4dc1087/src/qt/transactionview.cpp (L351-L353)

Tree-SHA512: 8bdd0d05bf879745fa39d3ca7524471720ae08ceee9427d5a08776e7b56d18542ae87a6991cd6779e232305f504fdfc77223702b72ecbe231f5f5e98453456dd
2018-01-03 21:58:46 -10:00
Chris Stewart 18be3ab139 Adding test case for SINGLE|ANYONECANPAY hash type in tx_valid.json 2018-01-03 11:07:29 -06:00
Anthony Towns c99a3c32c8 [tests] util_tests.cpp: actually check ignored args
An array with 7 elements was setup for checking argument parsing, but
was passed to ParseParamaeters with argc=5, meaning the interpretation
of the last two arguments was never actually checked.
2018-01-04 00:02:52 +10:00
Pieter Wuille 3eaa003c88 Extend validateaddress information for P2SH-embedded witness
This adds new fields 'pubkeys' and 'embedded' to the RPC's output, and improves the
documentation for previously added 'witness_version' and 'witness_program' fields.
2018-01-03 05:43:06 -08:00
Pieter Wuille 30a27dc5b1 Expose method to find key for a single-key destination 2018-01-03 05:43:06 -08:00