Commit graph

32994 commits

Author SHA1 Message Date
fanquake
bda692d246
Merge bitcoin/bitcoin#24489: build: Move guix time machine to prelude
6833aceac9 build: Move guix time machine to prelude (laanwj)

Pull request description:

  This deduplicates some code, and enforces consistency of the time machine configuration between scripts.

ACKs for top commit:
  achow101:
    ACK 6833aceac9
  dongcarl:
    ACK 6833aceac9

Tree-SHA512: c02ded154cdb982293101986ef863d46554fc428eb5617bee0288dbef0543f994de5044123ac9958e455d0d24276a1c4512149a10dd1efaca8677c8f6b74b0a9
2022-03-07 14:50:36 +00:00
MarcoFalke
5e49b2a252
Merge bitcoin/bitcoin#24050: validation: Give m_block_index ownership of CBlockIndexs
6c23c41561 refactor: Rewrite AddToBlockIndex with try_emplace (Carl Dong)
c05cf7aa1e style: Modernize range-based loops over m_block_index (Carl Dong)
c2a1655799 style-only: Use using instead of typedef for BlockMap (Carl Dong)
dd79dad175 refactor: Rewrite InsertBlockIndex with try_emplace (Carl Dong)
531dce0347 tests: Remove now-unnecessary manual Unload's (Carl Dong)
bec86ae326 blockstorage: Make m_block_index own CBlockIndex's (Carl Dong)

Pull request description:

  Part of: #24303
  Split off from: #22564

  ```
  Instead of having CBlockIndex's live on the heap, which requires manual
  memory management, have them be owned by m_block_index. This means that
  they will live and die with BlockManager.
  ```

  The second commit demonstrates how this makes calls to `Unload()` to satisfy the address sanitizer unnecessary.

ACKs for top commit:
  ajtowns:
    ACK 6c23c41561
  MarcoFalke:
    re-ACK 6c23c41561 🎨

Tree-SHA512: 81b2b5119be27cc0f8a9457b11da60cc60930315d2a5be36be89fe253d32073ffe622348ff153114b9b3212197bddbc791810913a43811b33cc58e7162bd105b
2022-03-07 13:15:27 +01:00
fanquake
e4e9dd3a28
contrib: fix implicit function decleration in win symbol check
```bash
test3.c: In function 'main':
test3.c:6:21: warning: implicit declaration of function 'CoFreeUnusedLibrariesEx' [-Wimplicit-function-declaration]
    6 |                     CoFreeUnusedLibrariesEx(0,0);
```
2022-03-07 11:51:11 +00:00
fanquake
b9894a1308
Merge bitcoin/bitcoin#24461: build: Minor leveldb subtree update
1b20109b04 Squashed 'src/leveldb/' changes from f8ae182c1e..330dd6235f (MarcoFalke)

Pull request description:

  A minor change to:

  * Consistently use the same symbol names in the whole project.
  * Fix compiling with C++20.

ACKs for top commit:
  fanquake:
    ACK fa0c32eb74

Tree-SHA512: b5d4540dd621cf4aa8caac811bae03bb74e502a31dbdda9354182e4caa39905550e62ad3cf8ea7d7f9bfc3e5120d119d34ab0f1e633716ec8089876037cbf192
2022-03-07 11:39:41 +00:00
laanwj
cba41db327
Merge bitcoin/bitcoin#24299: validation, refactor: UnloadBlockIndex and ChainstateManager::Reset thread safety cleanups
ae9ceed3e2 validation, refactoring: remove ChainstateManager::Reset() (Jon Atack)
daad0093e3 validation: replace lock with annotation in UnloadBlockIndex() (Jon Atack)

Pull request description:

  Thread safety refactoring seen in #24177:
  - replace re-acquiring lock cs_main with a thread safety annotation in UnloadBlockIndex()
  - remove ChainstateManager::Reset(), as it is currently unused (can be reintroduced in the test utilities if needed for unit testing)

ACKs for top commit:
  laanwj:
    Code review ACK ae9ceed3e2
  vasild:
    ACK ae9ceed3e2
  klementtan:
    crACK ae9ceed3e2

Tree-SHA512: cebb782572997cc2dda01590d6bb6c5e479e8202324d8b6ff459b814ce09e818b996c881736bfebd1b8bf4b6d7a0f79faf3ffea176a4699dd7d7429de2db2d13
2022-03-07 12:13:32 +01:00
Andrew Chow
db27ac9354 tests: Ensure sorted/multi_a descriptors always generate different addrs
Sometimes the multi_a and sortedmulti_a descriptors will produce some of
the same addresses in the tests. This causes the wallets to start
generating addresses at a different index as they detect that one of
the addresses is used. This subsequently causes a test failure.

To avoid this problem, use descriptors that will produce unique
addresses by putting one of the multi_a in a different branch.
2022-03-07 06:06:16 -05:00
laanwj
f6d335e828
Merge bitcoin/bitcoin#24468: init, doc: improve -onlynet help and related tor/i2p documentation
a1db99adea init, doc: improve -onlynet help and tor/i2p documentation (Jon Atack)

Pull request description:

  including review feedback from https://github.com/bitcoin/bitcoin/pull/22834#discussion_r795253056 and https://github.com/bitcoin/bitcoin/pull/24205#discussion_r818629106 concerning `src/init.cpp`, `doc/tor.md` and `doc/i2p.md`

  - s/outgoing/automatic outbound/
  - s/Incoming/Inbound and manual/ (are not affected by this option.)
  - s/only through network/only to network/
  - s/this option. This option/this option. It/
  - s/network types/networks/

  and pick up a few nits in `doc/p2p-bad-ports.md` from https://github.com/bitcoin/bitcoin/pull/23542#pullrequestreview-881415043.

ACKs for top commit:
  laanwj:
    ACK a1db99adea
  w0xlt:
    ACK a1db99a
  theStack:
    ACK a1db99adea

Tree-SHA512: dd727904b9b3dadb16053e2b0350e6c0814ef68fb0cca7d34880b883123cfe3aa03b15813b40a863f6367d596d17ee4517eab55281cfe35cd00767b8a39593ca
2022-03-07 11:42:36 +01:00
laanwj
6833aceac9 build: Move guix time machine to prelude
This deduplicates some code, and enforces consistency of the time
machine configuration between scripts.
2022-03-07 11:08:46 +01:00
MarcoFalke
3b08427b58
Merge bitcoin/bitcoin#24488: ci: Bump vcpkg to the latest version
68c4a9ed38 ci: Bump vcpkg to the latest version (Hennadii Stepanov)

Pull request description:

  It seems reasonable to run a CI task against the most recent dependencies.

  Dependency changes:
  - boost 1.75.0 -> 1.78.0
  - double-conversion 3.1.5 -> 3.2.0
  - sqlite3 3.35.4 -> 3.37.2

ACKs for top commit:
  fanquake:
    ACK 68c4a9ed38

Tree-SHA512: 8d8ea42cb37b5eb2e6b82db4fd14b2984a1dee87a5d79e2378feff2e2576403207f5a27d3da7c4b351c1cc570ec8d971ae963c179789ef0ee55e004fbd399fe1
2022-03-07 10:56:06 +01:00
MarcoFalke
6687bb24ae
Merge bitcoin/bitcoin#24306: util: Make ArgsManager::GetPathArg more widely usable
60aa179d8f Use GetPathArg where possible (Pavol Rusnak)
5b946edd73 util, refactor: Use GetPathArg to read "-settings" value (Ryan Ofsky)
687e655ae2 util: Add GetPathArg default path argument (Ryan Ofsky)

Pull request description:

  Improve `ArgsManager::GetPathArg` method added in recent PR #24265, so it is usable more places. This PR starts to use it for the `-settings` option. This can also be helpful for #24274 which is parsing more path options.

  - Add `GetPathArg` default argument so it is less awkward to use to parse options that have default values.
  - Fix `GetPathArg` negated argument handling. Return path{} not path{"0"} when path argument is negated.
  - Add unit tests for default and negated cases
  - Move `GetPathArg` method declaration next to `GetArg` declaration. The two methods are close substitutes for each, so this should help keep them consistent and make them more discoverable.

ACKs for top commit:
  w0xlt:
    Tested ACK 60aa179 on Ubuntu 21.10
  hebasto:
    re-ACK 60aa179d8f

Tree-SHA512: 3d24b885d8bbeef39ea5d0556e2f09b9e5f4a21179cef11cbbbc1b84da29c8fb66ba698889054ce28d80bc25926687654c8532ed46054bf5b2dd1837866bd1cd
2022-03-07 10:00:53 +01:00
MarcoFalke
384866e870
Merge bitcoin/bitcoin#24427: refactor: Release cs_main before MaybeSendFeefilter
faa329fd46 refactor: Release cs_main before MaybeSendFeefilter (MarcoFalke)

Pull request description:

  There is no need for any lock to be held, because net processing is single threaded. So holding the validation lock cs_main for sending a feefilter is confusing and might even degrade blockchain-related RPC performance minimally.

ACKs for top commit:
  ajtowns:
    ACK faa329fd46 ; code review only
  vasild:
    ACK faa329fd46

Tree-SHA512: 3e7f9faff1631cc64c86fc1a354ada67617ad1e7a046625cc741f4711854eb41ca8aad5a51ef0d94ff65947b68dba8345c9f786b20ee0a8b7a2e8741cfced21f
2022-03-07 08:47:05 +01:00
Hennadii Stepanov
68c4a9ed38
ci: Bump vcpkg to the latest version
Dependency changes:
- boost 1.75.0 -> 1.78.0
- double-conversion 3.1.5 -> 3.2.0
- sqlite3 3.35.4 -> 3.37.2
2022-03-07 08:51:20 +02:00
Sebastian Falbesoner
8ea6167099 wallet: refactor: dedup sqlite blob binding 2022-03-06 20:43:16 +01:00
Andrew Chow
4774b753bb
Merge bitcoin/bitcoin#24484: guix: use same commit for codesigning time-machine
29862bdd40 guix: use same commit for codesigning time-machine (fanquake)

Pull request description:

  The time machines should be updated in lockstep.

ACKs for top commit:
  gruve-p:
    ACK 29862bdd40
  achow101:
    ACK 29862bdd40
  hebasto:
    ACK 29862bdd40, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: 1cd6e449bba62041f6fde1463c490488b8d60dd86714818f27e92725008af850d3ce3fbde0c302406044cc73094cccc9e9bf4179256e9783627b18c5e66f8b49
2022-03-06 07:50:55 -05:00
fanquake
29862bdd40
guix: use same commit for codesigning time-machine
The time machines should be updated in lockstep.
2022-03-06 10:18:22 +00:00
Hennadii Stepanov
c8f2817bd6
Merge bitcoin-core/gui#549: refactor: use std::chrono for formatDurationStr() helper
6f2593dc23 gui, refactor: use std::chrono for formatDurationStr() helper (Jon Atack)

Pull request description:

  Updates `formatDurationStr()` to use the `chrono` standard lib. No change in behavior.

ACKs for top commit:
  RandyMcMillan:
    tACK 6f2593dc23
  shaavan:
    ACK 6f2593dc23
  w0xlt:
    tACK 6f2593d on Ubuntu 21.10 Qt 5.15.2
  promag:
    Code review ACK 6f2593dc23.

Tree-SHA512: 61e9afdb1db779150df338e6af08727c34f69639add465c2f7003ff775d97dce3e78e78d325bc6dea5bc13f0fce9ef1c3506d13f1661a5e083e52bba8a32ba44
2022-03-05 17:20:55 +01:00
fanquake
cc70f65d21
Merge bitcoin/bitcoin#24460: build: update ax_cxx_compile_stdcxx to serial 14
fa7dada1fc build: update ax_cxx_compile_stdcxx to serial 14 (MarcoFalke)

Pull request description:

  No strong reason for the bump, but this makes it easier to experiment with cpp20, see https://github.com/bitcoin/bitcoin/pull/24169#issuecomment-1048702236

ACKs for top commit:
  Empact:
    Code Review ACK fa7dada1fc
  fanquake:
    ACK fa7dada1fc

Tree-SHA512: bd3e884bae5319d434520a2947608913c3884de89aa563aa46ef17ba4e5b41ba209bd4780c8eaf81648297b2dc9534803be88d1b214ad05a93ee5992bee887c0
2022-03-04 15:39:34 +00:00
MarcoFalke
fae20e6b50
Revert "Avoid the use of P0083R3 std::set::merge"
This reverts commit 6cf4ea7187.
2022-03-04 14:13:55 +00:00
MarcoFalke
fab53b5fd4
ci/doc: Set minimum required clang/libc++ version to 8.0 2022-03-04 14:13:21 +00:00
Andrew Chow
bada9636d7
Merge bitcoin/bitcoin#24043: Add (sorted)multi_a descriptor for k-of-n multisig inside tr
4828d53ecc Add (sorted)multi_a descriptors to doc/descriptors.md (Pieter Wuille)
b5f33ac1f8 Simplify wallet_taproot.py functional test (Pieter Wuille)
eb0667ea96 Add tests for (sorted)multi_a derivation/signing (Pieter Wuille)
c17c6aa08d Add signing support for (sorted)multi_a scripts (Pieter Wuille)
3eed6fca57 Add multi_a descriptor inference (Pieter Wuille)
79728c4a3d Add (sorted)multi_a descriptor and script derivation (Pieter Wuille)
25e95f9ff8 Merge/generalize IsValidMultisigKeyCount/GetMultisigKeyCount (Pieter Wuille)

Pull request description:

  This adds a new `multi_a(k,key_1,key_2,...,key_n)` (and corresponding `sortedmulti_a`) descriptor for k-of-n policies inside `tr()`. Semantically it is very similar to the existing `multi()` descriptor, but with the following changes:
  * The corresponding script is `<key1> OP_CHECKSIG <key2> OP_CHECKSIGADD <key3> OP_CHECKSIGADD ... <key_n> OP_CHECKSIGADD <k> OP_NUMEQUAL`, rather than the traditional `OP_CHECKMULTISIG`-based script, making it usable inside the `tr()` descriptor.
  * The keys can optionally be specified in x-only notation.
  * Both the number of keys and the threshold can be as high as 999; this is the limit due to the consensus stacksize=1000 limit

  I expect that this functionality will later be replaced with a miniscript-based implementation, but I don't think it's necessary to wait for that.

  Limitations:
  * The wallet code will for not estimate witness size incorrectly for script path spends, which may result in a (dramatic) fee underpayment with large multi_a scripts.
  * The multi_a script construction is (slightly) suboptimal for n-of-n (where a `<key1> OP_CHECKSIGVERIFY ... <key_n-1> OP_CHECKSIGVERIFY <key_n> OP_CHECKSIG` would be better). Such a construction is not included here.

ACKs for top commit:
  achow101:
    ACK 4828d53ecc
  gruve-p:
    ACK 4828d53ecc
  sanket1729:
    code review ACK 4828d53ecc
  darosior:
    Code review ACK 4828d53ecc

Tree-SHA512: 5dcd434b79585f0ff830f7d501d27df5e346f5749f47a3109ec309ebf2cbbad0e1da541eec654026d911ab67fd7cf7793fab0f765628d68d81b96ef2a4d234ce
2022-03-04 07:28:23 -05:00
fanquake
4fae737f4b
Merge bitcoin/bitcoin#24441: fuzz: Limit script_format to 100kB
bbbbeaf9c8 fuzz: Limit script_format to 100kB (MarcoFalke)

Pull request description:

  The target is still one of the slowest ones, but doesn't seem incredibly important. Especially for sizes larger than the standard tx size.

  Fix that by limiting the script size.

ACKs for top commit:
  fanquake:
    ACK bbbbeaf9c8

Tree-SHA512: b6cf7248753909ef2f21d8824f187e7c05732dd3b99619c0067f862f3c2b0f9a87779d4ddbbd3a7a4bae5c794280e2f0a223bf835d6bc6ccaba01817d69479a2
2022-03-04 09:33:24 +00:00
MarcoFalke
619f8a27ad
Merge bitcoin/bitcoin#24304: [kernel 0/n] Introduce bitcoin-chainstate
2c03cec2ff ci: Build bitcoin-chainstate (Carl Dong)
095aa6ca37 build: Add example bitcoin-chainstate executable (Carl Dong)

Pull request description:

  Part of: #24303

  This PR introduces an example/demo `bitcoin-chainstate` executable using said library which can print out information about a datadir and take in new blocks on stdin.

  Please read the commit messages for more details.

  -----

  #### You may ask: WTF?! Why is `index/*.cpp`, etc. being linked in?

  This PR is meant only to capture the state of dependencies in our consensus engine as of right now. There are many things to decouple from consensus, which will be done in subsequent PRs. Listing the files out right now in `bitcoin_chainstate_SOURCES` is purely to give us a clear picture of the task at hand, it is **not** to say that these dependencies _belongs_ there in any way.

  ### TODO

  1. Clean up `bitcoin-chainstate.cpp`
     It is quite ugly, with a lot of comments I've left for myself, I should clean it up to the best of my abilities (the ugliness of our init/shutdown might be the upper bound on cleanliness here...)

ACKs for top commit:
  ajtowns:
    ACK 2c03cec2ff
  ryanofsky:
    Code review ACK 2c03cec2ff. Just rebase, comments, formatting change since last review
  MarcoFalke:
    re-ACK 2c03cec2ff 🏔

Tree-SHA512: 86e7fb5718caa577df8abc8288c754f4a590650d974df9d2f6476c87ed25c70f923c4db651c6963f33498fc7a3a31f6692b9a75cbc996bf4888c5dac2f34a13b
2022-03-03 19:31:36 +00:00
Ryan Ofsky
2f5fd3cf92 test: Correctly decode UTF-8 literal string paths
Call fs::u8path to convert some UTF-8 string literals to paths, instead
of relying on implicit conversions. The implicit conversions incorrectly
decode const char* paths using the current windows codepage, instead of
treating them as UTF-8. This could cause test failures depending what
environment windows tests are run in.

Issue was reported by MarcoFalke <falke.marco@gmail.com> in
https://github.com/bitcoin/bitcoin/pull/24306#discussion_r818566106
2022-03-03 14:12:07 -05:00
laanwj
727b0cb592
doc: Clean out release notes
23.x was forked off, release notes on master should be empty.

Tree-SHA512: 0b48006073302b7b1c7602b4843d3a3048e88f357fb7049e478ec946f12eb16ca813272e719e47de5fb9713984ccf59551372a7ccd7ced7afaac6b5f5687d78b
2022-03-03 19:05:37 +01:00
laanwj
e0cb7b371f
build: Bump version to 23.99
On the master branch, bump to 23.99 (pre-24.0).

Tree-SHA512: 1e3b0cee8a2b5080170b59a4c445a3c1b69b99152e8eec7eba7080ab447cc6f9c6bd8f69df2b18ee9416de44a6ed88009a200ad26e89275f6230339330d12314
2022-03-03 18:56:45 +01:00
Jon Atack
a1db99adea
init, doc: improve -onlynet help and tor/i2p documentation
and harmonize them as follows

- s/outgoing/automatic outbound/
- s/Incoming/Inbound and manual/ (are not affected by this option.)
- s/only through network/only to network/
- s/this option. This option/this option. It/
- s/network types/networks/

and also pick up a few nits in doc/p2p-bad-ports.md
2022-03-03 16:14:01 +01:00
laanwj
30308cc380
Merge bitcoin/bitcoin#20196: net: fix GetListenPort() to derive the proper port
7d64ea4a01 net: only assume all local addresses if listening on any (Vasil Dimov)
0cfc0cd322 net: fix GetListenPort() to derive the proper port (Vasil Dimov)
f98cdcb357 net: pass Span by value to CaptureMessage() (Vasil Dimov)
3cb9d9c861 net: make CaptureMessage() mockable (Vasil Dimov)
43868ba416 timedata: rename variables to match the coding style (Vasil Dimov)
60da1eaa11 timedata: make it possible to reset the state (Vasil Dimov)

Pull request description:

  `GetListenPort()` uses a simple logic: "if `-port=P` is given, then we
  must be listening on `P`, otherwise we must be listening on `8333`".
  This is however not true if `-bind=` has been provided with `:port` part
  or if `-whitebind=` has been provided. Thus, extend `GetListenPort()` to
  return the port from `-bind=` or `-whitebind=`, if any.

  Also, if `-bind=` is provided then we would bind only to a particular address
  and should not add all the other addresses of the machine to the list of
  local addresses.

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

ACKs for top commit:
  sipa:
    utACK 7d64ea4a01. I didn't review the tests in detail.
  jonatack:
    re-ACK 7d64ea4a01 per `git range-diff 08bcfa27 35ec977 7d64ea4`, changes are rebase-only, light re-review, re-ran the new tests locally

Tree-SHA512: 45135ab9c0ec3cc8c83e3b3e58a1c1f77eaeaba00618d54f1010db1d23d6db7d9c0dc7807e72ebc34e8b2d0e91f1e0d0e9239d13b90f1bdce8be84459e7837f0
2022-03-03 13:49:01 +01:00
Vasil Dimov
7d64ea4a01
net: only assume all local addresses if listening on any
If `-bind=` is provided then we would bind only to a particular address
and should not add all the other addresses of the machine to the list of
local addresses.

Fixes https://github.com/bitcoin/bitcoin/issues/20184 (case 4.)
2022-03-02 15:42:40 +01:00
Vasil Dimov
0cfc0cd322
net: fix GetListenPort() to derive the proper port
`GetListenPort()` uses a simple logic: "if `-port=P` is given, then we
must be listening on `P`, otherwise we must be listening on `8333`".
This is however not true if `-bind=` has been provided with `:port` part
or if `-whitebind=` has been provided. Thus, extend `GetListenPort()` to
return the port from `-bind=` or `-whitebind=`, if any.

Fixes https://github.com/bitcoin/bitcoin/issues/20184 (cases 1. 2. 3. 5.)
2022-03-02 15:42:37 +01:00
Vasil Dimov
f98cdcb357
net: pass Span by value to CaptureMessage()
Span is lightweight and need not be passed by const reference.
2022-03-02 15:40:36 +01:00
Vasil Dimov
3cb9d9c861
net: make CaptureMessage() mockable
Rename `CaptureMessage()` to `CaptureMessageToFile()` and introduce a
`std::function` variable called `CaptureMessage` whose value can be
changed by unit tests, should they need to inspect message contents.
2022-03-02 15:40:36 +01:00
Vasil Dimov
43868ba416
timedata: rename variables to match the coding style
Rename the local variables in `src/timedata.cpp`:
`setKnown` -> `g_sources`
`vTimeOffsets` -> `g_time_offsets`
`fDone` -> `g_warning_emitted`
2022-03-02 15:40:35 +01:00
Vasil Dimov
60da1eaa11
timedata: make it possible to reset the state
Add a new function `TestOnlyResetTimeData()` which would reset the
internal state used by `GetTimeOffset()`, `GetAdjustedTime()` and
`AddTimeData()`.

This is needed so that unit tests that call `AddTimeData()` can restore
the state in order not to confuse other tests that rely on it.

Currently `timedata_tests/addtimedata` is the only test that modifies
the state (via `AddTimeData()`) and also the only test that relies on
that state.
2022-03-02 15:40:30 +01:00
MarcoFalke
fa0c32eb74
build: Minor leveldb subtree update 2022-03-02 15:25:48 +01:00
MarcoFalke
1b20109b04 Squashed 'src/leveldb/' changes from f8ae182c1e..330dd6235f
330dd6235f Merge bitcoin-core/leveldb-subtree#31: Use memory_order symbols consistently
93ee8d875e Merge pull request #965 from ShawnZhong:cpp20

git-subtree-dir: src/leveldb
git-subtree-split: 330dd6235f50c01e49b4cfadf6df9e026dc61f0d
2022-03-02 15:24:44 +01:00
MarcoFalke
fa7dada1fc
build: update ax_cxx_compile_stdcxx to serial 14 2022-03-02 13:18:47 +01:00
Pavol Rusnak
60aa179d8f Use GetPathArg where possible
Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2022-03-02 12:09:27 +01:00
MarcoFalke
08bcfa2767
Merge bitcoin/bitcoin#24375: Do not use LocalTestingSetup in getarg_tests test file.
5d7f22595f Do not use `LocalTestingSetup` in getarg_tests test file. (Kiminuo)

Pull request description:

  Avoid using a test fixture in getarg_tests for better readability. Change was implemented by _kiminuo_ and posted https://github.com/bitcoin/bitcoin/pull/24306#issuecomment-1036643216

ACKs for top commit:
  kiminuo:
    ACK 5d7f22595f

Tree-SHA512: 0fd98622010e6923e91c66447a1d0861bf344a65d86a313dff7d428c089b1740a25f699327f6ed4c163255f270bcbd4f7be962bb551862214f9b9e395d40df04
2022-03-02 12:09:27 +01:00
Ryan Ofsky
5b946edd73 util, refactor: Use GetPathArg to read "-settings" value
Take advantage of GetPathArg to simplify code slightly.
2022-03-02 06:09:27 -05:00
Ryan Ofsky
687e655ae2 util: Add GetPathArg default path argument
Let GetPathArg method be used more places for path arguments that have
default values, like "-settings" and BITCOIN_SETTINGS_FILENAME in the
next commit.

Also:

- Fix negated argument handling. Return path{} not path{"0"} when path
  argument is negated.

- Add new tests for default and negated cases

- Move GetPathArg() method declaration next to GetArg() declarations.
  The two methods are close substitutes for each other, so this should
  help keep them consistent and make them more discoverable.
2022-03-02 06:09:27 -05:00
laanwj
8b6cd42c62
Merge bitcoin/bitcoin#24165: p2p: extend inbound eviction protection by network to CJDNS peers
b7be28cac5 test: add combined CJDNS/I2P/localhost/onion eviction protection tests (Jon Atack)
0a1bb84770 test: add tests for inbound eviction protection of CJDNS peers (Jon Atack)
0c00c0c981 test: fix off-by-one logic in an eviction protection test (Jon Atack)
f7b8094d61 p2p: extend inbound eviction protection by network to CJDNS peers (Jon Atack)

Pull request description:

  Extend inbound eviction protection for peers connected over CJDNS, as is the case for peers connected via onion, localhost, and I2P since #21261 and #20197.  CJDNS peers seem to have better min ping latency than onion and I2P peers but still higher than that of unencrypted IPv4/6 peers and can be disadvantaged under our eviction criteria. They are also very few in number, which is a further reason to protect them, as the goal of this logic is to favorise the diversity of our peer connections.  CJDNS support was added in #23077 for the upcoming v23 release.

ACKs for top commit:
  laanwj:
    Concept and code review ACK b7be28cac5
  w0xlt:
    tACK b7be28c

Tree-SHA512: 89ebdd217602e16ae14b9bd0d5a25fc09f9b2384c951f820bc0f5a6d8452bbc9042065db817d5d5296c0ad22988491a83fc5b9a611e660c40ebd4f03448c4061
2022-03-02 12:00:58 +01:00
laanwj
267917f563
Merge bitcoin/bitcoin#23304: wallet: Derive inactive HD chains in additional places
c4d76c6faa tests: Tests for inactive HD chains (Andrew Chow)
8077862c5e wallet: Refactor TopUp to be able to top up inactive chains too (Andrew Chow)
70134eb34f wallet: Properly set hd chain counters when loading (Andrew Chow)
961b9e4e40 wallet: Parse hdKeypath if key_origin is not available (Andrew Chow)
0652ee73ec Add size check on meta.key_origin.path (Rob Fielding)

Pull request description:

  Currently inactive HD chains are only derived from at the time a key in that chain is found to have been used. However, at that time, the wallet may not be able to derive keys (e.g. it is locked). Currently we would just move on and not derive any new keys, however this could result in missing funds.

  This PR resolves this problem by adding memory only variables to `CHDChain` which track the highest known index. `TopUp` is modified to always try to top up the inactive HD chains, and this process will use the new variables to determine how much to top up. In this way, after an encrypted wallet is unlocked, the inactive HD chains will be topped up and hopefully funds will not be missed.

  Note that because these variables are not persisted to disk (because `CHDChain`s for inactive HD chains are not written to disk), if an encrypted wallet is not unlocked in the same session as a key from an inactive chain is found to be used, then it will not be topped up later unless more keys are found.

  Additionally, wallets which do not have upgraded key metadata will not derive any keys from inactive HD chains. This is resolved by using the derivation path string in `CKeyMetadata.hdKeypath` to determine what indexes to derive.

ACKs for top commit:
  laanwj:
    Code review ACK c4d76c6faa

Tree-SHA512: b2b572ad7f1b1b2847edece09f7583543d63997e18ae32764e5a27ad608dd64b9bdb2d84ea27137894e986a8e82f047a3dba9c8015b74f5f179961911f0c4095
2022-03-02 09:35:07 +01:00
laanwj
ba11eb354b
Merge bitcoin/bitcoin#23542: net: open p2p connections to nodes that listen on non-default ports
36ee76d1af net: remove unused CNetAddr::GetHash() (Vasil Dimov)
d0abce9a50 net: include the port when deciding a relay destination (Vasil Dimov)
2e38a0e686 net: add CServiceHash constructor so the caller can provide the salts (Vasil Dimov)
97208634b9 net: open p2p connections to nodes that listen on non-default ports (Vasil Dimov)

Pull request description:

  By default, for mainnet, the p2p listening port is 8333. Bitcoin Core
  has a strong preference for only connecting to nodes that listen on that
  port.

  Remove that preference because connections over clearnet that involve
  port 8333 make it easy to detect, analyze, block or divert Bitcoin p2p
  traffic before the connection is even established (at TCP SYN time).

  For further justification see the OP of:
  https://github.com/bitcoin/bitcoin/pull/23306

ACKs for top commit:
  laanwj:
    Concept and light code review ACK 36ee76d1af
  prayank23:
    ACK 36ee76d1af
  stickies-v:
    tACK 36ee76d1a
  jonatack:
    ACK 36ee76d1af
  glozow:
    utACK 36ee76d1af

Tree-SHA512: 7f45ab7567c51c19fc50fabbaf84f0cc8883a8eef84272b76435c014c31d89144271d70dd387212cc1114213165d76b4d20a5ddb8dbc958fe7e74e6ddbd56d11
2022-03-02 09:33:03 +01:00
laanwj
848b11615b
Merge bitcoin/bitcoin#22834: net: respect -onlynet= when making outbound connections
0eea83a85e scripted-diff: rename `proxyType` to `Proxy` (Vasil Dimov)
e53a8505db net: respect -onlynet= when making outbound connections (Vasil Dimov)

Pull request description:

  Do not make outbound connections to hosts which belong to a network
  which is restricted by `-onlynet`.

  This applies to hosts that are automatically chosen to connect to and to
  anchors.

  This does not apply to hosts given to `-connect`, `-addnode`,
  `addnode` RPC, dns seeds, `-seednode`.

  Fixes https://github.com/bitcoin/bitcoin/issues/13378
  Fixes https://github.com/bitcoin/bitcoin/issues/22647
  Supersedes https://github.com/bitcoin/bitcoin/pull/22651

ACKs for top commit:
  naumenkogs:
    utACK 0eea83a85e
  prayank23:
    reACK 0eea83a85e
  jonatack:
    ACK 0eea83a85e code review, rebased to master, debug built, and did some manual testing with various config options on signet

Tree-SHA512: 37d68b449dd6d2715843fc84d85f48fa2508be40ea105a7f4a28443b318d0b6bd39e3b2ca2a6186f2913836adf08d91038a8b142928e1282130f39ac81aa741b
2022-03-01 18:32:01 +01:00
fanquake
024b8e12a5
Merge bitcoin/bitcoin#24451: qt: Pre-branch translation updates for 23.x
b67ef6d59b qt: Pre-branch translation updates for 23.x (laanwj)

Pull request description:

  Pull the translations from transifex once before the 23.x branch-off, so that master has at least somewhat-relevant translations.

ACKs for top commit:
  fanquake:
    ACK b67ef6d59b

Tree-SHA512: 1e7b759b4ed211584fe4ee7d9057621e858573b616802db21748f91d077ad51466edf4cf1f4f3f4e53d9afb24712f69f716ab08380fd0358a4beabe3f3c6d5dc
2022-03-01 13:48:24 +00:00
Luke Dashjr
e8272024ab doc: Use human-friendly DefaultHint for change_address/changeAddress in wallet RPC help 2022-02-28 23:28:22 +00:00
Luke Dashjr
9d5e693c9d Bugfix: doc: Correct type of change_address/changeAddress in wallet RPC help (STR, not STR_HEX) 2022-02-28 23:27:38 +00:00
laanwj
b67ef6d59b qt: Pre-branch translation updates for 23.x
Pull the translations from transifex once before the 23.x branch-off, so
that master has at least somewhat-relevant translations.
2022-02-28 16:59:56 +01:00
laanwj
25290071c4
Merge bitcoin/bitcoin#24397: build: Fix Boost.Process check for Boost 1.73 and older
774323e378 ci: Force `--enable-external-signer` to prevent future regressions (Hennadii Stepanov)
69978858a4 build: Fix Boost.Process check for Boost 1.73 and older (Hennadii Stepanov)
2199ef79cb build: Fix a non-portable use of `test` (Hennadii Stepanov)
d436c488d4 build, refactor: Replace tabs with spaces (Hennadii Stepanov)

Pull request description:

  On master (5f44c5c428) Boost.Process check false fails without the `-lpthread` flag.

  ```
  $ grep -C 2 pthread_detach config.log
  /usr/bin/ld: /tmp/cczCQfQv.o: in function `boost::asio::detail::posix_global_impl<boost::asio::system_context>::~posix_global_impl()':
  conftest.cpp:(.text._ZN5boost4asio6detail17posix_global_implINS0_14system_contextEED2Ev[_ZN5boost4asio6detail17posix_global_implINS0_14system_contextEED5Ev]+0xa3): undefined reference to `pthread_join'
  /usr/bin/ld: conftest.cpp:(.text._ZN5boost4asio6detail17posix_global_implINS0_14system_contextEED2Ev[_ZN5boost4asio6detail17posix_global_implINS0_14system_contextEED5Ev]+0xc4): undefined reference to `pthread_detach'
  collect2: error: ld returned 1 exit status
  configure:26674: $? = 1
  ```

  Not required for Boost 1.74+.

ACKs for top commit:
  laanwj:
    Code review ACK 774323e378, is a bugfix/workaround, seems fine to merge last minute for 23.0.

Tree-SHA512: 2a9d4b67fd8910e107af972d8c223286b7c933bc310616f86c8b6d8c903438916980fc76bd7e37f2698f6ce5361dc706cbf2933d1ac2c081bcabe1b83ca7d6b6
2022-02-28 14:06:16 +01:00
laanwj
159f89c118
Merge bitcoin/bitcoin#24365: wallet: Don't generate keys for wallets with private keys disabled during upgradewallet
c7376cc8d7 tests: Test upgrading wallet with privkeys disabled (Andrew Chow)
3d985d4f43 wallet: Don't generate keys when privkeys disabled when upgrading (Andrew Chow)

Pull request description:

  When we're upgrading a wallet, we shouldn't be trying to generate new keys for wallets where private keys are disabled.

  Fixes #23610

ACKs for top commit:
  laanwj:
    Code review ACK c7376cc8d7
  benthecarman:
    tACK c7376cc8d7 this fixed the issue for me

Tree-SHA512: fa07cf37df9196ff98671bb1ce5c9aa0bab46495066b4dab796d7e8e5d5c7adb414ff56adae4fd3e15658a610995bd19a9e1edb00c46144b0df635c5b343f3a6
2022-02-28 13:15:11 +01:00