Commit graph

14199 commits

Author SHA1 Message Date
MarcoFalke faec689bed
txmempool: Make entry time type-safe (std::chrono) 2019-09-23 08:00:14 -04:00
fanquake 3ce8298888
Merge #15558: Don't query all DNS seeds at once
6170ec5d3a Do not query all DNS seed at once (Pieter Wuille)

Pull request description:

  Before this PR, when we don't have enough connections after 11 seconds, we proceed to query all DNS seeds in a fixed order, loading responses from all of them.

  Change this to to only query three randomly-selected DNS seed. If 11 seconds later we still don't have enough connections, try again with another one, and so on.

  This reduces the amount of information DNS seeds can observe about the requesters by spreading the load over all of them.

ACKs for top commit:
  Sjors:
    ACK 6170ec5d3
  sdaftuar:
    ACK 6170ec5d3a
  jonasschnelli:
    utACK 6170ec5d3a - I think the risk of a single seeder codebase is orthogonal to this PR. Such risks could also be interpreted differently (diversity could also increase the risk based on the threat model).
  fanquake:
    ACK 6170ec5d3a - Agree with the reasoning behind the change. Did some testing with and without `-forcednsseed` and/or a `peers.dat` and monitored the DNS activity.

Tree-SHA512: 33f6be5f924a85d312303ce272aa8f8d5e04cb616b4b492be98832e3ff37558d13d2b16ede68644ad399aff2bf5ff0ad33844e55eb40b7f8e3fddf9ae43add57
2019-09-23 12:53:50 +08:00
Jon Atack 5c1cd78b7e
doc: improve rawtransaction code/test docs 2019-09-21 16:01:20 +02:00
MarcoFalke fa7847d99b
gui: Rename address checkbox back to bech32
This is the wording that has been used in the previous release
2019-09-21 08:25:58 -04:00
fanquake 630ec7bf41
Merge #16900: doc: Fix doxygen comment for SignTransaction in rpc/rawtransaction_util
fa8d65f071 doc: Fix doxygen comment for SignTransaction in rpc/rawtransaction_util (MarcoFalke)

Pull request description:

  The param `coins` to `SignTransaction` is final and can thus not be extended (as suggested by the doc).

ACKs for top commit:
  practicalswift:
    ACK fa8d65f071 -- const correctness is good and diff looks correct
  fanquake:
    ACK fa8d65f071

Tree-SHA512: 041e159f2c3cf96e296173c31f3e5f35bbc7711cc888aa4bf08aaa8c65c95ee7f7672f65396690a9af45795a618eea0fadde7fb02d29ec85f1b4df5e6d9e0c7a
2019-09-20 16:25:59 +08:00
MarcoFalke fa8d65f071
doc: Fix doxygen comment for SignTransaction in rpc/rawtransaction_util 2019-09-19 13:34:50 -04:00
MarcoFalke faaa1f01da
util: Add count_seconds time helper 2019-09-19 11:30:29 -04:00
MarcoFalke 7d4bc60f1f
Merge #16743: refactor: move LoadChainTip/RelayBlocks under CChainState
3cf36736e5 refactoring: move ReplayBlocks under CChainState (James O'Beirne)
bcf73d3b84 refactoring: move LoadChainTip to CChainState method (James O'Beirne)
f5809d5b13 doc: fix CChainState::ActivateBestChain doc (James O'Beirne)

Pull request description:

  This is part of the [assumeutxo project](https://github.com/bitcoin/bitcoin/projects/11):

  Parent PR: #15606
  Issue: #15605
  Specification: https://github.com/jamesob/assumeutxo-docs/tree/master/proposal

  ---

  Move more chainstate-related functionality to methods on CChainState. Nothing too interesting here, but needed to work with multiple chainstates. And brief to review. :)

  Also fixes doc on ActivateBestChain.

ACKs for top commit:
  MarcoFalke:
    ACK 3cf36736e5
  ryanofsky:
    Can confirm. utACK 3cf36736e5. Removes wrapper functions and removes more  ::ChainActive() and ::ChainstateActive() calls than it adds, so seems good.

Tree-SHA512: 4bf8a1dd454ca9d61c85f6736910fa7354c57acc0002e3a8e5ce494035d8280e4c20e066f03478eeff7d44195e7912c282a486526da9be53854b478b961affaa
2019-09-19 10:45:10 -04:00
fanquake 9bf5768dd6
Merge #16885: doc: Update tx-size-small comment with relevant CVE disclosure
c4b0c08f7c Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders)

Pull request description:

  Code first introduced under https://github.com/bitcoin/bitcoin/pull/11423 with essentially no description and no discussion.

ACKs for top commit:
  MarcoFalke:
    ACK c4b0c08f7c
  fanquake:
    ACK c4b0c08f7c

Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
2019-09-19 08:51:30 +08:00
Gregory Sanders c4b0c08f7c Update tx-size-small comment with relevant CVE disclosure 2019-09-18 16:21:44 -04:00
Pieter Wuille 5e69aeec3f Add documenting comments to spanparsing.h 2019-09-18 12:25:55 -07:00
Pieter Wuille 230d43fdbc Abstract out some of the descriptor Span-parsing helpers 2019-09-18 12:12:13 -07:00
Wladimir J. van der Laan 0ee0474234
Merge #16521: rpc: Use the default maxfeerate value as BTC/kB
2dfd6834ef test: Add test for default maxfeerate in sendrawtransaction (Joonmo Yang)
261843e4be wallet/rpc: Use the default maxfeerate value as BTC/kB (Joonmo Yang)

Pull request description:

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

  This patch tries to treat `maxfeerate` in sendrawtransaction/testmempoolaccept RPC as a rate(BTC/kB) instead of an absolute value(BTC).
  The included test case checks if the new behavior works correctly, by using the transaction with an absolute fee of ~0.02BTC, where the fee rate is ~0.2BTC/kB.
  This test should be failing if the default `maxfeerate` is 0.1BTC, but pass if the default value is 0.1BTC/kB

ACKs for top commit:
  laanwj:
    ACK 2dfd6834ef (ACKs by Sjors and MarcoFalke above for trivially different code)

Tree-SHA512: a1795bffe8a182acef8844797955db1f60bb0c0ded97148f3572dc265234d5219271a3a7aa0b6418a43f73b2b2720ef7412ba169c99bb1cdcac52051f537d6af
2019-09-18 16:49:18 +02:00
Wladimir J. van der Laan dd8cf82e96
Merge #15146: Solve SmartOS FD_ZERO build issue
b4fd0ca9be Include cstring for sanity_test_fdelt if required (Ben Woosley)
7fb886b1b1 [moveonly] Split glibc sanity_test_fdelt out (Ben Woosley)

Pull request description:

  SmartOS FD_ZERO is implemented in a way that requires
  an external declaration of memcpy. We can not simply
  include cstring in the existing file because
  sanity_test_memcpy is attempting to replace memcpy.

  Instead split glibc_sanity into fdelt and memcpy files,
  and include <cstring> in glibc_sanity/fdelt.cpp.

  Fixes #13581, see also #13619

ACKs for top commit:
  laanwj:
    Code review an lightly tested (but not on SmartOS) ACK b4fd0ca9be

Tree-SHA512: 231306da291ad9eca8ba91bea1e9c27b6c2e96e484d1602e1c2cf27761202f9287ce0bc19fefd000943d2b449d0e5929cd39e2f7e09cf930d89fa520228ccbec
2019-09-18 16:33:23 +02:00
Wladimir J. van der Laan 72d30d668a
Merge #16512: rpc: Shuffle inputs and outputs after joining psbts
c0b5d97103 Test that joinpsbts randomly shuffles the inputs (Andrew Chow)
6f405a1d3b Shuffle inputs and outputs after joining psbts (Andrew Chow)

Pull request description:

  `joinpsbts` currently just adds the inputs and outputs in the order of that the PSBTs were provided. This makes it extremely easy to identify which outputs belong to which inputs. This PR changes that so that all of the inputs and outputs are shuffled in the joined transaction.

ACKs for top commit:
  instagibbs:
    utACK c0b5d97103
  jonatack:
    ACK c0b5d97103 modulo suggestions for later.

Tree-SHA512: 14a0b7aae07d92e6d2c76a3a3b228b481e1964cb7d34f97515bdda18e2ea05a9f97c5a22affc143b86ae8b95c3cb239849fb54219d65512bc2112264dca915c8
2019-09-18 16:19:47 +02:00
Wladimir J. van der Laan 408c920381
Merge #16400: refactor: Rewrite AcceptToMemoryPoolWorker() using smaller parts
4a87c5cfdf [refactor] Rewrite AcceptToMemoryPoolWorker() using smaller parts (Suhas Daftuar)

Pull request description:

  This is in preparation for re-using these validation components for a new version of AcceptToMemoryPool() that can operate on multiple transactions ("package relay").

ACKs for top commit:
  MarcoFalke:
    re-ACK 4a87c5cfdf (did the rebase myself and arrived at the same result, mod whitespace)
  laanwj:
    ACK 4a87c5cfdf

Tree-SHA512: b0495c026ffe06146258bace3d5e0c9aaf23fa65f89f258abc4af5980812e68e63a799f1d923e78ac1ee6bcafaf1222b2c2690a527df9b65dff7b48a013f154e
2019-09-18 16:15:47 +02:00
Wladimir J. van der Laan feb162d500
Merge #14696: qa: Add explicit references to related CVE's in p2p_invalid_block test.
0c62e3aa73 New regression testing for CVE-2018-17144, CVE-2012-2459, and CVE-2010-5137. (lucash-dev)
38bfca6bb2 Added comments referencing multiple CVEs in tests and production code. (lucash-dev)

Pull request description:

  This functional test includes two scenarios that test for regressions of vulnerabilities, but they are only briefly described. There are freely available documents explaining in detail the issues, but without explicit mentions, the developer trying to maintain the code needs an additional step of digging in commit history and PR conversations to figure it out.
  Added comments to explicitly mention  CVE-2018-17144 and CVE-2012-2459, for more complete documentation.
  This improves developer experience by making understanding the tests easier.

ACKs for top commit:
  laanwj:
    ACK 0c62e3aa73, checked the CVE numbers, thanks for adding documentation

Tree-SHA512: 3ee05351745193b8b959e4a25d50f25a693b2d24b0732ed53cf7d5882df40b5dd0f1877bd5c69cffb921d4a7acf9deb3cc1160b96dc730d9b5984151ad06b7c9
2019-09-18 16:00:54 +02:00
MarcoFalke b3067f4338
Merge #16865: test: add some unit tests for merkle.cpp
8573429d46 test: add some unit tests for merkle.cpp (soroosh-sdi)

Pull request description:

  following situations are covered:
  - empty block
  - one Tx
  - Merkle root of a block with odd Txs should not change with repeating
  last one
  - Merkle root is computed with combining Merkle root of left subtree and right subtree
  - block witness is Merkle root of a block when setting first Tx
  to zero.

  Signed-off-by: soroosh-sdi <soroosh.sardari@gmail.com>

ACKs for top commit:
  laanwj:
    ACK 8573429d46

Tree-SHA512: e12228171de8f8480f173c9d9d0359f00f46bf09075e0767f5f1a367478a1b7b6d177d230f7e930914915cd2c6b66b18d24b1682f1233c38e97954ba331e5773
2019-09-17 14:28:10 -04:00
James O'Beirne 3cf36736e5 refactoring: move ReplayBlocks under CChainState 2019-09-17 09:45:38 -04:00
James O'Beirne bcf73d3b84 refactoring: move LoadChainTip to CChainState method 2019-09-17 09:45:38 -04:00
James O'Beirne f5809d5b13 doc: fix CChainState::ActivateBestChain doc 2019-09-17 09:45:38 -04:00
Sebastian Falbesoner a57a1d42d5 test: add unit test for wallet watch-only methods involving PubKeys
The motivation for this addition was to unit test the function
wallet.cpp:ExtractPubKey() (see recent change in commit
798a589aff) which is however static and only
indirectly available via the public methods AddWatchOnly(), LoadWatchOnly() and
RemoveWatchOnly(). Since the first of those methods also stores the addresses
to the disk, the second, simpler one was chosen which only operates in memory.

test: add missing wallet lock for test case WatchOnlyPubKeys

test: test case WatchOnlyPubKeys, suggested review changes by instagibbs

test: test case WatchOnlyPubKeys, suggested review changes by achow101

test: test case WatchOnlyPubKeys, s/isPubKeyFullyValid/is_pubkey_fully_valid
2019-09-16 23:23:48 +02:00
soroosh-sdi 8573429d46 test: add some unit tests for merkle.cpp
following situations are covered:
- empty block
- one Tx
- Merkle root of a block with odd Txs should not change with repeating
last one
- Merkle root is computed with combining Merkle root of left subtree and right subtree
- block witness is Merkle root of a block when setting first Tx
to zero.

Signed-off-by: soroosh-sdi <soroosh.sardari@gmail.com>
2019-09-16 23:36:43 +04:30
Suhas Daftuar 4a87c5cfdf [refactor] Rewrite AcceptToMemoryPoolWorker() using smaller parts
This is in preparation for re-using these validation components for a new
version of AcceptToMemoryPool() that can operate on multiple transactions
("package relay").
2019-09-16 11:07:40 -04:00
MarcoFalke fa27eded3a
qt: Run "make translate" in ./src 2019-09-16 09:45:11 -04:00
Wladimir J. van der Laan eb812257a3
Merge #16847: doc: add comments clarifying how local services are advertised
82e53f37e1 doc: add comments clarifying how local services are advertised (James O'Beirne)

Pull request description:

  Recent questions have come up regarding dynamic service registration
  (see https://github.com/bitcoin/bitcoin/pull/16442#discussion_r308702676
  and the assumeutxo project ~~which needs to dynamically flip NODE_NETWORK~~).

  While investigating how dynamic service registration might work, I was
  confused about how we convey local services to peers. This adds some
  documentation that hopefully clarifies this process.

ACKs for top commit:
  laanwj:
    ACK 82e53f37e1
  darosior:
    ACK 82e53f37e1

Tree-SHA512: a30c1020387d7a75b5b3cdde45f8b7f2ae46293da97e6227b2ee17e290b93deb5b16c0bbc2b1676972300e5c3c2ad74eb8b3910d6b93e028dac1ae2700468ef9
2019-09-16 13:15:05 +02:00
Wladimir J. van der Laan 871d3ae45b
Merge #16757: doc: CChainState return values
fa912a8ad5 doc: move-only ActivateBestChain doxygen comment to header (MarcoFalke)
fa99efd054 doc: ActivateBestChainStep return value (MarcoFalke)

Pull request description:

  It will always return true, unless a system error such as #15305 occurred

ACKs for top commit:
  laanwj:
    ACK fa912a8ad5

Tree-SHA512: d439da844a467f9705014b946d7d987fb62cb63fe6a325b2fdbbb73a6578fc0ade3f60892044f02face43948204fc4e3c9fa70d108233d4ca8eef27984059689
2019-09-16 12:58:22 +02:00
fanquake a953429a0e
Merge #16822: gui: Create wallet menu option follow-ups
cad3ab5db8 gui: fix autofocus in CreateWalletActivity::askPassphrase() (Jon Atack)
539d9403af gui: fix passphrase labels/tooltip in createwalletdialog/askpassphrasedialog (Jon Atack)
43aa9b0d79 gui: rename encrypt(), blank(), and askPasshprase() (Jon Atack)

Pull request description:

  Closes #16820. The wallet [name escaping issue](https://github.com/bitcoin/bitcoin/pull/15450#pullrequestreview-282297760) in that issue predates #15450 and is fixed by #16826.

  - [x]  rename encrypt() to encryptWallet(), and blank() to makeBlankWallet() // EDIT: updated to
          isEncryptWalletChecked()
          isDisablePrivateKeysChecked()
          isMakeBlankWalletChecked()
  - [x]  fix naming of askPasshprase() to askPassphrase()
  - [x]  fix passphrase labels and tooltip in createwalletdialog.ui and askpassphrasedialog.ui
  - [x]  fix grammar of labels in askpassphrase dialog and WalletController::closeWallet
  - [x]  fix autofocus in CreateWalletActivity::askPassphrase()

  Squashed down to three commits.

  Reviewers, to test manually: build, launch the gui wallet, and look at labels/tooltips/focus with the create wallet, encrypt wallet, change password, and close wallet commands.

ACKs for top commit:
  jb55:
    Approach ACK cad3ab5db8
  instagibbs:
    code review and tACK cad3ab5db8
  fanquake:
    ACK cad3ab5db8

Tree-SHA512: b441fbf8f8cd370dd692bac24f0d3c1b32fc7d947b6c3a2c9ba7cf0bc175a72b3460440f2f10f7632c0e8e0f8e65fe15615a30c46e2c7763bf258c504b457dd6
2019-09-16 16:52:00 +08:00
fanquake 9debfd0e28
Merge #16863: doc: Add a missing closing parenthesis in the bitcoin-wallet's help
b6233a4985 bitcoin-wallet: Add a missing closing parenthesis in the help (darosior)

Pull request description:

ACKs for top commit:
  kristapsk:
    utACK b6233a4985
  fanquake:
    ACK b6233a4985

Tree-SHA512: acf18633fdca4bd73838fcaa0ebe4121dd0b5308daa77c4458ec4c98a9e8aa6d9d6580a48c884147438af14e670b0606c1e76f72d1d7efd221c4da419061beed
2019-09-16 08:21:46 +08:00
Samuel Dobson b0a7a76c9d
Merge #16873: rpc: fix regression in gettransaction
1b41c2c8a1 test: improve gettransaction test coverage (Jon Atack)
0f34f54888 rpc: fix regression in gettransaction (Jon Atack)

Pull request description:

  Closes #16872.

  PR #16866 renamed the `decode` argument in gettransaction to `verbose` to make it more consistent with other RPC calls like getrawtransaction. However, it inadvertently overloaded the "details" field when `verbose` is passed. The result is that the original "details" field is no longer returned correctly, which seems to be a breaking API change.

  This PR:

  - takes the simplest path to restoring the "details" field by renaming the decoded one back to "decoded" while leaving the `verbose` argument for API consistency, which was the main intent of #16866,

  - addresses [this comment](https://github.com/bitcoin/bitcoin/pull/16185#discussion_r320740413) by mentioning in the RPC help that the new decoded field is equivalent to decoderawtransaction, and

  - updates the help, functional test, and release note.

  Reviewers, to test this manually, build and run `bitcoin-cli help gettransaction` and `bitcoin-cli gettransaction <wallet txid> false true`, and verify that the command returns both `details` and `decoded` fields.

ACKs for top commit:
  jnewbery:
    tACK 1b41c2c8a1

Tree-SHA512: 287edd5db7ed58fe8b548975aba58628bd45ed708b28f40174f10a35a455d89f796fbf27430aa881fc376f47aabda8803f74d4d100683bd86577a02279091cf3
2019-09-16 09:44:34 +12:00
Jonas Schnelli a40ccbb195
Merge #16858: Qt: advise users not to switch wallets when opening a BIP70 URI.
1153caf78e Qt: advise users not to switch wallets when opening a BIP70 URI. (James Hilliard)

Pull request description:

  It would probably be a good idea to have something like this before #15584 is merged.

ACKs for top commit:
  jonasschnelli:
    utACK 1153caf78e
  fanquake:
    ACK 1153caf78e

Tree-SHA512: 6e682dd280c44eaafb1206c32439df42a20173c33297bf93dd607f0a7a2faec8e2d17fff83c85027083ebd11a71795b443e707992251574370dd1d46b7bff060
2019-09-15 20:08:03 +02:00
Jon Atack 0f34f54888
rpc: fix regression in gettransaction
PR 16866 renamed the 'decode' argument in gettransaction to 'verbose' to make it more consistent with other RPC calls like getrawtransaction.

However, it seems it inadvertently overloaded the 'details' fields when 'verbose' is passed. The result is that the original 'details' fields are no longer returned, which seems to be a breaking API change.

This PR takes the simplest path to restoring the 'details' fields by renaming them from 'details' back to 'decoded', while leaving the 'verbose' argument for API consistency.

It also addresses [this comment](https://github.com/bitcoin/bitcoin/pull/16185#discussion_r320740413) to mention that the 'decoded' field is identical to decoderawtransaction.

Update the RPC help, functional test, and release note.
2019-09-14 20:17:19 +02:00
John Newbery 7dee8f4808 [wallet] Rename 'decode' argument in gettransaction method to 'verbose'
This makes the RPC method consistent with other RPC methods that have a
'verbose' option.

Change the name of the return object from 'decoded' to details.

Update help text.
2019-09-13 22:33:46 +03:00
Steven Roose 80031045fc
Clarify includeWatching for fundrawtransaction 2019-09-13 17:45:26 +01:00
darosior b6233a4985
bitcoin-wallet: Add a missing closing parenthesis in the help 2019-09-13 16:59:06 +02:00
Wladimir J. van der Laan fb4f5beb6e
Merge #16854: Prevent UpdateTip log message from being broken up
f390d8556b Prevent UpdateTip log message from being broken up (Steven Roose)

Pull request description:

  We had some occurrences of log messages colliding:
  ```
  $ grep ThreadRPC $(find . -type f -name debug.log -print | grep bitcoind.datadir ) | awk '{$1=""; print $0}' | sort -u
   ThreadRPCServer method=sendrawtransaction user=bitcoinrpc
   ThreadRPCServer method=sendtoaddress user=bitcoinrpc
   ThreadRPCServer method=signrawtransactionwithkey user=bitcoinrpc
   UpdateTip: new best=0026711b58616e8d4db7d9bc9f46b746ec535521feb3e0f077e83925e45daa8a height=630 version=0x20000000 log2_work=10.301496 tx=633 date='2019-09-10T00:43:41Z' progress=1.000000 cache=0.1MiB(811txo)ThreadRPCServer method=getblockheader user=bitcoinrpc
   UpdateTip: new best=466304b9c3ed652373d30207f0d99551c568c2dbc648518c077cb40826039e5f height=643 version=0x20000000 log2_work=10.330917 tx=647 date='2019-09-10T00:43:43Z' progress=1.000000 cache=0.1MiB(915txo)ThreadRPCServer method=getblockheader user=bitcoinrpc
  ```

ACKs for top commit:
  jonasschnelli:
    utACK f390d8556b
  laanwj:
    ACK f390d8556b

Tree-SHA512: 15f9836d6cac171fc2b7a36a65ea8db77727559e5a558114e8c767bf059b20067afa7d6a88cfc365e9f5fa21ab5bc462d92fd01997a299fa8ed1f5c1046d1ba6
2019-09-13 15:32:20 +02:00
Jonas Schnelli 884f7cc81b
Merge #16714: gui: add prune to intro screen with smart default
9924bce317 [gui] intro: enable pruning by default unless disk is big (Sjors Provoost)
c8de347a9d [gui] intro: add prune preference (Sjors Provoost)
1bbc49d207 [gui] intro: inform caller if intro was shown (Sjors Provoost)
1957103786 [gui] add explicit prune setter (Sjors Provoost)
1bccf6a52d [node] add forceSetArg to interface (Sjors Provoost)

Pull request description:

  This adds a checkbox to the intro screen to enable pruning from the get go.

  If the user has plenty of space, it's unchecked by default:

  <img width="671" alt="big" src="https://user-images.githubusercontent.com/10217/63641289-10339000-c6ac-11e9-98d7-caf64dff0da6.png">

  If the user has insufficient space it's checked by default:
  <img width="897" alt="low" src="https://user-images.githubusercontent.com/10217/63641276-d4002f80-c6ab-11e9-9f5b-a53472f814ff.png">

  When the user has barely enough space and is likely to need pruning in the near future, this is shown in yellow and we also check the prune box:

  <img width="662" alt="medium" src="https://user-images.githubusercontent.com/10217/63641294-1c1f5200-c6ac-11e9-8ecb-6b69e42b1ece.png">

  The cut-off for this 10 GB above `m_assumed_blockchain_size` (`=240` in `chainparams.cpp`).

  If the user launches the first time with `-prune=...` then we disable the check box and display the correct size (rounded to GB):
  <img width="658" alt="Schermafbeelding 2019-08-24 om 20 23 14" src="https://user-images.githubusercontent.com/10217/63641351-09594d00-c6ad-11e9-94fe-fe5ed562e109.png">

  The 2 GB default matches the settings default. The user can't change it in the intro screen, but can change it later. I'm tempted to increase that default to 10 GB, and then have the intro screen reduce it if space is really tight.

  Tips for testing:
  * move your existing data dir elsewhere
  * wipe data dir at every restart (behavior is different if it exists)
  * launch with `bitcoin-qt -resetguisettings -lang=en` (there's some space issues in different languages)
  * fake your free space by changing `intro.cpp` line 90: `freeBytesAvailable = 5000000000; // 5 GB`
  * try both testnet and mainnet, because settings are seperate. In particular note how step 7 in `GuiMain` switches where `QTSettings settings` points to; this had me thoroughly confused on testnet, because I was setting them too early.

ACKs for top commit:
  jonasschnelli:
    Tested ACK 9924bce317
  ryanofsky:
    utACK 9924bce317. The changes are very logical, and implement the feature in a clean that way that doesn't add a lot of complication and shouldn't interfere with future improvements. I looked at Luke's branch too, and I think there's also a lot of great stuff there that seems fully compatible with this change.

Tree-SHA512: 9523961451c53aebd347716976bc3a4a398f989dc21e9bbbd357060bd11a8f46c435f068bd421bb31ccb08e55445ef67bc347d8d19a4fb8fde9d6d3f9a3bcbb0
2019-09-12 15:00:51 +02:00
Steven Roose f390d8556b
Prevent UpdateTip log message from being broken up 2019-09-12 12:33:09 +01:00
James Hilliard 1153caf78e Qt: advise users not to switch wallets when opening a BIP70 URI. 2019-09-12 14:11:34 +03:00
James O'Beirne 82e53f37e1 doc: add comments clarifying how local services are advertised
Recent questions have come up regarding dynamic service registration
(see https://github.com/bitcoin/bitcoin/pull/16442#discussion_r308702676
and the assumeutxo project, which needs to dynamically flip NODE_NETWORK).

While investigating how dynamic service registration might work, I was
confused about how we convey local services to peers. This adds some
documentation that hopefully clarifies this process.
2019-09-11 10:24:44 -04:00
fanquake 2296fe65f5
Merge #16251: Improve signrawtransaction error reporting
ec4c79326b signrawtransaction*: improve error for partial signing (Anthony Towns)
3c481f8921 signrawtransactionwithkey: better error messages for bad redeemScript/witnessScript (Anthony Towns)

Pull request description:

  Two fixes for `signrawtransactionwith{key,wallet}` (in addition to #16250): one that checks redeemScript/witnessScript matches scriptPubKey (and if both are provided that they match each other sanely), and the other changes the warning when some-but-not-all the signatures for a CHECKMULTISIG are provided to something that suggests more signatures may be all that's required.

  Fixes: #13218
  Fixes: #14823

ACKs for top commit:
  instagibbs:
    utACK ec4c79326b
  achow101:
    Code Review ACK ec4c79326b
  meshcollider:
    utACK ec4c79326b

Tree-SHA512: 0c95c91d498e85b834662b9e5c83f336ed5fd306be7701ce1dbfa0836fbeb448a267a796585512f7496e820be668b07c2a0a2f45e52dc23f09ee7d9c87e42b35
2019-09-11 15:37:13 +10:00
Suhas Daftuar 2a4e60b482 Fix block index inconsistency in InvalidateBlock()
Previously, we could release cs_main while leaving the block index in a state
that would fail CheckBlockIndex, because setBlockIndexCandidates was not being
fully populated before releasing cs_main.
2019-09-10 14:54:50 -04:00
Larry Ruane efd2474d17 util: CBufferedFile fixes 2019-09-10 07:53:09 -06:00
MarcoFalke fa912a8ad5
doc: move-only ActivateBestChain doxygen comment to header 2019-09-10 15:48:23 +03:00
MarcoFalke 750c2fbf26
Merge #16680: Preparations for more testchains
3bf9d8cac0 Testchains: Qt: Simplify network/chain styles (Jorge Timón)
052c54ecb0 Testchains: Generic selection with -chain=<str> in addition of -testnet and -regtest (Jorge Timón)

Pull request description:

  Separated from #8994 as suggested by MarcoFalke and Sjors in https://github.com/bitcoin/bitcoin/pull/8994#issuecomment-522555390

  You can't really test the qt changes on their own, so to test them, use #8994 .

ACKs for top commit:
  MarcoFalke:
    ACK 3bf9d8cac0

Tree-SHA512: 5b5e6083ebc0a44505a507fac633e7af18037c85e5e73f5d1e6f7e730575d3297ba8a31d1c2441df623b273f061c32d8fa324f4aa6bead01d23e88582029b568
2019-09-10 12:44:01 +03:00
Wladimir J. van der Laan 33c466a642
Merge #16787: rpc: Human readable network services
66740f460a doc: add a release note for the new field in 'getpeerinfo' and 'getnetworkinfo' (darosior)
6564f58c87 rpc/net: decode the services flags in a new entry (darosior)

Pull request description:

  This is a reopen of https://github.com/bitcoin/bitcoin/pull/15511#issuecomment-527087370 since there have been concept ACKs from sdaftuar and Sjors.

  This adds a new entry to `getpeerinfo` and `getnetworkinfo` which decodes the network services flags.

  Here is a truncated output of `getpeerinfo`:
  ```
  "services": "000000000000040d",
  "servicesnames": "NODE_NETWORK | NODE_BLOOM | NODE_WITNESS | NODE_NETWORK_LIMITED",
  "relaytxes": true,
  ```
  And one of `getnetworkinfo`:
  ```
  "localservices": "0000000000000409",
  "localservicesnames": "NODE_NETWORK | NODE_WITNESS | NODE_NETWORK_LIMITED",
  "localrelay": true,
  ```

  Fixes #16780.

ACKs for top commit:
  MarcoFalke:
    unsigned ACK 66740f460a
  laanwj:
    ACK 66740f460a

Tree-SHA512: 0acc37134b283f56004a41243903d7790cb01591ddf0342489bd05f3a2c780563075373ba5fd55180fa15632e8968ffa11a979b8afece75a6a2e891342601440
2019-09-10 09:03:14 +02:00
Anthony Towns ec4c79326b signrawtransaction*: improve error for partial signing
Thanks to Danial Jaffy (tipu) for reporting this issue.
2019-09-10 15:41:50 +10:00
Anthony Towns 3c481f8921 signrawtransactionwithkey: better error messages for bad redeemScript/witnessScript
This adds checks to ensure the redeemScript/witnessScript actually
correspond to the provided scriptPubKey, and, if both are provided,
that they are sensibly related to each other.

Thanks to github user passionofvc for raising this issue.
2019-09-10 15:41:50 +10:00
fanquake d8fe24cbfb
Merge #16489: log: harmonize bitcoind logging
e90478f43e log: harmonize bitcoind server logging (Jon Atack)

Pull request description:

  Harmonize the user-facing output of the  `bitcoind -daemon`, `bitcoin-cli help stop`, `bitcoin-cli stop`, and `bitcoind -version` commands to be consistent with each other as well as with the "Bitcoin Core is probably already running" messages, e.g. `git grep 'probably already running.")'`.

  Before:

  ```
  $ bitcoind -regtest -daemon
  Bitcoin Core daemon starting

  $ bitcoind -regtest -daemon
  Error: Bitcoin Core is probably already running.

  $ bitcoind -regtest -version
  Bitcoin Core Daemon version v0.18.99.0-e653eeff76-dirty

  $ bitcoin-cli -regtest help stop
  stop

  Stop Bitcoin server.

  $ bitcoin-cli -regtest stop
  Bitcoin server stopping
  ```
  these five commands output:

  "Bitcoin Core daemon"
  "Bitcoin Core"
  "Bitcoin Core Daemon"
  "Bitcoin server"
  "Bitcoin server"

  After this commit, they are all "Bitcoin Core".

  ```
  $ bitcoind -regtest -daemon
  Bitcoin Core starting

  $ bitcoind -regtest -daemon
  Error: Bitcoin Core is probably already running.

  $ bitcoind -regtest -version
  Bitcoin Core version v0.18.99.0-e90478f43e-dirty

  $ bitcoin-cli -regtest help stop
  stop

  Request a graceful shutdown of Bitcoin Core.

  $ bitcoin-cli -regtest stop
  Bitcoin Core stopping
  ```

ACKs for top commit:
  practicalswift:
    ACK e90478f43e (read code which looks good)
  practicalswift:
    ACK e90478f43e -- diff looks correct
  fjahr:
    utACK e90478f
  michaelfolkson:
    ACK e90478f43e. Tested command outputs and as described.
  ariard:
    Tested ACK e90478f
  fanquake:
    ACK e90478f43e

Tree-SHA512: 9ee584d260b5c224463318a51c2856a7c0e463be039fea072e5d5bab8898f0043b3930cf887a47aafd0f3447adb551b5e47a4e98ebdefc6cdb8e77edde0347b0
2019-09-10 10:39:19 +10:00
Samuel Dobson 335b34c30c
Merge #16725: Don't show addresses or P2PK in decoderawtransaction
6d803494b5 Don't show addresses or P2PK in decoderawtransaction (nicolas.dorier)

Pull request description:

  I spent significant amount of time explaining to people that satoshi did not had any "bitcoin address", because bitcoin address was not existing at the time.

  Then I need to explain them that all blockchain explorer are wrong. Then I understood that the source of this widespread mistake come from Bitcoin Core itself.

  For:
  ```
  bitcoin-cli -regtest decoderawtransaction 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000
  ```

  Before:
  ```json
  {
    "txid": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
    "hash": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
    "version": 1,
    "size": 204,
    "vsize": 204,
    "weight": 816,
    "locktime": 0,
    "vin": [
      {
        "coinbase": "04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73",
        "sequence": 4294967295
      }
    ],
    "vout": [
      {
        "value": 50.00000000,
        "n": 0,
        "scriptPubKey": {
          "asm": "04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f OP_CHECKSIG",
          "hex": "4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac",
          "reqSigs": 1,
          "type": "pubkey",
          "addresses": [
            "mpXwg4jMtRhuSpVq4xS3HFHmCmWp9NyGKt"
          ]
        }
      }
    ]
  }
  ```

  After
  ```json
  {
    "txid": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
    "hash": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
    "version": 1,
    "size": 204,
    "vsize": 204,
    "weight": 816,
    "locktime": 0,
    "vin": [
      {
        "coinbase": "04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73",
        "sequence": 4294967295
      }
    ],
    "vout": [
      {
        "value": 50.00000000,
        "n": 0,
        "scriptPubKey": {
          "asm": "04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f OP_CHECKSIG",
          "hex": "4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac",
          "reqSigs": 1,
          "type": "pubkey",
          "addresses": [
          ]
        }
      }
    ]
  }
  ```

  This mistake is having widespread impact, as developer thinks P2PK are addresses, they start running into issues when somebody send a P2PK payment to them and then they don't understand why they can't sign it like a P2PKH.

ACKs for top commit:
  Sjors:
    Code review ACK 6d80349.
  MarcoFalke:
    ACK 6d803494b5
  meshcollider:
    utACK 6d803494b5
  kristapsk:
    ACK 6d803494b5 (applied changes except test, ran tests, then applied changes to test also)

Tree-SHA512: 6e4990164a6b8df6675f09b2b189b7197fad43f1918fc1a4530ebd98ce71c3c94d9ec54e1b4624210fd7c5200d4f04825ca37f4e42f5fe9b8a9c0f38c50591ef
2019-09-10 11:43:48 +12:00
Samuel Dobson 8af835a72d
Merge #16796: wallet: Fix segfault in CreateWalletFromFile
fa734603b7 wallet: Fix segmentation fault in CreateWalletFromFile (MarcoFalke)
fab3c34412 test: Print both messages on failure in assert_raises_message (MarcoFalke)
faa13539d5 wallet: Fix documentation around WalletParameterInteraction (MarcoFalke)

Pull request description:

  Comes with a test to aid review. The test should fail without the fix to bitcoind

  The following `CreateWalletFromFile` issues are fixed:

  * `walletFile` refers to freed memory and will thus corrupt the debug.log and/or crash the node if read
  * `WalletParameterInteraction` was moved to `CreateWalletFromFile` and `WalletInit::ParameterInteraction` without updating the documentation

ACKs for top commit:
  promag:
    ACK fa734603b7.
  darosior:
    ACK fa734603b7
  meshcollider:
    LGTM, code-read ACK fa734603b7

Tree-SHA512: 2aceb63a3f25b90a840cfa08d37f5874aad4eb3df8c2ebf94e2ed18b55809b185e6920bdb345b988bff1fcea5e68a214fe06c361f7da2c01a3cc29e0cc421cb4
2019-09-09 23:34:05 +12:00
Jon Atack cad3ab5db8
gui: fix autofocus in CreateWalletActivity::askPassphrase() 2019-09-09 11:04:32 +02:00
Jon Atack 539d9403af
gui: fix passphrase labels/tooltip in createwalletdialog/askpassphrasedialog
UI improvements:
- update remaining GUI wallet labels and tooltips from passwords to passphrases
- improve grammar of labels in askpassphrase dialog and WalletController::closeWallet
2019-09-09 10:57:38 +02:00
Jon Atack 43aa9b0d79
gui: rename encrypt(), blank(), and askPasshprase()
as well as disablePrivateKeys() to be consistent in naming.
2019-09-09 10:56:38 +02:00
fanquake 4c329d43a5
Merge #16826: Do additional character escaping for wallet names and address labels
ad52f054f6 Escape ampersands (&) in wallet names in Open Wallet menu (Andrew Chow)
2c530ea2ad HTML escape address labels in more dialogs and notifications (Andrew Chow)
1770a972d4 HTML escape the wallet name in more dialogs and notifications (Andrew Chow)

Pull request description:

  Fixes some places where wallet names and address labels which contain valid html or other interpreted characters are displayed incorrectly.

  In the send coins dialog, if the wallet name or the address label contains valid html, then the html would be shown rather than the literal string for the wallet name or label. This PR fixes that so the true name or label is shown.

  The Open Wallet menu would incorrectly show wallet names with ampersands (`&`). For some reason, Qt removes the first ampersand in a string. So by replacing the first ampersand with 2 ampersands, the correct number of ampersands will be shown.

  Fixes the HTML escaping issues in #16820

ACKs for top commit:
  laanwj:
    Untested ACK, thanks for adding proper escaping, ad52f054f6
  fanquake:
    ACK ad52f054f6

Tree-SHA512: 264bef28a8061c7f43cc30c3e04b361c614ea78b9915e8763c44553c8967131b066db500977fa6130de1f8874b9bba59e630486c58e1e3c5c165555105a6c254
2019-09-09 16:51:53 +08:00
Wladimir J. van der Laan 08bb4c3156
Merge #16285: rpc: Improve scantxoutset response and help message
bdd6a4fd5d qa: Check scantxoutset result against gettxoutsetinfo (João Barbosa)
fc0c410d6e rpc: Improve scantxoutset response and help message (João Barbosa)

Pull request description:

  The new response keys `height` and `bestblock` allow the client to know at what point the scan took place.

  The help message now has all the response keys (`result` and `txouts` were missing) and it's improved a bit. Note that `searched_items` key is renamed to `txouts`, considering `scantxoutset` is marked experimental.

ACKs for top commit:
  laanwj:
    ACK bdd6a4fd5d

Tree-SHA512: 6bb7c3464b19857b756b8bc491ab7c58b0d948aad8c005b26ed27c55a1278f5639217e11a315bb505b4f44ebe86f413068c1e539c8a5f7a4007735586cc6443c
2019-09-09 08:08:51 +02:00
João Barbosa fc0c410d6e rpc: Improve scantxoutset response and help message 2019-09-09 00:51:31 +01:00
Samuel Dobson 91fcb9ff66
Merge #16830: refactor: wallet: Cleanup walletinitinterface.h
4be3b7680e refactor: Cleanup walletinitinterface.h (Hennadii Stepanov)

Pull request description:

  Forward declarations of `CScheduler` and `CRPCTable` classes are no longer needed after ea961c3d72 (#14437) commit.

  Including `<string>` is no longer needed after 4d4185a4f0 (#13190) commit.

ACKs for top commit:
  theStack:
    ACK 4be3b76
  promag:
    ACK 4be3b7680e.
  kristapsk:
    ACK 4be3b7680e (tested that it builds)

Tree-SHA512: 5ed72e3deda3d7c7fb698a1a11db76199727e6c570dfc78422690dbda9a92af32e1913920062dd3c9f618095e7498c219ff9c145a4c151486865ebeaa20a1d3c
2019-09-09 11:19:20 +12:00
Andrew Chow ad52f054f6 Escape ampersands (&) in wallet names in Open Wallet menu 2019-09-08 16:40:53 -04:00
Andrew Chow 2c530ea2ad HTML escape address labels in more dialogs and notifications 2019-09-08 16:40:37 -04:00
Andrew Chow 1770a972d4 HTML escape the wallet name in more dialogs and notifications 2019-09-08 16:40:05 -04:00
Hennadii Stepanov 4be3b7680e
refactor: Cleanup walletinitinterface.h
Forward declarations of CScheduler and CRPCTable classes are no longer 
needed after ea961c3d72 commit.
Including <string> is no longer needed after 
4d4185a4f0 commit.
2019-09-08 17:29:30 +03:00
MarcoFalke 410b745fe0
Merge #16735: gui: Remove unused menu items for Windows and Linux
f091dc8180 GUI: Remove unused menu items for Windows and Linux (GChuf)

Pull request description:

  Removed "Main Window" and "Restore" menu option for Windows and linux
  Keep the options for macOS

ACKs for top commit:
  MarcoFalke:
    unsigned ACK f091dc8180
  fanquake:
    ACK f091dc8180 - tested on macOS, Windows and Linux.
  MarcoFalke:
    ACK f091dc8180
  kristapsk:
    ACK f091dc8180 (tested on Linux with Xfce4)

Tree-SHA512: a84a9a8bd3b09224f111cad4712076150524a24d6f09910147194c4149222443c453372db61eed8aa82c3450339b63fd216288196feb4ab637b6ea21b0109830
2019-09-08 13:53:07 +02:00
fanquake 189c19e012
Merge #15759: p2p: Add 2 outbound block-relay-only connections
0ba08020c9 Disconnect peers violating blocks-only mode (Suhas Daftuar)
937eba91e1 doc: improve comments relating to block-relay-only peers (Suhas Daftuar)
430f489027 Don't relay addr messages to block-relay-only peers (Suhas Daftuar)
3a5e885306 Add 2 outbound block-relay-only connections (Suhas Daftuar)
b83f51a4bb Add comment explaining intended use of m_tx_relay (Suhas Daftuar)
e75c39cd42 Check that tx_relay is initialized before access (Suhas Daftuar)
c4aa2ba822 [refactor] Change tx_relay structure to be unique_ptr (Suhas Daftuar)
4de0dbac9b [refactor] Move tx relay state to separate structure (Suhas Daftuar)
26a93bce29 Remove unused variable (Suhas Daftuar)

Pull request description:

  Transaction relay is optimized for a combination of redundancy/robustness as well as bandwidth minimization -- as a result transaction relay leaks information that adversaries can use to infer the network topology.

  Network topology is better kept private for (at least) two reasons:

  (a) Knowledge of the network graph can make it easier to find the source IP of a given transaction.

  (b) Knowledge of the network graph could be used to split a target node or nodes from the honest network (eg by knowing which peers to attack in order to achieve a network split).

  We can eliminate the risks of (b) by separating block relay from transaction relay; inferring network connectivity from the relay of blocks/block headers is much more expensive for an adversary.

  After this commit, bitcoind will make 2 additional outbound connections that are only used for block relay. (In the future, we might consider rotating our transaction-relay peers to help limit the effects of (a).)

ACKs for top commit:
  sipa:
    ACK 0ba08020c9
  ajtowns:
    ACK 0ba08020c9 -- code review, ran tests. ran it on mainnet for a couple of days with MAX_BLOCKS_ONLY_CONNECTIONS upped from 2 to 16 and didn't observe any unexpected behaviour: it disconnected a couple of peers that tried sending inv's, and it successfully did compact block relay with some block relay peers.
  TheBlueMatt:
    re-utACK 0ba08020c9. Pointed out that stats.fRelayTxes was sometimes uninitialized for blocksonly peers (though its not a big deal and only effects RPC), which has since been fixed here. Otherwise changes are pretty trivial so looks good.
  jnewbery:
    utACK 0ba08020c9
  jamesob:
    ACK 0ba08020c9

Tree-SHA512: 4c3629434472c7dd4125253417b1be41967a508c3cfec8af5a34cad685464fbebbb6558f0f8f5c0d4463e3ffa4fa3aabd58247692cb9ab8395f4993078b9bcdf
2019-09-07 17:45:03 +08:00
fanquake b5a8d0cff1
Merge #15450: gui: Create wallet menu option
613de61a04 Add Create Wallet menu action (Andrew Chow)
9b41cbb28f Expose wallet creation to the GUI via WalletController (Andrew Chow)
78863e2900 Add CreateWalletDialog to create wallets from the GUI (Andrew Chow)
60adb21c7a Optionally allow AskPassphraseDialog to output the passphrase (Andrew Chow)
bc6d8a3662 gui: Refactor OpenWalletActivity (João Barbosa)

Pull request description:

  This PR adds a menu option to create a new wallet. When clicked, a `CreateWalletDialog` will be created and prompt the user to name the wallet and choose whether to disable private keys, make a blank wallet, and encrypt the wallet. If the wallet is encrypted, the wallet will be born encrypted with the wallet first created blank, then encrypted, and then a new HD seed generated and set.

  To allow the newly created wallets to be encrypted, some changes to how encrypting a wallet works. Instead of encrypting and locking the wallet, the wallet will be encrypted and then unlocked. This is also an extra belt-and-suspenders check to make sure that encryption worked.

ACKs for top commit:
  fanquake:
    ACK 613de61a04 - re-reviewed on macOS. I'm going to merge this now. It's had a stack of review, and as mentioned multiple times above, lets get this into `master` so it can get more testing pre `v0.19.0`.

Tree-SHA512: 3f22cc20b13703ffc90d366ae9133114832fea77f4f319da7fd85eb454f2f0bd5d7e1e6e20284dea2f370d8574f83b45669dcbbe506b994410d32e8e7a6fa877
2019-09-07 14:45:58 +08:00
fanquake 0d20c42a01
Merge #16421: Conservatively accept RBF bumps bumping one tx at the package limits
5ce822efbe Conservatively accept RBF bumps bumping one tx at the package limits (Matt Corallo)

Pull request description:

  Based on #15681, this adds support for some simple cases of RBF inside of large packages. Issue pointed out by sdaftuar in #15681, and this fix (or a broader one) is required ot make #15681 fully useful.

  Accept RBF bumps of single transactions (ie which evict exactly one
  transaction) even when that transaction is a member of a package
  which is currently at the package limit iff the new transaction
  does not add any additional mempool dependencies from the original.

  This could be made a bit looser in the future and still be safe,
  but for now this fixes the case that a transaction which was
  accepted by the carve-out rule will not be directly RBF'able

ACKs for top commit:
  instagibbs:
    re-ACK 5ce822efbe
  ajtowns:
    ACK 5ce822efbe ; GetSizeWithDescendants is only change and makes sense
  sipa:
    Code review ACK 5ce822efbe. I haven't thought hard about the effect on potential DoS issues this policy change may have.

Tree-SHA512: 1cee3bc57393940a30206679eb60c3ec8cb4f4825d27d40d1f062c86bd22542dd5944fa5567601c74c8d9fd425333ed3e686195170925cfc68777e861844bd55
2019-09-07 10:15:43 +08:00
fanquake 46494b08e2
Merge #16798: Refactor rawtransaction_util's SignTransaction to separate prevtx parsing
39034f1ee6 Refactor rawtransaction_util's SignTransaction to have previous tx parsing be separate (Andrew Chow)

Pull request description:

  Currently the `SignTransaction` function has to handle both the actual signing and parsing of previous transaction data. This PR splits it so that `SignTransaction` only handles the signing itself and adds a `ParsePrevouts` function which handles parsing the prevtx information.

  This allows for `SignTransaction` to just take any `SigningProvider`.

  Split from #16341

ACKs for top commit:
  MarcoFalke:
    ACK 39034f1ee6
  instagibbs:
    utACK 39034f1ee6
  ryanofsky:
    utACK 39034f1ee6. No change since previously reviewed b49bbb939be92a67ff77c3f7bca5bb94dd141906, https://github.com/bitcoin/bitcoin/pull/16341#pullrequestreview-278610269 other than rebase with no conflicts.

Tree-SHA512: 09f7733e90691766bfb5cf0f20e913dbf270bd3b51abdcad966b24d110e562ed85fd3d0d1d7bbea61f903340060052ec73c4817b09aee0dc1f3916d781a9e40c
2019-09-07 08:39:56 +08:00
Jorge Timón 3bf9d8cac0
Testchains: Qt: Simplify network/chain styles 2019-09-06 22:13:49 +02:00
Jorge Timón 052c54ecb0
Testchains: Generic selection with -chain=<str> in addition of -testnet and -regtest 2019-09-06 22:05:33 +02:00
MarcoFalke ae3e3bd151
Merge #16793: refactor: Avoid locking cs_main in ProcessNewBlockHeaders
3109a1f948 refactor: Avoid locking cs_main in ProcessNewBlockHeaders (João Barbosa)

Pull request description:

  Builds on #16774, this change avoids locking `cs_main` in `ProcessNewBlockHeaders` when the tip has changed - in this case the removed lock was necessary to just log a message.

Top commit has no ACKs.

Tree-SHA512: 31be6d319fa122804f72fa813cec5ed041dd7e4aef3c1921124a1f03016925c43cd4d9a272d80093e77fa7600e3506ef47b7bb821afcbffe01e6be9bceb6dc00
2019-09-06 13:58:32 +02:00
Andrew Chow 613de61a04 Add Create Wallet menu action
Co-authored-by: João Barbosa <joao.paulo.barbosa@gmail.com>
2019-09-05 20:36:57 -04:00
Andrew Chow 9b41cbb28f Expose wallet creation to the GUI via WalletController
Co-authored-by: João Barbosa <joao.paulo.barbosa@gmail.com>
2019-09-05 20:36:57 -04:00
Andrew Chow 78863e2900 Add CreateWalletDialog to create wallets from the GUI
Co-authored-by: João Barbosa <joao.paulo.barbosa@gmail.com>
2019-09-05 20:36:57 -04:00
Andrew Chow 60adb21c7a Optionally allow AskPassphraseDialog to output the passphrase 2019-09-05 20:36:57 -04:00
João Barbosa 3109a1f948 refactor: Avoid locking cs_main in ProcessNewBlockHeaders 2019-09-06 00:38:53 +01:00
João Barbosa bc6d8a3662 gui: Refactor OpenWalletActivity 2019-09-06 00:05:07 +01:00
Anthony Towns fdb3e8f8b2 Ignore old versionbit activations
Adds a hardcoded height to the consensus chain parameters for
ignoring versionbit activations prior to a fixed height.
2019-09-05 13:51:01 -04:00
MeshCollider 5e202382a9
Merge #16624: wallet: encapsulate transactions state
442a87cc0a Add a test wallet_reorgsrestore (Antoine Riard)
40ede992d9 Modify wallet tx status if has been reorged out (Antoine Riard)
7e89994133 Remove SyncTransaction for conflicted txn in CWallet::BlockConnected (Antoine Riard)
a31be09bfd Encapsulate tx status in a Confirmation struct (Antoine Riard)

Pull request description:

  While working on #15931, I've tried to rationalize tx state management to ease integration of block height tracking per-wallet tx. We currently rely on a combination of `hashBlock` and `nIndex` with magic value to determine tx confirmation, conflicted or abandoned state. It's hard to reason and error-prone.  To solve that, we encapsulate these fields in a `TxConfirmation` struct and introduce a `TxState` member that we update accordingly at block connection/disconnection.

  Following jnewbery [recommendation](https://github.com/bitcoin/bitcoin/pull/15931#discussion_r312576506), I've taken these changes in its own commit, and open a PR to get them first. It would ease review of aforementioned PR, but above all should ease fixing of long-term issues like :
  * https://github.com/bitcoin/bitcoin/issues/7315 (but maybe we should abandon abandontransaction or relieve it to only free outpoints not track the transaction as abandoned in itself, need its own discussion)
  * https://github.com/bitcoin/bitcoin/issues/8692 where we should cancel conflicted state of transactions chain smoothly
  * `MarkConflicted` in `LoadToWallet` is likely useless if we track conflicts rights at block connection

  Main changes of this PR to get right are tx update in `AddToWallet` and serialization/deserialization logic.

ACKs for top commit:
  meshcollider:
    Light re-Code Review ACK 442a87cc0a
  ryanofsky:
    utACK 442a87cc0a. Changes since last review are switching from `hasChain` to `LockChain` and removing chain lock in `WalletBatch::LoadWallet` that's redundant with the new lock still added in `CWallet::LoadWallet`, and fixing python test race condition.

Tree-SHA512: 029209e006de0240436817204e69e548c5665e2b0721b214510e7aba7eba130a5eab441d3a1ad95bd6426114dd27390492c77bf4560a9610009b32cd0a1f72f7
2019-09-06 01:28:54 +12:00
darosior 6564f58c87
rpc/net: decode the services flags in a new entry 2019-09-05 15:11:48 +02:00
Wladimir J. van der Laan 5667b0d758
Merge #16792: Assert that the HRP is lowercase in Bech32::Encode
2457aea83c Assert that the HRP is lowercase in Bech32::Encode (Samuel Dobson)

Pull request description:

  From BIP-173:
  > The lowercase form is used when determining a character's value for checksum purposes.
  > Encoders MUST always output an all lowercase Bech32 string. If an uppercase version of the encoding result is desired, (e.g.- for presentation purposes, or QR code use), then an uppercasing procedure can be performed external to the encoding process.

  Currently if HRP contains uppercase characters, the checksum will be generated over these uppercase characters resulting in mixed-case output that will always be invalid even if the case is changed manually after encoding. This shouldn't happen because both prefix's `bc` and `tb` are lowercase currently, but we assert this condition anyway.

  This is consistent also with the [C reference implementation](2b0aac650c/ref/c/segwit_addr.c (L59))

ACKs for top commit:
  laanwj:
    ACK 2457aea83c

Tree-SHA512: 24fcbbc2f315c72c550cc3d82b4332443eea6378fc73d571f98b87492604d023378dd102377c9e05467192cae6049606dee98e4c5688c8d5e4caac50c970284b
2019-09-05 13:31:14 +02:00
Samuel Dobson 2457aea83c Assert that the HRP is lowercase in Bech32::Encode 2019-09-05 13:25:11 +12:00
Andrew Chow 6f405a1d3b Shuffle inputs and outputs after joining psbts 2019-09-04 17:44:31 -04:00
Matt Corallo 5ce822efbe Conservatively accept RBF bumps bumping one tx at the package limits
Accept RBF bumps of single transactions (ie which conflict with one
transaction) even when that transaction is a member of a package
which is currently at the package limit iff the new transaction
does not add any additional mempool dependencies from the original.

This could be made a bit looser in the future and still be safe,
but for now this fixes the case that a transaction which was
accepted by the carve-out rule will not be directly RBF'able.
2019-09-04 15:53:14 -04:00
Suhas Daftuar 0ba08020c9 Disconnect peers violating blocks-only mode
If we set fRelay=false in our VERSION message, and a peer sends an INV or TX
message anyway, disconnect. Since we use fRelay=false to minimize bandwidth,
we should not tolerate remaining connected to a peer violating the protocol.
2019-09-04 14:58:36 -04:00
Suhas Daftuar 937eba91e1 doc: improve comments relating to block-relay-only peers 2019-09-04 14:58:36 -04:00
Suhas Daftuar 430f489027 Don't relay addr messages to block-relay-only peers
We don't want relay of addr messages to leak information about
these network links.
2019-09-04 14:58:36 -04:00
Suhas Daftuar 3a5e885306 Add 2 outbound block-relay-only connections
Transaction relay is primarily optimized for balancing redundancy/robustness
with bandwidth minimization -- as a result transaction relay leaks information
that adversaries can use to infer the network topology.

Network topology is better kept private for (at least) two reasons:

(a) Knowledge of the network graph can make it easier to find the source IP of
a given transaction.

(b) Knowledge of the network graph could be used to split a target node or
nodes from the honest network (eg by knowing which peers to attack in order to
achieve a network split).

We can eliminate the risks of (b) by separating block relay from transaction
relay; inferring network connectivity from the relay of blocks/block headers is
much more expensive for an adversary.

After this commit, bitcoind will make 2 additional outbound connections that
are only used for block relay. (In the future, we might consider rotating our
transaction-relay peers to help limit the effects of (a).)
2019-09-04 14:58:36 -04:00
Suhas Daftuar b83f51a4bb Add comment explaining intended use of m_tx_relay 2019-09-04 14:58:36 -04:00
Suhas Daftuar e75c39cd42 Check that tx_relay is initialized before access 2019-09-04 14:58:34 -04:00
MarcoFalke 8e00a68552
Merge #16774: Avoid unnecessary "Synchronizing blockheaders" log messages
dcc448e3d2 Avoid unnecessary "Synchronizing blockheaders" log messages (Jonas Schnelli)

Pull request description:

  Fixes #16773

  I'm not entirely sure why 16773 happend, but probably due to headers fallback in a compact block.

  However, this PR should fix it and should have been included in #15615.

ACKs for top commit:
  ajtowns:
    ACK dcc448e3d2 ; code review only, haven't compiled or tested.
  promag:
    ACK dcc448e3d2.
  TheBlueMatt:
    utACK dcc448e3d2. Went and read how pindexBestHeader is handled and this code looks correct (worst case it breaks a LogPrint, so whatever). I also ran into this on #16762.
  fanquake:
    ACK dcc448e3d2

Tree-SHA512: f8cac3b6eb9d4e8fab53a535b55f9ea9b058e3ab6ade64801ebc56439ede4f54b5fee36d5d2b316966ab987b65b13ab9dc18849f345d08b81ecdf2722a3f5f5a
2019-09-03 16:39:11 -04:00
Andrew Chow 39034f1ee6 Refactor rawtransaction_util's SignTransaction to have previous tx parsing be separate 2019-09-03 15:49:19 -04:00
MarcoFalke fa734603b7
wallet: Fix segmentation fault in CreateWalletFromFile 2019-09-03 14:11:11 -04:00
MarcoFalke faa13539d5
wallet: Fix documentation around WalletParameterInteraction 2019-09-03 14:10:25 -04:00
Wladimir J. van der Laan 6e431296da
Merge #16745: wallet: Translate all initErrors in CreateWalletFromFile
fa61365a13 wallet: Translate all initErrors in CreateWalletFromFile (MarcoFalke)
fa70d199d0 util: Make util/error bilingual_str (refactor) (MarcoFalke)

Pull request description:

  The translations are going to close in three days (#15940), so I am submitting this as a standalone pull request.

  Those changes are part of a bugfix #16661, which includes a test. The first change (the refactor) is required, the second commit is not. I am happy to drop it, if needed.

ACKs for top commit:
  laanwj:
    utACK fa61365a13
  hebasto:
    ACK fa61365a13, I have tested the code on Linux Mint 19.2.

Tree-SHA512: a7616cc38b9ffd301c6b915ea808a65815c3d97e9f57ec091772eb260e5cf0d75a13a6e4dfa3913e236833677c7929b9a748cb7d7a0e406d51749944b614e11b
2019-09-03 16:24:15 +02:00
MarcoFalke fa99efd054
doc: ActivateBestChainStep return value 2019-09-03 07:32:33 -04:00
Wladimir J. van der Laan 057fac3453 gui: Update English source translation 2019-09-02 13:42:01 +02:00
MeshCollider 33f9750b1b
Merge #16185: gettransaction: add an argument to decode the transaction
9965940e35 doc: Add release note for the new gettransaction argument (darosior)
b8b3f0435a tests: Add a new functional test for gettransaction (darosior)
7f3bb247a8 gettransaction: add an argument to decode the transaction (darosior)

Pull request description:

  This PR adds a new parameter to the `gettransaction` call : `decode`. If set to `true`, it will add a new `decoded` field to the response. This mimics the behavior of `getrawtransaction`'s `verbose` argument to avoid using 2 calls if we want to decode a wallet transaction (`gettransaction` then `decoderawtransaction`).

  Fix #16181 .

ACKs for top commit:
  meshcollider:
    re-utACK 9965940e35

Tree-SHA512: bcb6b4bd252b3488d6afc77659c499c2ad99fd58661eb24b6a2e17014c74f22e47fde70e00fedb4f4754915786622ad02483b2cf2c4dea0ab0eb4ac8276dbeee
2019-09-02 23:31:41 +12:00
fanquake 6519be6054
Merge #13868: Remove unused fScriptChecks parameter from CheckInputs
9b92538ade Remove unused fScriptChecks parameter from CheckInputs (Matt Corallo)

Pull request description:

  fScriptChecks = false just short-circuits the entire function, so
  passing it in is entirely useless.

  This is extracted from #13233 /cc TheBlueMatt.

  Recommend reviewing with `git show --ignore-all-space`, i.e.:
  https://github.com/bitcoin/bitcoin/pull/13868/files?w=1

ACKs for top commit:
  TheBlueMatt:
    utACK 9b92538ade. Checked diff had no functional change and new comment copy looks correct.
  kallewoof:
    ACK 9b92538ade
  ajtowns:
    ACK 9b92538ade ; code review, checked tests work. Looks right to me, and fanquake's notes make sense. Could change the coinbase early exit to `assert(!tx.IsCoinBase());`.
  fanquake:
    ACK 9b92538ade - Notes / testing below.

Tree-SHA512: add253a3e8cf4b33eddbc49efcec333c14b5ea61c7d34e43230351d40cff6adc919a75b91c72c4de8647a395284db74a61639f4c67848d4b2fec3a705b557790
2019-09-02 16:17:11 +08:00
fanquake 7d6f63cc2c
Merge #16720: qt: Replace objc_msgSend() function calls with the native Objective-C syntax
0bb33b5348 qt: Replace objc_msgSend with native syntax (Hennadii Stepanov)

Pull request description:

  Changes in Xcode 11 Objective-C Runtime cause an error (#16387) during building on MacOS 10.15 Catalina.

  This PR fixes this issue by replacing `objc_msgSend()` function calls with the native Objective-C syntax.

  Refs:
  - [changes in `objc_msgSend` function](https://developer.apple.com/documentation/objectivec/1456712-objc_msgsend?changes=latest_minor&language=objc)
  - [`OBJC_OLD_DISPATCH_PROTOTYPES` macro](https://developer.apple.com/documentation/objectivec/objc_old_dispatch_prototypes?language=objc)

ACKs for top commit:
  l2a5b1:
    ACK 0bb33b5 - Diff looks good. Sending messages via native Objective-C code feels more robust and is more readable than casting all the `objc_msgSend` function calls to the appropriate function signature (which would also have fixed the issue).
  jonasschnelli:
    utACK 0bb33b5348 - Confirmed that the called macOS framework function is available on our build targets.
  fanquake:
    ACK 0bb33b5348 - Still works as expected.

Tree-SHA512: c09cb684d06bd1da053a17c182b7bb1642e45bb347d26c76e1c5d835c320567caee366d85e34bb7f2be38e63ed041e0d06a56c2a9d89f7e5bece9b19cc5c6772
2019-09-01 16:20:26 +08:00
Jonas Schnelli dcc448e3d2
Avoid unnecessary "Synchronizing blockheaders" log messages 2019-08-31 22:00:35 +02:00
Hennadii Stepanov 0bb33b5348
qt: Replace objc_msgSend with native syntax 2019-08-31 12:25:34 +03:00
fanquake e9ef1b2c2e
Merge #16716: wallet: Use wallet name instead of pointer on unload/release
d9d8984270 wallet: Use wallet name instead of pointer on unload/release (João Barbosa)

Pull request description:

  Fixes #16668. Wallet name is unique so it can be used instead of pointer.

ACKs for top commit:
  meshcollider:
    utACK d9d8984270
  instagibbs:
    utACK d9d8984270
  ryanofsky:
    utACK d9d8984270. Alternately I think it might be possible to use an intptr_t set instead of a string set to get around the undefined behavior described in the issue.

Tree-SHA512: eccd4d260cd4c02b52c30deeb32dbfd190a1151a5340eb3aa4ece0dc6ae3b3ed746ce5617336461f6f27c437c435629cd07d20beb1c5450f23b75edde6728598
2019-08-31 09:17:41 +08:00
GChuf f091dc8180 GUI: Remove unused menu items for Windows and Linux 2019-08-30 17:54:45 +02:00
darosior 7f3bb247a8
gettransaction: add an argument to decode the transaction
This adds a new boolean parameter 'decode' to the gettransaction call, which, if set to true, add a 'decoded' field to the result containing the decoded transaction
2019-08-30 11:38:49 +02:00
nicolas.dorier 6d803494b5
Don't show addresses or P2PK in decoderawtransaction 2019-08-30 11:29:21 +09:00
fanquake f5db3f2128
Merge #16758: qt: Replace QFontMetrics::width() with TextWidth()
8b6f5aabb9 qt: Replace QFontMetrics::width() with TextWidth() (Hennadii Stepanov)

Pull request description:

  Compiling master (d8fc997913) on macOS Catalina (with a patch from #16720) reveals one more instance of `QFontMetrics::width()` which is supposed to be replaced with `TextWidth()` in the merged #16701.

  Sorry for incomplete solution provided in #16701. It’s especially sad that the line I missed lies in only 7 lines from the code touched in #16701.

ACKs for top commit:
  fanquake:
    ACK 8b6f5aabb9

Tree-SHA512: 65cd8bea550150e5ee47c1e906d8c2393547cf4feba3701a933a4f24fad5ecdb552ac2de4e1200ed14efaa0df0480150dd58fccbddc3b902f6c2141603874902
2019-08-30 10:27:28 +08:00
fanquake a8ecd0dada
Merge #16753: wallet: extract PubKey from P2PK script with Solver
798a589aff wallet: extract PubKey from P2PK script with Solver (Sebastian Falbesoner)

Pull request description:

  The function `ExtractPubKey()` checks if a given script matches the P2PK pattern
  (`<PubKey> OP_CHECKSIG`), extracts the PubKey and additionally checks if it is
  cryptographically valid (full validation with ECC library via `CPubKey::IsFullyValid()`).

  Currently this is done manually in the following order:
  1. check if first script OP is data push with valid PubKey length (first part of pattern match), extract PubKey
  2. create `CPubKey` object with extracted PubKey
  3. fully validate public key
  4. check if last script OP is `OP_CHECKSIG` (second part of pattern match)

  Using Solver, the pattern matching and PubKey extraction can be done via a
  single step, leading to the following simplified order with shorter code:
  1. check if given script matches P2PK pattern with Solver (also contains valid PubKey length check), extracts Pubkey
  2. create `CPubKey` object with extracted Pubkey
  3. fully validate public key

ACKs for top commit:
  instagibbs:
    utACK 798a589aff
  theStack:
    > utACK [798a589](798a589aff)
  sipa:
    ACK 798a589aff
  achow101:
    Code Review ACK 798a589aff

Tree-SHA512: 350358a89afed8c2a7967c50e9714a2d4a909259b50e694ce68dde3e7d0fa0bf3238d33642e73f2bdb53860f6d3f7327ca3eb6426b74eaffacfbca0a384d68cd
2019-08-30 09:22:31 +08:00
fanquake 74da99e010
Merge #14862: doc: Declare BLOCK_VALID_HEADER reserved
fa0b910486 [doc] chain: Declare BLOCK_VALID_HEADER reserved (MarcoFalke)

Pull request description:

  `BLOCK_VALID_HEADER` was never used and the comment is confusing to me in several ways:

  * It claims "version ok". However, without the previous header, it is not possible to check the validity of the version since the height needs to be known (c.f. BIP 90)
  * It claims "hash satisfies claimed PoW". While it is possible to check against the claimed PoW, it is not possible without the previous header to check that the claimed PoW is itself valid.
  * It claims "1 <= vtx count <= max". However, with the header alone and current consensus rules, the number of transactions is unknown.

ACKs for top commit:
  sipa:
    ACK fa0b910486
  ryanofsky:
    ACK fa0b910486

Tree-SHA512: 3972995a0a2f83aa55767bf8982af1fcb9493483f62aee6df27e58be9181a48d5968ae718b390cecc8be3ed4f26495683b1cffde8ef272dea0bd610ec169ef8b
2019-08-30 08:47:03 +08:00
Jonas Schnelli bcf7004a89
Merge #16707: qt: Remove obsolete QModelIndex::child()
c53667764e qt: Remove obsolete QModelIndex::child() (Hennadii Stepanov)

Pull request description:

  The `QModelIndex::child()` member function is [obsolete](https://doc.qt.io/qt-5.12/qmodelindex-obsolete.html) since Qt 5.12.

  This PR removes it, does not change behavior and keeps compatibility with [Qt 5.5.1](https://github.com/bitcoin/bitcoin/pull/15393).

  Here is an excerpt from the master build log:
  ```
  qt/receivecoinsdialog.cpp: In member function ‘void ReceiveCoinsDialog::copyColumnToClipboard(int)’:
  qt/receivecoinsdialog.cpp:264:111: warning: ‘QModelIndex QModelIndex::child(int, int) const’ is deprecated: Use QAbstractItemModel::index [-Wdeprecated-declarations]
       GUIUtil::setClipboard(model->getRecentRequestsTableModel()->data(firstIndex.child(firstIndex.row(), column), Qt::EditRole).toString());
                                                                                                                 ^
  In file included from /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/qabstractitemview.h:45:0,
                   from /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/qheaderview.h:44,
                   from /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/QHeaderView:1,
                   from ./qt/guiutil.h:12,
                   from ./qt/receivecoinsdialog.h:8,
                   from qt/receivecoinsdialog.cpp:7:
  /home/hebasto/Qt/5.13.0/gcc_64/include/QtCore/qabstractitemmodel.h:457:20: note: declared here
   inline QModelIndex QModelIndex::child(int arow, int acolumn) const
                      ^~~~~~~~~~~
  ```

ACKs for top commit:
  laanwj:
    Code review ACK c53667764e
  promag:
    ACK c53667764e, just read the change.
  jonasschnelli:
    utACK c53667764e

Tree-SHA512: 99fcb6ff60a6d47b925bda9f14006269eaad09ba4f7a41ac4975c6cf04bd906b58aed721cbfa0be7da8e6613d92e30d4be18b7e4d3960f026c7226558a4c3196
2019-08-29 18:36:13 +02:00
Hennadii Stepanov 8b6f5aabb9
qt: Replace QFontMetrics::width() with TextWidth() 2019-08-29 19:13:19 +03:00
Antoine Riard 40ede992d9 Modify wallet tx status if has been reorged out
Add a LockChain method to CWallet to know if we can lock or query
chain state safely.

At tx loading, we rely on chain to know if hashBlock of tx is still
in main chain. If not, we set its status to unconfirmed and reset
its hashBlock/nIndex.

If wallet loaded is the wallet-tool one, all wallet txn will
show up with a height of zero. It doesn't matter as status is not
used by wallet-tool.

We take lock prematurely in CWallet::LoadWallet and CWallet::Verify
to ensure that lock order is respected between cs_main an cs_wallet.
2019-08-29 11:17:51 -04:00
Wladimir J. van der Laan d8fc997913
Merge #16695: rpc: Add window final block height to getchaintxstats
d48c1e837a Add window final block height to getchaintxstats (Jonathan "Duke" Leto)

Pull request description:

  This patch is motivated by the desire to make the output of `getchaintxstats` more useful and optimized for applications to consume and render the data.

  Firstly, this data is already available to the RPC, no additional work is done. Currently additional RPC calls will be needed to look up the height of the final block in the window or the block height that began the window.

  By adding the block height of the final block in the window, the JSON is "self-contained" and applications can calculate the exact block height range of the window with no additional RPC requests.
  For example, a web application which wants to render historical information for `getchaintxstats` RPC on various window sizes might call the RPC with various window lengths, once per day, and store the JSON results somewhere. Because the final block height of each dataset is included, it's no extra work to determine the exact block window range of each JSON response.

ACKs for top commit:
  promag:
    ACK d48c1e837a.

Tree-SHA512: fd4952c125f81a4ad18f7c78498c6b3e265b93cb574832166ac25596321ce84957f971f3f78f37d7e42638dc65f2a5d4d760f289873c9c2f2a82eb00a0f87c3f
2019-08-29 16:41:46 +02:00
Wladimir J. van der Laan 75142ece6b
Merge #16706: qt: Replace deprecated QSignalMapper by lambda expressions
0912134039 qt: Remove QSignalMapper from TransactionView (Hennadii Stepanov)
9e0c1d676c qt: Remove QSignalMapper from RPCConsole (Hennadii Stepanov)

Pull request description:

  The [`QSignalMapper`](https://doc.qt.io/qt-5/qsignalmapper.html) class has been [deprecated](https://doc-snapshots.qt.io/qt5-5.10/obsoleteclasses.html) since Qt 5.10.

  This PR replaces it by lambdas and does not change behavior.

ACKs for top commit:
  jonasschnelli:
    utACK 0912134039

Tree-SHA512: 0c102d5cab4adc8b6252f72e07123ac87c65434c88cada3e72816ecea8fc4803f15b9c050fb5e1c7e8a96f709265521fd6813ab1890dbf5634032f7ee0d50675
2019-08-29 15:59:29 +02:00
Wladimir J. van der Laan 1f8378508a
Merge #15615: Add log output during initial header sync
d75e704ac0 Add log output during initial header sync (Jonas Schnelli)

Pull request description:

  The non debug log output is completely quiet during the header sync. I see two main reasons to add infos about the state of the initial header sync...
  * users may think the node did fail to start sync
  * it's a little complicate to check if your getting throttled during header sync (repeatedly calling `getchaintips` or similar)

ACKs for top commit:
  fanquake:
    Concept ACK d75e704ac0
  practicalswift:
    utACK d75e704ac0
  laanwj:
    Tested ACK d75e704ac0

Tree-SHA512: 2e738571b703d7251290864603c3a829729645962c2fa3187250bab0585e66a5f01fce892e9b5b98da451fab2b40a2e4784f9b2e5a9cad75ff62c535affe7430
2019-08-29 15:47:26 +02:00
Jonathan "Duke" Leto d48c1e837a Add window final block height to getchaintxstats
The getchaintxstats RPC now returns the additional key of window_final_block_height
2019-08-29 06:24:44 -07:00
Wladimir J. van der Laan d20d171f26
Merge #16701: qt: Replace functions deprecated in Qt 5.13
c6dd32da69 qt: Replace obsolete functions of QDesktopWidget (Hennadii Stepanov)
1260ecd812 qt: Add TextWidth() wrapper (Hennadii Stepanov)

Pull request description:

  The following functions are obsolete in Qt 5.13:
  - [`QFontMetrics::width()`](https://doc.qt.io/qt-5/qfontmetrics-obsolete.html#width)
  - [`QDesktopWidget::availableGeometry()`](https://doc.qt.io/qt-5/qdesktopwidget-obsolete.html#availableGeometry)
  - [`QDesktopWidget::screenGeometry()`](https://doc.qt.io/qt-5/qdesktopwidget-obsolete.html#screenGeometry)

  This PR replaces them and does not change behavior.

  Here are some excerpts from the master build log:
  ```
  qt/bitcoingui.cpp: In constructor ‘BitcoinGUI::BitcoinGUI(interfaces::Node&, const PlatformStyle*, const NetworkStyle*, QWidget*)’:
  qt/bitcoingui.cpp:84:57: warning: ‘const QRect QDesktopWidget::availableGeometry(int) const’ is deprecated: Use QGuiApplication::screens() [-Wdeprecated-declarations]
           move(QApplication::desktop()->availableGeometry().center() - frameGeometry().center());
                                                           ^
  In file included from /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/QDesktopWidget:1:0,
                   from qt/bitcoingui.cpp:43:
  /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/qdesktopwidget.h:88:67: note: declared here
       QT_DEPRECATED_X("Use QGuiApplication::screens()") const QRect availableGeometry(int screen = -1) const;
                                                                     ^~~~~~~~~~~~~~~~~
  ```
  ```
  qt/bitcoingui.cpp:1410:74: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations]
           max_width = qMax(max_width, fm.width(BitcoinUnits::longName(unit)));
                                                                            ^
  In file included from /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/qwidget.h:50:0,
                   from /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/qdialog.h:44,
                   from /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/QDialog:1,
                   from ./qt/optionsdialog.h:8,
                   from ./qt/bitcoingui.h:12,
                   from qt/bitcoingui.cpp:5:
  /home/hebasto/Qt/5.13.0/gcc_64/include/QtGui/qfontmetrics.h:108:9: note: declared here
       int width(const QString &, int len = -1) const;
           ^~~~~
  ```
  ```
  qt/splashscreen.cpp: In constructor ‘SplashScreen::SplashScreen(interfaces::Node&, Qt::WindowFlags, const NetworkStyle*)’:
  qt/splashscreen.cpp:127:50: warning: ‘const QRect QDesktopWidget::screenGeometry(int) const’ is deprecated: Use QGuiApplication::screens() [-Wdeprecated-declarations]
       move(QApplication::desktop()->screenGeometry().center() - r.center());
                                                    ^
  In file included from /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/QDesktopWidget:1:0,
                   from qt/splashscreen.cpp:24:
  /home/hebasto/Qt/5.13.0/gcc_64/include/QtWidgets/qdesktopwidget.h:79:67: note: declared here
       QT_DEPRECATED_X("Use QGuiApplication::screens()") const QRect screenGeometry(int screen = -1) const;
                                                                      ^~~~~~~~~~~~~~
  ```

ACKs for top commit:
  jonasschnelli:
    utACK c6dd32da69

Tree-SHA512: deb7bcbf86e1dcc6508bd91288772c2fe8811db79fa2011de37d0469cdd094fbf7fd8c4512c607bed0bd08dc2968e893c0bbc190732c43c69ed1085259df766c
2019-08-29 14:57:06 +02:00
Sebastian Falbesoner 798a589aff wallet: extract PubKey from P2PK script with Solver
The function ExtractPubKey() checks if a given script matches the P2PK pattern
(<PubKey> OP_CHECKSIG), extracts the PubKey and additionally checks if it is
cryptographically valid (full validation with ECC library via .IsFullyValid()).

Currently this is done manually in the following order:
    1) check if first script OP is data push with valid PubKey length
       (first part of pattern match), extract PubKey
    2) create CPubKey object with extracted PubKey
    3) fully validate public key
    4) check if last script OP is OP_CHECKSIG
       (second part of pattern match)

Using Solver, the pattern matching and PubKey extraction can be done via a
single step, leading to the following simplified order with shorter code:
    1) check if given script matches P2PK pattern with Solver
       (also contains valid PubKey length check), extracts Pubkey
    2) create CPubKey object with extracted Pubkey
    3) fully validate public key
2019-08-29 13:34:20 +02:00
fanquake b7ff38972c
Merge #16752: doc: Delete stale URL in test README
41d484d5c8 doc: Delete stale URL in test README (Michael Folkson)

Pull request description:

  The resource on the Boost unit test framework previously linked to in src/test/README.md was a stale URL.

  Instead of deleting it, I've replaced it with an alternative resource on the framework on [boost.org](https://www.boost.org/doc/libs/1_45_0/libs/test/doc/html/utf/tutorials.html).

ACKs for top commit:
  promag:
    ACK 41d484d5c8.
  hebasto:
    ACK 41d484d5c8, the removed link is really obsolete.
  fanquake:
    ACK 41d484d5c8 - Thanks.

Tree-SHA512: 764f12548441bde615f77b7a2ca7c5188b4ab936972d16b84960fbd8604d4cbd224415bc59ce839e7e63293aa84fd97f31a69e38734e531231cdb0e148d2e1bd
2019-08-29 19:18:23 +08:00
Wladimir J. van der Laan aca76b9ee8
Merge #16708: qt: Replace obsolete functions of QSslSocket
2e1455c4a1 Replace obsolete functions of QSslSocket (Hennadii Stepanov)

Pull request description:

  The [`QSslSocket::setDefaultCaCertificates()`](https://doc.qt.io/qt-5/qsslsocket-obsolete.html#setDefaultCaCertificates) and [`QSslSocket::systemCaCertificates()`](https://doc.qt.io/qt-5/qsslsocket-obsolete.html#systemCaCertificates) member functions are [obsolete](https://doc.qt.io/qt-5.12/qsslsocket-obsolete.html) since Qt 5.12.

  This PR replaces them, does not change behavior and keeps compatibility with [Qt 5.5.1](https://github.com/bitcoin/bitcoin/pull/15393).

ACKs for top commit:
  laanwj:
    ACK 2e1455c4a1
  promag:
    ACK 2e1455c4a1.

Tree-SHA512: 4182cd22a3e7a998d62a0fe84e748803a6962a65920b74da9fcf5666a700507468bb6e428054ccb70c2fbb7969a56933f450bc405c7a32ecbc1f8af4c1f983a3
2019-08-29 13:09:51 +02:00
Michael Folkson 41d484d5c8 doc: Delete stale URL in test README 2019-08-29 13:58:00 +03:00
MarcoFalke 93305e6d46
Merge #14879: qt: Add warning messages to the debug window
593ba696fb Add warning messages to the debug window (Hennadii Stepanov)

Pull request description:

  Fix: #11016

  This PR adds warning messages to the debug window in `-disablewallet` mode.

  ![screenshot from 2018-12-06 01-01-27](https://user-images.githubusercontent.com/32963518/49550070-413c1c80-f8f3-11e8-9865-efb49ea8da45.png)

ACKs for top commit:
  jonasschnelli:
    utACK 593ba696fb
  promag:
    ACK 593ba696fb, agree with @Sjors https://github.com/bitcoin/bitcoin/pull/14879#pullrequestreview-196433092 above.
  ryanofsky:
    utACK 593ba696fb

Tree-SHA512: a8ca78529bb16813ba7bfaf5ccd4349189979f08e78ea857746a6fb00fd9d7ed98d8f06f384830acba21dac57070060af23f6be8249398feb32a6efff1333de8
2019-08-28 16:03:09 -04:00
MarcoFalke fa61365a13
wallet: Translate all initErrors in CreateWalletFromFile
Every warning or error in this method is translated, except for those
two. Translate them as well for consistency.
2019-08-28 15:52:31 -04:00
MarcoFalke fa70d199d0
util: Make util/error bilingual_str (refactor)
Translated strings should not end up in the debug log, stderr, or
returned by an RPC.

Changing the util methods in util/error to return a bilingual_str paves
the way to achieve this goal in the long term.
2019-08-28 15:52:26 -04:00
Suhas Daftuar c4aa2ba822 [refactor] Change tx_relay structure to be unique_ptr 2019-08-28 13:41:58 -04:00
Suhas Daftuar 4de0dbac9b [refactor] Move tx relay state to separate structure 2019-08-28 13:41:58 -04:00
MarcoFalke a7be1cc92b
Merge #16728: move-only: move coins statistics utils out of RPC
8a3b2eb175 move-only: move coins statistics utils out of RPC (James O'Beirne)

Pull request description:

  This is part of the [assumeutxo project](https://github.com/bitcoin/bitcoin/projects/11):

  Parent PR: #15606
  Issue: #15605
  Specification: https://github.com/jamesob/assumeutxo-docs/tree/master/proposal

  ---

  In the short-term, this move-only commit will help with fuzzing (https://github.com/bitcoin/bitcoin/pull/15606#issuecomment-524482297). Later, these procedures will be used to compute statistics (particularly a content hash) for UTXO sets coming in from snapshots.

  Most easily reviewed with `git ... --color-moved=dimmed_zebra`. A nice follow-up would be adding unittests, which I'll do if nobody else gets around to it.

ACKs for top commit:
  MarcoFalke:
    ACK 8a3b2eb175, checked --color-moved=dimmed-zebra

Tree-SHA512: a187d2f7590ad2450b8e8fa3d038c80a04fc3d903618c24222d7e3172250ce51badea35860c86101f2ba266eb4354e6efb8d7d508b353f29276e4665a1efdf74
2019-08-27 13:10:45 -04:00
James O'Beirne 8a3b2eb175 move-only: move coins statistics utils out of RPC
These procedures will later be used in the ChainstateManager to compute
statistics (particularly a content hash) for UTXO sets coming in from
snapshots.
2019-08-27 11:51:56 -04:00
Matt Corallo 9b92538ade
Remove unused fScriptChecks parameter from CheckInputs
fScriptChecks = false just short-circuits the entire function, so
passing it in is entirely useless.
2019-08-26 16:27:58 -07:00
Pieter Wuille 92528c260e Support serialization of std::vector<bool> 2019-08-26 11:36:33 -07:00
ezegom 1a4c791cf4 rpc bumpfee: move feerate estimation logic into separate method 2019-08-26 12:25:36 -04:00
Hennadii Stepanov 0912134039
qt: Remove QSignalMapper from TransactionView
The QSignalMapper class is obsolete since Qt 5.10.
2019-08-25 09:12:38 +03:00
Hennadii Stepanov c6dd32da69
qt: Replace obsolete functions of QDesktopWidget 2019-08-25 08:46:32 +03:00
Hennadii Stepanov c53667764e
qt: Remove obsolete QModelIndex::child()
The QModelIndex::child() member function is obsolete since Qt 5.12.
2019-08-25 08:16:14 +03:00
João Barbosa d9d8984270 wallet: Use wallet name instead of pointer on unload/release 2019-08-25 02:07:04 +01:00
Sjors Provoost 9924bce317
[gui] intro: enable pruning by default unless disk is big
Color the text "GB needed for full chain" orange for nodes that barely have enough space.
2019-08-24 22:41:32 +02:00
Sjors Provoost c8de347a9d
[gui] intro: add prune preference
Adds a checkbox to the introduction screen letting the user enable pruning from the start.
Disable checkbox when launched with -prune
2019-08-24 22:41:32 +02:00
Sjors Provoost 1bbc49d207
[gui] intro: inform caller if intro was shown 2019-08-24 22:39:47 +02:00
Sjors Provoost 1957103786
[gui] add explicit prune setter
This makes it possible to enable pruning after the OptionsModel has been initialized and reset.
2019-08-24 22:36:11 +02:00
Sjors Provoost 1bccf6a52d
[node] add forceSetArg to interface 2019-08-24 22:36:11 +02:00
nicolas.dorier 66ad75472f
[Doc] Add documentation for the new whitelist permissions 2019-08-24 23:22:29 +09:00
Hennadii Stepanov 2e1455c4a1
Replace obsolete functions of QSslSocket
The QSslSocket::setDefaultCaCertificates() and 
QSslSocket::systemCaCertificates() member functions are obsolete since 
Qt 5.12.
2019-08-24 15:32:04 +03:00
Hennadii Stepanov 9e0c1d676c
qt: Remove QSignalMapper from RPCConsole
The QSignalMapper class is obsolete since Qt 5.10.
2019-08-24 10:23:24 +03:00
Antoine Riard 7e89994133 Remove SyncTransaction for conflicted txn in CWallet::BlockConnected
We shouldn't rely on this sync call to get an accurate view of txn
state, if a tx conflicts with one in mapTx we are going to update
our wallet dependencies in AddToWalletIfInvolvingMe while conflicting
txn get connected. If it doesn't conflict with one of our dependencies
we are not going to track it anyway.

This is a cleanup, as this SyncTransaction is redundant with the
following one for confirmation which is triggering the MarkConflicted
logic. We keep the loop because set of conflicted txn isn't same as txn
included in block.
2019-08-23 14:53:23 -04:00
Antoine Riard a31be09bfd Encapsulate tx status in a Confirmation struct
Instead of relying on combination of hashBlock and nIndex
values to manage tx in its lifecycle, we introduce 4
status : CONFIRMED, UNCONFIRMED, CONFLICTED, ABANDONED.

hashBlock and nIndex magic values should only be used at
serialization/deserialization for backward-compatibility.

At block disconnection, we know flag txn as UNCONFIRMED where
previously they kept their states until being override by a
block connection or abandontransaction call. This is a change
in behavior for which user may have to call abandon twice
if transaction is disconnected and not accepted back in the mempool.

We assert status transitioning right in AddToWallet. Doing so
flagged a misbehavior in ComputeTimeSmart unit test where same
tx is confirmed twice in different block. To avoid inconsistencies
we unconfirmed tx before new connection in different block. We
also remove a cs_main lock in test, as AddToWallet and its
callees don't rely on locked chain.
2019-08-23 14:53:20 -04:00
Hennadii Stepanov 1260ecd812
qt: Add TextWidth() wrapper
In Qt 5.12 and before the QFontMetrics::width() is used and it is
deprecated since Qt 13.0.
In Qt 5.11 the QFontMetrics::horizontalAdvance() was introduced.
2019-08-23 21:27:50 +03:00
bpay a4765bd77f
gui: Ensure tx send error highlight is visible
If sending to multiple recipients and one of the recipient fields is malformed,
the highlighted field may not be visible due to being scrolled out of view,
leading to a confusing lack of error feedback when clicking Send. To avoid this
problem ensure the first field containing an error is scrolled into view
when Send is clicked.
2019-08-23 19:20:48 +08:00
Jonas Schnelli d72758c3f6
Merge #16677: gui: remove unused PlatformStyle::TextColorIcon
bca388db0d gui: remove unused PlatformStyle::TextColorIcon (fanquake)

Pull request description:

  This is unused after #16612.

ACKs for top commit:
  emilengler:
    Concept ACK bca388d
  practicalswift:
    ACK bca388db0d -- diff looks correct & less cruft is better
  hebasto:
    ACK bca388db0d, I have reviewed the code and it looks OK, I agree it can be merge.
  jonasschnelli:
    utACK bca388db0d

Tree-SHA512: ae5c5cfc02cf2e6f138e75e227320f4c430b93bd529a8ead7ba971ceb5bbc997cdb721c6fd8a46a5a897008f0bc6e519422d6beef240b9d2e28ecf4f8cbbcc6a
2019-08-23 11:13:36 +02:00
fanquake 12f7147c89
Merge #16570: tests: Make descriptor tests deterministic
b9ee63c71b Make descriptor test deterministic (David Reikher)

Pull request description:

  This is an improvement to a test, inspired by #14343 - removing non determinism from a test.

  The test `descriptor_test` is non-deterministic, as it relies on the `MaybeUseHInsteadOfApostrophy` function which randomly either swaps all apostrophes with 'h' or doesn't at all in a descriptor. This fix makes both cases always run, if an apostrophe is found in a test descriptor.
  This does not reduce test coverage but removes the non-determinism.

  Additionally, the `MaybeUseHInsteadOfApostrophy` function removed the checksum if found at the end of a descriptor when the apostrophes are swapped by 'h's, since after being swapped the checksum is no longer correct. I instead added re-calculation of the checksum using the `DescriptorChecksum` function, which adds coverage for the case of a descriptors having 'h's instead of apostrophes and a checksum. This was previously lacking.
  To achieve this I had to move `DescriptorChecksum` and `PolyMod` out of the anonymous namespace in descriptor.cpp to make `DescriptorChecksum` accessible in descriptor_tests.cpp.

  All tests complete successfully (functional as well as unit tests).

ACKs for top commit:
  achow101:
    Code Review ACK b9ee63c71b

Tree-SHA512: 992c73a6644a07bfe7c72301ee2666f3c4845a012aaedd7a099a05cea8bdac84fa8280b28e44a7856260c00c0be1a6f1b6768f5694c2a22edf4c489e53fec424
2019-08-23 08:02:35 +08:00
MarcoFalke 52b9797119
Merge #16670: util: Add Join helper to join a list of strings
faebf62714 rpc: Use Join helper in rpc/util (MarcoFalke)
fa8cd6f9c1 util: Add Join helper to join a list of strings (MarcoFalke)

Pull request description:

  We have a lot of enumerations in the code and sometimes those enumerations need to be mentioned in the RPC or command line documentation. Previously, each caller would have a couple of lines inline to join the strings or the joined string is hardcoded in the documentation. A helper to join strings would make code such as https://github.com/bitcoin/bitcoin/pull/16629#discussion_r315852446 less verbose and easier to read.

  Also, warnings commonly accumulate in complex RPCs, since a warning doesn't lead to an early return. A helper to join those warnings would make code such as https://github.com/bitcoin/bitcoin/pull/16394/files#r309324997 less verbose and easier to read.

ACKs for top commit:
  practicalswift:
    ACK faebf62714

Tree-SHA512: 80f2db86a05c63b686f510585c1c631250271a8958fd71fafaac91559ffd2ec25d609bf7d53412ba27f87eff5893ac9dd9c2f296fc0c73581556e1d6a734a36f
2019-08-22 08:41:00 -04:00
fanquake 868a8cea15
Merge #16674: refactor: remove obsolete qt algorithm usage
153d9dd9ac refactor: replace qLowerBound & qUpperBound with std:: upper_bound & lower_bound (fanquake)
59373e3e94 refactor: replace qSort with std::sort (fanquake)
fea33cbbdf refactor: replace qStableSort with std::stable_sort (fanquake)

Pull request description:

  `qStablesort`, `qSort`, `qLowerBound` and `qUpperBound` have been marked as obsolete since at least Qt 5.9: [Obsolete Members for QtAlgorithms](https://doc.qt.io/qt-5.9/qtalgorithms-obsolete.html).

  This pull request replaces their usage with the suggested `std::` replacements.

  This also removes some warning spam when compiling against newer Qt (5.13.0 via brew):
  ```bash
    CXX      qt/libbitcoinqt_a-walletcontroller.o
  qt/transactiontablemodel.cpp:96:52: warning: 'qLowerBound<QList<TransactionRecord>::iterator, uint256, TxLessThan>' is deprecated: Use std::lower_bound [-Wdeprecated-declarations]
          QList<TransactionRecord>::iterator lower = qLowerBound(
  qt/transactiontablemodel.cpp:98:52: warning: 'qUpperBound<QList<TransactionRecord>::iterator, uint256, TxLessThan>' is deprecated: Use std::upper_bound [-Wdeprecated-declarations]
          QList<TransactionRecord>::iterator upper = qUpperBound(
  ```

  ```bash
    CXX      qt/libbitcoinqt_a-moc_walletcontroller.o
  qt/bantablemodel.cpp:64:13: warning: 'qStableSort<QList<CCombinedBan>::iterator, BannedNodeLessThan>' is deprecated: Use std::stable_sort [-Wdeprecated-declarations]
              qStableSort(cachedBanlist.begin(), cachedBanlist.end(), BannedNodeLessThan(sortColumn, sortOrder));
  ```

  ```bash
    CXX      qt/libbitcoinqt_a-sendcoinsentry.o
  qt/recentrequeststablemodel.cpp:205:5: warning: 'qSort<QList<RecentRequestEntry>::iterator, RecentRequestEntryLessThan>' is deprecated: Use std::sort [-Wdeprecated-declarations]
      qSort(list.begin(), list.end(), RecentRequestEntryLessThan(column, order));
  ```

ACKs for top commit:
  hebasto:
    ACK 153d9dd9ac
  promag:
    ACK 153d9dd9ac.
  jonasschnelli:
    utACK 153d9dd9ac

Tree-SHA512: 22f7290ed798ce8b0f5f313405377845d4c8e48dc8687be7464e27fff53363b451a40e9e18910a8c3b4b9d4dcc236a366c92e7d171fcb8576c48f149a1886c26
2019-08-22 18:07:01 +08:00