Commit graph

13668 commits

Author SHA1 Message Date
John Newbery
5c759c73b2 [wallet] Move maxTxFee to wallet
This commit moves the maxtxfee setting to the wallet. There is only
one minor behavior change:

- an error message in feebumper now refers to -maxtxfee instead of
maxTxFee.
2019-04-18 11:34:42 -04:00
James O'Beirne
89e8df1674 tests: fix outdate include in blockfilter_index_tests 2019-04-18 10:25:47 -04:00
MarcoFalke
e4beef611a
Merge #14121: Index for BIP 157 block filters
c7efb652f3 blockfilter: Update BIP 158 test vectors. (Jim Posen)
19308c9e21 rpc: Add getblockfilter RPC method. (Jim Posen)
ff35105096 init: Add CLI option to enable block filter index. (Jim Posen)
accc8b8b18 index: Access functions for global block filter indexes. (Jim Posen)
2bc90e4e7b test: Unit test for block filter index reorg handling. (Jim Posen)
6bcf0998c0 test: Unit tests for block index filter. (Jim Posen)
b5e8200db7 index: Implement lookup methods on block filter index. (Jim Posen)
75a76e3619 index: Implement block filter index with write operations. (Jim Posen)
2ad2338ef9 serialize: Serialization support for big-endian 32-bit ints. (Jim Posen)
ba6ff9a6f7 blockfilter: Functions to translate filter types to/from names. (Jim Posen)
62b7a4f094 index: Ensure block locator is not stale after chain reorg. (Jim Posen)
4368384f1d index: Allow atomic commits of index state to be extended. (Jim Posen)

Pull request description:

  This introduces a new BlockFilterIndex class, which is required for BIP 157 support.

  The index is uses the asynchronous BaseIndex infrastructure driven by the ValidationInterface callbacks. Filters are stored sequentially in flat files and the disk location of each filter is indexed in LevelDB along with the filter hash and header. The index is designed to ensure persistence of filters reorganized out of the main chain to simplify the BIP 157 net implementation.

  Stats (block height = 565500):
  - Syncing the index from scratch takes 45m
  - Total index size is 3.8 GiB

ACKs for commit c7efb6:
  MarcoFalke:
    utACK c7efb652f3
  ryanofsky:
    Slightly tested ACK c7efb652f3 (I just rebuilt the index with the updated PR and tested the RPC). Changes since last review: rebase, fixed compile errors in internal commits, new comments, updated error messages, tweaked cache size logic, renamed commit method, renamed constants and globals, fixed whitespace, extra BlockFilterIndex::Init error check.

Tree-SHA512: f8ed7a9b6f76df45933aa5eba92b27b3af83f6df2ccb3728a5c89eec80f654344dc14f055f6f63eb9b3a7649dd8af6553fe14969889e7e2fd2f8461574d18f28
2019-04-18 09:48:25 -04:00
MarcoFalke
dae72998e8
Merge #15779: test: Add wallet_balance benchmark
fad7c33342 refactor: Add handleNotifications method to wallet (MarcoFalke)
fa46ac3127 bench: Add wallet_balance benchmarks (MarcoFalke)

Pull request description:

ACKs for commit fad7c3:
  ryanofsky:
    utACK fad7c33342. I might squash or rearrange the commits to avoid adding code in one commit that just gets deleted in the next one. But overall this looks good and the cleanup is nice.

Tree-SHA512: 231faac168cbe9bb0ab4bf10ac1d5b042c610364406d75061fba27f1e9d16c71867e74cc4606e9f42659aa980d7133c00e29fcc18bbba7da2fa7a80178b3246c
2019-04-17 15:14:12 -04:00
MarcoFalke
fad7c33342
refactor: Add handleNotifications method to wallet
Further stylistic cleanups in touched files:

* Sort the includes
* Wrap long single-line constructors into multiple lines
2019-04-17 14:20:44 -04:00
MarcoFalke
e2b5fdee00
Merge #15474: rest/rpc: Make mempoolinfo atomic
e377846ff1 rest/rpc: Make mempoolinfo atomic (João Barbosa)

Pull request description:

  Make `/rest/mempool/info.json` endpoint and `getmempoolinfo` RPC atomic.

ACKs for commit e37784:

Tree-SHA512: 6b40844df813e180d68731fc263bd9a2c2a01fe143a4f5a8974e3e0023e6e2e1e9bc46669ddfdf44f0e47142feda2a2aad1ea02ef8837081e11522347f314b0b
2019-04-17 10:30:38 -04:00
Antoine Riard
99e88a3726 rpc: Remove dependency on interfaces::Chain in SignTransaction
Comment SignTransaction utility
2019-04-17 08:17:17 -04:00
MarcoFalke
0c9de67f34
Merge #15352: tests: Reduce noise level in test_bitcoin output
0aef39d067 Silence "Test case [...] did not check any assertions" warnings when running "test_bitcoin --log_level=test_suite" (practicalswift)
5fd73c8694 Avoid repeated log messages in tests by connecting to signal handlers (ThreadSafeMessageBox, etc.) only once (practicalswift)
e502c3c515 tests: Reduce noise level in test_bitcoin output (practicalswift)

Pull request description:

  Reduce noise level in `test_bitcoin` output.

  Context: When working on the non-determinism issues in the unit tests (see #15296) I got a bit tired of the amount of noise in the `test_bitcoin` output :-)

  Before:

  ```
  $ src/test/test_bitcoin --log_level=test_suite 2>&1 | grep -vE '(Entering|Leaving)' | uniq -c
        1 Running 341 test cases...
        1 Test case blockencodings_tests/TransactionsRequestDeserializationOverflowTest did not check any assertions
        1 CheckSplitTorReplyLine(PROTOCOLINFO PIVERSION)
        1 CheckSplitTorReplyLine(AUTH METHODS=COOKIE,SAFECOOKIE COOKIEFILE="/home/x/.tor/control_auth_cookie")
        1 CheckSplitTorReplyLine(AUTH METHODS=NULL)
        1 CheckSplitTorReplyLine(AUTH METHODS=HASHEDPASSWORD)
        1 CheckSplitTorReplyLine(VERSION Tor="0.2.9.8 (git-a0df013ea241b026)")
        1 CheckSplitTorReplyLine(AUTHCHALLENGE SERVERHASH=aaaa SERVERNONCE=bbbb)
        1 CheckSplitTorReplyLine(COMMAND)
        1 CheckSplitTorReplyLine(COMMAND SOME  ARGS)
        1 CheckSplitTorReplyLine(COMMAND  ARGS)
        1 CheckSplitTorReplyLine(COMMAND   EVEN+more  ARGS)
        1 CheckParseTorReplyMapping(METHODS=COOKIE,SAFECOOKIE COOKIEFILE="/home/x/.tor/control_auth_cookie")
        1 CheckParseTorReplyMapping(METHODS=NULL)
        1 CheckParseTorReplyMapping(METHODS=HASHEDPASSWORD)
        1 CheckParseTorReplyMapping(Tor="0.2.9.8 (git-a0df013ea241b026)")
        1 CheckParseTorReplyMapping(SERVERHASH=aaaa SERVERNONCE=bbbb)
        1 CheckParseTorReplyMapping(ServiceID=exampleonion1234)
        1 CheckParseTorReplyMapping(PrivateKey=RSA1024:BLOB)
        1 CheckParseTorReplyMapping(ClientAuth=bob:BLOB)
        1 CheckParseTorReplyMapping(Foo=Bar=Baz Spam=Eggs)
        1 CheckParseTorReplyMapping(Foo="Bar=Baz")
        1 CheckParseTorReplyMapping(Foo="Bar Baz")
        1 CheckParseTorReplyMapping(Foo="Bar\ Baz")
        1 CheckParseTorReplyMapping(Foo="Bar\Baz")
        1 CheckParseTorReplyMapping(Foo="Bar\@Baz")
        1 CheckParseTorReplyMapping(Foo="Bar\"Baz" Spam="\"Eggs\"")
        1 CheckParseTorReplyMapping(Foo="Bar\\Baz")
        1 CheckParseTorReplyMapping(Foo="Bar\nBaz\t" Spam="\rEggs" Octals="\1a\11\17\18\81\377\378\400\2222" Final=Check)
        1 CheckParseTorReplyMapping(Valid=Mapping Escaped="Escape\\")
        1 CheckParseTorReplyMapping(Valid=Mapping Bare="Escape\")
        1 CheckParseTorReplyMapping(OneOctal="OneEnd\1" TwoOctal="TwoEnd\11")
        1 CheckParseTorReplyMapping(Null="\0")
        1 CheckParseTorReplyMapping(SOME=args,here MORE optional=arguments  here)
        1 CheckParseTorReplyMapping(ARGS)
        1 CheckParseTorReplyMapping(MORE ARGS)
        1 CheckParseTorReplyMapping(MORE  ARGS)
        1 CheckParseTorReplyMapping(EVEN more=ARGS)
        1 CheckParseTorReplyMapping(EVEN+more ARGS)
        1 Test case util_tests/util_criticalsection did not check any assertions
        1 Testing known outcomes
      326 Error: Specified -walletdir "/tmp/test_bitcoin/1553850209_943311758/tempdir/path_does_not_exist" does not exist
      327 Error: Specified -walletdir "/tmp/test_bitcoin/1553850209_643733972/tempdir/not_a_directory.dat" is not a directory
      328 Error: Specified -walletdir "wallets" is a relative path
        1
        1 *** No errors detected

  ```

  After:

  ```
  $ src/test/test_bitcoin --log_level=test_suite 2>&1 | grep -vE '(Entering|Leaving)' | uniq -c
        1 Running 341 test cases...
        1 Error: Specified -walletdir "/tmp/test_bitcoin/1553850026_943311758/tempdir/path_does_not_exist" does not exist
        1 Error: Specified -walletdir "/tmp/test_bitcoin/1553850026_643733972/tempdir/not_a_directory.dat" is not a directory
        1 Error: Specified -walletdir "wallets" is a relative path
        1
        1 *** No errors detected

  ```

ACKs for commit 0aef39:
  MarcoFalke:
    utACK 0aef39d067

Tree-SHA512: 9cc22f64aa5c875861bae6533d18675ad978c623f053754deef6a8e271ea70bda3f72fb4ec5c8fd19b841757f21380639051d5f5b44301b9d2464b57655e9c05
2019-04-16 14:18:47 -04:00
Tobias Kaderle
81b2830b15
qt: update request payment button text and tab description 2019-04-16 20:40:13 +08:00
MarcoFalke
598323911e
Merge #15770: rpc: Validate maxfeerate with AmountFromValue
aa410c2b17 rpc: Validate maxfeerate with AmountFromValue (João Barbosa)

Pull request description:

  With this change `maxfeerate` can also be set as a string, accordingly to the help test:
  ```
    maxfeerate    (numeric or string,
  ```
  Beside, there are no tests for the removed errors.

ACKs for commit aa410c:
  meshcollider:
    utACK aa410c2b17
  MarcoFalke:
    utACK aa410c2b17 Good catch

Tree-SHA512: f3bfea91dc7daa943729e270585dbf333055aeda805fbd01eaab20a7e0e6147382647c11525334382d198df0d3d45da6102b541efda5a1361f96271c98d5d89d
2019-04-15 17:05:42 -04:00
MarcoFalke
fa46ac3127
bench: Add wallet_balance benchmarks 2019-04-15 16:49:34 -04:00
r8921039
2d8ba4f867 remove out-of-date comment on pay-to-witness support 2019-04-15 09:15:25 -07:00
MarcoFalke
78295e97b8
Merge #15788: test: Unify testing setups for fuzz, bench, and unit tests
faf400077d scripted-diff: Bump copyright headers in test, bench (MarcoFalke)
fa821904bf scripted-diff: Rename test_bitcoin to test/setup_common (MarcoFalke)
fa8685d49e test: Use test_bitcoin setup in bench, Add test utils (MarcoFalke)
666696b673 test: Have segwit always active in (Basic)TestingSetup (MarcoFalke)

Pull request description:

  Now that the fuzz tests can use the BasicTestingSetup [1], do the same for bench.

  Also move some duplicate code to a common "test/util" module.

  [1]:  fuzz: Link BasicTestingSetup (shared with unit tests) #15504

ACKs for commit faf400:
  jonatack:
    ACK faf400077d

Tree-SHA512: 8ac5692e72cf50e460958f291643ae6b8bb04d5c1331ed50dce9eb4e9457e5a925144c532c42b360a26707e11eeece74aab27db8c76ab9a429b9dd7167e7cdc4
2019-04-15 11:28:25 -04:00
MarcoFalke
2a854a1781
Merge #15750: [rpc] Remove the addresses field from the getaddressinfo return object
b4338c151d [rpc] Remove the addresses field from the getaddressinfo return object (John Newbery)

Pull request description:

  The "addresses" field was confusing because it refered to public keys
  using their P2PKH address.  It was included in the return object when
  needed for backward compatibility. Remove that compatibility now that
  the -deprecatedrpc=validateaddress option has been removed.

  New applications should use the 'embedded'->'address' field for P2SH or
  P2WSH wrapped addresses, and 'pubkeys' for inspecting multisig
  participants.

ACKs for commit b4338c:
  jonatack:
    ACK b4338c151d. Tests [gist](https://gist.github.com/jonatack/31915e290bb1be39b9769dc9357385ca).

Tree-SHA512: 2c207510e565df600428838bfc6db5211fa06aaace365e31cbd74f1d2376b598675cb90df2fc1440858d49b22095aaa9d6b9ce3de0aff22417fe72cc6a6a321f
2019-04-15 11:09:18 -04:00
Wladimir J. van der Laan
0c6487c74f
Merge #15751: Speed up deriveaddresses for large ranges
41a46cbb31 Speed up deriveaddresses for large ranges (Pieter Wuille)

Pull request description:

  `deriveaddresses` dumps all generated addresses into a single `FlatSigningProvider`, which is also used for looking up information for future derivations. @achow101 points out that the growing data structures may unnecessary increase lookup time for later derivations.

  Fix this by separating the provider used for lookups (`key_provider`) and the one we dump things into.

  This gives a 10x speedup for a range of 7000 elements, and probably a larger speedup for larger ranges.

ACKs for commit 41a46c:
  achow101:
    Regardless, I do think this is a good change, so utACK 41a46cbb31
  fanquake:
    tACK 41a46cb
  meshcollider:
    utACK 41a46cbb31

Tree-SHA512: a1b894ce9d5195d8f9760f44acc6d67a90bb259283fd8c1524c38a222fe53e8c1d35b6653a508b121b7ad91e155c97d26c658f6bdcebf6c360546931e4a26a22
2019-04-15 13:52:17 +02:00
MeshCollider
4f4ef3138b
Merge #15557: Enhance bumpfee to include inputs when targeting a feerate
184f8785f wallet_bumpfee.py: add test for change key preservation (Gregory Sanders)
d08becff8 add functional tests for feerate bumpfee with adding inputs (Gregory Sanders)
0ea47ba7b generalize bumpfee to add inputs when needed (Gregory Sanders)

Pull request description:

  When targeting a feerate using `bumpfee`, call a new function that directly uses `CWallet::CreateTransaction` and coin control to get the desired result. This allows us to get a superset of previous behavior, with an arbitrary RBF bump of a transaction provided it passes the preconditional checks and spare confirmed utxos are available.

  Note(s):
  0) The coin selection will use knapsack solver for the residual selection.
  1) This functionality, just like knapsack coin selection in general, will hoover up negative-value inputs when given the chance.
  2) Newly added inputs must be confirmed due to current Core policy. See error: `replacement-adds-unconfirmed`
  3) Supporting this with `totalFee` is difficult since the "minimum total fee" option in `CreateTransaction` logic was (rightly)taken out in #10390 .

ACKs for commit 184f87:
  jnewbery:
    utACK 184f8785f7

Tree-SHA512: fb6542bdfb2c6010e328ec475cf9dcbff4eb2b1a1b27f78010214534908987a5635797196fa05edddffcbcf2987335872dc644a99261886d5cbb34a8f262ad3e
2019-04-15 08:39:50 +12:00
John Newbery
ef2d515af3 [wallet] move-only: move CReserveKey to be next to CKeyPool
reviewer tip: use git diff --color-moved=dimmed-zebra
2019-04-14 09:32:40 -04:00
MeshCollider
adc55dbac5
Merge #15748: [rpc] remove dead mining code
1b46a4889 [cleanup] Remove unused CReserveKey (John Newbery)
9819ad6d0 [rpc] simplify generate RPC (John Newbery)

Pull request description:

  Removes dead code from after the generate method was removed

ACKs for commit 1b46a4:
  MarcoFalke:
    utACK 1b46a4889f
  meshcollider:
    utACK 1b46a4889f
  scravy:
    utACK 1b46a48
  Empact:
    utACK 1b46a4889f

Tree-SHA512: d1fab1bf76ac3036b85cf33be89868bc016f912575545ecaa16f958397b0ec4f1ce4de8fe254d4f21aabeea9c83a8928530cc520de26af0d1a8bdb4ca0f2cb77
2019-04-14 16:09:05 +12:00
Ben Woosley
510c6532ba
Extract ParseDescriptorRange
So as to be consistently informative when the checks fail, and
to protect against unintentional divergence among the checks.
2019-04-13 18:52:11 -07:00
Luke Dashjr
8a33f4d63f GUI: Options: Remove the upper-bound limit from pruning size setting
Hypothetically, someone may wish to begin pruning at a future blockchain size, and there's no reason to limit it lower
2019-04-11 23:44:48 +00:00
Luke Dashjr
4ddeb2f860 GUI: Options: Set the range of pruning size before loading its value
Without this, an out-of-default-range value gets limited to the range
2019-04-11 23:42:26 +00:00
John Newbery
b4338c151d [rpc] Remove the addresses field from the getaddressinfo return object
The "addresses" field was confusing because it refered to public keys
using their P2PKH address.  It was included in the return object when
needed for backward compatibility. Remove that compatibility now that
the -deprecatedrpc=validateaddress option has been removed.

New applications should use the 'embedded'->'address' field for P2SH or
P2WSH wrapped addresses, and 'pubkeys' for inspecting multisig
participants.
2019-04-11 15:10:53 -04:00
MarcoFalke
faf400077d
scripted-diff: Bump copyright headers in test, bench
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./src/bench/
./contrib/devtools/copyright_header.py update ./src/test/
-END VERIFY SCRIPT-
2019-04-11 13:34:43 -04:00
MarcoFalke
fa821904bf
scripted-diff: Rename test_bitcoin to test/setup_common
-BEGIN VERIFY SCRIPT-
sed -i --regexp-extended -e 's/test_bitcoin\.(h|cpp)/setup_common.\1/g' $(git grep -l test_bitcoin)
git mv ./src/test/test_bitcoin.h   ./src/test/setup_common.h
git mv ./src/test/test_bitcoin.cpp ./src/test/setup_common.cpp
sed -i -e 's/BITCOIN_TEST_TEST_BITCOIN_H/BITCOIN_TEST_SETUP_COMMON_H/g' ./src/test/setup_common.h
-END VERIFY SCRIPT-
2019-04-11 10:12:36 -04:00
Wladimir J. van der Laan
bb68abe784
Merge #15718: docs: Improve netaddress comments
303372c41a docs: Improve netaddress comments (Carl Dong)

Pull request description:

  Improves comments for `netaddress`, making them available to Doxygen.

  I think this is worthwhile because a lot of the code require some context (e.g., A lot of the things that we do to fit hostnames and tor addresses into `CNetAddr` is non-obvious, and documenting it is beneficial).

ACKs for commit 303372:

Tree-SHA512: 2a35784a01ed8ec5fdbe111a540192d31bde16afa96e4be97b0385daf290fc7469a66d7cb8905a70b920fad6a0e7400ca4e5da082d6e4af1d1aaccc0e8297720
2019-04-11 16:02:54 +02:00
Wladimir J. van der Laan
570eb7b130
Merge #15782: Avoid redefine warning
0b3a65455a Avoid redefine warning (Peter Bushnell)

Pull request description:

  Wrap preprocessor definition of NOMINMAX in ifndef conditional to suppress warning when cross compiling Windows.

  `fs.cpp:6:0: warning: "NOMINMAX" redefined`
  `/usr/lib/gcc/x86_64-w64-mingw32/7.3-posix/include/c++/x86_64-w64-mingw32/bits/os_defines.h:45:0: note: this is the location of the previous definition
   #define NOMINMAX 1`

  #define NOMINMAX was introduced in the following merge.

  https://github.com/bitcoin/bitcoin/pull/14426

ACKs for commit 0b3a65:
  practicalswift:
    utACK 0b3a65455a
  promag:
    utACK 0b3a654.

Tree-SHA512: 0175195b88e63d3d44ffac2b8cc87ae7b285a45ed4e49605bca0cc82db073006c22024ef9c2f287980d357dac1099f798f1eeaa0bd75bb7a625919dc1632366c
2019-04-11 15:57:13 +02:00
Gregory Sanders
0ea47ba7b3 generalize bumpfee to add inputs when needed 2019-04-11 07:21:49 -04:00
MeshCollider
c536dfbcb0
Merge #15639: bitcoin-wallet tool: Drop libbitcoin_server.a dependency
78a2fb55c bitcoin-wallet tool: Drop libbitcoin_server.a dependency (Russell Yanofsky)
b874747b5 Remove access to node globals from wallet-linked code (Russell Yanofsky)
fbc6bb8e8 bitcoin-wallet tool: Drop MakeChain calls (Russell Yanofsky)

Pull request description:

  Dropping the `bitcoin-wallet` dependency on `libbitcoin_server.a` ensures wallet code can't access node global state, avoiding bugs like https://github.com/bitcoin/bitcoin/pull/15557#discussion_r267735431

ACKs for commit 78a2fb:
  jnewbery:
    utACK 78a2fb55c9. Nice work, Russ.
  MarcoFalke:
    utACK 78a2fb5
  MeshCollider:
    utACK 78a2fb55c9

Tree-SHA512: ee6ea774f683b936bea66638211dd53c42b8316e1ef03dd58d12fb7ee3891432a43c5c149944173c1e2436aa756b672e1679c39fc10043792ac55cd4d8af2823
2019-04-11 21:29:59 +12:00
MeshCollider
f6120d40d5
Merge #15728: [wallet] Refactor relay transactions
7a9046e48 [wallet] Refactor CWalletTx::RelayWalletTransaction() (John Newbery)

Pull request description:

  Refactor `CWalletTx::RelayWalletTransaction()` function.

  This was a suggestion from the wallet-node separation PR: https://github.com/bitcoin/bitcoin/pull/15288#discussion_r256036330, which we deferred until after the main PR was merged.

  There are also makes two minor behavior changes:

  - no longer assert if fBroadcastTransactions is false. Just return false from the function.
  - no longer print the relay message if p2pEnabled is set to false (since the transaction is not actually relayed).

ACKs for commit 7a9046:
  promag:
    utACK 7a9046e48d.
  MeshCollider:
    utACK 7a9046e48d
  ryanofsky:
    utACK 7a9046e48d. No changes at all, just rebase after base PR #15632 was merged

Tree-SHA512: 2ae6214cfadd917a1b3a892c4277e5e57c3eb791e17f67511470e6fbc634d19356554b9f9c55af6b779fdef821914aad59b7cc9e6c13ece145df003bf507d486
2019-04-11 21:25:07 +12:00
MarcoFalke
fa8685d49e
test: Use test_bitcoin setup in bench, Add test utils 2019-04-10 15:59:11 -04:00
MarcoFalke
666696b673
test: Have segwit always active in (Basic)TestingSetup 2019-04-10 15:57:48 -04:00
Carl Dong
303372c41a docs: Improve netaddress comments
- Improve IsRFC methods docs
- Improve {Is,Set}Internal docs
- Add tor methods docs
- Add IsIPv{4,6} docs
- Add IsValid docs
- Add IsRoutable docs
- Improve GetGroup docs
- Add CService::GetSockAddr docs
- Add CService::GetKey docs
- Add CSubNet::Match docs
- Add NetmaskBits docs
- Add CNetAddr default constructor docs
2019-04-10 11:48:47 -04:00
John Newbery
1b46a4889f [cleanup] Remove unused CReserveKey 2019-04-10 11:44:40 -04:00
John Newbery
9819ad6d07 [rpc] simplify generate RPC
Removes dead code from after the generate method was removed
2019-04-10 11:44:37 -04:00
Russell Yanofsky
78a2fb55c9 bitcoin-wallet tool: Drop libbitcoin_server.a dependency
This ensures wallet code doesn't access node global state, avoiding bugs like
https://github.com/bitcoin/bitcoin/pull/15557#discussion_r267735431
2019-04-10 09:51:37 -04:00
Wladimir J. van der Laan
6a135fbe5b
Merge #15638: Move-only: Pull wallet code out of libbitcoin_server
4d074e84a2 [build] Move AnalyzePSBT from psbt.cpp to node/psbt.cpp (Russell Yanofsky)
fd509bd1f7 [docs] Document src subdirectories and different libraries (John Newbery)
9eaeb7fb8d [build] Move wallet load functions to wallet/load unit (John Newbery)
91a25d1e71 [build] Add several util units (John Newbery)
99517866b6 [build] Move several units into common libraries (John Newbery)
0509465542 [build] Move rpc rawtransaction util functions to rpc/rawtransaction_util.cpp (John Newbery)
1acc61f874 [build] Move rpc utility methods to rpc/util (John Newbery)
4a75c9d651 [build] Move policy settings to new src/policy/settings unit (John Newbery)
fdf8888b6f [build] Move CheckTransaction from lib_server to lib_consensus (John Newbery)

Pull request description:

  This is a move-only commit. No code is changing and the moves can be easily verified with:

  ```sh
  git log -p -n1 --color-moved=dimmed_zebra
  ```

  This commit moves functions and variables that wallet code depends on out of libbitcoin_server.a, so the bitcoin-wallet tool can be built without libbitcoin_server.a in #15639, and attempting to access server state from wallet code will result in link errors instead of silently broken code.

  List of moves:

  - `CheckTransaction` moves from `consensus/tx_verify.cpp` to `consensus/tx_check.cpp`
  - `urlDecode` moves from `httpserver.cpp` to `util/url.cpp`
  - `TransactionErrorString` moves from `node/transaction.cpp` to `util/error.cpp`
  - `StringForFeeReason` and `FeeModeFromString` move from `policy/fees.cpp` to `util/fees.cpp`
  - `incrementalRelayFee` `dustRelayFee` and `nBytesPerSigOp` move from `policy/policy.cpp` to `policy/settings.cpp`
  - `SignalsOptInRBF` moves from `policy/rbf.cpp` to `util/rbf.cpp`
  - `fIsBareMultisigStd` moves from `validation.cpp` to `policy/settings.cpp`
  - `ConstructTransaction` `TxInErrorToJSON` and `SignTransaction` move from `rpc/rawtransaction.cpp` to `rpc/rawtransaction_util.cpp`
  - `RPCTypeCheck` `RPCTypeCheckArgument` `RPCTypeCheckObj` `AmountFromValue` `ParseHashV``ParseHashO` `ParseHexV` `ParseHexO` `HelpExampleCli` and `HelpExampleRpc` move from `rpc/server.cpp` to `rpc/util.cpp`
  - `AmountHighWarn` and `AmountErrMsg` move from `ui_interface.cpp` to `util/error.cpp`
  - `FormatStateMessage` and `strMessageMagic` move from `validation.cpp` to `util/validation.cpp`
  - `VerifyWallets` `LoadWallets` `StartWallets` `FlushWallets` `StopWallets` and `UnloadWallets` move from `wallet/init.cpp` to `wallet/node.cpp`

ACKs for commit 4d074e:
  jnewbery:
    utACK 4d074e84a2 (checked by doing the rebase myself and verifying no difference between my branch and 4d074e84a2)

Tree-SHA512: 5e1604a9fb06475f2b96da0de0baa8330f4dda834dc20a0183ef11e1e4c27631d1d1bbb9abf0054efc03d56945fdf9920f63366b6a4f200f665b742a479ff75c
2019-04-10 15:51:37 +02:00
Russell Yanofsky
b874747b51 Remove access to node globals from wallet-linked code
Remove last few instances of accesses to node global variables from wallet
code. Also remove accesses to node globals from code in policy/policy.cpp that
isn't actually called by wallet code, but does get linked into wallet code.

This is the last change needed to allow bitcoin-wallet tool to be linked
without depending on libbitcoin_server.a, to ensure wallet code doesn't access
node global state and avoid bugs like
https://github.com/bitcoin/bitcoin/pull/15557#discussion_r267735431
2019-04-10 09:51:37 -04:00
Russell Yanofsky
fbc6bb8e83 bitcoin-wallet tool: Drop MakeChain calls
Pass null Chain interface pointer to CWallet. This is needed to drop
libbitcoin_server dependency and avoid linking node code.
2019-04-10 09:51:37 -04:00
MarcoFalke
e3a0688f82
Merge #15659: [docs] fix findFork comment
c968780785 [docs] fix comment: the return value of findFork is _not_ an ancestor when the specified block is on the active chain (r8921039)

Pull request description:

  The return value of findFork is an ancestor of the specified block only when specified block is _not_ on the active chain. When it is on the active chain, the return value is the specified block itself, not an ancestor of it.

ACKs for commit c96878:
  promag:
    utACK c968780, however comment could be shorter.
  ryanofsky:
    utACK c968780785. Only change since last review is squash

Tree-SHA512: bb05d734059898784c4a59b5b0344719eb4dfb2d49a0f7f705fcb2eb630702e66be81c01299185faf0c219fa9f9aa64cbdf6d5f91e0b3dce0ff420909a454a18
2019-04-10 09:34:02 -04:00
MarcoFalke
e82f6ad6f2
Merge #15754: rpc: getrpcinfo docs
f4b7a2f205 rpc: getrpcinfo docs (Ben Carman)

Pull request description:

  Fixes #15731

ACKs for commit f4b7a2:
  laanwj:
    utACK f4b7a2f205

Tree-SHA512: 45dce83c4bfac2ddf85133a29aee332e9de8f73c15438ce899a2edbcd0d82d4f743753f6699c50cbc62d110fa8c6bc257722447e1090cdd23acbe00f26014ec8
2019-04-10 09:24:22 -04:00
John Newbery
7a9046e48d [wallet] Refactor CWalletTx::RelayWalletTransaction()
This refactors the CWalletTx::RelayWalletTransaction() function to be
clearer and adds comments. It also makes two minor behavior
changes:

- no longer assert if fBroadcastTransactions is false. Just return false
from the function.
- no longer print the relay message if p2pEnabled is set to false (since
the transaction is not actually relayed).
2019-04-10 09:19:55 -04:00
Peter Bushnell
0b3a65455a Avoid redefine warning 2019-04-10 12:16:52 +01:00
MarcoFalke
8c022e8ac4
Merge #15746: rpc: RPCHelpMan: Always name dictionary keys
fa26eb5e8f rpc: RPCHelpMan: Always push_name when outer type is an object (MarcoFalke)
fa652b229e rpc: Add some doxygen comments to utils (MarcoFalke)

Pull request description:

  Fixes two issues reported in #15737:

  * > I am very perplexed as to how the code I'm looking at is generating the help text I'm seeing

  So add documentation

  * > This is a value for which a key is missing

  So always serialize the name of the dictionary key if the outer type is a dictionary

ACKs for commit fa26eb:
  promag:
    Tested ACK fa26eb5.

Tree-SHA512: b6f0cee1f1123d245d4902e8e113b5260cae7f2cb39c9bfb8893c5b0b33ffb6349ad05813d560d39a94ccf655399c05fcda15d9b0733e6bd696538fe0aca7021
2019-04-09 21:20:48 -04:00
MarcoFalke
5392aee64f
Merge #15629: init: Throw error when network specific config is ignored
fae38c3dc6 doc: Fix all typos reported by codespell (MarcoFalke)
fa9058f0ed doc: Add release notes for 15629 (MarcoFalke)
fa4a922d78 qa: Add test for missing testnet section in conf file (MarcoFalke)
dddd6f0f58 init: Throw error when network specific config is ignored (MarcoFalke)

Pull request description:

  This should have no effect on mainnet users, but simplifies testing, where config settings are currently ignored with only a warning. Fix this by making it an error.

  Issues:
  *  bitcoin client 0.17.0 ignores wallet's name (file) #14523
  *  Can't set custom rpcport on testnet #13777
  * ...

ACKs for commit fae38c:

Tree-SHA512: 2e209526898eea6e444c803ec2666989cee4ca137492d32984998733c50a70056cb54657df8dc3027a6a0612738a8afce0bc35824b868c5f22281e00e0188530
2019-04-09 21:14:49 -04:00
Russell Yanofsky
4d074e84a2 [build] Move AnalyzePSBT from psbt.cpp to node/psbt.cpp
psbt.cpp definitions except for AnalyzePSBT are used by the wallet and need to
be linked into the wallet binary. AnalyzePSBT is an exception in that it is not
used by the wallet, and depends on node classes like CCoinsViewCache, and on
node global variables like nBytesPerSigOp.

So AnalyzePSBT is more at home in libbitcoin_server than libbitcoin_common, and
in any case needs to be defined in a separate object file than other PSBT
utilities, to avoid dragging link dependencies on node functions and global
variables into the wallet.
2019-04-09 17:53:08 -04:00
John Newbery
fd509bd1f7 [docs] Document src subdirectories and different libraries 2019-04-09 17:53:08 -04:00
John Newbery
9eaeb7fb8d [build] Move wallet load functions to wallet/load unit
Moves the following wallet load functions to a new wallet/load unit in
the libbitcoin_wallet library. All other functions in wallet/init remain
in libbitcoin_server:

- `VerifyWallets`
- `LoadWallets`
- `StartWallets`
- `FlushWallets`
- `StopWallets`
- `UnloadWallets`
2019-04-09 17:53:08 -04:00
John Newbery
91a25d1e71 [build] Add several util units
Adds the following util units and adds them to libbitcoin_util:

- `util/url.cpp` takes `urlDecode` from `httpserver.cpp`
- `util/error.cpp` takes `TransactionErrorString` from
  `node/transaction.cpp` and `AmountHighWarn` and `AmountErrMsg` from
  `ui_interface.cpp`
- `util/fees.cpp` takes `StringForFeeReason` and `FeeModeFromString` from `policy/fees.cpp`
- `util/rbf.cpp` takes `SignalsOptInRBF` from `policy/rbf.cpp`
- 'util/validation.cpp` takes `FormatStateMessage` and `strMessageMagic` from 'validation.cpp`
2019-04-09 17:53:08 -04:00
John Newbery
99517866b6 [build] Move several units into common libraries
Moves the following units into libbitcoin_util or libbitcoin_common
since they are required by multiple libraries:

- bloom
- interfaces/handler
- merkleblock
- outputtype
2019-04-09 17:53:08 -04:00
John Newbery
0509465542 [build] Move rpc rawtransaction util functions to rpc/rawtransaction_util.cpp
rpc/rawtransaction.cpp moves to libbitcoin_server since it should not be
accessed by non-node libraries. The utility following utility methods
move to their own unit rpc/rawtransaction_util since they need to be
accessed by non-node libraries:

- `ConstructTransaction`
- `TxInErrorToJSON`
- `SignTransaction`
2019-04-09 17:53:08 -04:00
John Newbery
1acc61f874 [build] Move rpc utility methods to rpc/util
Moves the following utility methods to rpc/util and moves that unit to
libbitcoin_common so they can be accessed by all libraries.

- `RPCTypeCheck`
- `RPCTypeCheckArgument`
- `RPCTypeCheckObj`
- `AmountFromValue`
- `ParseHashV``ParseHashO`
- `ParseHexV`
- `ParseHexO`
- `HelpExampleCli`
- `HelpExampleRpc`
2019-04-09 17:53:08 -04:00
John Newbery
4a75c9d651 [build] Move policy settings to new src/policy/settings unit
This moves the following policy settings functions and globals to a new
src/policy/settings unit in lib_server:

- `incrementalRelayFee`
- `dustRelayFee`
- `nBytesPerSigOp`
- `fIsBareMultisigStd`

These settings are only required by the node and should not be accessed
by other libraries.
2019-04-09 17:53:08 -04:00
John Newbery
fdf8888b6f [build] Move CheckTransaction from lib_server to lib_consensus
CheckTransaction is a context-free function that does not require access
to the blockchain or mempool. Move it from src/consensus/tx_verify in
lib_server to a new unit src/consensus/tx_check in lib_consensus so that
it can be called by non-server libraries.
2019-04-09 17:53:08 -04:00
John Newbery
833d98ae07 [wallet] Remove unnecessary Chain::Lock parameter from ResendWalletTransactions 2019-04-09 10:38:28 -04:00
John Newbery
52b760fc6a [wallet] Schedule tx rebroadcasts in wallet
Removes the now-unused Broadcast/ResendWalletTransactions interface from
validationinterface.

The wallet_resendwallettransactions.py needs a sleep added at the start
to make sure that the rebroadcast scheduler is warmed up before the next
block is mined.
2019-04-09 10:38:13 -04:00
John Newbery
f463cd1073 [wallet] Keep track of the best block time in the wallet
Move nTimeBestReceived (which is only used for wallet
rebroadcasts) into the wallet.
2019-04-09 10:37:49 -04:00
MeshCollider
54798c3a31
Merge #15749: Fix: importmulti only imports origin info for PKH outputs
b5d398772 Take non-importing keys into account for spendability warning in descriptor import (Pieter Wuille)
6e597001a Import all origin info in importmulti; even for non-importing pubkeys (Pieter Wuille)
9a93c91c8 Keep full pubkeys in FlatSigningProvider::origins (Pieter Wuille)

Pull request description:

  This fixes #15743 and #15742.

  Since #15263, pubkeys are no longer imported for non-PKH (or WPKH, or any wrapped form of those) outputs, as that would incorrectly mark outputs to single-key versions of multisig policies as watched.

  As a side effect, this change also caused origin info not to be imported anymore for multisig policies.

  Fix this by plumbing through the full pubkey information for origins in FlatSigningProvider, and then importing all origin info we have in `importmulti` (knowing more never hurts, and additional origin information has no negative consequences like importing the pubkeys themselves).

ACKs for commit b5d398:
  MeshCollider:
    utACK b5d3987724

Tree-SHA512: 37caa2be8d01b8baa12f70a58eaa7c583f5f0afbe012e02936dd8790dc5dc852f880b77258b34ddb68cae30c029585f2d1c4f5d00015380557a1e8b471e500f3
2019-04-10 00:33:35 +12:00
MeshCollider
db2985651d
Merge #15747: wallet: Remove plethora of Get*Balance
fa57411fc wallet: Get all balances in one call (MarcoFalke)

Pull request description:

  The wallet provides a getter for each "type" of balance. However, a single iteration over `mapWallet` is sufficient to calculate all types of balances.

ACKs for commit fa5741:
  Empact:
    utACK fa57411fcb
  promag:
    utACK fa57411.
  MeshCollider:
    utACK fa57411fcb

Tree-SHA512: 38b7f346ec95d2604a4d32f4caef2841b8fe59511d2d23890ba3dc497bb2f45eb6be87d12eb004005cad16e9fea83ae6e3000f2197c7a677a07debdb457064a2
2019-04-10 00:22:02 +12:00
João Barbosa
aa410c2b17 rpc: Validate maxfeerate with AmountFromValue 2019-04-08 16:12:54 +01:00
MarcoFalke
297ea51caf
Merge #15760: doc: Clarify sendrawtransaction::maxfeerate==0 help
fa49db7eac doc: Clarify sendrawtransaction::maxfeerate==0 help (MarcoFalke)

Pull request description:

  Used a lot in e.g. the tests: `git grep 'maxfeerate=0)' test`

ACKs for commit fa49db:
  promag:
    ACK fa49db7.
  jonatack:
    ACK fa49db7eac

Tree-SHA512: cb3fa10960f45606c3599b76c48666a663e5c44cfb7c29bab5d44caa7dc6cb57aaac81cb9b173e079dde01d07c5363c99416f25303a8fd41010928118474a741
2019-04-08 10:30:27 -04:00
MarcoFalke
414d8461fd
Merge #15711: gui: Generate bech32 addresses by default
faf62d9415 gui: Generate bech32 addresses by default (MarcoFalke)

Pull request description:

  Most services support bech32 addresses now, so generating legacy addresses by default seems overly cautious. bech32 addresses are more robust and user friendly in multiple ways.

ACKs for commit faf62d:
  promag:
    utACK faf62d9, maybe add a release note "checkbox changed, but the behavior/outcome remains the same".
  laanwj:
    utACK faf62d9415, don't think a release note is needed for this specifically, though a general release note on switching to bech32 by default would make sense
  fanquake:
    tACK faf62d9
  Empact:
    utACK faf62d9415

Tree-SHA512: a03e6ccf1e5476fe800941992c531664830cec0644984d8bce97c8d8f5d6d9abd528ab979892368cd195e7c8b9083d6b8dfd36a7cb172aa9dbeaa01a948e30e1
2019-04-08 10:21:46 -04:00
MarcoFalke
fa49db7eac
doc: Clarify sendrawtransaction::maxfeerate==0 help 2019-04-06 17:40:06 -04:00
Jim Posen
c7efb652f3 blockfilter: Update BIP 158 test vectors.
New tests for the case of non-standard OP_RETURN outputs.
2019-04-06 12:10:55 -07:00
Jim Posen
19308c9e21 rpc: Add getblockfilter RPC method.
Retrieves and returns block filter and header from index.
2019-04-06 12:10:55 -07:00
Jim Posen
ff35105096 init: Add CLI option to enable block filter index. 2019-04-06 12:10:55 -07:00
Jim Posen
accc8b8b18 index: Access functions for global block filter indexes. 2019-04-06 12:10:55 -07:00
Jim Posen
2bc90e4e7b test: Unit test for block filter index reorg handling. 2019-04-06 12:10:22 -07:00
Jim Posen
6bcf0998c0 test: Unit tests for block index filter. 2019-04-06 12:10:22 -07:00
Jim Posen
b5e8200db7 index: Implement lookup methods on block filter index. 2019-04-06 12:10:22 -07:00
Jim Posen
75a76e3619 index: Implement block filter index with write operations. 2019-04-06 12:10:22 -07:00
Jim Posen
2ad2338ef9 serialize: Serialization support for big-endian 32-bit ints. 2019-04-06 12:03:21 -07:00
Jim Posen
ba6ff9a6f7 blockfilter: Functions to translate filter types to/from names. 2019-04-06 12:03:21 -07:00
Jim Posen
62b7a4f094 index: Ensure block locator is not stale after chain reorg. 2019-04-06 12:03:21 -07:00
Jim Posen
4368384f1d index: Allow atomic commits of index state to be extended. 2019-04-06 12:03:21 -07:00
Pieter Wuille
b5d3987724 Take non-importing keys into account for spendability warning in descriptor import 2019-04-06 09:14:56 -07:00
Pieter Wuille
e439aeb30c
Merge #15508: Refactor analyzepsbt for use outside RPC code
892eff05f1 Add documentation of struct PSBTAnalysis et al (Glenn Willen)
ef22fe8c1f Refactor analyzepsbt for use outside RPC code (Glenn Willen)
afd20a25f2 Move PSBT decoding functions from core_io to psbt.cpp (Glenn Willen)

Pull request description:

  Refactor the analyzepsbt RPC into (1) an AnalyzePSBT function, which returns
  its output as a new strongly-typed PSBTAnalysis struct, and (2) a thin wrapper
  which converts the struct into a UniValue for RPC use.

  ----

  As with my previous refactoring PR, I need this because I am creating a dependency on this code from the GUI. Per discussion in #bitcoin-core-dev on IRC, since we don't want to create a dependency on UniValue in anything outside RPC, I introduced some new structs to hold the info we get when analyzing a PSBT. For the field types, I used whatever types are already used internally for this data (e.g. CAmount, CFeeRate, CKeyID), and only convert to int/string etc. in the wrapper.

  @achow101, maybe take the first look? :-)

ACKs for commit 892eff:
  sipa:
    utACK 892eff05f1
  achow101:
    utACK 892eff05f1
  ryanofsky:
    utACK 892eff05f1. Just small cleanups since the last review: removing unneeded include, forward decl, adding const ref

Tree-SHA512: eb278b0a82717ebc3eb0c08dc5bb4eefb996a317a6a3a8ecf51cd88110ddbb188ad3482cdd9563e557995e73aca5a282c1f6e352bc598155f1203b7b46fe5dee
2019-04-06 08:55:17 -07:00
Peter Bushnell
4831aec5b1 Remove unused var 2019-04-05 11:03:40 +01:00
Ben Carman
f4b7a2f205
rpc: getrpcinfo docs 2019-04-05 02:04:34 -05:00
MarcoFalke
c83442e174
Merge #15654: net: Remove unused unsanitized user agent string CNode::strSubVer
fa8548c5d1 net: Remove unused unsanitized user agent string CNode::strSubVer (MarcoFalke)

Pull request description:

  I fail to see a use case for this unsanitized byte array. In fact this can easily be confused with `cleanSubVer` and be displayed to the user (or logged) by a simple typo that is hard to find in review.

  Further reading: https://btcinformation.org/en/developer-reference#version

ACKs for commit fa8548:
  promag:
    utACK fa8548c, good catch.
  practicalswift:
    utACK fa8548c5d1
  sipa:
    utACK fa8548c5d1

Tree-SHA512: 3c3ff1504d1583ad099df9a6aa761458a82ec48a58ef7aaa9b5679a5281dd1b59036ba2932ed708488951a565b669a3083ef70be5a58472ff8677b971162ae2f
2019-04-04 16:45:23 -04:00
Pieter Wuille
41a46cbb31 Speed up deriveaddresses for large ranges 2019-04-04 13:12:21 -07:00
Pieter Wuille
6e597001a4 Import all origin info in importmulti; even for non-importing pubkeys 2019-04-04 12:48:42 -07:00
Pieter Wuille
9a93c91c88 Keep full pubkeys in FlatSigningProvider::origins 2019-04-04 12:45:32 -07:00
MarcoFalke
fa57411fcb
wallet: Get all balances in one call 2019-04-04 13:22:08 -04:00
MarcoFalke
daef20fb50
Merge #15596: rpc: Ignore sendmany::minconf as dummy value
fabfb79673 doc: Add release notes for 15596 (MarcoFalke)
fac1a0fe54 wallet: Remove unused GetLegacyBalance (MarcoFalke)
faa3a246e8 scripted-diff: wallet: Rename pcoin to wtx (MarcoFalke)
fae5f874d5 rpc: Document that minconf is an ignored dummy value (MarcoFalke)

Pull request description:

  Other RPCs such as `sendtoaddress` don't have this option at all and `sendmany` should by default spend from (lets say) our change.

ACKs for commit fabfb7:
  jnewbery:
    utACK fabfb79673
  ryanofsky:
    utACK fabfb79673. Nice writeup! Release notes are only change since previous review.

Tree-SHA512: 2526ead2330be7c2beb78b96bc5e55440566c4a3a809bbbd66f5c9fc517f6890affa5d14005dc102644d49679a374510f9507255e870cf88aaa63e429beef658
2019-04-04 13:17:31 -04:00
MarcoFalke
fa26eb5e8f
rpc: RPCHelpMan: Always push_name when outer type is an object 2019-04-04 10:49:09 -04:00
MarcoFalke
fa652b229e
rpc: Add some doxygen comments to utils 2019-04-04 10:41:36 -04:00
MarcoFalke
ba54342c9d
Merge #15685: doc: rpc-mining: Clarify error messages
fa292adce9 doc: rpc-mining: Clarify error messages (MarcoFalke)

Pull request description:

  Fixes #13274

ACKs for commit fa292a:
  fanquake:
    tACK fa292ad

Tree-SHA512: 58946a52ce49b97c35cbf5eaa9175447a231690cb2bac0d39e5db524bdf2cbad274a905038aca270c080d5660f58176d43c01a22a8417c0f5b8276816939c1d6
2019-04-03 12:17:58 -04:00
MarcoFalke
8dbb2c5e67
Merge #15680: Remove resendwallettransactions RPC method
ea1a2d8794 [wallet] Remove ResendWalletTransactionsBefore (John Newbery)
f5162458cd [rpc] remove resendwallettransactions RPC (John Newbery)

Pull request description:

  Remove resendwallettransactions RPC method

  This RPC was added for testing wallet rebroadcasts. Since we now have a real test for wallet rebroadcasts, it's no longer needed.

  The call in wallet_basic.py can be removed because wallet_resendwallettransactions.py tests wallet rebroadcast.

ACKs for commit ea1a2d:
  MarcoFalke:
    re-utACK ea1a2d8794
  promag:
    utACK ea1a2d8.

Tree-SHA512: 48245d947be1a2d2b8c30d2946105818c454a03b70b63534ecadf2144da64dafe1c9527ea670a5f4d1acd05ccdfc6c9be43ca636ee2ba58a8b7a7b2fc7bc88fd
2019-04-02 10:30:57 -04:00
MarcoFalke
5a2a9b5b06
Merge #15652: wallet: Update transactions with current mempool after load
4bf1b1cefa qa: Check unconfirmed balance after loadwallet (João Barbosa)
2ebf650b2e wallet: Update transactions with current mempool after load (João Barbosa)
57908a739c interfaces: Add Chain::requestMempoolTransactions (João Barbosa)
0440481c6b wallet: Move CWallet::ReacceptWalletTransactions locks to callers (João Barbosa)

Pull request description:

  Fixes #15591.

ACKs for commit 4bf1b1:
  MarcoFalke:
    re-utACK 4bf1b1cefa
  jnewbery:
    utACK 4bf1b1cefa

Tree-SHA512: 604b1057c7f9fc3772084bf6914e52dd1a68a1cfd365f907e8ec78f6f5f726bc56a3cad9f2b665642714fbf3d51e37c1184ac396460bddeafd918e8f9f7af392
2019-04-01 15:27:02 -04:00
MarcoFalke
35477e9e4e
Merge #15644: Make orphan processing interruptible
866c8058a7 Interrupt orphan processing after every transaction (Pieter Wuille)
6e051f3d32 [MOVEONLY] Move processing of orphan queue to ProcessOrphanTx (Pieter Wuille)
9453018fdc Simplify orphan processing in preparation for interruptibility (Pieter Wuille)

Pull request description:

  As individual orphan transactions can be relatively expensive to handle, it's undesirable to process all of them (max 100) as soon as the parent becomes available, as it pegs the net processing the whole time.

  Change this by interrupting orphan handling after every transactions, and continue in the next processing slot of the peer that gave us the parent - similar to how getdata processing works now. Messages from other peers arriving in the mean time are processed normally, but other messages from the peer that gave us the parent have to wait until all orphan processing is done.

ACKs for commit 866c80:
  sdaftuar:
    ACK 866c8058a7
  MarcoFalke:
    utACK 866c8058a7
  promag:
    utACK 866c805. Verified refactor in 9453018fdc and moved code in 6e051f3d32. Not so sure about change in 866c8058a7 just because I'm not familiar with net processing.

Tree-SHA512: d8e8a1ee5f2999446cdeb8fc9756ed9c24f3d5cd769a7774ec4c317fc8d463fdfceec88de97266f389b715a5dfcc2b0a3abaa573955ea451786cc43b870e8cde
2019-04-01 11:09:40 -04:00
John Newbery
ea1a2d8794 [wallet] Remove ResendWalletTransactionsBefore
This is only called from ResendWalletTransactions(), so bring it inline.
2019-04-01 11:07:31 -04:00
MarcoFalke
faf62d9415
gui: Generate bech32 addresses by default 2019-03-31 17:56:12 -04:00
Pieter Wuille
99df276dae Update the secp256k1 subtree to the latest upstream version 2019-03-31 11:41:05 -07:00
Pieter Wuille
54245985fb Squashed 'src/secp256k1/' changes from 0b70241850..b19c000063
b19c000063 Merge #607: Use size_t shifts when computing a size_t
4d01bc2d9c Merge #606: travis: Remove unused sudo:false
e6d01e9347 Use size_t shifts when computing a size_t
7667532bd7 travis: Remove unused sudo:false
ee99f12f3d Merge #599: Switch x86_64 asm to use "i" instead of "n" for immediate values.
d58bc93f2c Switch x86_64 asm to use "i" instead of "n" for immediate values.
05362ee042 Merge #597: Add $(COMMON_LIB) to exhaustive tests to fix ARM asm build
83483869ac Add $(COMMON_LIB) to exhaustive tests to fix ARM asm build
aa15154a48 Merge #568: Fix integer overflow in ecmult_multi_var when n is large
2277af5ff0 Fix integer overflow in ecmult_multi_var when n is large
85d0e1bcce Merge #591: Make bench_internal obey secp256k1_fe_sqrt's contract wrt aliasing.
14196379ec Merge #580: Add trivial ecmult_multi algorithm which does not require a scratch space
a697d82da9 Add trivial ecmult_multi to the benchmark tool
bade617417 Add trivial ecmult_multi algorithm. It is selected when no scratch space is given and just multiplies and adds the points.
5545e13dea Merge #584: configure: Use CFLAGS_FOR_BUILD when checking native compiler
20c5869df2 Merge #516: improvements to random seed in src/tests.c
b76e45d5d6 Make bench_internal obey secp256k1_fe_sqrt's contract wrt aliasing.
870a977644 Merge #562: Make use of TAG_PUBKEY constants in secp256k1_eckey_pubkey_parse
be40c4d0b5 Fixup for C90 mixed declarations.
c71dd2c08f Merge #509: Fix algorithm selection in bench_ecmult
6492bf88cc Merge #518: Summarize build options after running configure
0e9ada1941 Merge #567: Correct order of libs returned on pkg-config --libs --static libsecp2…
e96901a4b9 Merge #587: Make randomization of a non-signing context a noop
58df8d03ad Merge #511: Portability fix for the configure scripts generated
2ebdad772a Merge #552: Make constants static:
1c131affd3 Merge #551: secp256k1_fe_sqrt: Verify that the arguments don't alias.
ba698f883b Merge #539: Assorted minor corrections
949e85b009 Merge #550: Optimize secp256k1_fe_normalize_weak calls.
a34bcaadf1 Actually pass CFLAGS_FOR_BUILD and LDFLAGS_FOR_BUILD to linker
2d5f4cebdc configure: Use CFLAGS_FOR_BUILD when checking native compiler
b408c6a8b2 Merge #579: Use __GNUC_PREREQ for detecting __builtin_expect
6198375218 Make randomization of a non-signing context a noop
c663397f46 Use __GNUC_PREREQ for detecting __builtin_expect
e34ceb333b Merge #557: Eliminate scratch memory used when generating contexts
b3bf5f99a3 ecmult_impl: expand comment to explain how effective affine interacts with everything
efa783f8f0 Store z-ratios in the 'x' coord they'll recover
ffd3b346fe add `secp256k1_ge_set_all_gej_var` test which deals with many infinite points
84740acd2a ecmult_impl: save one fe_inv_var
47045270fa ecmult_impl: eliminate scratch memory used when generating context
7f7a2ed3a8 ecmult_gen_impl: eliminate scratch memory used when generating context
314a61d724 Merge #553: add static context object which has no capabilities
89a20a8945 Correct order of libs returned on pkg-config --libs --static libsecp256k1 call.
1086fda4c1 Merge #354: [ECDH API change] Support custom hash function
d3cb1f95eb Make use of TAG_PUBKEY constants in secp256k1_eckey_pubkey_parse
40fde611bd prevent attempts to modify `secp256k1_context_no_precomp`
ed7c08417a add static context object which has no capabilities
496c5b43b8 Make constants static: static const secp256k1_ge secp256k1_ge_const_g; static const int CURVE_B;
bf8b86cc07 secp256k1_fe_sqrt: Verify that the arguments don't alias.
9bd89c836b Optimize secp256k1_fe_normalize_weak calls. Move secp256k1_fe_normalize_weak calls out of ECMULT_TABLE_GET_GE and ECMULT_TABLE_GET_GE_STORAGE and into secp256k1_ge_globalz_set_table_gej instead.
52ab96fedb clean dependendies in field_*_impl.h
deff5edd42 Correct math typos in field_*.h
4efb3f8dd1 Add check that restrict pointers don't alias with all parameters.
1e6f1f5ad5 Merge #529: fix tests.c in the count == 0 case
c8fbc3c397 [ECDH API change] Allow pass arbitrary data to hash function
b00be65056 [ECDH API change] Support custom hash function
95e99f196f fix tests.c in the count == 0 case
452d8e4d2a Merge #523: scratch: add stack frame support
6fe50439ae scratch: add stack frame support
9bc2e26502 Merge #522: parameterize ecmult_const over input size
7c1b91ba4b parameterize ecmult_const over input size
dbc3ddd5e2 Merge #513: Increase sparsity of pippenger fixed window naf representation
3965027c81 Summarize build options in configure script
0f0517369c Fix algorithm selection in bench_ecmult
fb9271dcf0 Merge #510: add a couple missing `const`s to ecmult_pippenger_wnaf
cd5f6028e5 Merge #515: Fix typo
09146ae854 Merge #512: secp256k1_ec_privkey_negate - fix documentation
ec0a7b3ae3 Don't touch leading zeros in wnaf_fixed.
9e36d1bfe2 Fix bug in wnaf_fixed where the wnaf array is not completely zeroed when given a 0 scalar.
96f68a0afc Don't invert scalar in wnaf_fixed when it is even because a caller might intentionally give a scalar with many leading zeros.
8b3841c91d fix bug in fread() failure check
cddef0c0be tests: add warning message when /dev/urandom fails
9b7c47a21e Fix typo
6dbb007869 Increase sparsity of pippenger fixed window naf representation
1646ace4d5 secp256k1_ec_privkey_negate - fix documentation
270f6c80db Portability fix for the configure scripts generated
9b3ff0309d add a couple missing `const`s to ecmult_pippenger_wnaf
cd329dbc3e Merge #460: [build] Update ax_jni_include_dir.m4 macro
7f9c1a1565 Merge #498: tests: Avoid calling fclose(...) with an invalid argument
f99aa8d4d3 Merge #499: tests: Make sure we get the requested number of bytes from /dev/urandom
b549d3d5f7 Merge #472: [build] Set --enable-jni to no by default instead of auto.
d333521516 Merge #494: Support OpenSSL versions >= 1.1 for ENABLE_OPENSSL_TESTS
2ef8ea5d21 Merge #495: Add bench_ecmult to .gitignore
82a96e4587 tests: Make sure we get the requested number of bytes from /dev/urandom
5aae5b5bb2 Avoid calling fclose(...) with an invalid argument
cb32940df3 Add bench_ecmult to .gitignore
31abd3ab8d Support OpenSSL versions >= 1.1 for ENABLE_OPENSSL_TESTS
c95f6f1360 Merge #487: fix tests typo, s/changed/unchanged
fb46c83881 Merge #463: Reduce usage of hardcoded size constants
02f5001dfc Merge #490: Disambiguate bench functions and types
1f46d6089e Disambiguate bench functions and types
f54c6c5083 Merge #480: Enable benchmark building by default
c77fc08597 Merge #486: Add pippenger_wnaf for multi-multiplication
d2f9c6b5dc Use more precise pippenger bucket windows
4c950bbeaf Save some additions per window in _pippenger_wnaf
a58f543f5a Add flags for choosing algorithm in ecmult_multi benchmark
36b22c9337 Use scratch space dependent batching in ecmult_multi
355a38f113 Add pippenger_wnaf ecmult_multi
bc65aa794e Add bench_ecmult
dba5471b69 Add ecmult_multi tests
8c1c831bdb Generalize Strauss to support multiple points
548de42ecf add resizeable scratch space API
0e96cdc6b6 fix typo, s/changed/unchanged
c7680e570f Reduce usage of hardcoded size constants
6ad5cdb42a Merge #479: Get rid of reserved _t in type names
7a78f60598 Print whether we're building benchmarks
4afec9f1ae Build benchmarks by default
d1dc9dfc0a Get rid of reserved _t in type names
57752d28b3 [build] Set --enable-jni to no by default instead of auto.
e7daa9b3c2 [build] Tweak JNI macro to warn instead of error for JNI not found.
5b22977922 [build] Update ax_jni_include_dir.m4 macro to deal with recent versions of macOS

git-subtree-dir: src/secp256k1
git-subtree-split: b19c000063be11018b4d1a6b0a85871ab9d0bdcf
2019-03-31 11:41:05 -07:00
João Barbosa
2ebf650b2e wallet: Update transactions with current mempool after load 2019-03-31 11:37:41 +01:00
João Barbosa
57908a739c interfaces: Add Chain::requestMempoolTransactions 2019-03-31 11:37:28 +01:00
MarcoFalke
79c345a011
Merge #15669: rpc: Fix help text for signtransactionwithXXX
afc06fc868 rpc: Fix help text for signtransactionwithXXX (Torkel Rogstad)

Pull request description:

  This PR fixes the help text for the `signrawtransactionwithwallet` and `signrawtransactionwithkey` RPC calls. They both marked the `amount` field in the UTXO dependencies as required. This field is omitted in the [`rpc_rawtransaction.py` test](8a8b03ecd2/test/functional/rpc_rawtransaction.py (L155)) and [`successful_signing_test`](8a8b03ecd2/test/functional/rpc_signrawtransaction.py (L42)) in `rpc_signrawtransaction.py`.

ACKs for commit afc06f:
  promag:
    utACK afc06fc.
  MarcoFalke:
    utACK afc06fc868

Tree-SHA512: 7847844ca38d8033fef2f5255700d21487d78a63ecee8b80362fa28fadfafc80ba29a89f38d7ebb3a1be4c7d47ff6c338f67afec9ee22bf065fb352bb3d03d3a
2019-03-29 18:26:00 -04:00
John Newbery
f5162458cd [rpc] remove resendwallettransactions RPC
This RPC was added for testing wallet rebroadcasts. Since we now have a
real test for wallet rebroadcasts, it's no longer needed.

The call in wallet_basic.py can be removed because
wallet_resendwallettransactions.py tests wallet rebroadcast.
2019-03-29 15:06:59 -04:00
practicalswift
6dd469a3be Disconnect BlockNotifyGenesisWait and RPCNotifyBlockChange properly. Remove no-op CClientUIInterface::[signal_name]_disconnect. 2019-03-29 19:34:53 +01:00
MarcoFalke
0baf4b1f96
Merge #15683: Comment for seemingly duplicate LIBBITCOIN_SERVER
2a1408c3ec Comment for seemingly duplicate LIBBITCOIN_SERVER (Peter Bushnell)

Pull request description:

  Added a comment to explain the addition of LIBBITCOIN_SERVER twice in bitcoind_LDADD which seems incorrect at a glance until the behaviour of Linux linkers is understood.

ACKs for commit 2a1408:
  practicalswift:
    ACK 2a1408c3ec
  MarcoFalke:
    ACK 2a1408c
  fanquake:
    utACK 2a1408c
  ryanofsky:
    utACK 2a1408c3ec

Tree-SHA512: dd2a7f61d53ce8882a56c831c32e1f48e9eab741ef21361f195c38bb455abdc4bc524d3b44b6f69c7498898cd871a23c39d215de28db3b20ef5fd2135d5e136a
2019-03-29 13:21:24 -04:00
practicalswift
0aef39d067 Silence "Test case [...] did not check any assertions" warnings when running "test_bitcoin --log_level=test_suite" 2019-03-29 15:31:48 +01:00
practicalswift
5fd73c8694 Avoid repeated log messages in tests by connecting to signal handlers (ThreadSafeMessageBox, etc.) only once 2019-03-29 15:14:35 +01:00
practicalswift
e502c3c515 tests: Reduce noise level in test_bitcoin output 2019-03-29 15:14:09 +01:00
Jonas Schnelli
edc68d40e9
Merge #15663: crypto: Remove unused AES-128 code
f6ee177f7 Remove unused AES-128 code (practicalswift)

Pull request description:

  Remove unused AES-128 code.

  As far as I can tell this AES-128 code has never been in use in the project (outside of testing/benchmarking).

  The AES-256 code is used in `CCrypter::Encrypt`/`CCrypter::Decrypt` (`src/wallet/crypter.cpp`).

  Trivia: 0.15% of the project's C++ LOC count (excluding dependencies) is trimmed off:

  ```
  $ LOC_BEFORE=$(git grep -I "" HEAD~1 -- "*.cpp" "*.h" ":(exclude)src/leveldb/" ":(exclude)src/secp256k1/" ":(exclude)src/univalue/" | wc -l)
  $ LOC_AFTER=$(git grep -I "" -- "*.cpp" "*.h" ":(exclude)src/leveldb/" ":(exclude)src/secp256k1/" ":(exclude)src/univalue/" | wc -l)
  $ bc <<< "scale=4; ${LOC_AFTER}/${LOC_BEFORE}"
  .9985
  ```

  :-)

Tree-SHA512: 9588a3cd795a89ef658b8ee7323865f57723cb4ed9560c21de793f82d35e2835059e7d6d0705e99e3d16bf6b2a444b4bf19568d50174ff3776caf8a3168f5c85
2019-03-29 10:22:24 +01:00
Peter Bushnell
2a1408c3ec Comment for seemingly duplicate LIBBITCOIN_SERVER 2019-03-28 15:31:42 +00:00
MarcoFalke
9e7dc682e0
Merge #15616: rpc: Clarify decodescript RPCResult doc
fa926ec24f rpc: Mention all output types in decodescript doc (MarcoFalke)
fa3caa1666 rpc: decodescript use IsValidNumArgs over hardcoded check (MarcoFalke)
faad33ff15 rpc: Clarify decodescript RPCResult doc (MarcoFalke)

Pull request description:

  * Remove `"hex"` from the decodescript RPCResult doc
  * Add `"segwit`" to the doc

  Follow up to a6099ef319 and 4f933b3d23

ACKs for commit fa926e:
  ryanofsky:
    utACK fa926ec24f. Only change since last review is listing possible output types in the help string using a new `GetAllOutputTypes` function

Tree-SHA512: e6ecc563d04769942567118d50188467bf64ceb276ba6268928d469e8f06621f2ca1ae1e555d3daa6ec22a615ee259bb31c4141c19818d0f53fb6c529b18381b
2019-03-28 10:56:56 -04:00
MarcoFalke
fa292adce9
doc: rpc-mining: Clarify error messages 2019-03-28 09:35:32 -04:00
Torkel Rogstad
afc06fc868 rpc: Fix help text for signtransactionwithXXX 2019-03-28 08:54:37 +01:00
Antoine Riard
765c0b364d refactor: combine Chain::findFirstBlockWithTime/findFirstBlockWithTimeAndHeight
As suggested in #14711, pass height to CChain::FindEarliestAtLeast to
simplify Chain interface by combining findFirstBlockWithTime and
findFirstBlockWithTimeAndHeight into one

Extend findearliestatleast_edge_test in consequence
2019-03-27 18:29:48 -04:00
João Barbosa
0440481c6b wallet: Move CWallet::ReacceptWalletTransactions locks to callers 2019-03-27 16:59:47 +00:00
MarcoFalke
656a15e539
Merge #15620: rpc: Uncouple non-wallet rpcs from maxTxFee global
fa1ad200d3 doc: Add release notes for 15620 (MarcoFalke)
fa96d76421 rpc: Uncouple rpcs from maxTxFee global (MarcoFalke)
fa965e03c7 rpc: Use IsValidNumArgs over hardcoded size checks (MarcoFalke)

Pull request description:

  This makes the rpcs a bit more stateless by falling back to their own default max fee instead of the global maxTxFee.

  A follow up pull request will move `-maxtxfee` to the wallet.

  See also related discussions:

  * `-maxtxfee` should not be used by both node and wallet #15355
  *  [RFC] Long term plan for wallet command-line args #13044

ACKs for commit fa1ad2:
  jnewbery:
    utACK fa1ad200d3
  Empact:
    utACK fa1ad200d3
  jnewbery:
    utACK fa1ad200d3
  promag:
    utACK fa1ad20.

Tree-SHA512: c9cf0b54cd30ff3ab0d090b072cc38fcbb2840bc6ad9a9711995333bc927d2500aece6b5a60e061666eca5ed72b70aa318d21e51eb15ee0106b41f5b6e4e1adf
2019-03-27 09:01:53 -04:00
Jonas Schnelli
3b64f852e4
QA: add test for CKey::Negate() 2019-03-27 13:59:53 +01:00
Jonas Schnelli
463921bb64
CKey: add method to negate the key 2019-03-27 13:59:50 +01:00
Wladimir J. van der Laan
208406038c
Merge #15519: Add Poly1305 implementation
e9d5e97561 Poly1305: tolerate the intentional unsigned wraparound in poly1305.cpp (Jonas Schnelli)
b34bf302f2 Add Poly1305 bench (Jonas Schnelli)
03be7f48fa Add Poly1305 implementation (Jonas Schnelli)

Pull request description:

  This adds a currently unused Poly1305 implementation including test vectors from RFC7539.

  Required for BIP151 (and related to #15512).

Tree-SHA512: f8c1ad2f686b980a7498ca50c517e2348ac7b1fe550565156f6c2b20faf764978e4fa6b5b1c3777a16e7a12e2eca3fb57a59be9c788b00d4358ee80f2959edb1
2019-03-27 11:53:15 +01:00
Glenn Willen
892eff05f1 Add documentation of struct PSBTAnalysis et al 2019-03-26 17:38:00 -07:00
Glenn Willen
ef22fe8c1f Refactor analyzepsbt for use outside RPC code
Refactor the analyzepsbt RPC into (1) an AnalyzePSBT function, which returns
its output as a new strongly-typed PSBTAnalysis struct, and (2) a thin wrapper
which converts the struct into a UniValue for RPC use.
2019-03-26 17:38:00 -07:00
Glenn Willen
afd20a25f2 Move PSBT decoding functions from core_io to psbt.cpp
Move PSBT decoding functions from core_io.h/core_read.cpp to psbt.h/psbt.cpp,
to deal with a linker issue.
2019-03-26 17:38:00 -07:00
Jonas Schnelli
b34bf302f2
Add Poly1305 bench 2019-03-26 18:12:31 +01:00
Jonas Schnelli
03be7f48fa
Add Poly1305 implementation 2019-03-26 18:12:29 +01:00
r8921039
c968780785 [docs] fix comment: the return value of findFork is _not_ an ancestor when the specified block is on the active chain
update with suggested comment text from the reviewers
2019-03-25 14:28:05 -07:00
practicalswift
f6ee177f7d Remove unused AES-128 code 2019-03-25 14:46:30 +01:00
Miguel Herranz
e16b6a7188
rpc: Rename size to vsize in mempool related calls 2019-03-24 12:01:43 +08:00
Luca Venturini
5d35ae3326 Handle the result of posix_fallocate system call 2019-03-23 20:35:24 +00:00
251
418d3230f8 Resolve the checkpoints <-> validation CD.
This commit resolves the checkpoints -> validation -> checkpoints
cirular dependency by moving
`CheckPoints::GetLastCheckpoint(const CCheckpointData& data)` from
`checkpoints.cpp` to `validation.cpp`.
2019-03-23 17:43:54 +01:00
MarcoFalke
fa8548c5d1
net: Remove unused unsanitized user agent string CNode::strSubVer 2019-03-23 11:32:40 -04:00
Luke Dashjr
8a2656702b torcontrol: Use the default/standard network port for Tor hidden services, even if the internal port is set differently
Currently, the hidden service is published on the same port as the public listening port.
But if a non-standard port is configured, this can be used to guess (pretty reliably) that the public IP and the hidden service are the same node.
2019-03-23 06:13:37 +00:00
Pieter Wuille
866c8058a7 Interrupt orphan processing after every transaction
This makes orphan processing work like handling getdata messages:
After every actual transaction validation attempt, interrupt
processing to deal with messages arriving from other peers.
2019-03-22 19:25:50 -07:00
Pieter Wuille
6e051f3d32 [MOVEONLY] Move processing of orphan queue to ProcessOrphanTx 2019-03-22 19:21:58 -07:00
Pieter Wuille
9453018fdc Simplify orphan processing in preparation for interruptibility 2019-03-22 19:10:22 -07:00
MarcoFalke
fae38c3dc6
doc: Fix all typos reported by codespell 2019-03-22 13:19:44 -04:00
John Newbery
7b6616b78b [rpc] Remove deprecated functionality message from validateaddress help
This functionality was removed in v0.18.
2019-03-22 10:30:25 -04:00
John Newbery
839c3f7c49 [rpc] Remove signrawtransaction warning
signrawtransaction was deprecated in 0.17 and removed in 0.18. A warning
was left in place to tell users to migrate to using
signrawtransactionswithwallet or signrawtransactionwithkey. Remove the
warning now that it's been two releases since the method was removed.
2019-03-22 10:30:25 -04:00
João Barbosa
a10972bc03 gui: Defer removeAndDeleteWallet when no modal widget is active 2019-03-22 09:51:04 +00:00
Ben Woosley
effe81f750
Move g_is_mempool_loaded into CTxMemPool::m_is_loaded
So the loaded state is explicitly mempool-specific.
2019-03-22 02:31:25 -07:00
Ben Woosley
bb8ae2c419
rpc: Expose g_is_mempool_loaded via getmempoolinfo and /rest/mempool/info.json
And use it to fix a race condition in mempool_persist.py:
https://travis-ci.org/Empact/bitcoin/jobs/487577243

Since e.g. getrawmempool returns errors based on this status, this
enables users to test it for readiness.
2019-03-22 02:31:20 -07:00
MeshCollider
717fd58c4b
Merge #15625: refactor: Remove unused function
bb6195e34 refactor: Remove unused function (practicalswift)

Pull request description:

  Last use removed in cad5dd2368.

Tree-SHA512: f65bf8f77b9aadbfba39bd80076a4d773eddf685a8a90ef2db549552a3d0ccd426ce3920b2f71954703f64d840fa88349957996d1f64a9c4d3f27a99b4da70e7
2019-03-21 21:00:25 +13:00
MeshCollider
2607d960a0
Merge #10973: Refactor: separate wallet from node
d358466de Remove remaining wallet accesses to node globals (Russell Yanofsky)
b1b2b2389 Remove use of CCoinsViewMemPool::GetCoin in wallet code (Russell Yanofsky)
4e4d9e9f8 Remove use of CRPCTable::appendCommand in wallet code (Russell Yanofsky)
91868e628 Remove use CValidationInterface in wallet code (Russell Yanofsky)

Pull request description:

  This PR is the last in a chain of PRs (#14437, #14711, and #15288) that make the wallet code access node state through an abstract [`Chain`](https://github.com/ryanofsky/bitcoin/blob/pr/wipc-sep/src/interfaces/chain.h) class in [`src/interfaces/`](https://github.com/ryanofsky/bitcoin/tree/pr/wipc-sep/src/interfaces) instead of using global variables like `cs_main`, `chainActive`, and `g_connman`. After this PR, wallet code no longer accesses global variables declared outside the wallet directory, and no longer calls functions accessing those globals (as verified by the `hide-globals` script in #10244).

  This PR and the previous PRs have been refactoring changes that do not affect behavior. Previous PRs have consisted of lots of mechanical changes like:

  ```diff
  -    wtx.nTimeReceived = GetAdjustedTime();
  +    wtx.nTimeReceived = m_chain->getAdjustedTime();
  ```

  This PR is smaller, but less mechanical. It replaces last few bits of wallet code that access node state directly (through `CValidationInterface`, `CRPCTable`, and `CCoinsViewMemPool` interfaces) with code that uses the `Chain` interface.

  These changes allow followup PR #10102 (multiprocess gui & wallet PR) to work without any significant updates to wallet code. Additionally they:

  * Provide a single place to describe the interface between wallet and node code.
  * Can make better wallet testing possible, because the `Chain` object consists of virtual methods that can be overloaded for mocking. (This could be used to test edge cases in the rescan code, for example).

Tree-SHA512: e6291d8a3c50bdff18a9c8ad11e729beb30b5b7040d7aaf31ba678800b4a97b2dd2be76340b1e5c01fe2827d67d37ed1bb4c8380cf8ed653aadfea003e9b22e7
2019-03-21 20:58:43 +13:00
Wladimir J. van der Laan
b3f82284ba
Merge #15597: net: Generate log entry when blocks messages are received unexpectedly
ef0019e054 Generate log entry when blocks messages are received unexpectedly. (Patrick Strateman)

Pull request description:

  Currently these are incorrectly logged as an unknown command.

Tree-SHA512: dd272388a90b79897f8c1ea6d4c949323fcf75493f3a5b2ec9a26a2cf6a8ee743b497941702f21df8fae0f5b9481444363643379832dbd5053b0cc0b0363de04
2019-03-20 20:36:25 +01:00
MarcoFalke
93623eea71
Merge #15623: refactor: Expose UndoReadFromDisk in header
fa11c036e9 refactor: Expose UndoReadFromDisk in header (MarcoFalke)

Pull request description:

  It is not possible to calculate the fee of a non-mempool transaction in RPCs unless txindex is active or the prevtxs are passed in through the RPC.

  Fix that issue for confirmed txs by exposing `UndoReadFromDisk` in the header file.

  This pull is a requirement for
  * rpc: faster getblockstats using BlockUndo data #14802
  *  Index for BIP 157 block filters #14121
  * my local patches

Tree-SHA512: 859ea5f2dfb4feac612b50faeb0e2b6c07b83f1d983e519d7647a78058d85c0390fd09ec66b460ae7a4c3b273e81b0013ee9f4bb8dfba0c4782ffaa1fa453ea6
2019-03-20 12:28:18 -04:00
Wladimir J. van der Laan
81f732bcaa
Merge #15617: p2p: Do not relay banned IP addresses
054d01d0a8 Do not relay banned IP addresses (Pieter Wuille)

Pull request description:

Tree-SHA512: 538c43781c789949e1ae566533e76835d478e40e8ba6427b22234ee611cb4a311b2940a214e37c1e9c9afe28a6814a00d490a39e3580bb5ebd85b03e95040246
2019-03-20 11:38:08 +01:00
practicalswift
bb6195e34d refactor: Remove unused function 2019-03-20 10:51:15 +01:00
MarcoFalke
fa1ad200d3
doc: Add release notes for 15620 2019-03-19 17:06:43 -04:00
MarcoFalke
dddd6f0f58
init: Throw error when network specific config is ignored 2019-03-19 16:30:07 -04:00
MarcoFalke
fa926ec24f
rpc: Mention all output types in decodescript doc 2019-03-19 15:54:39 -04:00
MarcoFalke
fa11c036e9
refactor: Expose UndoReadFromDisk in header 2019-03-19 14:20:43 -04:00
Wladimir J. van der Laan
e45b7f20e6
Merge #15618: refactor: Remove unused function
fa5c511a83 refactor: Remove unused function (MarcoFalke)

Pull request description:

  Oversight of kallewoof and mine in https://github.com/bitcoin/bitcoin/pull/13541#discussion_r266555476

Tree-SHA512: 2fd3c4ecde5d3c58b113aa58d606976ceb4998358bde0547ead8e83df210722fa9821d2c88b717bdd190ef71593cd9c0154c3a5d3f2ccc3af8cbf6c36aaa6d45
2019-03-18 20:06:11 +01:00
MarcoFalke
fa96d76421
rpc: Uncouple rpcs from maxTxFee global 2019-03-18 13:56:56 -04:00
MarcoFalke
fa965e03c7
rpc: Use IsValidNumArgs over hardcoded size checks 2019-03-18 13:55:19 -04:00
MarcoFalke
fa5c511a83
refactor: Remove unused function 2019-03-18 13:30:55 -04:00
MarcoFalke
c033c4b5ce
Merge #13541: wallet/rpc: sendrawtransaction maxfeerate
7abd2e697c wallet/rpc: add maxfeerate parameter to testmempoolaccept (Karl-Johan Alm)
6c0a6f73e3 wallet/rpc: add maxfeerate parameter to sendrawtransaction (Karl-Johan Alm)
e5efacb941 test: Refactor vout fetches in rpc_rawtransaction (Karl-Johan Alm)

Pull request description:

  This adds a new `maxfeerate` parameter to `sendrawtransaction` which forces the node to reject a transaction whose feerate is above the given fee rate.

  This is a safety harness from shooting yourself in the foot and accidentally overpaying fees.

  See also #12911.

Tree-SHA512: efa50134a7c17c9330cfdfd48ba400e095c0a419cc45e630618d8b44929c25d780d1bb2710c1fbbb6e687eca373505b0338cdaa7f2ff4ca22636d84c31557a2e
2019-03-18 13:22:15 -04:00
Carl Dong
340ef50772 depends: Defer to Python detected by autoconf
Since autoconf already detects the correct python binary path, we should
use that instead of going around it. Also has the benefit of working in
extremely restricted environments where /usr/bin/env might not be
available.
2019-03-18 11:05:17 -04:00
MeshCollider
7ec7aea442
Merge #15491: wallet: Improve log output for errors during load
faf369880 wallet: Improve log output for errors during load (Glenn Willen)

Pull request description:

  When loading the wallet, display the entire path in error messages, instead of
  the name (which, for the default wallet, is the empty string.)

  When an exception occurs during wallet loading, display e.what() if possible,
  instead of nothing.

Tree-SHA512: 435247628db669579bb694ba4b53ba174fe42c0329fc72f09fc274bb28463ee69f53412abb2a3b45bb8f59f7eb928c0167e397b8d0a514135142192a87294614
2019-03-18 20:34:55 +13:00
Pieter Wuille
054d01d0a8 Do not relay banned IP addresses 2019-03-17 22:05:49 -07:00
MarcoFalke
fa3caa1666
rpc: decodescript use IsValidNumArgs over hardcoded check 2019-03-17 22:52:18 -04:00
MarcoFalke
faad33ff15
rpc: Clarify decodescript RPCResult doc 2019-03-17 22:51:33 -04:00
Wladimir J. van der Laan
2f501fb5c6
Merge #15522: Document sizeof(size_t) assumptions and compiler assumptions in assumptions.h
c7a7250302 Document assumptions about C++ compiler (practicalswift)
c7ea8d3236 Add sizeof(size_t) assumptions (practicalswift)

Pull request description:

  Document `sizeof(size_t)` assumptions and compiler assumptions by adding compile-time checks in `assumptions.h`.

Tree-SHA512: db46481eecad6a87718ae637a7761d39d32cfe6f95fc8ad2b3a52a3d966c2a05c8f540dd3f362721279816571b04b6cce2de9b3b1d17606d7b197126cd4a8d1f
2019-03-16 17:11:14 +01:00
Glenn Willen
faf3698808 wallet: Improve log output for errors during load
When loading the wallet, display the entire path in error messages, instead of
the name (which, for the default wallet, is the empty string.)

When an exception occurs during wallet loading, display e.what() if possible,
instead of nothing.
2019-03-14 18:49:19 -07:00
MarcoFalke
fac1a0fe54
wallet: Remove unused GetLegacyBalance 2019-03-14 16:05:13 -04:00
MarcoFalke
faa3a246e8
scripted-diff: wallet: Rename pcoin to wtx
-BEGIN VERIFY SCRIPT-
sed -i --regexp-extended -e 's/const CWalletTx ?\* ?pcoin = &/const CWalletTx\& wtx = /g' src/wallet/wallet.cpp
sed -i -e 's/\<pcoin->/wtx./g' src/wallet/wallet.cpp
sed -i -e 's/\<pcoin\>/\&wtx/g' src/wallet/wallet.cpp
-END VERIFY SCRIPT-
2019-03-14 16:03:53 -04:00
Wladimir J. van der Laan
7fa1f6258c
Merge #15583: wallet: Log and ignore errors in ListWalletDir and IsBerkeleyBtree
15c69b158d wallet: Log and ignore errors in ListWalletDir and IsBerkeleyBtree (João Barbosa)

Pull request description:

  Use the `noexcept` members of `boost::filesystem::recursive_directory_iterator` in order to ignore `boost::filesystem::directory_iterator::construct: Permission denied` errors. The errors are logged though.

  Steps to reproduce the issue:

  ```sh
  # 1. create directory for -walletdir without read access:
  mkdir /tmp/foo && chmod a-r /tmp/foo

  # 2. run bitcoin-qt and should print an error, but continues running:
  /Volumes/Bitcoin-Core/Bitcoin-Qt.app/Contents/MacOS/Bitcoin-Qt -regtest -walletdir=/tmp/foo
  /private/tmp/foo: Permission denied

  # 4. go to File -> Open Wallet and should segfault:
  EXCEPTION: N5boost10filesystem16filesystem_errorE
  boost::filesystem::directory_iterator::construct: Permission denied: "/private/tmp/foo"
  bitcoin in Runaway exception
  ```

Tree-SHA512: 37e8bf5a1e0defc331030fd511bf9cac2765d01dfbf23e7233f37506e85b8ad07edcde9ba6dae7a2c95700c78d28c7dd248153607381852da96273cb159c4934
2019-03-14 18:58:43 +01:00
Patrick Strateman
ef0019e054 Generate log entry when blocks messages are received unexpectedly. 2019-03-13 21:05:15 -04:00
Karl-Johan Alm
6c0a6f73e3
wallet/rpc: add maxfeerate parameter to sendrawtransaction 2019-03-14 08:48:46 +09:00
Karl-Johan Alm
7abd2e697c
wallet/rpc: add maxfeerate parameter to testmempoolaccept 2019-03-14 08:48:46 +09:00
João Barbosa
15c69b158d wallet: Log and ignore errors in ListWalletDir and IsBerkeleyBtree 2019-03-13 20:41:42 +00:00
MarcoFalke
fae5f874d5
rpc: Document that minconf is an ignored dummy value 2019-03-13 14:43:55 -04:00
Wladimir J. van der Laan
8e1704c015
Merge #15559: doc: correct analyzepsbt rpc doc
335931df4a rpc: return a number for estimated_feerate in analyzepsbt (fanquake)
a4d0fd026b doc: correct analysepsbt rpc doc (fanquake)

Pull request description:

  Even though `missing` is optional, all its field are also all optional.

  `estimated_vsize` is optional (calculate alongside `estimated_feerate`).

  Make `estimated_feerate` output numeric.

Tree-SHA512: 5e063bcfbca73d3d08d29c5d1f59bc1791757f69248da4a9c70fe4b2fe82807ec4ed9fca48d439101d66ba924916fa5da9232167d74ea2b967fc04f0a36f190e
2019-03-13 12:18:19 +01:00
Wladimir J. van der Laan
c3b1cb958f
Merge #15573: dead code: Remove dead option in HexStr conversion
56f1d28d9b dead code: Remove dead option in HexStr conversion (Lenny Maiorani)

Pull request description:

  Problem:
  - Nothing uses the `fspaces` argument to `HexStr()` besides unit
    tests. This argument results in extra complexity and a small
    performance decrease within the function.

  Solution:
  - Remove unused `fspaces` option.
  - Remove associated unit tests.

Tree-SHA512: 33d00ce354bbc62a77232fa301cdef0a9ed2c5a09e792bc40e9620c2f2f88636e322a38c76b81d10d12a1768dd1b3b2b9cf180f7e33daef9b4f27afed68ccf70
2019-03-12 13:11:26 +01:00
fanquake
335931df4a
rpc: return a number for estimated_feerate in analyzepsbt 2019-03-12 07:17:42 +08:00
fanquake
a4d0fd026b
doc: correct analysepsbt rpc doc 2019-03-12 07:17:22 +08:00
Pieter Wuille
c9963ae8b1 Fix overflow bug in analyzepsbt fee: CAmount instead of int 2019-03-11 15:17:05 -07:00
MarcoFalke
c94852e791
Merge #15564: cli: remove duplicate wallet fields from -getinfo
3f6568d66b cli: remove duplicate wallet fields from -getinfo (fanquake)

Pull request description:

  `walletversion` and `balance` are both included below.

Tree-SHA512: cd9fe9739a2f492c8f7c0407b43a6fa95187f7e5318f05e080bac112f9f4333d2e9b84c505d098f8d66fa79439007d1c0b22e5a87d70bf5ea53ab647ee4c2046
2019-03-11 10:28:42 -04:00
MarcoFalke
887f57eb72
Merge #15566: cli: replace testnet with chain and return network name as per BIP70.
890396cbd5 cli: replace testnet with chain and return network name as per BIP70. (fanquake)

Pull request description:

  Related IRC discussion [here (line 151)](http://www.erisian.com.au/bitcoin-core-dev/log-2019-03-09.html).

Tree-SHA512: 8bdbacc7b8ce8bd2cc7c47aa9d73f2830a7c2e2ec43686430e3fba1a9db0e53a285467f26cde6dcc3bf948b7d6d59b9b7f184ce1a30a8970f39e5396dfc122f0
2019-03-11 10:26:46 -04:00
Lenny Maiorani
56f1d28d9b dead code: Remove dead option in HexStr conversion
Problem:
- Nothing uses the `fspaces` argument to `HexStr()` besides unit
  tests. This argument results in extra complexity and a small
  performance decrease within the function for branch evalulation.

Solution:
- Remove unused `fspaces` option.
2019-03-10 21:45:31 -06:00
fanquake
3f6568d66b
cli: remove duplicate wallet fields from -getinfo 2019-03-09 16:40:46 +08:00
fanquake
890396cbd5
cli: replace testnet with chain and return network name as per BIP70. 2019-03-09 16:35:26 +08:00
Wladimir J. van der Laan
ff38148808
Merge #15486: [addrman, net] Ensure tried collisions resolve, and allow feeler connections to existing outbound netgroups
20e6ea259b [addrman] Improve collision logging and address nits (Suhas Daftuar)
f71fdda3bc [addrman] Ensure collisions eventually get resolved (Suhas Daftuar)
4991e3c813 [net] feeler connections can be made to outbound peers in same netgroup (Suhas Daftuar)
4d834018e3 [addrman] Improve tried table collision logging (Suhas Daftuar)

Pull request description:

  The restriction on outbound peers sharing the same network group is not intended to apply to feeler connections, so fix this.

  This fixes an issue where a tried table collision with an entry to a netgroup we already have an outbound connection to could cause feelers to stop working, because the tried collision buffer (`m_tried_collisions`) would never be drained.

  Also, ensure that all entries don't linger in `m_tried_collisions` by evicting an old entry if its collisions is unresolved after 40 minutes.

Tree-SHA512: 553fe2b01b82cd7f0f62f90c6781e373455a45b254e3bec085b5e6b16690aa9f3938e8c50e7136f19dafa250ed4578a26227d944b76daf9ce4ef0c75802389b6
2019-03-09 07:12:17 +01:00
João Barbosa
e377846ff1 rest/rpc: Make mempoolinfo atomic 2019-03-08 16:25:04 +00:00
João Barbosa
2d5cf4c41d rpc: Speedup getrawmempool when verbose=true
Co-Authored-By: MarcoFalke <falke.marco@gmail.com>
2019-03-08 15:50:18 +00:00
Wladimir J. van der Laan
efed9809b4
Merge #15532: Remove sharp edge (uninit member) when using the compiler-generated ctor for BlockFilter
82c3b3f8e0 Remove sharp edge (uninitialized m_filter_type) when using the compiler-generated constructor for BlockFilter (practicalswift)

Pull request description:

  Remove sharp edge (uninitialised member `m_filter_type`) when using the compiler-generated constructor for `BlockFilter`.

  Before (but after added test):

  ```
  $ src/test/test_bitcoin -t blockfilter_tests/blockfilter_basic_test
  Running 1 test case...
  test/blockfilter_tests.cpp(118): error: in "blockfilter_tests/blockfilter_basic_test": check default_ctor_block_filter_1.GetFilterType() == default_ctor_block_filter_2.GetFilterType() has failed [ != ]

  *** 1 failure is detected in the test module "Bitcoin Test Suite"
  ```

  After:

  ```
  $ src/test/test_bitcoin -t blockfilter_tests/blockfilter_basic_test
  Running 1 test case...

  *** No errors detected
  ```

Tree-SHA512: 21d41f036b0bf12adcf1a788d84747353f2023cb85fd8ea6c97222967032e8bf54e7910cadb45dfcecd78e5b5dca86685f78cad0596b6d1a08f910ebf20d90aa
2019-03-08 15:26:28 +01:00
Jonas Schnelli
d211edb349
Merge #15464: gui: Drop unused return values in WalletFrame
28c86de3b gui: Drop unused return values in WalletFrame (João Barbosa)

Pull request description:

  This is a small cleanup since the return value of `WalletFrame` methods are not used. This is in line with the usual async slot declaration.

Tree-SHA512: ff0ca098804118bba200a58cd796ff90e853a6430e58125bd178b7bfa9b2b763c13d17b81e8f3ebd94395cac249d80379ba1529680c47682ba6a2ed81492ba33
2019-03-07 21:04:28 +01:00
Wladimir J. van der Laan
3db0cc3947
Merge #15402: Granular invalidateblock and RewindBlockIndex
519b0bc5dc Make last disconnected block BLOCK_FAILED_VALID, even when aborted (Pieter Wuille)
8d220417cd Optimization: don't add txn back to mempool after 10 invalidates (Pieter Wuille)
9ce9c37004 Prevent callback overruns in InvalidateBlock and RewindBlockIndex (Pieter Wuille)
9bb32eb571 Release cs_main during InvalidateBlock iterations (Pieter Wuille)
9b1ff5c742 Call InvalidateBlock without cs_main held (Pieter Wuille)
241b2c74ac Make RewindBlockIndex interruptible (Pieter Wuille)
880ce7d46b Call RewindBlockIndex without cs_main held (Pieter Wuille)
436f7d735f Release cs_main during RewindBlockIndex operation (Pieter Wuille)
1d342875c2 Merge the disconnection and erasing loops in RewindBlockIndex (Pieter Wuille)
32b2696ab4 Move erasure of non-active blocks to a separate loop in RewindBlockIndex (Pieter Wuille)
9d6dcc52c6 Abstract EraseBlockData out of RewindBlockIndex (Pieter Wuille)

Pull request description:

  This PR makes a number of improvements to the InvalidateBlock (`invalidateblock` RPC) and RewindBlockIndex functions, primarily around breaking up their long-term cs_main holding. In addition:
  * They're made safely interruptible (`bitcoind` can be shutdown, and no progress in either will be lost, though if incomplete, `invalidateblock` won't continue after restart and will need to be called again)
  * The validation queue is prevented from overflowing (meaning `invalidateblock` on a very old block will not drive bitcoind OOM) (see #14289).
  * `invalidateblock` won't bother to move transactions back into the mempool after 10 blocks (optimization).

  This is not an optimal solution, as we're relying on the scheduler call sites to make sure the scheduler doesn't overflow. Ideally, the scheduler would guarantee this directly, but that needs a few further changes (moving the signal emissions out of cs_main) to prevent deadlocks.

  I have manually tested the `invalidateblock` changes (including interrupting, and running with -checkblockindex and -checkmempool), but haven't tried the rewinding (which is probably becoming increasingly unnecessary, as very few pre-0.13.1 nodes remain that would care to upgrade).

Tree-SHA512: 692e42758bd3d3efc2eb701984a8cb5db25fbeee32e7575df0183a00d0c2c30fdf72ce64c7625c32ad8c8bdc56313da72a7471658faeb0d39eefe39c4b8b8474
2019-03-07 17:40:58 +01:00
MarcoFalke
726d0668ff
Merge #15530: doc: Move wallet lock annotations to header
faebd2ef40 doc: Move wallet lock annotations to header (MarcoFalke)

Pull request description:

  We put the annotations in a central place (the header) as opposed to spreading them over the cpp files, where they easily get outdated.

Tree-SHA512: 18d8c7329efd3471713de18fe8d63d67c50fcb9fa99bc372294d829aa7668ea33e10d44e9e50121a04d8cc3302d5fd7759224f7935451a4693c4498a555257e6
2019-03-07 11:34:04 -05:00
MarcoFalke
3515612e06
Merge #15473: bench: Benchmark MempoolToJSON
fa38535130 bench: Benchmark MempoolToJSON (MarcoFalke)
fa5dc3534b rpc: Pass mempool into MempoolToJSON (MarcoFalke)

Pull request description:

  This is used in production (e.g. https://jochen-hoenicke.de/queue/#0,24h), so add a benchmark to avoid making it even slower.

  Related:

  * "getrawmempool true RPC call is O(n^2)" #14765

Tree-SHA512: da09d2e54ee261af8671152f97f863cf1acd7a6adc6578e94046b1ec9e647a670c67499760ef765254f65522dfdf773c3c8729006fa2d63ccb6d53166bafc425
2019-03-06 16:58:37 -05:00
Russell Yanofsky
d358466de1 Remove remaining wallet accesses to node globals 2019-03-06 16:47:57 -05:00
MarcoFalke
df36ddf9ce
Merge #15504: fuzz: Link BasicTestingSetup (shared with unit tests)
faa9b88199 fuzz: Link BasicTestingSetup (shared with unit tests) (MarcoFalke)
fa85468cd2 test: Move main_tests to validation_tests (MarcoFalke)
fa02b22245 test: Remove useless test_bitcoin_main.cpp (MarcoFalke)
fab2daa026 test: Add missing LIBBITCOIN_ZMQ to test_test_bitcoin_LDADD (MarcoFalke)

Pull request description:

  Link against BasicTestingSetup in the fuzz tests, so we can fuzz against validation.

  Also include a commit to remove test_bitcoin_main.cpp. That file may or may not overwrite globals in the link stage depending on the link order. This is confusing and useless anyway: The unit tests should never `std::exit` in the middle of the run (especially with success as exit code), since it will skip all test modules afterward.

  Also include a commit to remove some unused forward declarations and move the main_tests to validation_tests, since main was long ago split into net_processing and validation.

Tree-SHA512: bdd34c87505450ec106d632f6664aadcbdac7c198172a77da55fab75b274f869ae1a8d06573ba2aff4cb186be9c7a34b7697894ab6f9c82b392f769c9135f36c
2019-03-06 15:16:23 -05:00
Russell Yanofsky
b1b2b23892 Remove use of CCoinsViewMemPool::GetCoin in wallet code
This commit does not change behavior.
2019-03-05 10:20:00 -04:00
Russell Yanofsky
4e4d9e9f85 Remove use of CRPCTable::appendCommand in wallet code
This commit does not change behavior.
2019-03-05 10:20:00 -04:00
Russell Yanofsky
91868e6288 Remove use CValidationInterface in wallet code
This commit does not change behavior.
2019-03-05 10:20:00 -04:00
practicalswift
c7a7250302 Document assumptions about C++ compiler 2019-03-05 11:19:32 +01:00
practicalswift
82c3b3f8e0 Remove sharp edge (uninitialized m_filter_type) when using the compiler-generated constructor for BlockFilter 2019-03-05 09:08:04 +01:00
MarcoFalke
faebd2ef40
doc: Move wallet lock annotations to header 2019-03-04 15:59:23 -05:00
Russell Yanofsky
4d4e4c6448 Suggested interfaces::Chain cleanups from #15288
Mostly documentation improvements requested in the last review of #15288 before
it was merged
(https://github.com/bitcoin/bitcoin/pull/15288#pullrequestreview-210241864)
2019-03-04 15:57:58 -05:00
MarcoFalke
45f434f44d
Merge #15288: Remove wallet -> node global function calls
f7efd87c8f Change brace formatting (Russell Yanofsky)
a1df1b48a8 Remove use of IsInitialBlockDownload in wallet code (Russell Yanofsky)
1106a6fde4 Remove use of uiInterface.LoadWallet in wallet code (Russell Yanofsky)
318f41fb2c circular-dependencies: Avoid treating some .h/.cpp files as a unit (Russell Yanofsky)
d02b34c8a8 Remove use of AcceptToMemoryPool in wallet code (Russell Yanofsky)
e2c8ba9f6e Remove uses of InitMessage/Warning/Error in wallet code (Russell Yanofsky)
c5e59a96a8 Remove uses of GetAdjustedTime in wallet code (Russell Yanofsky)
6d6bcc77c0 Remove use of g_connman / PushInventory in wallet code (Russell Yanofsky)
00dfb2a440 Remove uses of g_connman in wallet code (Russell Yanofsky)
cc3836e8f9 Remove uses of fPruneMode in wallet code (Russell Yanofsky)
cc02c796d3 Remove uses of fee globals in wallet code (Russell Yanofsky)
1fb0a4a04e Remove use of CalculateMemPoolAncestors in wallet code (Russell Yanofsky)
cd32160af0 Remove use of GetTransactionAncestry in wallet code (Russell Yanofsky)
291276f7f4 Remove use of GetCountWithDescendants in wallet code (Russell Yanofsky)
bdc6628683 Remove use of IsRBFOptIn in wallet code (Russell Yanofsky)
80f52a2267 Remove uses of CheckFinalTx in wallet code (Russell Yanofsky)

Pull request description:

  This change removes wallet calls to node functions that access global chain and mempool state.

  This is the next step in the larger #10973 refactoring change, which removes all other accesses to node global variables from wallet code. Doing this is useful to provide a better defined interface between the wallet and node, and necessary to allow wallet and node code to run in separate processes in #10102.

Tree-SHA512: 40dbaf1f59fb22b32e70b054b30ba5638d638aa3240fa30e0f721d53c721cd6138a7ab4d423a24d7d2fda0b956e68d44c733abc2c9259c3d6c9fd6d4be89aa23
2019-03-04 13:13:36 -05:00
practicalswift
c7ea8d3236 Add sizeof(size_t) assumptions 2019-03-04 14:15:58 +01:00
Pieter Wuille
519b0bc5dc Make last disconnected block BLOCK_FAILED_VALID, even when aborted 2019-03-03 13:01:26 -08:00
Wladimir J. van der Laan
2d46f1be0c
Merge #15118: Refactor block file logic
04cca33094 Style cleanup. (Jim Posen)
4c01e4e159 flatfile: Unit tests for FlatFileSeq methods. (Jim Posen)
65a489e93d scripted-diff: Rename CBlockDiskPos to FlatFilePos. (Jim Posen)
d6d8a78f26 Move CDiskBlockPos from chain to flatfile. (Jim Posen)
e0380933e3 validation: Refactor file flush logic into FlatFileSeq. (Jim Posen)
992404b31e validation: Refactor block file pre-allocation into FlatFileSeq. (Jim Posen)
e2d2abb99f validation: Refactor OpenDiskFile into method on FlatFileSeq. (Jim Posen)
9183d6ef65 validation: Extract basic block file logic into FlatFileSeq class. (Jim Posen)
62e7addb63 util: Move CheckDiskSpace to util. (Jim Posen)

Pull request description:

  This cleans up and refactors block file helpers so that they may be used by the block filter indexer. Per [design discussion](https://github.com/bitcoin/bitcoin/pull/14121#issuecomment-451252591) about storing BIP 157 block filters, it has been suggested that they are stored in the same way as block and undo data. This refactor is sufficient to simplify file operations for this use case, though in the future perhaps more pruning-related logic ought to be moved into the new classes.

  The basic abstraction is a `FlatFileSeq` which manages access to a sequence of numbered files into which raw data is written.

Tree-SHA512: b2108756777f2dad8964a1a2ef2764486e708a4a4a8cfac47b5de8bcb0625388964438eb096b10cfd9ea39212c299b5cb32fa943e768db2333cf49ea7def157e
2019-03-02 23:20:38 +01:00
MarcoFalke
789b0bbf2a
Merge #15335: Fix lack of warning of unrecognized section names
1a7ba84e11 Fix lack of warning of unrecognized section names (Akio Nakamura)

Pull request description:

  In #14708, It was introduced that to warn when unrecognized section names are exist in the config file.
  But ```m_config_sections.clear()```  in ```ArgsManager::ReadConfigStream()``` is called every time when reading each configuration file, so it can warn about only last reading file if ```includeconf``` exists.

  This PR fix lack of warning by collecting all section names by moving ```m_config_sections.clear()```  to ```ArgsManager::ReadConfigFiles()``` .
  Also add a test code to confirm this situation.

Tree-SHA512: 26aa0cbe3e4ae2e58cbe73d4492ee5cf465fd4c3e5df2c8ca7e282b627df9e637267af1e3816386b1dc6db2398b31936925ce0e432219fec3a9b3398f01e3e65
2019-03-02 09:59:18 -05:00
MarcoFalke
9e3122de05
Merge #15492: [rpc] remove deprecated generate method
07cae5287c [wallet] remove unused GetScriptForMining (Sjors Provoost)
8bb3e4c487 [rpc] remove deprecated generate method (Sjors Provoost)

Pull request description:

  As announced in v0.18, the wallet generate rpc method is deprecated and will be fully removed in v0.19.

  Clients should transition to using the node rpc method `generatetoaddress`.

Tree-SHA512: 9e5e913b59f3e18440b2b7b356124c7b87ad19f81a1ab6ada06a6c396b84e734895465f569296f1ba8c12abf74863bab5fd77765c9e806c239713aa83a59485f
2019-03-02 09:43:39 -05:00
Suhas Daftuar
20e6ea259b [addrman] Improve collision logging and address nits 2019-03-01 16:15:50 -05:00
Sjors Provoost
9586157c0f
[rpc] deriveaddresses: add range to CRPCConvertParam 2019-03-01 15:34:43 +01:00
Sjors Provoost
07cae5287c
[wallet] remove unused GetScriptForMining 2019-03-01 13:14:08 +01:00
Pieter Wuille
ca253f6ebf Make deriveaddresses use stop/[start,stop] notation for ranges 2019-02-28 21:40:09 -08:00
Pieter Wuille
8d220417cd Optimization: don't add txn back to mempool after 10 invalidates 2019-02-28 14:12:26 -08:00
Pieter Wuille
9ce9c37004 Prevent callback overruns in InvalidateBlock and RewindBlockIndex 2019-02-28 14:12:26 -08:00
Pieter Wuille
9bb32eb571 Release cs_main during InvalidateBlock iterations 2019-02-28 14:12:22 -08:00
Pieter Wuille
1675b7ce55 Use stop/[start,stop] notation in importmulti desc range 2019-02-28 13:05:10 -08:00
Pieter Wuille
4566011631 Add support for stop/[start,stop] ranges to scantxoutset 2019-02-28 13:01:44 -08:00
Pieter Wuille
6b9f45e81b Support ranges arguments in RPC help 2019-02-28 13:00:13 -08:00
Pieter Wuille
7aa6a8aefb Add ParseRange function to parse args of the form int/[int,int] 2019-02-28 13:00:09 -08:00
MarcoFalke
faa9b88199
fuzz: Link BasicTestingSetup (shared with unit tests) 2019-02-28 15:45:56 -05:00
MarcoFalke
fa85468cd2
test: Move main_tests to validation_tests 2019-02-28 15:44:55 -05:00
MarcoFalke
fa02b22245
test: Remove useless test_bitcoin_main.cpp 2019-02-28 15:44:02 -05:00
MarcoFalke
fab2daa026
test: Add missing LIBBITCOIN_ZMQ to test_test_bitcoin_LDADD 2019-02-28 15:42:37 -05:00
Suhas Daftuar
f71fdda3bc [addrman] Ensure collisions eventually get resolved
After 40 minutes, time out a test-before-evict entry and just evict without
testing. Otherwise, if we were unable to test an entry for some reason, we
might break using feelers altogether.
2019-02-27 16:53:44 -05:00
Sjors Provoost
8bb3e4c487
[rpc] remove deprecated generate method 2019-02-27 17:41:01 +01:00
Suhas Daftuar
4991e3c813 [net] feeler connections can be made to outbound peers in same netgroup
Fixes a bug where feelers could be stuck trying to resolve a collision in the
tried table that is to an address in the same netgroup as an existing outbound peer.

Thanks to Muoi Tran for the original bug report and detailed debug logs to track
this down.
2019-02-27 09:30:13 -05:00
Wladimir J. van der Laan
a0d4e79b4d
Merge #15477: doc: Remove misleading hint in getrawtransaction
9999879f56 refactor: Use RPCHelpMan::IsValidNumArgs in getrawtransaction (MarcoFalke)
fa9ff8fe21 doc: Remove misleading hint in getrawtransaction (MarcoFalke)

Pull request description:

  For 0.18.0

  I asked this line to be added in #15159, which was wrong because getmempoolentry does not return the raw transaction hex.

Tree-SHA512: 7ac85500c8192314347b7283cd369196bb959c124863642b6c1ce73d5662b1cbe4f42ded9c374dac6657458ab70b01810caf1235dd1d2b404bf376ebf09efa69
2019-02-27 12:25:37 +01:00
Wladimir J. van der Laan
a4f9c024c6
Merge #15468: wallet: Use fsbridge::ifstream to fix Windows path issue
6ad79cbd56 wallet: Use fsbridge::ifstream to fix Windows path issue (Chun Kuan Lee)

Pull request description:

  Fix #15460

Tree-SHA512: 1dab04184608543d49c86cbcfb679d63d35cb7bf3bde2e2d9ddf25ec8977de42b7131db5e81a305f3452858079dbcf68f6ad4624c89575d3d7e5b550687fc6ad
2019-02-27 12:05:58 +01:00
Wladimir J. van der Laan
6f43ed4c5a
Merge #15462: gui: Fix async open wallet call order
a720a98301 gui: Fix async open wallet call order (João Barbosa)

Pull request description:

  Fixes #15455. Must call `OpenWalletActivity::open` asynchronously only after all connections are made to the `OpenWalletActivity` instance, otherwise signals can be missed.

Tree-SHA512: 4e5fdbd09d2ca017ed07a1813c2707c09f96275f1498779804e322e0a4dbd7dcff0c2e9cd6ec18463cd427b88b192a8d02373de9edc2b03ba5e4b8484b264417
2019-02-27 12:00:19 +01:00
Suhas Daftuar
4d834018e3 [addrman] Improve tried table collision logging 2019-02-26 14:59:30 -05:00
MarcoFalke
d88f7f8764
Merge #15471: rpc/gui: Remove 'Unknown block versions being mined' warning
ef362f2773 rpc/gui: Remove 'Unknown block versions being mined' warning (Wladimir J. van der Laan)

Pull request description:

  Due to miners inserting garbage into the version numbers causing false positives, the current version signalling has become completely useless. This removes the "unknown block versions" warning which has the tendency to scare users unnecessarily (and might get them to "update" to something bad).

  It preserves the warning in the logs. Whether this is desirable can be a point of discussion.

Tree-SHA512: 51407ccd24a571462465d9c7180f0f28307c50b82a03284abe783e181d8ab7e0638dbb710698d883f28de8a609db70763e39be2470d956e67c833da0768e43e9
2019-02-26 09:20:39 -05:00
MarcoFalke
9999879f56
refactor: Use RPCHelpMan::IsValidNumArgs in getrawtransaction 2019-02-25 23:47:36 -05:00
MarcoFalke
fa9ff8fe21
doc: Remove misleading hint in getrawtransaction 2019-02-25 23:45:48 -05:00
MarcoFalke
fa38535130
bench: Benchmark MempoolToJSON 2019-02-25 10:13:23 -05:00
MarcoFalke
fa5dc3534b
rpc: Pass mempool into MempoolToJSON 2019-02-25 10:12:29 -05:00
Wladimir J. van der Laan
ef362f2773 rpc/gui: Remove 'Unknown block versions being mined' warning
Due to miners inserting garbage into the version numbers, the current
version signalling has become completely useless. This removes the
"unknown block versions" warning which has the tendency to scare
users unnecessarily (and might get them to "update" to something
bad).

It preserves the warning in the logs. Whether this is desirable can
be a point of discussion.
2019-02-25 15:59:02 +01:00
Wladimir J. van der Laan
b4fc5257b7
Merge #15456: Enable PID file creation on WIN
3f5ad622e5 Enable PID file creation on Windows - Add available WIN PID function - Consider WIN32 in each relevant case - Add new preprocessor definitions to suppress warning - Update error message for generic OS (riordant)

Pull request description:

  # Introduction

  As discussed with @laanwj on IRC:

  - PID file creation was never enabled for Windows, as the `pid_t` filetype is not available for it. However, the WIN32 API contains the header [`Processthreadsapi.h`](https://github.com/CodeShark/x86_64-w64-mingw32/blob/master/include/processthreadsapi.h) which in turn contains the function [`GetCurrentProcessId()`](https://docs.microsoft.com/en-gb/windows/desktop/api/processthreadsapi/nf-processthreadsapi-getcurrentprocessid). ~~This function is called at a higher level by [`_getpid()`](https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/getpid?view=vs-2017)~~ EDIT: `_getpid()` is not available to the MSVC compiler used in the AppVeyor build. As a result, I have changed the function call to`GetCurrentProcessId()`, which performs the same function and is available to both MinGW & MSVC.
  This allows one to capture the PID in Windows, without any additional includes - the above function is already available.

  - Within this PR, I have added a separate line that calls `GetCurrentProcessId()` in the case of a WIN compilation, and the usual `getpid()` otherwise. All code blocks processing PID file logic that avoid WIN32 have been changed to consider it. I have also updated the preprocessor definitions in `libbitcoin_server.vcxproj.in` to suppress a warning related to `std::strerror` for the MSVC build, that was causing the AppVeyor build to fail (see @fanquake comment below).

  # Rationale
  - Consistency between OS's running Bitcoin
      - Applications which build off of `bitcoind`, such as novel front-end clients, often need access to the PID in order to control the daemon. Instead of designing some alternate way of doing this for one system, it should be consistent between all of them.

  In collaboration with @joernroeder

Tree-SHA512: 22fcbf866e99115d12ed29716e68d200d4c118ae2f7b188b7705dc0cf5f0cd0ce5fb18f772744c6238eecd9e6d0922c615e2f0e12a7fe7c810062a79d97aa6a2
2019-02-25 13:20:01 +01:00
riordant
3f5ad622e5 Enable PID file creation on Windows
- Add available WIN PID function
- Consider WIN32 in each relevant case
- Add new preprocessor definitions to suppress warning
- Update error message for generic OS

Co-authored-by: Jörn Röder <kontakt@joernroeder.de>
2019-02-25 16:00:34 +07:00
Wladimir J. van der Laan
1a8a5ede9f
Merge #15401: rpc: Actually throw help when passed invalid number of params
fa4ce7038d rpc: Actually throw help when passed invalid number of params (MarcoFalke)
fa05626ca7 rpc: Add RPCHelpMan::IsValidNumArgs() (MarcoFalke)

Pull request description:

  Can be tested by

  * running the included test against an old binary (compiled without this patch)
  * calling `setban 1 "add" 3 4 5 6 7 8 9 0` in the gui

Tree-SHA512: aa6a25bbe6f40722913ea292252a62a4012c964eed9f4035335a2e2d13be98eb60f368e8a3251a104a26a62c08b2cb926b06e5ab1418ef1cf4abdd71d87c2919
2019-02-25 09:31:08 +01:00
Pieter Wuille
9b1ff5c742 Call InvalidateBlock without cs_main held 2019-02-24 18:55:21 -08:00
Pieter Wuille
241b2c74ac Make RewindBlockIndex interruptible 2019-02-24 18:55:21 -08:00
Pieter Wuille
880ce7d46b Call RewindBlockIndex without cs_main held 2019-02-24 18:55:21 -08:00
Pieter Wuille
436f7d735f Release cs_main during RewindBlockIndex operation 2019-02-24 18:55:17 -08:00
Pieter Wuille
1d342875c2 Merge the disconnection and erasing loops in RewindBlockIndex 2019-02-24 18:41:13 -08:00
Pieter Wuille
32b2696ab4 Move erasure of non-active blocks to a separate loop in RewindBlockIndex
This lets us simplify the iteration to just walking back in the chain,
rather than looping over all of mapBlockIndex.
2019-02-24 12:45:48 -08:00
Pieter Wuille
9d6dcc52c6 Abstract EraseBlockData out of RewindBlockIndex
Note that the former 'else' branch in RewindBlockIndex is now
dealt with more naturally inside the EraseBlockData call (by
checking whether the parent needs to be re-added as candidate
after deleting a child).
2019-02-24 12:38:23 -08:00
Chun Kuan Lee
6ad79cbd56 wallet: Use fsbridge::ifstream to fix Windows path issue 2019-02-23 23:44:28 +08:00
João Barbosa
a720a98301 gui: Fix async open wallet call order 2019-02-23 09:29:59 +00:00
Jim Posen
04cca33094 Style cleanup. 2019-02-22 17:38:45 -08:00
Jim Posen
4c01e4e159 flatfile: Unit tests for FlatFileSeq methods. 2019-02-22 17:38:45 -08:00
Jim Posen
65a489e93d scripted-diff: Rename CBlockDiskPos to FlatFilePos.
-BEGIN VERIFY SCRIPT-
sed -i 's/CDiskBlockPos/FlatFilePos/g' $(git ls-files 'src/*.h' 'src/*.cpp')
-END VERIFY SCRIPT-
2019-02-22 17:38:45 -08:00
Jim Posen
d6d8a78f26 Move CDiskBlockPos from chain to flatfile. 2019-02-22 17:38:45 -08:00
Jim Posen
e0380933e3 validation: Refactor file flush logic into FlatFileSeq. 2019-02-22 17:38:45 -08:00
Jim Posen
992404b31e validation: Refactor block file pre-allocation into FlatFileSeq. 2019-02-22 17:38:45 -08:00
Jim Posen
e2d2abb99f validation: Refactor OpenDiskFile into method on FlatFileSeq. 2019-02-22 17:38:45 -08:00
Jim Posen
9183d6ef65 validation: Extract basic block file logic into FlatFileSeq class. 2019-02-22 17:38:45 -08:00
Jim Posen
62e7addb63 util: Move CheckDiskSpace to util. 2019-02-22 17:38:45 -08:00
Russell Yanofsky
f7efd87c8f Change brace formatting
Suggested https://github.com/bitcoin/bitcoin/pull/15288#pullrequestreview-197915100
2019-02-22 14:43:02 -05:00
MarcoFalke
f3f9c1de19
Merge #15435: rpc: Add missing #include
39e20fc54f Add missing #include. (Daniel Kraft)

Pull request description:

  bd0dbe8763 introduced a dependency of `rpc/util.h` on `RPCErrorCode`, defined in `rpc/protocol.h`.  The latter file is only included from `rpc/util.cpp`, though.  This commit fixes the missing include, by moving the `#include` of `rpc/protocol.h` to `rpc/util.h`.

Tree-SHA512: 75c03cfadb28a309d6deb36feeb0ee6ce0b38e8a1176919bc611ea720feff8c42ec9ed0ac8ab74ba9c531a3b7ec9ccbed0c8692ebdf5f9fc17867b9750a1d9f6
2019-02-22 14:43:02 -05:00
Russell Yanofsky
a1df1b48a8 Remove use of IsInitialBlockDownload in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky
1106a6fde4 Remove use of uiInterface.LoadWallet in wallet code
This also changes the uiInterface.LoadWallet signal argument type from
shared_ptr<CWallet> to unique_ptr<interfaces::Wallet> because CWallet is an
internal wallet class that shouldn't be used in non-wallet code (and also can't
be passed across process boundaries).

This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky
d02b34c8a8 Remove use of AcceptToMemoryPool in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky
e2c8ba9f6e Remove uses of InitMessage/Warning/Error in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky
c5e59a96a8 Remove uses of GetAdjustedTime in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky
6d6bcc77c0 Remove use of g_connman / PushInventory in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky
00dfb2a440 Remove uses of g_connman in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky
cc3836e8f9 Remove uses of fPruneMode in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky
cc02c796d3 Remove uses of fee globals in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky
1fb0a4a04e Remove use of CalculateMemPoolAncestors in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky
cd32160af0 Remove use of GetTransactionAncestry in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky
291276f7f4 Remove use of GetCountWithDescendants in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky
bdc6628683 Remove use of IsRBFOptIn in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
Russell Yanofsky
80f52a2267 Remove uses of CheckFinalTx in wallet code
This commit does not change behavior.
2019-02-22 15:43:02 -04:00
João Barbosa
28c86de3b1 gui: Drop unused return values in WalletFrame 2019-02-22 16:26:09 +00:00
MarcoFalke
169dced9a4
Merge #15408: Remove unused TransactionError constants
fa9b60c842 Remove unused TransactionError constants (MarcoFalke)

Pull request description:

  Fixup to #14978, which introduced a bunch of unused enum values, such as `UNKNOWN_ERROR`, `ERROR_COUNT` and `TRANSACTION_ERR_LAST`. None of those have a meaning in the context of an `enum class`, where the compiler can infer if all cases have been covered in a switch-case.

  Also, move the global `::maxTxFee` back to the rpc caller, so it can be set on a per call basis (in the future).

Tree-SHA512: 7f1e2d795f1c1278ecd54ddab2b92c2a862f3c637b482d1d008208925befa1c9dd4b3c4bb1bfcbc5ca4b66a41004aaf01ea96ea95236f944250b8a6cf99ff173
2019-02-22 11:13:43 -05:00
MarcoFalke
77fcf252f6
Merge #15458: refactor: Drop redundant wallet reference
53b310390c refactor: Drop redundant wallet reference (João Barbosa)

Pull request description:

  Removes the redudant wallet reference from `WalletImpl`.

  ```cpp
  // before:
  std::shared_ptr<CWallet> m_shared_wallet;
  CWallet& m_wallet;

  // after
  std::shared_ptr<CWallet> m_wallet;
  ```

Tree-SHA512: c78c5a75a59df20b1684f746305c5b3505f73adfd84f00fd800da61ca07c6a37a992fedea3da390afd9564dc6b6a022d183a38995124783ad62c0cc7610be92b
2019-02-22 10:44:02 -05:00
Wladimir J. van der Laan
a83aedca18
Merge #13676: Explain that mempool memory is added to -dbcache
7cb1a1401d Explain that unused mempool memory is added to -dbcache (Sjors Provoost)

Pull request description:

  Since `-maxmempool` is 450 MB by default it's quite possible for a user to accidentally OOM a low
  memory device if they increase `-dbcache` beyond the default.

  <img width="563" alt="schermafbeelding 2018-09-06 om 17 02 40" src="https://user-images.githubusercontent.com/10217/45166219-c9c4f700-b1f6-11e8-9ee5-14b8b3a9830b.png">

Tree-SHA512: 44c7419d0b06c14aee5d2c02a41e5da488bcb40a5f65ba24554a45707b222f1e4b03d42486dfef9336d917ac2990eef2b1aec287a75b3ef1ccca0e88ac86a0c0
2019-02-21 18:57:21 +01:00
João Barbosa
53b310390c refactor: Drop redundant wallet reference 2019-02-21 16:19:29 +00:00
Wladimir J. van der Laan
3e1ca1348c
Merge #15278: Improve PID file error handling
3782075a5f Move all PID file stuff to init.cpp (Hennadii Stepanov)
561e375c73 Make PID file creating errors fatal (Hennadii Stepanov)
745a2ace18 Improve PID file removing errors logging (Hennadii Stepanov)

Pull request description:

  Digging into #15240 the lack of the proper logging has been discovered.
  Fixed by this PR.

  UPDATE (inspired by @laanwj's [comment](https://github.com/bitcoin/bitcoin/pull/15278#discussion_r252641810)):
  Not being able to create the PID file is fatal now.

  Output of `bitcoind`:

  ```
  $ src/bitcoind -pid=/run/bitcoind/bitcoind.pid
  2019-02-01T23:20:10Z Bitcoin Core version v0.17.99.0-561e375c7 (release build)
  2019-02-01T23:20:10Z Assuming ancestors of block 0000000000000037a8cd3e06cd5edbfe9dd1dbcc5dacab279376ef7cfc2b4c75 have valid signatures.
  2019-02-01T23:20:10Z Setting nMinimumChainWork=00000000000000000000000000000000000000000000007dbe94253893cbd463
  2019-02-01T23:20:10Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
  2019-02-01T23:20:10Z Using RdRand as an additional entropy source
  2019-02-01T23:20:11Z Error: Unable to create the PID file '/run/bitcoind/bitcoind.pid': No such file or directory
  Error: Unable to create the PID file '/run/bitcoind/bitcoind.pid': No such file or directory
  2019-02-01T23:20:11Z Shutdown: In progress...
  2019-02-01T23:20:11Z Shutdown: Unable to remove PID file: File does not exist
  2019-02-01T23:20:11Z Shutdown: done
  ```

  Output of `bitcoin-qt`:
  ![screenshot from 2019-02-02 01-19-05](https://user-images.githubusercontent.com/32963518/52154886-9349b600-2688-11e9-8128-470f16790305.png)

  **Notes for reviewers**
  1. `CreatePidFile()` has been moved from `util/system.cpp` to `init.cpp` for the following reasons:
  - to get the ability to use `InitError()`
  - now `init.cpp` contains code of both creating PID file and removing it

  2. Regarding 0.18 release process: this PR modifies 1 string and introduces 2 new ones.

Tree-SHA512: ac07d0f800e61ec759e427d0afc0ca43d67f232e977662253963afdd0a220d34b871050f58149fc9fabd427bfc8e0d3f6a6032f2a38f30ad366fc0d074b0f2b3
2019-02-21 09:23:10 +01:00
MarcoFalke
fa4ce7038d
rpc: Actually throw help when passed invalid number of params 2019-02-20 13:34:16 -05:00
MarcoFalke
fa05626ca7
rpc: Add RPCHelpMan::IsValidNumArgs() 2019-02-20 13:32:17 -05:00
Akio Nakamura
1a7ba84e11 Fix lack of warning of unrecognized section names
1. Fix lack of warning by collecting all section names by moving
   m_config_sections.clear() to ArgsManager::ReadConfigFiles().
2. Add info(file name, line number) to warning message.
3. Add a test code to confirm this situation.
3. Do clear() in ReadConfigString().
2019-02-19 10:49:19 +09:00
MeshCollider
904308dca3
Merge #15433: Use a single wallet batch for UpgradeKeyMetadata
0bedcbafd Use a single wallet batch for UpgradeKeyMetadata (Jonas Schnelli)

Pull request description:

  Opening wallets (the first time) after #14021 took on my end around 30 seconds due to the keymetadata migration (tested on regtest).

  Using a single wallet batch reduces the required time for the migration down to <1s on my system for a default 2k keypool wallet.

Tree-SHA512: f68739e452d382f5294186f47511b94884a1a0868688dd3179034a7e091a67f93bc9dd45cdfc9fa6b1fe90362772b719278012f2f56b752b803c87db8597a7b0
2019-02-19 09:39:06 +13:00
Daniel Kraft
39e20fc54f Add missing #include.
bd0dbe8763 introduced a dependency of
rpc/util.h on RPCErrorCode, defined in rpc/protocol.h.  The latter file
is only included from rpc/util.cpp, though.  This commit fixes the
missing include, by moving the #include of rpc/protocol.h to
rpc/util.h.
2019-02-18 12:11:41 +01:00
Wladimir J. van der Laan
29e82e460e
Merge #15250: Use RdSeed when available, and reduce RdRand load
1435fabc19 Use RdSeed when available, and reduce RdRand load (Pieter Wuille)

Pull request description:

  This introduces support for autodetecting and using the RdSeed instruction on x86/x86_64 systems.

  In addition:
  * In SeedFast, only 64 bits of entropy are generated through RdRand (256 was relatively slow).
  * In SeedStartup, 256 bits of entropy are generated, using RdSeed (preferably) or RdRand (otherwise).

Tree-SHA512: fb7d3e22e93e14592f4b07282aa79d7c3cc4e9debdd9978580b8d2562bbad345e289bf3f80de2c50c9b50b8bac2aa9b838f9f272f7f8d43f1efc0913aa8acce3
2019-02-18 10:56:55 +01:00
Jonas Schnelli
0bedcbafdf
Use a single wallet batch for UpgradeKeyMetadata 2019-02-17 19:32:58 -10:00
Gregory Maxwell
a083f75ba7 Update assumevalid, minimumchainwork, and getchaintxstats to height 563378.
m_assumed_blockchain_size/m_assumed_chain_state_size were still accurate.
2019-02-17 03:38:08 +00:00
Wladimir J. van der Laan
4064d048d6
Merge #15425: [Doc] add missing newline to listunspent help for witnessScript
d3661a3fd2 [Doc] add missing newline to witnessScript in listunspent help (David A. Harding)

Pull request description:

Tree-SHA512: 85bb9c693bac36da0239eb6a1f42c2173d0170d5ff3d4c2fcd8897cfab233ef8c8ebc1eb5591e3dc89d091fde221d77c872f14a1eec201fee4dc83ba788390c3
2019-02-17 02:46:59 +01:00
David A. Harding
a607c9ae4c
[Doc] importmulti: add missing description of keypool option 2019-02-16 16:59:55 -05:00
David A. Harding
d3661a3fd2
[Doc] add missing newline to witnessScript in listunspent help 2019-02-16 16:27:28 -05:00
Wladimir J. van der Laan
f60d029a2a
Merge #15368: Descriptor checksums
fd637be8d2 Add checksums to descriptors.md (Pieter Wuille)
be62903c41 Make descriptor checksums mandatory in deriveaddresses and importmulti (Pieter Wuille)
b52cb63688 Add getdescriptorinfo to compute checksum (Pieter Wuille)
3b40bff988 Descriptor checksum (Pieter Wuille)

Pull request description:

  This adds support for a descriptor-specific 8-character checksum.

  Descriptors may optionally be suffixed with a `#` plus these 8 checksum characters. Any descriptor that contains a `#` at the end must be followed by a valid checksum. If the `#` is missing entirely, it is valid without checksum.

  All RPCs are updated to report descriptors that include the checksum. On input, they are optional except in `deriveaddress` and `importmulti`, which require descriptors which include a checksum.

  A new RPC is also added to analyse descriptors (`getdescriptorinfo`), which can be used to compute the checksum for a descriptor without.

Tree-SHA512: a8294b09155eb6c67fbc178b5e2d3fbc0e9bec8b6de57a13f8835550d51c2cb32a428b3c9a188ded42b454d594e9305edbd4797906b755de77a8f33c79165f6b
2019-02-16 21:39:32 +01:00
Wladimir J. van der Laan
d5b929c813
Merge #13932: Additional utility RPCs for PSBT
540729ef4b Implement analyzepsbt RPC and tests (Andrew Chow)
77542cf2a5 Move PSBT UTXO fetching to a separate method (Andrew Chow)
cb40b3abd4 Figure out what is missing during signing (Andrew Chow)
08f749c914 Implement joinpsbts RPC and tests (Andrew Chow)
7344a7b998 Implement utxoupdatepsbt RPC and tests (Andrew Chow)

Pull request description:

  This PR adds 3 new utility RPCs for interacting with PSBTs.

  `utxoupdatepsbt` updates a PSBT with UTXO information from the node. It only works with witness UTXOs because full transactions (as would be needed for non-witness UTXOs) are not available unless txindex is enabled.

  `joinpsbts` joins the inputs from multiple distinct PSBTs into one PSBT. e.g. if PSBT 1 has inputs 1 and 2, and PSBT 2 has inputs 3 and 4, `joinpsbts` would create a new PSBT with inputs 1, 2, 3, and 4.

  `analyzepsbt` analyzes a PSBT and determines the current state of it and all of its inputs, and the next step that needs to be done.

Tree-SHA512: 3c1fa302201abca76a8901d0c2be7b4ccbce334d989533c215f8b3e50e22f2f018ce6209544b26789f58f5980a253c0655111e1e20d47d5656e0414c64891a5c
2019-02-16 20:45:03 +01:00
MarcoFalke
f9d50e83e2
Merge #15410: test: txindex: interrupt threadGroup before calling destructor
fab6b07c16 test: txindex: interrupt threadGroup before calling destructor (MarcoFalke)

Pull request description:

  Fixes the data races with the tread sanitizer such as

  * https://travis-ci.org/MarcoFalke/bitcoin/jobs/492330554
  * https://github.com/bitcoin/bitcoin/pull/15402#discussion_r256676622
  * ...

Tree-SHA512: 40608c70d92a1dd68efc1d41eecc8e2fb7738508e21f91f0ad353adcceed60fa624f15bf72a5b69a9444157b261183abbe9fc4cc5dd8aebc1c49506b239e8e88
2019-02-16 12:58:26 -05:00
Andrew Chow
540729ef4b Implement analyzepsbt RPC and tests 2019-02-16 11:51:02 -05:00
Pieter Wuille
be62903c41 Make descriptor checksums mandatory in deriveaddresses and importmulti 2019-02-15 22:36:05 -08:00
Pieter Wuille
b52cb63688 Add getdescriptorinfo to compute checksum 2019-02-15 22:36:05 -08:00
Pieter Wuille
3b40bff988 Descriptor checksum 2019-02-15 22:36:05 -08:00
Andrew Chow
77542cf2a5 Move PSBT UTXO fetching to a separate method 2019-02-16 00:04:27 -05:00
Andrew Chow
cb40b3abd4 Figure out what is missing during signing
When signing an input, figure out what was requested for but was unable
to be found and store it in a SignatureData.

Return this information in SignPSBTInput.
2019-02-16 00:04:27 -05:00
Andrew Chow
08f749c914 Implement joinpsbts RPC and tests
Adds a joinpsbts RPC which combines multiple distinct PSBTs into
one PSBT.
2019-02-16 00:04:27 -05:00
Andrew Chow
7344a7b998 Implement utxoupdatepsbt RPC and tests 2019-02-16 00:04:27 -05:00
MarcoFalke
743c2f461c
Merge #15399: fuzz: Script validation flags
fab15ff70e fuzz: Script validation flags (MarcoFalke)
fabcfa5f0c fuzz: Move deserialize tests to test/fuzz/deserialize.cpp (MarcoFalke)

Pull request description:

Tree-SHA512: 83c0cfeae0771b7ffe14e6b0eaeda06602b91f5bf4aa2f54fd4f7ef2350299679fd2d9339b02e43309bfddccc01d3aef25ce1a3d2c4f9b54f26e16e1249e05db
2019-02-15 13:14:24 -05:00
Wladimir J. van der Laan
95801902b9
Merge #15391: Add compile time verification of assumptions we're currently making implicitly/tacitly
7cee85807c Add compile time verification of assumptions we're currently making implicitly/tacitly (practicalswift)

Pull request description:

  Add compile time verification of assumptions we're currently making implicitly/tacitly.

  As suggested by @sipa in https://github.com/bitcoin/bitcoin/pull/14239#issuecomment-462508012 and @MarcoFalke in https://github.com/bitcoin/bitcoin/pull/14479#issuecomment-462534878.

Tree-SHA512: e68fe51164dbd3eeb76aa8a7e83dfcd3b4d5a66037c0f1822bbbd189bbe3c280e03b3b10af870880ecc09b612e62fb3d9bcd6cf1e16cb7ba818c257db0712ce4
2019-02-15 16:05:27 +01:00
MarcoFalke
eca1273c35
Merge #15383: [rpc] mining: Omit uninitialized currentblockweight, currentblocktx
fa178a6385 [rpc] mining: Omit uninitialized currentblockweight, currentblocktx (MarcoFalke)

Pull request description:

  Previously we'd report "0", which could be mistaken for a valid number. E.g. the number of transactions is 0 or the block weight is 0, whatever that means.

Tree-SHA512: ee94ab203a329e272211b726f4c23edec4b09c650ec363b77fd59ad9264165d73064f78ebb9e11b5c2c543b73c157752410a307655560531c7d5444d203aa0ea
2019-02-15 08:57:50 -05:00
practicalswift
543ef7d626 tests: Add missing cs_main locks required when accessing pcoinsdbview, pcoinsTip or pblocktree 2019-02-15 10:41:52 +01:00
Andrew Chow
f4b00b70e8 Import public keys in order
Do public key imports in the order that they are specified in the import
or in the descriptor range.
2019-02-14 18:34:03 -05:00
Andrew Chow
513719c5f8 Add option to importmulti add an imported pubkey to the keypool
Adds a new option to importmulti where the pubkeys specified in the import
object can be added to the keypool. This only works if the wallet has
private keys disabled.
2019-02-14 18:14:42 -05:00
Andrew Chow
9b81fd19ac Fetch keys from keypool when private keys are disabled
When private keys are disabled, still fetch keys from the keypool
if the keypool has keys. Those keys come from importing them and
adding them to the keypool.
2019-02-14 18:14:00 -05:00
Andrew Chow
99cccb900b Add a method to add a pubkey to the keypool
Introduces AddKeypoolPubkey in order to add a pubkey to the keypool
2019-02-14 18:14:00 -05:00
MeshCollider
8d0ec74801
Merge #14021: Import key origin data through descriptors in importmulti
cb3511b9d Add release notes for importing key origin info change (Andrew Chow)
4c75a69f3 Test importing descriptors with key origin information (Andrew Chow)
02d6586d7 Import KeyOriginData when importing descriptors (Andrew Chow)
3d235dff5 Implement a function to add KeyOriginInfo to a wallet (Andrew Chow)
eab63bc26 Store key origin info in key metadata (Andrew Chow)
345bff601 Remove hdmasterkeyid (Andrew Chow)
bac8c676a Add a method to CWallet to write just CKeyMetadata (Andrew Chow)
e7652d3f6 Add WriteHDKeypath function and move *HDKeypath to util/bip32.{h,cpp} (Andrew Chow)
c45415f73 Refactor keymetadata writing to a separate method (Andrew Chow)

Pull request description:

  This PR allows for key origin data as defined by the descriptors document to be imported to the wallet when importing a descriptor using `importmulti`. This allows the `walletprocesspsbt` to include the BIP 32 derivation paths for keys that it is watching that are from a different HD wallet.

  In order to make this easier to use, a new field `hdmasterkeyfingerprint` has been added to `getaddressinfo`. Additionally I have removed `hdmasterkeyid` as was planned. I think that this API change is fine since it was going to be removed in 0.18 anyways. `CKeyMetadata` has also been extended to store key origin info to facilitate this.

Tree-SHA512: 9c7794f3c793da57e23c5abbdc3d58779ee9dea3d53168bb86c0643a4ad5a11a446264961e2f772f35eea645048cb60954ed58050002caee4e43cd9f51215097
2019-02-15 12:11:28 +13:00
Andrew Chow
02d6586d7a Import KeyOriginData when importing descriptors 2019-02-14 17:58:25 -05:00
Andrew Chow
3d235dff5d Implement a function to add KeyOriginInfo to a wallet 2019-02-14 17:58:25 -05:00
Andrew Chow
eab63bc264 Store key origin info in key metadata
Store the master key fingerprint and derivation path in the
key metadata. hdKeypath is kept to indicate the seed and for
backwards compatibility, but all key derivation path output
uses the key origin info instead of hdKeypath.
2019-02-14 17:58:25 -05:00
MarcoFalke
31f7c6dd21
Merge #15295: fuzz: Add test/fuzz/test_runner.py and run it in travis
fa535af92c fuzz: test_runner: Better error message when built with afl (MarcoFalke)
fa7ca8ef58 qa: Add test/fuzz/test_runner.py (MarcoFalke)

Pull request description:

  Can be run with `./test/fuzz/test_runner.py` after building as described in `doc/fuzzing.md`

Tree-SHA512: f6a3cd8165ec2de4b363be4fd0a936b4a60829cce923f93fe5d6a046b1bbd64c959cdf790440bf70c0e13b0bb1b956a746a24c6fd92bddeab15b837ed50ffad2
2019-02-14 16:32:26 -05:00
Wladimir J. van der Laan
3facd9fdc4
Merge #14481: Add P2SH-P2WSH support to listunspent RPC
6ca836ab3a Add release note for listunspent P2WSH change (MeshCollider)
928beae007 Add test for P2SH-P2WSH in signrawtransactionwithkey and listunspent (MeshCollider)
314784a60f Make listunspent and signrawtransaction RPCs support witnessScript (MeshCollider)

Pull request description:

  This is a reworked version of #11708 after #12427 and the `signrawtransaction` split.

  For a P2WSH address, listunspent should return the witness script, and for a P2SH-P2WSH address, it should also return the inner witness script (because SignTransaction will automatically wrap it in P2SH if required).

  Includes a test which also tests the behaviour of #12427, and release note.

Tree-SHA512: a8e72cf16930312bf48ec47e44a68f8d7e26664043c1b4cc0983eb25aec4087e511188ff9a0f181cd7b8a0c068c60d7f1e7e3f226b79e8c48890039dcf57f7b7
2019-02-14 22:17:52 +01:00
MarcoFalke
cd8ca8be31
Merge #14626: Select orphan transaction uniformly for eviction
7257353b93 Select orphan transaction uniformly for eviction (Pieter Wuille)

Pull request description:

  The previous code was biased towards evicting transactions whose txid has a larger gap (lexicographically) with the previous txid in the orphan pool.

Tree-SHA512: e35f700aea5ed79d1bc57f64bffcb623424b40156fd0a12f05f74f981a8aa4175d5c18d042989243f7559242bdf1d6d720bcf588d28f43d74a798a4843f09c70
2019-02-14 16:11:44 -05:00
Hennadii Stepanov
3782075a5f
Move all PID file stuff to init.cpp
It is only used from init.cpp.
Move-only refactoring.
2019-02-14 22:53:03 +02:00
Jonas Schnelli
b7456e6bf9
Merge #15195: gui: Add Close Wallet action
94086fb59 gui: Add close wallet action (João Barbosa)
f77ba3431 gui: Add closeWallet to WalletController (João Barbosa)
f6122abe0 interfaces: Add remove to Wallet (João Barbosa)

Pull request description:

  This PR adds support to close the current wallet in the GUI.

  <img width="543" alt="screenshot 2019-01-18 at 00 44 26" src="https://user-images.githubusercontent.com/3534524/51358241-424b9680-1aba-11e9-88f2-b85869507737.png">
  <img width="532" alt="screenshot 2019-01-18 at 00 44 38" src="https://user-images.githubusercontent.com/3534524/51358242-424b9680-1aba-11e9-83e2-fa275a9017b3.png">

Tree-SHA512: fd7da4d0f73dc240864cc57a1ff1526daf2376904ce3872e52eeca5d40cc21c6dd29eb2ef25f85ffa63697362c150221a2369d80ad36ae445cc99989d337b688
2019-02-14 10:46:48 -10:00
Jonas Schnelli
3b33cbc2b6
Merge #15393: build: Bump minimum Qt version to 5.5.1
fd46c4c00 Bump minimum Qt version to 5.5.1 (Sjors Provoost)

Pull request description:

  Fixes #13478

  Compiled and lightly tested on 10.14.3 against QT 5.12.0.

Tree-SHA512: 6890331969bbf4c66dc0993b8817b1f0831d008f5863554e9c09a38f4700260b84044ff961664c377decc9fb8300e3543c267f935ec64fbc97b20f8fb396247a
2019-02-14 10:17:53 -10:00
MarcoFalke
fab6b07c16
test: txindex: interrupt threadGroup before calling destructor 2019-02-14 14:40:49 -05:00
Jonas Schnelli
758c6d784d
Merge #15063: GUI: If BIP70 is disabled, attempt to fall back to BIP21 parsing
84f53154e Travis: Add test without BIP70 (but still full wallet + tests) (Luke Dashjr)
113f0004b GUI: If BIP70 is disabled, give a proper error when trying to open a payment request file (Luke Dashjr)
9975282fa GUI: If BIP70 is disabled, attempt to fall back to BIP21 parsing (Luke Dashjr)

Pull request description:

Tree-SHA512: 66a684ce4336d0eac8b0107b405ff3a2cf312258a967f3e1b14734cd39db11e2db3e9b03492755583170d94d54754ef536b0776e5f19a0cc2caca8379eeb4495
2019-02-14 09:31:17 -10:00
Andrew Chow
345bff6013 Remove hdmasterkeyid 2019-02-14 14:00:29 -05:00
Andrew Chow
bac8c676a7 Add a method to CWallet to write just CKeyMetadata 2019-02-14 14:00:29 -05:00
Andrew Chow
e7652d3f64 Add WriteHDKeypath function and move *HDKeypath to util/bip32.{h,cpp}
Creates new files util/bip32.h and util/bip32.cpp for containing
BIP 32 stuff.
Moves FormatKeyPath from descriptor.cpp to util/bip32.
Adds a wrapper around it to prepent the 'm' for when just the
BIP 32 style keypath is needed.
2019-02-14 14:00:28 -05:00
Andrew Chow
c45415f73a Refactor keymetadata writing to a separate method 2019-02-14 14:00:28 -05:00
MarcoFalke
fa9b60c842
Remove unused TransactionError constants 2019-02-14 10:32:02 -05:00
practicalswift
7cee85807c Add compile time verification of assumptions we're currently making implicitly/tacitly 2019-02-14 16:10:02 +01:00
marcoagner
8c3fdd3a6d
fixes m_assumed_blockchain_size variables values:
This commit was a fix to `m_assumed_blockchain_size` reverted from
3fc2063's 220 to 9d0e528's 200 since work on 9d0e528 was being done in
parallel and ended up reverting `m_assumed_blockchain_size`.

This commits is now a intended to be a bump of
`m_assumed_blockchain_size` for both mainnet and testnet for new
reasonable values.
2019-02-14 12:43:10 +00:00
Sjors Provoost
fd46c4c001
Bump minimum Qt version to 5.5.1 2019-02-14 11:12:30 +01:00
MeshCollider
2452c6cc0a
Merge #14978: Factor out PSBT utilities from RPCs for use in GUI code; related refactoring.
102faad81 Factor out combine / finalize / extract PSBT helpers (Glenn Willen)
78b9893d0 Remove op== on PSBTs; check compatibility in Merge (Glenn Willen)
bd0dbe876 Switch away from exceptions in refactored tx code (Glenn Willen)
c6c3d42a7 Move PSBT definitions and code to separate files (Glenn Willen)
81cd95884 Factor BroadcastTransaction out of sendrawtransaction (Glenn Willen)
c734aaa15 Split DecodePSBT into Base64 and Raw versions (Glenn Willen)
162ffefd2 Add pf_invalid arg to std::string DecodeBase{32,64} (Glenn Willen)

Pull request description:

  * Move most PSBT definitions into psbt.h.
  * Move most PSBT RPC utilities into psbt.{h,cpp}.
  * Move wallet-touching PSBT RPC utilities (FillPSBT) into
      wallet/psbtwallet.{h,cpp}.
  * Switch exceptions from JSONRPCError() to new PSBTException class.
  * Split DecodePSBT into DecodeBase64PSBT (old behavior) and DecodeRawPSBT.
  * Add one new version of DecodeBase64 utility in strencodings.h (and
      corresponding DecodeBase32 for completeness).
  * Factor BroadcastTransaction utility function out of sendrawtransaction RPC
      handler in rpc/rawtransaction.cpp

  Note: For those keeping score at home wondering why refactor, this is in anticipation of (and developed in parallel with) a change to actually introduce GUI use of all this stuff, which is already under development and working-ish.

Tree-SHA512: 2197c448e657421f430943025357597e7b06c4c377d5d4b2622b9edea52a7193c48843dd731abb3a88ac4023a9c88d211991e0a9b740c22f2e1cbe72adefe390
2019-02-14 21:49:01 +13:00
MarcoFalke
fa7ca8ef58
qa: Add test/fuzz/test_runner.py 2019-02-13 17:12:28 -05:00
Wladimir J. van der Laan
9c93f5d9fc
Merge #15334: wallet: Log absolute paths for the wallets
a4b92e467d Log full paths for wallets (Hennadii Stepanov)

Pull request description:

  Fix #15333

  `debug.log` with this PR:
  ```
  ...
  2019-02-03T19:02:35Z Using wallet directory /home/hebasto/.bitcoin/testnet3/wallets
  2019-02-03T19:02:35Z init message: Verifying wallet(s)...
  2019-02-03T19:02:35Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
  2019-02-03T19:02:35Z Using wallet test_alpha/wallet.dat
  2019-02-03T19:02:35Z BerkeleyEnvironment::Open: LogDir=/home/hebasto/.bitcoin/testnet3/wallets/test_alpha/database ErrorFile=/home/hebasto/.bitcoin/testnet3/wallets/test_alpha/db.log
  2019-02-03T19:02:35Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
  2019-02-03T19:02:35Z Using wallet alpha_wallet/wallet.dat
  2019-02-03T19:02:35Z BerkeleyEnvironment::Open: LogDir=/home/hebasto/.bitcoin/testnet3/wallets/alpha_wallet/database ErrorFile=/home/hebasto/.bitcoin/testnet3/wallets/alpha_wallet/db.log
  2019-02-03T19:02:35Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
  2019-02-03T19:02:35Z Using wallet wallet.dat
  2019-02-03T19:02:35Z BerkeleyEnvironment::Open: LogDir=/home/hebasto/.bitcoin/testnet3/wallets/database ErrorFile=/home/hebasto/.bitcoin/testnet3/wallets/db.log
  2019-02-03T19:02:35Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
  2019-02-03T19:02:35Z Using wallet none/wallet.dat
  2019-02-03T19:02:35Z BerkeleyEnvironment::Open: LogDir=/home/hebasto/.bitcoin/testnet3/wallets/none/database ErrorFile=/home/hebasto/.bitcoin/testnet3/wallets/none/db.log
  2019-02-03T19:02:35Z init message: Loading banlist...
  ...
  ```

Tree-SHA512: 8dd4408d3f6b04f396dd0ae0d248fedc3a0f6d36788556ae1662443f06f2ecce1c2be9456bf8d1b3d25b29c2a0cfb03cb805bde0a40387e68988ab932e17e118
2019-02-13 22:51:44 +01:00
MarcoFalke
9c4a90040d
Merge #15390: [wallet-tool] Close bdb when flushing wallet
318b1f7af1 [wallet] Close bdb when flushing wallet. (John Newbery)

Pull request description:

  bdb would not be closed when closing the wallet in wallet-tool. Fix this by calling wallet->flush with true.

Tree-SHA512: f722e527e4806eca5254221e944f57853d11bf89a9264309fa558a6cc2b23feefb7bb2963e87b4fad9cfb31ac4cffe563688988e0614a481a8ff1d393aceb132
2019-02-13 15:49:13 -05:00
MarcoFalke
fab15ff70e
fuzz: Script validation flags 2019-02-13 14:53:57 -05:00
MarcoFalke
fabcfa5f0c
fuzz: Move deserialize tests to test/fuzz/deserialize.cpp 2019-02-13 11:46:36 -05:00
Wladimir J. van der Laan
cbe7efe9ea
Merge #15389: Remove unnecessary const_cast
5039e4b61b Remove unnecessary const_cast (Julian Fleischer)

Pull request description:

  The const_cast

  ```C++
  CBlock &block = const_cast<CBlock&>(chainparams.GenesisBlock());
  ```

  is not necessary as all the functions invoked form this block receive a `const CBlock&` anyway. Simply add the `const` to `block`:

  ```C++
  const CBlock& block = chainparams.GenesisBlock();
  ```

  Casting away `const`, especially from something as precious as the genesis block, feels really weird to me as a reader of bitcoin-core source code.

Tree-SHA512: 0290b2cabb216a60655ded153ed1f213c051fb216cec6f3f810f8b760e276f8def86eb696c492e89631682531e215f56d7897b59685d3aa787bcd80cc4f86c90
2019-02-13 17:09:32 +01:00
MeshCollider
314784a60f Make listunspent and signrawtransaction RPCs support witnessScript 2019-02-13 14:26:19 +13:00
MarcoFalke
0d1160e421
Merge #14918: RPCHelpMan: Check default values are given at compile-time
fa0ad4e7ce RPCHelpMan: Check default values are given at compile-time (MarcoFalke)

Pull request description:

  Remove the run time assertions on the default values and ensure that the correct default type and value is provided at compile time.

Tree-SHA512: 80df2f3fab4379b500c773c27da63f22786c58be5963fe99744746320e43627a5d433eedf8b32209158df7805ebdce65ed4d242c829c4fe6e5d13deb4799ed42
2019-02-12 18:43:06 -05:00
Hennadii Stepanov
a4b92e467d
Log full paths for wallets 2019-02-13 00:47:45 +02:00
João Barbosa
94086fb59d gui: Add close wallet action 2019-02-12 22:07:45 +00:00
João Barbosa
f77ba34313 gui: Add closeWallet to WalletController 2019-02-12 22:07:45 +00:00
João Barbosa
f6122abe03 interfaces: Add remove to Wallet 2019-02-12 22:07:45 +00:00
Julian Fleischer
5039e4b61b Remove unnecessary const_cast
Signed-off-by: Julian Fleischer <julian@thirdhash.com>
2019-02-12 22:25:47 +01:00
John Newbery
318b1f7af1 [wallet] Close bdb when flushing wallet.
bdb would not be closed when closing the wallet in wallet-tool. Fix this
by calling wallet->flush with true.
2019-02-12 13:27:18 -05:00
Jonas Schnelli
7d3f255316
Merge #15153: gui: Add Open Wallet menu
1951ea434 gui: Show indeterminate progress dialog while opening walllet (João Barbosa)
8847cdaaa gui: Add OpenWalletActivity (João Barbosa)
4c8982a88 interfaces: Avoid interface instance if wallet is null (João Barbosa)
be82dea23 gui: Add thread to run background activity in WalletController (João Barbosa)
6c49a55b4 gui: Add Open Wallet menu (João Barbosa)
32a8c6abf gui: Add openWallet and getWalletsAvailableToOpen to WalletController (João Barbosa)
ab288b4e5 interfaces: Add loadWallet to Node (João Barbosa)
17abc0fd5 wallet: Factor out LoadWallet (João Barbosa)

Pull request description:

  The *Open Wallet* menu has all the available wallets currently not loaded. The list of the available wallets comes from `listWalletDir`.

  In the future the menu can be replaced by a custom dialog.

  <img width="674" alt="screenshot 2019-01-12 at 12 17 02" src="https://user-images.githubusercontent.com/3534524/51073166-ac041480-1664-11e9-8302-be81702bc146.png">

Tree-SHA512: ebfd75eee0c8264863748899843afab67dadb7dff21313c11e3cb5b6108d954978dd1f1ae786bc07580c5a771ea4ab38d18c1643c9b9b3683ed53f0f6c582e38
2019-02-12 08:20:50 -10:00
MarcoFalke
fa178a6385
[rpc] mining: Omit uninitialized currentblockweight, currentblocktx 2019-02-12 11:34:57 -05:00
Wladimir J. van der Laan
65435701ef
Merge #15358: util: Add SetupHelpOptions()
a99999cc04 util: Add SetupHelpOptions() (MarcoFalke)

Pull request description:

  Every binary we have sets up the help option in their own way and wording.

  Solve that by having one function take care of it for all of them.

Tree-SHA512: 6e947fa8bc2a46fa6ca9f45777020aa269a5df0dd916ebc863224f9a1e0f79e8e7754a1478567307edd9461e8babd77d26bc2710bbd56e8f8da9020aa85a8c9c
2019-02-12 15:27:39 +01:00
Glenn Willen
102faad81e Factor out combine / finalize / extract PSBT helpers
Refactor the new CombinePSBT, FinalizePSBT, and FinalizeAndExtractPSBT
general-purpose functions out of the combinepsbt and finalizepsbt RPCs,
for use in the GUI code.
2019-02-11 14:08:04 -08:00
Glenn Willen
78b9893d02 Remove op== on PSBTs; check compatibility in Merge
Remove the op== on PartiallySignedTransaction, which only checks that the
CTransactions are equal. Instead, check this directly in Merge, and return
false if the CTransactions are not equal (so the PSBTs cannot be merged.)
2019-02-11 14:08:04 -08:00
Glenn Willen
bd0dbe8763 Switch away from exceptions in refactored tx code
After refactoring general-purpose PSBT and transaction code out of RPC code,
for use in the GUI, it's no longer appropriate to throw exceptions. Instead we
now return bools for success, and take an output parameter for an error object.
We still use JSONRPCError() for the error objects, since only RPC callers
actually care about the error codes.
2019-02-11 14:08:04 -08:00
Glenn Willen
c6c3d42a7d Move PSBT definitions and code to separate files
Move non-wallet PSBT code to src/psbt.{h,cpp}, and PSBT wallet code to
src/wallet/psbtwallet.{h,cpp}. This commit contains only code movement (and
adjustments to includes and Makefile.am.)
2019-02-11 12:23:14 -08:00
Glenn Willen
81cd958848 Factor BroadcastTransaction out of sendrawtransaction
Factor out a new BroadcastTransaction function, performing the core work of the
sendrawtransaction rpc, so that it can be used from the GUI code. Move it from
src/rpc/ to src/node/.
2019-02-11 12:23:14 -08:00
Glenn Willen
c734aaa15d Split DecodePSBT into Base64 and Raw versions
Split up DecodePSBT, which both decodes base64 and then deserializes a
PartiallySignedTransaction, into two functions: DecodeBase64PSBT, which retains
the old behavior, and DecodeRawPSBT, which only performs the deserialization.

Add a test for base64 decoding failure.
2019-02-11 12:23:14 -08:00
Glenn Willen
162ffefd2f Add pf_invalid arg to std::string DecodeBase{32,64}
Add support for the optional "pf_invalid" out parameter (which allows the caller
to detect decoding failures) to the std::string versions of DecodeBase32 and
DecodeBase64. The char* versions already have this feature.

Also, rename all uses of pfInvalid to pf_invalid to match style guidelines.
2019-02-11 12:23:14 -08:00
Luke Dashjr
113f0004be GUI: If BIP70 is disabled, give a proper error when trying to open a payment request file 2019-02-11 15:08:41 +00:00
Luke Dashjr
9975282fa8 GUI: If BIP70 is disabled, attempt to fall back to BIP21 parsing 2019-02-11 15:08:41 +00:00
MarcoFalke
fa0ad4e7ce
RPCHelpMan: Check default values are given at compile-time 2019-02-11 08:40:10 -05:00
MarcoFalke
ad039aa0d3
Merge #15373: Move ParseConfirmTarget from rpc/mining to rpc/util
50e647210d Move ParseConfirmTarget from rpc/mining to rpc/util (Russell Yanofsky)

Pull request description:

  Util is a better home since it's called both by wallet and mining code.

  Suggested https://github.com/bitcoin/bitcoin/pull/15288#discussion_r254449444

Tree-SHA512: 4320caf2a3f70d2885c421de04f2ec68ff3f6519258c5155fc46e245dc1765fd15c81f260af5096318f24ff9deb88fc3c5ef40eec8b7393f467f5b963d17215b
2019-02-11 08:34:14 -05:00
MarcoFalke
ff9e197212
Merge #15380: trivial: correct parameter name in comments
1a0139cbaf trivial: correct parameter name in comments (andrewtoth)

Pull request description:

Tree-SHA512: 029b5ca5406cd7bf704b4d7611dac072cdc46a8659041bf631d77372ed4c16fa9ddf02c754044e310b16ea9bdd0803d051bef6ef6a86815d523826666134c649
2019-02-11 08:20:27 -05:00
MarcoFalke
e84e0d4b5e
Merge #15337: rpc: Fix for segfault if combinepsbt called with empty inputs
30d0f7be6e rpc: Fix for segfault if combinepsbt called with empty inputs (benthecarman)

Pull request description:

  Fixes #15300

Tree-SHA512: 25e7b4e6e48d8b0d197f0ab96df308fff33e2110f8929cb48914877fa7f4c4a84f173b1378fdb2dec5d03fe7d6d1aced4b577e55f9fe180d8147d9106ebf543f
2019-02-11 08:08:17 -05:00