Commit graph

10879 commits

Author SHA1 Message Date
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
Pieter Wuille 985c79552c Improve witness destination types and use them more 2018-01-03 05:43:06 -08:00
Pieter Wuille cbe197470e [refactor] GetAccount{PubKey,Address} -> GetAccountDestination 2018-01-03 05:42:57 -08:00
Wladimir J. van der Laan 5961b23898
Merge #12062: Increment MIT Licence copyright header year on files modified in 2017
595a7ba Increment MIT Licence copyright header year on files modified in 2017 (Akira Takizawa)

Pull request description:

  Edited via:

  $ contrib/devtools/copyright_header.py update .

  ps) It is the same commit as #9450

Tree-SHA512: 274bfcd6cf2914315ed52f6db773a68800ce9d6bd225a3142654483f0bbc3fd865009e62f9d954f65765d038c626e55d2a64e37e16843809adc2f67abe659b6d
2018-01-03 14:33:28 +01:00
Pieter Wuille 0c8ea6380c Abstract out IsSolvable from Witnessifier 2018-01-03 05:32:00 -08:00
251 0d663f8197 Fixes issue #12067 sendmany curl example is wrong.
This commit removes the escaped backslash and quote characters from the keys in the JSON object to make it a plain JSON object.
2018-01-02 20:53:30 +01:00
Akira Takizawa 595a7bab23 Increment MIT Licence copyright header year on files modified in 2017 2018-01-03 02:26:56 +09:00
251 6dda059bde [qt] Simplifies boolean expression model && model->haveWatchOnly()
The boolean expression model && model->haveWatchOnly() can be simplified to model->haveWatchOnly(), because if (!model || !model->getOptionsModel()) { return; } guards against a potential dereferenced null pointer.
2018-01-02 01:06:23 +01:00
251 bdb3231bee Implements a virtual destructor on the BaseRequestHandler class.
Implements a virtual destructor on the BaseRequestHandler class to protect against undefined behavior in
the event that a derived BaseRequestHandler class has a destructor and an object of such derived class
is destroyed through a pointer to its base class.
2017-12-29 16:20:28 +01:00
Jeff Rade aad309065d [rpc] Adding ::minRelayTxFee amount to getmempoolinfo and updating mempoolminfee help description 2017-12-29 08:56:44 -06:00
Pieter Wuille d9fdac130a
Merge #11824: Block ActivateBestChain to empty validationinterface queue
97d2b09c12 Add helper to wait for validation interface queue to catch up (Matt Corallo)
36137497f1 Block ActivateBestChain to empty validationinterface queue (Matt Corallo)
5a933cefcc Add an interface to get the queue depth out of CValidationInterface (Matt Corallo)
a99b76f269 Require no cs_main lock for ProcessNewBlock/ActivateBestChain (Matt Corallo)
a734896038 Avoid cs_main in net_processing ActivateBestChain calls (Matt Corallo)
66aa1d58a1 Refactor ProcessGetData in anticipation of avoiding cs_main for ABC (Matt Corallo)
818075adac Create new mutex for orphans, no cs_main in PLV::BlockConnected (Matt Corallo)

Pull request description:

  This should fix #11822.

  It ended up bigger than I hoped for, but its not too gnarly. Note that "
  Require no cs_main lock for ProcessNewBlock/ActivateBestChain" is mostly pure code-movement.

Tree-SHA512: 1127688545926f6099449dca6a4e6609eefc3abbd72f1c66e03d32bd8c7b31e82097d8307822cfd1dec0321703579cfdd82069cab6e17b1024e75eac694122cb
2017-12-29 01:51:23 -08:00
William Casarin 275b2eeed4 [qt] change µBTC to bits
* Now that we have bip176, change "µBTC" to the more colloquial "bits"

* We retain the `µBTC (bits)` description in dropdowns and status bars.
  The more concise "bits" is used when appended to numbers.

Signed-off-by: William Casarin <jb55@jb55.com>
2017-12-28 09:54:58 -08:00
Matt Corallo 97d2b09c12 Add helper to wait for validation interface queue to catch up 2017-12-26 11:56:00 -05:00
Matt Corallo 36137497f1 Block ActivateBestChain to empty validationinterface queue 2017-12-26 11:54:49 -05:00
Matt Corallo 5a933cefcc Add an interface to get the queue depth out of CValidationInterface 2017-12-26 11:54:49 -05:00
Matt Corallo a99b76f269 Require no cs_main lock for ProcessNewBlock/ActivateBestChain
This requires the removal of some very liberal (incorrect) cs_mains
sprinkled in some tests. It adds some chainActive.Tip() races, but
the tests are all single-threaded anyway.
2017-12-26 11:54:43 -05:00
Matt Corallo a734896038 Avoid cs_main in net_processing ActivateBestChain calls 2017-12-24 13:20:52 -05:00
Matt Corallo 66aa1d58a1 Refactor ProcessGetData in anticipation of avoiding cs_main for ABC 2017-12-24 13:08:38 -05:00
Matt Corallo fb6f6b1519 bluematt's testnet-seed now supports x9 (and is just a static list) 2017-12-24 11:47:19 -05:00
Wladimir J. van der Laan 5180a86c96
Merge #11517: Tests: Improve benchmark precision
760af84 Removed CCheckQueueSpeed benchmark (Martin Ankerl)
00721e6 Improved microbenchmarking with multiple features. (Martin Ankerl)

Pull request description:

  The benchmark's KeepRunning() used to make a function call for each call, inflating measurement times for short running code. This change inlines the critical code that is executed each run and moves the slow timer updates into a new function.

  This change increases the average runtime for Trig from 0.000000082339208 sec to 0.000000080948591.

Tree-SHA512: 36b3bc55fc9b1d4cbf526b7103af6af18e9783e6b8f3ad3adbd09fac0bf9401cfefad58fd1e6fa2615d3c4e677998f912f3323d61d7b00b1c660d581c257d577
2017-12-23 14:53:05 +01:00
Wladimir J. van der Laan 20166f8a44
Merge #11748: [Tests] Adding unit tests for GetDifficulty in blockchain.cpp.
3e1ee31 [Tests] Adding unit tests for GetDifficulty in blockchain.cpp. (sean)

Pull request description:

  blockchain.cpp has low unit test coverage. This commit is intended
  to start improving its code coverage to reasonable levels. One or more
  follow up commits will complete the task that this commit is starting
  (though the usefulness of this commit is not dependent upon later
  commits).

  Note that these tests were not written based upon a specification of how
  GetDifficulty *should* work, but rather how it actually *does* work. As
  a result, if there are any bugs in the current GetDifficulty
  implementation, these unit tests serve to lock them in rather than
  expose them.

  -- Why has blockchain.cpp been modified if this is a unit testing change?

  Since the existing GetDifficulty function relies on a global variable,
  chainActive, it was not suitable for unit testing purposes. Both the
  existing GetDifficulty function and the unit tests now call through to
  a new, more modular version of GetDifficulty that can work on any chain,
  not just chainActive.

  -- Why does blockchain_tests.cpp directly include blockchain.cpp instead
  of blockchain.h?

  While the new GetDifficulty function's signature is arguably better than
  the old one's, it still isn't great, and doesn't seem to warrant inclusion
  as part of the blockchain.h API, especially since only test code is
  directly using it. If a better way of exposing the new GetDifficulty
  function to unit tests exists, please mention it and the commit will be
  updated accordingly.

  -- Why is the test fixture named blockchain_difficulty_tests rather than
  blockchain_tests?

  The Bitcoin Core policy for naming unit test files is to match the the
  file under test ("blockchain" becomes "blockchain_tests"). While this
  commit complies with that, blockchain.cpp is a massive file, such that
  having all of the unit tests in one file will tend towards disorder.
  Since there will be a lot more tests added to this file, the intention
  is to divide up different types of tests into different test fixtures
  within the same file.

Tree-SHA512: a7dda9c2a9414d4819b4d2911f5637891dc19cecbecfc1463846161d2a78793151927a5ab911c69a5d3013f7668e75a1d78a65667cb9d83910cda439cbe84d62
2017-12-23 11:22:18 +01:00
Martin Ankerl 760af84072 Removed CCheckQueueSpeed benchmark
This benchmark's runtime was rather unpredictive on different machines, not really a useful benchmark.
2017-12-23 11:03:17 +01:00
Martin Ankerl 00721e69f8 Improved microbenchmarking with multiple features.
* inline performance critical code
* Average runtime is specified and used to calculate iterations.
* Console: show median of multiple runs
* plot: show box plot
* filter benchmarks
* specify scaling factor
* ignore src/test and src/bench in command line check script
* number of iterations instead of time
* Replaced runtime in BENCHMARK makro number of iterations.
* Added -? to bench_bitcoin
* Benchmark plotly.js URL, width, height can be customized
* Fixed incorrect precision warning
2017-12-23 11:03:17 +01:00
Wladimir J. van der Laan 9bad8d6472
Merge #11475: [rpc] mempoolinfo should take ::minRelayTxFee into account
149dffd [rpc] mempoolinfo should take ::minRelayTxFee into account (Cristian Mircea Messel)

Pull request description:

  Fixes #6941 following https://github.com/bitcoin/bitcoin/pull/11410#issuecomment-332991078 's suggestion

  This takes care of the mentioned ticket without changing the behavior of https://github.com/bitcoin/bitcoin/pull/11410/files#diff-24efdb00bfbe56b140fb006b562cc70bL629

  By modifying 5a9da37fb3/src/txmempool.cpp (L984) the syncing mempools becomes problematic as per https://github.com/bitcoin/bitcoin/pull/11410#issuecomment-333868390

  ~~Same code causes different tests to fail: https://travis-ci.org/bitcoin/bitcoin/jobs/286128241 https://travis-ci.org/bitcoin/bitcoin/jobs/286128241 . I can't reproduce the problems locally, am I doing something wrong?~~ travis sometimes fails unexpectedly

Tree-SHA512: fd81628da6a3eff51bd09e5342d781bac0710f79d6b330b1df3662756ecaceb2e1682bf9768b5f8edbcba6479a3223dfa6604d37c9e9d37d00d077172da4f6ea
2017-12-23 10:00:24 +01:00
Wladimir J. van der Laan f19ca129ff
Merge #11605: [Wallet] Enable RBF by default in QT
5cbbbd7 [Wallet] Use RBF by default in QT only (Sjors Provoost)

Pull request description:

  ~If there are no objections, this would supersede #11556.~

  Enabling RBF by default avoids the need to explain all possible use cases of RBF.

  This PR does not change the default RPC wallet behavior, as this could break implementations that depend on it and it's not clear what happens when automated services suddenly switch on RBF on a large scale.

  After trying various approaches, we settled on just having QT ignore `-walletrbf`.

  Send screen:
  <img width="388" alt="send" src="https://user-images.githubusercontent.com/10217/34251097-329c8dee-e63f-11e7-9e14-d7f55d2b52cc.png">

  Confirmation screen by default (with RBF):
  <img width="429" alt="rbf yes" src="https://user-images.githubusercontent.com/10217/32442799-f50d54aa-c2fc-11e7-9392-96339d0f1f74.png">

  Confirmation screen without RBF:
  <img width="431" alt="rf no" src="https://user-images.githubusercontent.com/10217/32442793-ef30bc34-c2fc-11e7-8ca2-e86a97175278.png">

Tree-SHA512: 53efb5d277144478143e69dcae8112c1b9c2beb981fdd0fe778592e5f7d5bf838f73d48052ead874586a75b944e8af469b25e5f376c135cf48cc3598e77f5891
2017-12-22 13:15:31 +01:00
Sjors Provoost 5cbbbd7143
[Wallet] Use RBF by default in QT only
GUI wallet uses RBF by default, regardless of -walletrbf.

RPC and debug console in the GUI remain unchanged; they don't
use RBF by default, unless launched with -walletrbf=1.
2017-12-22 09:18:05 +01:00
Wladimir J. van der Laan 711d16ca4a
Merge #11667: Add scripts to dumpwallet RPC
656fde5 Add script birthtime metadata to dump and import wallet (MeshCollider)
1bab9b2 Add script dump note to RPC help text and release notes (MeshCollider)
68c1e00 Add test for importwallet (MeshCollider)
9e1184d Add dumpwallet scripts test (MeshCollider)
ef0c730 Add scripts to importwallet RPC (MeshCollider)
b702ae8 Add CScripts to dumpwallet RPC (MeshCollider)
cdc260a Add GetCScripts to CBasicKeyStore (MeshCollider)

Pull request description:

  As discussed in https://github.com/bitcoin/bitcoin/pull/11289#issuecomment-334600457, adds the CScripts from the wallet to the `dumpwallet` RPC and then allows them to be imported with the `importwallet` RPC. Includes a basic test, and modifies the helptext of the dumpwallet RPC.

  Notes:
  - Reviewers: use `?w=1` to avoid the indentation-only change in commit `Add scripts to importwallet RPC `
  - currently the scripts are followed with `# addr=` comments just as the other keys are, unsure if this might confuse users into thinking all the scripts are for valid P2SH addresses though, but I don't think that should be an issue.
  - there are no birthtimes for scripts, so script imports don't affect rescans
  - `importwallet` imports the CScripts but I'm not sure how to approach specifying whether scripts are for P2SH addresses, BIP173 addresses, etc. whether that matters or not. Otherwise the RPC helptext might just need modification.

  Fixes #11715

Tree-SHA512: 36c55837b3a58b9d3499d4c0c2ae82153d62aa71919e751574651b63a1d2b8ecc83796db4553cc65dad9b5341c3a42ae2fcf4d62598c30af267f8e1461ba8272
2017-12-21 13:03:26 +01:00
MarcoFalke 604e08c83c
Merge #11726: Cleanups + nit fixes for walletdir PR
aac6b3f067 Update files.md for new wallets/ subdirectory (MeshCollider)
b67342906c Cleanups for walletdir PR (MeshCollider)

Pull request description:

  This addresses the remaining nits from https://github.com/bitcoin/bitcoin/pull/11466

  - Updates `doc/files.md` with respect to the new default wallet directory
  - Fixes @promag and @laanwj's error message nit, and Jonas' release notes nit
  - ~Addresses @laanwj's net-specific wallet subdirectory concern in the case that a walletdir is specified~
  - Changes the #includes from "" to <> style after #11651

Tree-SHA512: b86bf5fdc4de54c1b0f65b60a83af3cf82b35d216ce9c0de724803bfba6934796238b6c412659dcc29ae2e3e856d4eb97ae777c80f36f4089d8acecfddefe9aa
2017-12-20 17:37:57 -05:00
Wladimir J. van der Laan 79399c8cd0
Merge #10657: Utils: Improvements to ECDSA key-handling code
63179d0 Scope the ECDSA constant sizes to CPubKey / CKey classes (Jack Grigg)
1ce9f0a Ensure that ECDSA constant sizes are correctly-sized (Jack Grigg)
48abe78 Remove redundant `= 0` initialisations (Jack Grigg)
17fa391 Specify ECDSA constant sizes as constants (Jack Grigg)
e4a1086 Update Debian copyright list (Jack Grigg)
e181dbe Add comments (Jack Grigg)
a3603ac Fix potential overflows in ECDSA DER parsers (Jack Grigg)

Pull request description:

  Mostly trivial, but includes fixes to potential overflows in the ECDSA DER parsers.

  Cherry-picked from Zcash PR https://github.com/zcash/zcash/pull/2335

Tree-SHA512: 8fcbd51b0bd6723e5d33fa5d592f7cb68ed182796a9b837ecc8217991ad69d6c970258617dc00eb378c8caa4cec5d6b304d9d2c066acd40cda98e4da68e0caa4
2017-12-20 18:00:32 +01:00
Wladimir J. van der Laan bc66765144
Merge #11917: Add testnet DNS seed: seed.testnet.bitcoin.sprovoost.nl
f455a24 [net] add seed.testnet.bitcoin.sprovoost.nl to testnet DNS seeds (Sjors Provoost)

Pull request description:

  I tested it myself by:
  * `dig seed.testnet.bitcoin.sprovoost.nl`  (should have propagated by now, but if you only see two records with `A 66.111... ` try again later)
  * deleting the other seeds and all data in `.../testnet3`, recompiling and then starting the node. Log shows `21 addresses found from DNS seeds`.

  ACK https://github.com/bitcoin/bitcoin/blob/master/doc/dnsseed-policy.md

  I'm willing to keep it up and running at least throughout 2018, unless something bad happens.

  About my setup:
  * Amazon EC2 instance in Europe, running Ubuntu 16.04; I use this instance for some other chores, but only port 53 is world reachable (for mainnet I'd probably run a dedicated instance, and perhaps a location I have physical control over)
  * running [sipa/bitcoin-seeder](https://github.com/sipa/bitcoin-seeder) with default settings (and the non-root port redirect)
  * feedback about my domain / DNS setup is welcome, I can provide more details via private email

  I can use guidance on _Any hosting services contracted by the operator are equally expected to uphold these expectations_. Although I assume the requirements for testnet are less strict than for mainnet, in case I want to pursue the latter in the future: what unpleasant things can Amazon, my domain registrar and other intermediaries do? How would I mitigate that?

  Also note that The Netherlands passed some pretty onerous legislation creating uncertainty over what the secret service can compel people like myself to do. However these laws won't take effect before mid 2018, there's probably more interesting targets than myself to go after, and it's easier for them to just monitor all unencrypted P2P traffic everywhere, or monitor some intermediary I depend on.

  Any good tools for monitoring uptime?

Tree-SHA512: 386fe688e5006ab8352d93ab3954fc07dc566876ae002891baa51acfaa5bb113f51b1f5ca08c7394a530b10a2f5008c56d57153af3ed07544a305586dda06b97
2017-12-20 17:04:22 +01:00
Wladimir J. van der Laan d4e404a3af
Merge #11879: [tests] remove redundant univalue_tests.cpp
2862b56 [tests] remove redundant univalue_tests.cpp (John Newbery)

Pull request description:

  univalue unit tests were added in #4730 , and exist at `/src/test/univalue_tests.cpp` (outside the univalue tree). That test was brought into the univalue repository in https://github.com/bitcoin-core/univalue/pull/4 , which was pulled into the github repository in https://github.com/bitcoin/bitcoin/pull/11420.

  That means that the univalue test exists in two places:
  1. `/src/test/univalue_tests.cpp`
  2. `/src/univalue/test/object.cpp`

  (2) is a strict superset of (1). It adds some macros to work around boost not being a univalue dependency, and adds a few extra lines of test.

  Therefore remove `/src/test/univalue_tests.cpp`

Tree-SHA512: 3747b10bbf62e9f12363905488b29945ad559ddca68c5c03d8a362de612a51f408f41a04d3712c6889bfc1632fb1a5fa0d7df0fbf02c322b3981a6d698f501b0
2017-12-20 16:53:02 +01:00
Wladimir J. van der Laan 9ab9963386
Merge #11952: [qa] univalue: Bump subtree
88411e9 Squashed 'src/univalue/' changes from fe805ea74f..07947ff2da (MarcoFalke)

Pull request description:

  Pulls in the test changes to the univalue subtree.

  Beside looking at the code, reviewers should refer to https://github.com/bitcoin/bitcoin/blob/master/contrib/devtools/README.md#git-subtree-checksh on how to verify the subtree pull.

Tree-SHA512: 09493625a573dca1140570326ee90c1bb84e4893e1dab2cdd51bc23ae1fba1e33c43ed771ca9e112ac71b0242e8a8d058071334562c738d502587eadd5a0f114
2017-12-20 16:51:39 +01:00
MeshCollider 656fde53a3 Add script birthtime metadata to dump and import wallet 2017-12-20 20:24:37 +13:00
MeshCollider 1bab9b23af Add script dump note to RPC help text and release notes 2017-12-20 18:47:56 +13:00
MeshCollider ef0c730220 Add scripts to importwallet RPC 2017-12-20 18:47:56 +13:00
MeshCollider b702ae812c Add CScripts to dumpwallet RPC 2017-12-20 18:47:56 +13:00
MeshCollider cdc260afd5 Add GetCScripts to CBasicKeyStore 2017-12-20 18:47:55 +13:00
MarcoFalke fad349c507 univalue: Bump subtree 2017-12-19 16:44:57 -05:00
Matt Corallo 62e7c04fb8 Remove dead feeest-file read code for old versions
0.15.0 introduced a new feeest file format, and support for parsing
old versions was never fully added. We now simply fail to read the
old format, so remove the dead partial-implementation.
2017-12-19 11:19:28 -05:00
Wladimir J. van der Laan cdd6bbf10a
Merge #11273: Ignore old format estimation file
3a3a9f9 Ignore old format estimation file (Murch)

Pull request description:

  The fee estimation data format changed from 0.14.x to 0.15.0, so we should no longer read the old data. H/T @jnewbery, @morcos

  Pending testing.

Tree-SHA512: c8e3824dbdd8f6730133d5ad20b00995e9a63ab54431158a91e2f4d2aba5763b8aa698bce1fffca2713ba3a162e23d8fcd6e3efb9847b015c2e1e8725398150b
2017-12-19 17:09:59 +01:00
Sjors Provoost c8edc2c3cb
[docs] initial QT documentation, move Qt Creator instructions 2017-12-19 16:48:07 +01:00
Wladimir J. van der Laan 81c89e966e
Merge #11923: Wallet : remove unused fNoncriticalErrors variable from CWalletDB::FindWalletTx
ecf9b25 remove unused fNoncriticalErrors variable from CWalletDB::FindWalletTx (Pierre Rochard)

Pull request description:

  The `CWalletDB::FindWalletTx` method was patterned after `CWalletDB::LoadWallet`, where `fNoncriticalErrors` is used when a tx check fails in `ReadKeyValue`.

  Since `FindWalletTx` is only used by methods which are zapping txs, it makes sense that `ReadKeyValue` is not called and the tx is not checked, so I think that deleting the unused `fNoncriticalErrors` boolean variable and its conditional statement is appropriate.

Tree-SHA512: 0976eae97522719fdaeca1fb3f4a080561e46c06d0b8dc75e14262c6bc242998db3f7057183a230a1d7e4ac5fc348e9059f545b7d718ebbcdf6dcdfc63bcc286
2017-12-19 16:16:39 +01:00
Wladimir J. van der Laan 2971fd030f
Merge #11220: Check specific validation error in miner tests
12781db [Tests] check specific validation error in miner tests (Sjors Provoost)

Pull request description:

  ## Problem

  `BOOST_CHECK_THROW` merely checks that some `std::runtime_error` is
  thrown, but not which one.

  Here's an example of how this can cause a test to pass when a developer
  introduces a consensus bug. The test for the sigops limit assumes
  that `CreateNewBlock` fails with `bad-blk-sigops`. However it can
  also fail with bad-txns-vout-negative, if a naive developer lowers
  `BLOCKSUBSIDY` to `1*COIN`.

  ## Solution

  `BOOST_CHECK_EXCEPTION` allows an additional predicate function. This
  commit uses this for all exceptions that are checked for in
  `miner_tets.cpp`:
  * `bad-blk-sigops`
  * `bad-cb-multiple`
  * `bad-txns-inputs-missingorspent`
  * `block-validation-failed`

  If the function throws a different error, the test will fail. Although the message produced by Boost is a bit [confusing](http://boost.2283326.n4.nabble.com/Test-BOOST-CHECK-EXCEPTION-error-message-still-vague-tt4683257.html#a4683554), it does show which error was actually thrown. Here's what the above `1*COIN` bug would result in:

  <img width="1134" alt="schermafbeelding 2017-09-02 om 23 42 29" src="https://user-images.githubusercontent.com/10217/29998976-815cabce-9038-11e7-9c46-f5f6cfb0ca7d.png">

  ## Other considerations

  A more elegant solution in my opinion would be to subclass `std::runtime_error` for each `INVALID_TRANSACTION` type, but this would involve touching consensus code.

  I put the predicates in `test_bitcoin.h` because I assume they can be reused in other test files. However [serialize_tests.cpp](https://github.com/bitcoin/bitcoin/blob/v0.15.0rc3/src/test/serialize_tests.cpp#L245) also uses `BOOST_CHECK_EXCEPTION` and it defines the predicate in the test file itself.

  Instead of four `IsRejectInvalidReasonX(std::runtime_error const& e)` functions, I'd prefer something reusable like `bool IsRejectInvalidReason(String reason)(std::runtime_error const& e)`, which would be used like `BOOST_CHECK_EXCEPTION(functionThatThrows(), std::runtime_error, IsRejectInvalidReason("bad-blk-sigops")`. I couldn't figure out how to do that in C++.

Tree-SHA512: e364f19b4ac19f910f6e8d6533357f57ccddcbd9d53dcfaf923d424d2b9711446d6f36da193208b35788ca21863eadaa7becd9ad890334d334bccf8c2e63dee1
2017-12-19 13:06:01 +01:00
Wladimir J. van der Laan fee0370fd6
Merge #11178: Add iswitness parameter to decode- and fundrawtransaction RPCs
6f39ac0 Add test for decoderawtransaction bool (MeshCollider)
bbdbe80 Add iswitness parameter to decode- and fundrawtransaction RPCs (MeshCollider)

Pull request description:

  Suggested in https://github.com/bitcoin/bitcoin/pull/10481#issuecomment-325244946, this adds the option to explicitly choose whether a serialized transaction should be decoded as a witness or non-witness transaction rather than relying on the heuristic checks in #10481. The parameter defaults to relying on #10481 if not included, but it overrides that if included.

Tree-SHA512: d4846a5bb7d64dc19c516445488b00af329fc1f4181d9dfdf9f2382a086568edc98250a4ac7594e24a1bc231dfdee53c699b12c8380c355b920a67cc6770b7a9
2017-12-19 09:55:11 +01:00
Pierre Rochard ecf9b25a03 remove unused fNoncriticalErrors variable from CWalletDB::FindWalletTx 2017-12-17 11:01:23 -05:00
Sjors Provoost f455a24da7
[net] add seed.testnet.bitcoin.sprovoost.nl to testnet DNS seeds 2017-12-16 16:48:48 +01:00
Matt Corallo 818075adac Create new mutex for orphans, no cs_main in PLV::BlockConnected
This should (marginally) speed up validationinterface queue
draining by avoiding a cs_main lock in one client.
2017-12-15 15:27:45 -05:00
Wladimir J. van der Laan df71819524
Merge #11886: Clarify getbalance meaning a tiny bit in response to questions.
c79d73d Clarify getbalance meaning a tiny bit in response to questions. (Matt Corallo)

Pull request description:

  Someone was asking why getbalance "*" was more "correct" than getbalance, which should rarely be true...spendzeroconfchange was the issue.

Tree-SHA512: 90201cad1acec5161aee469fb4c6d737a0eb90f8380ac93abf0e41e0f02d120afcc3e2e873e5096d3655bb63bbd16fe99e72452f308d72e69139c7f6bb2d745e
2017-12-15 13:53:07 +01:00
Wladimir J. van der Laan 8585bb8f05
Merge #11616: Update ban-state in case of dirty-state during periodic sweep
57ac471 Call BannedListChanged outside of cs_setBanned lock (Jonas Schnelli)
c853812 Update ban-state in case of dirty-state during periodic sweep (Jonas Schnelli)

Pull request description:

  We do currently not update the UI during periodic ban list sweeps (via dump banlist).
  Fixes #11612

Tree-SHA512: bffbdcc03c63042177bdd511b0a9187c211c2b5011178481e8ee3e43a71eef1e4cd6b72f73672babab142b644f62f8b56f0aac1d26d3f19372b1f8644fec9395
2017-12-15 10:43:34 +01:00
Wladimir J. van der Laan c66adb286a
Merge #10839: Don't use pass by reference to const for cheaply-copied types (bool, char, etc.)
99ba0c3 Don't use pass by reference to const for cheaply-copied types (bool, char, etc.). (practicalswift)

Pull request description:

  Don't use pass by reference to const for cheaply-copied types (`bool`, `char`, etc.).

Tree-SHA512: ccad5e2695dff0b3d6de3e713ff3448f2981168cdac72d73bee10ad346b9919d8d4d588933369e54657a244b8b222fa0bef919bc56d983e1fa64b2004e51b225
2017-12-14 18:28:01 +01:00
Wladimir J. van der Laan 66479c0e61
Merge #11884: Remove unused include in hash.cpp
3f09e03 Remove unused include in hash.cpp (Karl-Johan Alm)

Pull request description:

Tree-SHA512: 543a72656460fba1c5498a0b85c49601d9b0399a4ecc49f4acf4715c258918da729df388e3be724c3161438e903ee16ad3c50626a71483aa6d85ffdbb827742d
2017-12-14 17:01:05 +01:00
Wladimir J. van der Laan 2ae58d5bfb
Merge #11864: Make CWallet::FundTransaction atomic
03a5dc9 [wallet] Make CWallet::FundTransaction atomic (João Barbosa)
95d4450 [wallet] Tidy up CWallet::FundTransaction (João Barbosa)

Pull request description:

  This PR fixes a race for `setLockedCoins` when `lockUnspents` is true. For instance, it should not be possible to use the same unspent in concurrent `fundrawtransaction` calls.

  Now the `cs_main` and `cs_wallet` locks are held during `CreateTransaction` and `LockCoin`(s). Also added some style nits around the change.

Tree-SHA512: ccf383c0c5f6db775655a3e9ccd200c3bd831a83afae2b7c389564c74f7227f5bea86a4775727de2c3603b188f383f8a12d3f9d6d94f7887865c31c94ce95ef6
2017-12-14 10:38:20 +01:00
João Barbosa 03a5dc9c3c [wallet] Make CWallet::FundTransaction atomic 2017-12-14 03:18:29 +00:00
João Barbosa 95d4450a41 [wallet] Tidy up CWallet::FundTransaction 2017-12-14 03:17:58 +00:00
Matt Corallo c79d73dc94 Clarify getbalance meaning a tiny bit in response to questions. 2017-12-13 12:18:33 -05:00
Wladimir J. van der Laan d4991c0cbb
Merge #11877: Improve createrawtransaction functional tests
88af502 test: Add createrawtransaction functional tests (João Barbosa)
27c6199 test: Add multidict to support dictionary with duplicate key (laanwj) (João Barbosa)
320669a rpc: Validate replaceable type in createrawtransaction (João Barbosa)

Pull request description:

  This was motivated by the `Invalid parameter, duplicated address` test.

  Credit to @laanwj for `multidict` implementation.

Tree-SHA512: a87139ae11004b73b467db1e8a072b75e23a0622b173a5668eed383b3575d8abc709817ddd2dfdc53f55afc90750fb61331199ad5de38c1ef6d482f2bc220f74
2017-12-13 17:34:08 +01:00
Wladimir J. van der Laan 68e021e3a3
Merge #11558: Minimal code changes to allow msvc compilation
fbf327b Minimal code changes to allow msvc compilation. (Aaron Clauson)

Pull request description:

  These changes are required to allow the Bitcoin source to build with Microsoft's C++ compiler (#11562 is also required).

  I looked around for a better place for the typedef of ssize_t which is in random.h. The best candidate looks like src/compat.h but I figured including that header in random.h is a bigger change than the typedef. Note that the same typedef is in at least two other places including the OpenSSL and Berkeley DB headers so some of the Bitcoin code already picks it up.

Tree-SHA512: aa6cc6283015e08ab074641f9abdc116c4dc58574dc90f75e7a5af4cc82946d3052370e5cbe855fb6180c00f8dc66997d3724ff0412e4b7417e51b6602154825
2017-12-13 14:05:25 +01:00
Karl-Johan Alm 3f09e03e0f
Remove unused include in hash.cpp 2017-12-13 20:08:49 +09:00
MeshCollider b67342906c Cleanups for walletdir PR 2017-12-13 23:36:43 +13:00
Wladimir J. van der Laan ba2f19504c
Merge #11363: net: Split socket create/connect
3830b6e net: use CreateSocket for binds (Cory Fields)
df3bcf8 net: pass socket closing responsibility up to caller for outgoing connections (Cory Fields)
9e3b2f5 net: Move IsSelectableSocket check into socket creation (Cory Fields)
1729c29 net: split socket creation out of connection (Cory Fields)

Pull request description:

  Requirement for #11227.

  We'll need to create sockets and perform the actual connect in separate steps, so break them up.

  #11227 adds an RAII wrapper around connection attempts, as a belt-and-suspenders in case a CloseSocket is missed.

Tree-SHA512: de675bb718cc56d68893c303b8057ca062c7431eaa17ae7c4829caed119fa3f15b404d8f52aca22a6bca6e73a26fb79e898b335d090ab015bf6456cf417fc694
2017-12-13 05:42:32 +01:00
Cory Fields 3830b6e065 net: use CreateSocket for binds 2017-12-12 15:25:25 -05:00
Cory Fields df3bcf89e4 net: pass socket closing responsibility up to caller for outgoing connections
This allows const references to be passed around, making it clear where the
socket may and may not be invalidated.
2017-12-12 15:25:25 -05:00
Cory Fields 9e3b2f576b net: Move IsSelectableSocket check into socket creation
We use select in ConnectSocketDirectly, so this check needs to happen before
that.

IsSelectableSocket will not be relevant after upcoming changes to remove select.
2017-12-12 15:25:25 -05:00
Cory Fields 1729c29ded net: split socket creation out of connection
Also, check for the correct error during socket creation
2017-12-12 15:25:25 -05:00
Wladimir J. van der Laan ef8ba7d73a
Merge #11870: wallet: Remove unnecessary mempool lock in ReacceptWalletTransactions
5b25293 wallet: Remove unnecessary mempool lock in ReacceptWalletTransactions (João Barbosa)

Pull request description:

Tree-SHA512: 13b922c6c9b5ca95a77742050f449366b80bdd7819c34e7ca09af8a4bd68085f4d0c6e0cde119c403f661499f97f2c465071a8047a7d794268e8d2dfe909e6d5
2017-12-12 20:26:55 +01:00
Wladimir J. van der Laan 22149540f9
Merge #11854: Split up key and script metadata for better type safety
9c8eca7 Split up key and script metadata for better type safety (Russell Yanofsky)

Pull request description:

  Suggested by @TheBlueMatt
  https://github.com/bitcoin/bitcoin/pull/11403#discussion_r155599383

  Combining the maps was probably never a good arrangement but is more
  problematic now in presence of WitnessV0ScriptHash and WitnessV0KeyHash types.

Tree-SHA512: 9263e9c01090fb49221e91d88a88241a9691dda3e92d86041c8e284306a64d3af5e2438249f9dcc3e6e4a5c11c1a89f975a86d55690adf95bf2636f15f99f92a
2017-12-12 19:57:43 +01:00
John Newbery 2862b562cc [tests] remove redundant univalue_tests.cpp 2017-12-12 12:45:53 -05:00
João Barbosa 320669a363 rpc: Validate replaceable type in createrawtransaction 2017-12-12 14:57:03 +00:00
Wladimir J. van der Laan 5d132e8b97
Merge #10574: Remove includes in .cpp files for things the corresponding .h file already included
a720b92 Remove includes in .cpp files for things the corresponding .h file already included (practicalswift)

Pull request description:

  Remove includes in .cpp files for things the corresponding .h file already included.

  Example case:
  * `addrdb.cpp` includes `addrdb.h` and `fs.h`
  * `addrdb.h` includes `fs.h`

  Then remove the direct inclusion of `fs.h` in `addrman.cpp` and rely on the indirect inclusion of `fs.h` via the included `addrdb.h`.

  In line with the header include guideline (see #10575).

Tree-SHA512: 8704b9de3011a4c234db336a39f7d2c139e741cf0f7aef08a5d3e05197e1e18286b863fdab25ae9638af4ff86b3d52e5cab9eed66bfa2476063aa5c79f9b0346
2017-12-12 14:56:25 +01:00
Wladimir J. van der Laan 214046f69b
Merge #10279: Add a CChainState class to validation.cpp to take another step towards clarifying internal interfaces
22fddde Avoid calling GetSerializeSize on each tx in a block if !fTxIndex (Matt Corallo)
2862aca Move some additional variables into CChainState private (Matt Corallo)
fd4d80a Create initial CChainState to hold chain state information (Matt Corallo)
e104f0f Move block writing out of AcceptBlock (Matt Corallo)
50701ba Move txindex/undo data disk location stuff out of ConnectBlock (Matt Corallo)
93a34cf Make DisconnectBlock unaware of where undo data resides on disk (Matt Corallo)

Pull request description:

  CChainState should eventually, essentially, be our exposed "libconsensus", but we're probably a few releases away, so the real goal is to clarify our internal interfaces. The main split was a big step, but validation.cpp is still a somewhat ranomly-mixed bag of functions that are pure functions which validate inputs (which should probably either merge with their callers or move into another file in consensus/), read/write data from disk, manipulate our current chain state (which moves into CChainState), and do mempool transaction validation.

  Obviously this is only a small step, but some effort is made to clean up what functions the functions in CChainState call, and obviously as things are added its easy to keep clear "CChainState::* cannot call anything except via callbacks through CValidationInterface, pure functions, or disk read/write things". Right now there are some glaring violations in mempool callbacks, and general flushing logic needs cleaning up (FlushStateToDisk maybe shouldnt be called, and there should be an API towards setDirtyBlockIndex, but I'll leave that for after @sipa's current changesets land).

Tree-SHA512: 69b8ec191b36b19c9492b4dee74c8057621fb6ec98ad219e8da0b2ed5c3ad711b10b5af9ff1117e8807ccf88918eeeab573be8448baecc9a59f099c53095985b
2017-12-12 14:36:57 +01:00
Wladimir J. van der Laan d48ab83f00
Merge #11831: Always return true if AppInitMain got to the end
07c4838 Always return true if AppInitMain got to the end (Matt Corallo)

Pull request description:

  This should fix a rare zapwallettxes failure on travis, but also
  avoids having init operations (re-adding wallet transactions to
  mempool) running after RPC is free'd.

  I believe this was the failure at https://travis-ci.org/bitcoin/bitcoin/jobs/311747844 (from #11605).

Tree-SHA512: f0fea8c1b9265e2eeda57043d541380a3e58e4d9388fa24628a52fd56324257fcd7df0ca02e8f77f66fadd68d951893bab0f610ed9fd0a89b2ccd6bad1efa351
2017-12-12 10:27:53 +01:00
Wladimir J. van der Laan c0902624b0
Merge #10699: Make all script validation flags backward compatible
01013f5 Simplify tx validation tests (Pieter Wuille)
2dd6f80 Add a test that all flags are softforks (Pieter Wuille)
2851b77 Make all script verification flags softforks (Pieter Wuille)

Pull request description:

  This change makes `SCRIPT_VERIFY_UPGRADABLE_NOPS` not apply to `OP_CHECKLOCKTIMEVERIFY` and `OP_CHECKSEQUENCEVERIFY`. This is a no-op as `UPGRADABLE_NOPS` is only set for mempool transactions, and those always have `SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY` and `SCRIPT_VERIFY_CHECKSEQUENCEVERIFY` set as well. The advantage is that setting more flags now always results in a reduction in acceptable scripts (=softfork).

  This results in a nice and testable property for validation, for which a new test is added.

  This also means that the introduction of a new definition for a NOP or witness version will likely need the following procedure (example OP_NOP8 here)
  * Remove OP_NOP8 from being affected by `SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS`.
  * Add a `SCRIPT_VERIFY_DISCOURAGE_NOP8`, which only applies to `OP_NOP8`.
  * Add a `SCRIPT_VERIFY_NOP8` which implements the new consensus logic.
  * Before activation, add `SCRIPT_VERIFY_DISCOURAGE_NOP8` to the mempool flags.
  * After activation, add `SCRIPT_VERIFY_NOP8` to both the mempool and consensus flags.

Tree-SHA512: d3b4538986ecf646aac9dba13a8d89318baf9e308e258547ca3b99e7c0509747f323edac6b1fea4e87e7d3c01b71193794b41679ae4f86f6e11ed6be3fd62c72
2017-12-12 10:11:00 +01:00
Wladimir J. van der Laan 0e722e8879
Merge #11516: crypto: Add test cases covering the relevant HMAC-SHA{256,512} key length boundaries
a3f5657 Add test cases covering the relevant key length boundaries: 64 bytes +/- 1 byte for HMAC-SHA256 and 128 bytes +/- 1 byte for HMAC-SHA512 (practicalswift)

Pull request description:

  * Add test cases covering the relevant key length boundaries: 64 bytes +/- 1 byte for HMAC-SHA256 and 128 bytes +/- 1 byte for HMAC-SHA512.
  * ~~Avoid creating a one-past-the-end pointer in the case of key length 64 (HMAC-SHA256) and key length 128 (HMAC-SHA512).~~
  * ~~Avoid performing a noop memset call (zero length argument) in the case of key length 64 (HMAC-SHA256) and key length 128 (HMAC-SHA512).~~

Tree-SHA512: 48ff9ab79d41aab97b5b8f6496cc08a39955a07eb424f74ada6440d3b168b6204d3527fa677e175c47e40142f9d62c7456ae162e5a2f5b557e90fb353beef1d0
2017-12-12 09:57:12 +01:00
João Barbosa 5b25293436 wallet: Remove unnecessary mempool lock in ReacceptWalletTransactions 2017-12-11 23:43:31 +00:00
Wladimir J. van der Laan 37ffa16933
Merge #11583: Do not make it trivial for inbound peers to generate log entries
be9f38c Do not make it trivial for inbound peers to generate log entries (Matt Corallo)

Pull request description:

  Based on #11580 because I'm lazy.

  We should generally avoid writing to debug.log unconditionally for
  inbound peers which misbehave (the peer being about to be banned
  being an exception, since they cannot do this twice).

Tree-SHA512: 8e59c8d08d00b1527951b30f4842d010a4c2fc440503ade112baa2c1b9afd0e0d1c5c2df83dde25183a242af45089cf9b9f873b71796771232ffb6c5fc6cc0cc
2017-12-11 17:06:22 +01:00
Wladimir J. van der Laan 8ab6c0b09e
Merge #11839: don't attempt mempool entry for wallet transactions on startup if alr…
6697a70 add test for unconfirmed balance between restarts (Gregory Sanders)
6ba8f30 don't attempt mempool entry for wallet transactions on startup if already in mempool (Gregory Sanders)

Pull request description:

  …eady in mempool

  Mempool loads first, wallet second. Second attempt fails, marking that transaction !fInMempool. Those funds will disappear until confirmation is reached.

Tree-SHA512: 955f0565ec1dc1ba395e0b803a98c07b7cd00c8cac5ec618ed832fed259a856fb7bbbe41310cf6a4e43c0435e09b156109d2a4467d403811dc8379d2caebeede
2017-12-11 16:21:03 +01:00
Gregory Sanders 6ba8f30e7b don't attempt mempool entry for wallet transactions on startup if already in mempool 2017-12-11 09:08:54 -05:00
Wladimir J. van der Laan 59d3dc85b6
Merge #11740: Implement BIP159 NODE_NETWORK_LIMITED (pruned peers) *signaling only*
de74c62 [Doc] Update bip.md, add support for BIP 159 (Jonas Schnelli)
e054d0e [QA] Add node_network_limited test (Jonas Schnelli)
bd09416 Avoid leaking the prune height through getdata (fingerprinting countermeasure) (Jonas Schnelli)
27df193 Always set NODE_NETWORK_LIMITED bit (Jonas Schnelli)
7caba38 Add NODE_NETWORK_LIMITED flags and min block amount constants (Jonas Schnelli)

Pull request description:

  Extracted from #10387.
  Does implement BIP159, but only the signalling part. No connections are made to NODE_NETWORK_LIMITED in this PR.

  The address relay and connection work (the more complicated part) can then be separated (probably in #10387).

Tree-SHA512: e3218eb4789a9320b0f42dc10f62d30c13c49bdef00443fbe653bee22933477adcfc1cf8f6a95269324560b5721203ed41f3c5e2dd8a98ec2791f6a9d8346b1a
2017-12-09 08:38:36 +01:00
Russell Yanofsky 9c8eca7704 Split up key and script metadata for better type safety
Suggested by Matt Corallo <git@bluematt.me>
https://github.com/bitcoin/bitcoin/pull/11403#discussion_r155599383

Combining the maps was probably never a good arrangement but is more
problematic now in presence of WitnessV0ScriptHash and WitnessV0KeyHash types.
2017-12-08 12:50:46 -05:00
Wladimir J. van der Laan 4ef4dfebbc
Merge #11847: Make boost::multi_index comparators const
1ec0c0a Make boost::multi_index comparators const (Suhas Daftuar)

Pull request description:

  This fixes compatibility with boost 1.66.

  Fixes #11837

Tree-SHA512: 3181336fcc159aa7ee70c843d76f2a063e4a401f427c218d7f856a3548ca70eaf8eee9d20abb73be259a5656273d3a65aa748e946e09cf656de5f50e6d4eb880
2017-12-07 18:37:43 +01:00
Wladimir J. van der Laan 80f9dad0b7
Merge #11809: gui: Fix proxy setting options dialog crash
f05d349 gui: Fix proxy setting options dialog crash (Wladimir J. van der Laan)

Pull request description:

  This fixes a crash bug when opening the options dialog.

  - Check the return value of split() to avoid segmentation faults due to   out of bounds when the user manages to enter invalid proxy settings.  This is reported resonably often.

  - Move the default proxy/port to a constant instead of hardcoding magic values.

  - Factor out some common code.

  - Revert #11448 because this proves a more robust replacement, it is no longer necessary and didn't generally solve the issue.

  No attempt is made to do full sanity checking on the proxy, so it can still be rejected by the core with an InitError message.

Tree-SHA512: 72b700b7d6c4d3e3410f0c60e9e4facf93d7c6c1a1b6b23957c48b074a045970f518166952859d1ebca8620062cb70d222670a7310bbd6fe50550ec6d04417b5
2017-12-07 17:40:11 +01:00
Wladimir J. van der Laan 3e50024120
Merge #11838: qa: Add getrawtransaction in_active_chain=False test
fa4c16d qa: Add getrawtransaction in_active_chain=False test (MarcoFalke)

Pull request description:

  #10275 accidentally forgot to add a test for `in_active_chain==False`.

  This adds a test and also removes the special casing of `blockhash.IsNull()`, which makes no sense imo.

Tree-SHA512: 6c51295820b3dcd53b0b48020ab2b8c8f5864cd5061ddab2b35d35d643eb3e60ef95ff20c06c985a2e47f7080e82f27f3e00ee61c85dce627776d5ea6febee8f
2017-12-07 17:37:32 +01:00
Wladimir J. van der Laan f05d349887 gui: Fix proxy setting options dialog crash
This fixes a crash bug when opening the options dialog.

- Check the return value of split() to avoid segmentation faults due to
  out of bounds when the user manages to enter invalid proxy settings.
  This is reported resonably often.

- Move the default proxy/port to a constant instead of hardcoding magic
  values.

- Factor out some common code.

- Revert #11448 because this proves a more robust replacement, it is no
  longer necessary and didn't generally solve the issue.

No attempt is made to do full sanity checking on the proxy, so it can
still be rejected by the core with an InitError message.
2017-12-07 17:34:16 +01:00
Suhas Daftuar 1ec0c0a01c Make boost::multi_index comparators const
This fixes compatibility with boost 1.66
2017-12-07 10:06:38 -05:00
Wladimir J. van der Laan 7630a1fe9a
Merge #11829: Test datadir specified in conf file exists
529b866 Test datadir in conf file exists (MeshCollider)

Pull request description:

  Provoked by Nick ODell's discovery here: https://bitcoin.stackexchange.com/questions/64189/when-running-bitcoind-i-keep-getting-boostfilesystemspace-operation-not-p/64210#64210

  If a custom data directory is specified using `-datadir` argument, its existence is checked before the conf file is loaded. But if the conf file then specifies a different non-existent `datadir`, that isn't tested, and results in esoteric errors like:

      EXCEPTION: N5boost10filesystem16filesystem_errorE
      boost::filesystem::space: Operation not permitted

  This just adds a check for the datadir existence at the end of `ReadConfigFile()`

Tree-SHA512: e488618c40aa356263f94040ae00aa4be98038abef66e8674b01032d22a5553a7fafcb8fe2d1f095865b39fb138c07b7a94415a00ef837573f92f95af065f712
2017-12-07 14:09:09 +01:00
MarcoFalke fa4c16d2e7 qa: Add getrawtransaction in_active_chain=False test 2017-12-06 11:00:08 -05:00
Wladimir J. van der Laan 497d0e014c
Merge #10275: [rpc] Allow fetching tx directly from specified block in getrawtransaction
434526a [test] Add tests for getrawtransaction with block hash. (Karl-Johan Alm)
b167951 [rpc] Allow getrawtransaction to take optional blockhash to fetch transaction from a block directly. (Karl-Johan Alm)
a5f5a2c [rpc] Fix fVerbose parsing (remove excess if cases). (Karl-Johan Alm)

Pull request description:

  [Reviewer hint: use [?w=1](https://github.com/bitcoin/bitcoin/pull/10275/files?w=1) to avoid seeing a bunch of indentation changes.]

  Presuming a user knows the block hash of the block containing a given transaction, this PR allows them to fetch the raw transaction, even without `-txindex`. It also enables support for getting transactions that are in orphaned blocks.

  Note that supplying a block hash will override mempool and txindex support in `GetTransaction`. The rationale behind this is that a transaction may be in multiple places (orphaned blocks) and if the user supplies an explicit block hash it should be adhered to.

  ```Bash
  $ # a41.. is a tx inside an orphan block ..3c6f.. -- first try getting it normally
  $ ./bitcoin-cli getrawtransaction a41e66ee1341aa9fb9475b98cfdc1fe1261faa56c0a49254f33065ec90f7cd79 1
  error code: -5
  error message:
  No such mempool transaction. Use -txindex to enable blockchain transaction queries. Use gettransaction for wallet transactions.
  $ # now try with block hash
  $ ./bitcoin-cli getrawtransaction a41e66ee1341aa9fb9475b98cfdc1fe1261faa56c0a49254f33065ec90f7cd79 1 0000000000000000003c6fe479122bfa4a9187493937af1734e1e5cd9f198ec7
  {
    "hex": "01000000014e7e81144e42f6d65550e59b715d470c9301fd7ac189[...]90488ac00000000",
    "inMainChain": false,
    "txid": "a41e66ee1341aa9fb9475b98cfdc1fe1261faa56c0a49254f33065ec90f7cd79",
    "hash": "a41e66ee1341aa9fb9475b98cfdc1fe1261faa56c0a49254f33065ec90f7cd79",
    "size": 225,
  [...]
  }
  $ # another tx 6c66... in block 462000
  $ ./bitcoin-cli getrawtransaction 6c66b98191e9d6cc671f6817142152ebf6c5cab2ef008397b5a71ac13255a735 1 00000000000000000217f2c12922e321f6d4aa933ce88005a9a493c503054a40
  {
    "hex": "0200000004d157[...]88acaf0c0700",
    "inMainChain": true,
    "txid": "6c66b98191e9d6cc671f6817142152ebf6c5cab2ef008397b5a71ac13255a735",
    "hash": "6c66b98191e9d6cc671f6817142152ebf6c5cab2ef008397b5a71ac13255a735",
    "size": 666,
  [...]
  }
  $
  ```

Tree-SHA512: 279be3818141edd3cc194a9ee65929331920afb30297ab2d6da07293a2d7311afee5c8b00c6457477d9f1f86e86786a9b56878ea3ee19fa2629b829d042d0cda
2017-12-06 12:10:21 +01:00
Jonas Schnelli bd09416524
Avoid leaking the prune height through getdata (fingerprinting countermeasure) 2017-12-05 11:08:34 -10:00
Jonas Schnelli 27df193efd
Always set NODE_NETWORK_LIMITED bit
The current pruning implementation does ensure to always conform to BIP159
2017-12-05 11:03:59 -10:00
Jonas Schnelli 7caba38568
Add NODE_NETWORK_LIMITED flags and min block amount constants 2017-12-05 11:03:59 -10:00
Matt Corallo 07c483895d Always return true if AppInitMain got to the end
This should fix a very rare travis failure in zapwallettxes, but
is also more correct, as you can currently race
ReacceptWalletTransactions with stop RPC calls to get bitcoind to
(IMO) eroneously return a non-0 exit code.
2017-12-05 10:39:44 -05:00
MeshCollider 529b866759 Test datadir in conf file exists 2017-12-06 00:24:06 +13:00
Jonas Schnelli 91eeaa0335
Merge #11556: [Qt] Improved copy for RBF checkbox and tooltip
db0b7373f [Qt] Improved copy: RBF checkbox, tooltip and confirmation screen (Sjors Provoost)

Pull request description:

  Fixes #11344 and replaces #11428.

  **Before**:
  <img width="588" alt="before" src="https://user-images.githubusercontent.com/10217/31984211-3299e81a-b993-11e7-94e9-bf63d2fed4bd.png">

  **After**:
  <img width="578" alt="after" src="https://user-images.githubusercontent.com/10217/31984404-11f839da-b994-11e7-86ad-4c17a7d44b86.png">

Tree-SHA512: 04876b2f2eab53c8d4fd4279e8384fd4869af7e15de7648b2689092f800b6ae9c890c01c26c2f7deffe79a1d70c6440d702cbe420e44fe3ded25c5b83d44ecfa
2017-12-04 21:30:25 -10:00
Karl-Johan Alm b167951677
[rpc] Allow getrawtransaction to take optional blockhash to fetch transaction from a block directly. 2017-12-05 11:03:24 +09:00
Wladimir J. van der Laan 24df9af816
Merge #11781: Add -debuglogfile option
5a7c09a test: Add tests for `-debuglogfile` with subdirs (Anthony Towns)
4158734 doc: Update release notes for `-debuglogfile` (Wladimir J. van der Laan)
2323242 test: Add test for `-debuglogfile` (Wladimir J. van der Laan)
cf5f432 Add `-debuglogfile` option (Wladimir J. van der Laan)

Pull request description:

  This patch adds an option to configure the name and/or directory of the debug log file.

  The user can specify either a relative path, in which case the path is relative to the (network specific) data directory. They can also specify an absolute path to put the log anywhere else in the file system.

  Alternative to #11741 that gets rid of the concept of a "log directory" by specifying the path for the specific kind of log, the debug log. Which happens to be the only kind of log we have at this point*, but a hypothetical new kind of log (say, an audit log) would get a new option. This has more flexibility than specifying a directory which has to contain all of them.

  \* excluding `db.log` which is internally generated by the wallet database library, but that one moves along with `-walletdir`.

Tree-SHA512: 4434d0e598dc23504e5c9e67fdbaef56db4f0fd490f9f54fd503e69d4dda9b5b69c539e1794ed841e72161b7b1dc3374d2f1193dd431b057566750e56fd8f24b
2017-12-04 18:55:17 +01:00
Matt Corallo 22fdddeabb Avoid calling GetSerializeSize on each tx in a block if !fTxIndex 2017-12-04 09:39:21 -05:00
Matt Corallo 2862aca40f Move some additional variables into CChainState private 2017-12-04 09:39:20 -05:00
Matt Corallo fd4d80a2f8 Create initial CChainState to hold chain state information 2017-12-04 09:34:46 -05:00
Matt Corallo e104f0fb7e Move block writing out of AcceptBlock 2017-12-04 09:33:10 -05:00
Matt Corallo 50701ba5fc Move txindex/undo data disk location stuff out of ConnectBlock 2017-12-04 09:33:10 -05:00
Matt Corallo 93a34cfeec Make DisconnectBlock unaware of where undo data resides on disk 2017-12-04 09:33:10 -05:00