Commit graph

21949 commits

Author SHA1 Message Date
fanquake
74cd038e30
refactor: fix includes in src/init 2022-04-20 13:51:33 +01:00
fanquake
c79ad935f0
refactor: fix includes in src/compat
Add missing includes.

Swap C headers for their C++ counterparts.

Remove pointless / unmaintainable include comments. This is even more the case
when we are actually using IWYU, as if anyone wants to see the comments they can
just get IWYU to generate them.
2022-04-20 13:51:33 +01:00
dergoegge
10b83e2aa3 [net processing] Move block cache state into PeerManagerImpl 2022-04-20 13:33:07 +02:00
dergoegge
a4c55a93ef [net processing] Inline and simplify UpdatePreferredDownload
We inline `UpdatePreferredDownload` because it is only used in one
location during the version handshake. We simplify it by removing the
initial subtraction of `state->fPreferredDownload` from
`nPreferredDownload`. This is ok since the version handshake is only
called once per peer and `state->fPreferredDownload` will always be
false before the newly inlined code is called, making the subtraction a
noop.
2022-04-20 13:33:07 +02:00
dergoegge
490c08f96a [net processing] Move nPreferredDownload into PeerManagerImpl 2022-04-20 13:33:07 +02:00
dergoegge
a292df283a [net processing] Move mapNodeState into PeerManagerImpl 2022-04-20 13:33:07 +02:00
dergoegge
37ecaf3e7a [net processing] Move CNodeState declaration above PeerManagerImpl 2022-04-20 13:33:07 +02:00
MarcoFalke
dbdc83ae01
Merge bitcoin/bitcoin#24909: refactor: Move and rename pindexBestHeader, fHavePruned
f0a2fb3c5d scripted-diff: Rename pindexBestHeader, fHavePruned (Carl Dong)
a401402125 Clear fHavePruned in BlockManager::Unload() (Carl Dong)
3308ecd3fc move-mostly: Make fHavePruned a BlockMan member (Carl Dong)
c96524113c Clear pindexBestHeader in ChainstateManager::Unload() (Carl Dong)
73eedaaacc style-only: Miscellaneous whitespace changes (Carl Dong)
0d567daf23 move-mostly: Make pindexBestHeader a ChainMan member (Carl Dong)
5d670173a3 validation: Load pindexBestHeader in ChainMan (Carl Dong)

Pull request description:

  Split off from #22564 per Marco's suggestion: https://github.com/bitcoin/bitcoin/pull/22564#issuecomment-1100011503

  This is basically the move-mostly parts of #22564. The overall intent is to move mutable globals manually reset by `::UnloadBlockIndex` into appropriate structs such that they are cleared at the appropriate times. Please read #22564's description for more rationale.

  In summary , this PR moves:
  1. `pindexBestHeader` -> `ChainstateManager::m_best_header`
  2. `fHavePruned` -> `BlockManager::m_have_pruned`

ACKs for top commit:
  ajtowns:
    ACK f0a2fb3c5d -- code review only
  MarcoFalke:
    kirby ACK f0a2fb3c5d 😋

Tree-SHA512: 8d161701af81af1ff42da1b22a6bef2f8626e8642146bc9c3b27f3a7cd24f4d691910a2392b188ae058fec0611a17304dd73f60da695f53832d327f73d2fc963
2022-04-20 12:13:25 +02:00
Carl Dong
f0a2fb3c5d scripted-diff: Rename pindexBestHeader, fHavePruned
...to m_best_header and m_have_pruned

-BEGIN VERIFY SCRIPT-
find_regex="\bpindexBestHeader\b" \
    && git grep -l -E "$find_regex" -- src \
        | xargs sed -i -E "s@$find_regex@m_best_header@g"
find_regex="\bfHavePruned\b" \
    && git grep -l -E "$find_regex" -- src \
        | xargs sed -i -E "s@$find_regex@m_have_pruned@g"
-END VERIFY SCRIPT-
2022-04-19 14:36:18 -04:00
Carl Dong
a401402125 Clear fHavePruned in BlockManager::Unload()
-----

Code Reviewer Notes

Call graph of relevant functions:

UnloadBlockIndex() <-- Moved from
    calls ChainstateManager::Unload()
        which calls BlockManager::Unload() <-- Moved to

So calling UnloadBlockIndex() would still run this moved code. The code
will also now run when ~BlockManager gets called, which makes sense.
2022-04-19 14:34:56 -04:00
Carl Dong
3308ecd3fc move-mostly: Make fHavePruned a BlockMan member
[META] In the next commit, we move the clearing of fHavePruned to
       BlockManager::Unload()
2022-04-19 14:34:56 -04:00
Carl Dong
c96524113c Clear pindexBestHeader in ChainstateManager::Unload()
-----

Code Reviewer Notes

Call graph of relevant functions:

UnloadBlockIndex() <-- Moved from
    calls ChainstateManager::Unload() <-- Moved to

Safe because ChainstateManager::Unload() is called only by
UnloadBlockIndex() and no other callers.
2022-04-19 14:34:56 -04:00
Carl Dong
73eedaaacc style-only: Miscellaneous whitespace changes
...of touched lines and surrounding
2022-04-19 14:34:56 -04:00
Carl Dong
0d567daf23 move-mostly: Make pindexBestHeader a ChainMan member
[META] In the next commit, we move the clearing of pindexBestHeader to
       ChainstateManager::Unload()
2022-04-19 14:34:55 -04:00
Hennadii Stepanov
254f3cc368
Merge bitcoin-core/gui#584: Getting ready to Qt 6 (5/n). Do not assume qDBusRegisterMetaType return type
6cf4dc7f64 qt: Do not assume `qDBusRegisterMetaType` return type (Hennadii Stepanov)

Pull request description:

  `qDBusRegisterMetaType` returns:
  - [`int`](https://doc.qt.io/qt-5/qdbusargument.html#qDBusRegisterMetaType) in Qt 5
  - [`QMetaType`](https://doc.qt.io/qt-6/qdbusargument.html#qDBusRegisterMetaType) in Qt 6

ACKs for top commit:
  laanwj:
    Anyhow code review ACK 6cf4dc7f64
  w0xlt:
    tACK 6cf4dc7f64 on Ubuntu 21.10, Qt 5.15.2.

Tree-SHA512: 17d43e191d31a6f927d19550c52471ed3b9222f492a23cee2e553f2c679cf37125e00637b00ea9f4ee3e37dfcf5278171be9a5e1e2e899592516291c7b5cd942
2022-04-19 19:36:50 +02:00
Hennadii Stepanov
37e49cc1b5
Merge bitcoin-core/gui#580: Getting ready to Qt 6 (3/n). Do not use QKeyEvent copy constructor
3ec6504a2e qt: Do not use `QKeyEvent` copy constructor (Hennadii Stepanov)

Pull request description:

  This PR is preparation for [Qt 6](https://github.com/bitcoin/bitcoin/pull/24798), and it fixes an experimental build with Qt 6.2.4 as copying of `QEvent` has been [disabled](19f9b0d5f5) in Qt 6.0.0.

ACKs for top commit:
  w0xlt:
    tACK 3ec6504a2e on Ubuntu 21.10, Qt 5.15.2
  shaavan:
    reACK 3ec6504a2e

Tree-SHA512: 583a9dad0c621d9f02f77ccaa9f55ee79e12e3c47f418911ef2dfe0de357d772d1928ae3ec19b6f0c0674da858bab9d4542a26cc14b06ed921370dfeabd1c194
2022-04-19 19:32:21 +02:00
Andrew Chow
8103fffe5c
Merge bitcoin/bitcoin#24906: miniscript: the 'd:' wrapper must not be 'u'
7417594187 miniscript: the 'd:' wrapper must not be 'u' (Antoine Poinsot)

Pull request description:

  The type system was incorrectly relying on a standardness rule to be sound.

  This bug was found and reported by Andrew Poelstra [based on a question from Aman Kumar Kashyap](https://github.com/rust-bitcoin/rust-miniscript/discussions/341).

ACKs for top commit:
  sipa:
    ACK 7417594187
  apoelstra:
    utACK 7417594187
  achow101:
    ACK 7417594187

Tree-SHA512: af68c1df1c40e40dd105ef54544c226f560524dd8e35248fa0305dbef966e96ec1fa6ff2fe50fb8f2792ac310761a29c55ea81dd7b6d122a0de0a68b135e5aaa
2022-04-19 13:26:36 -04:00
laanwj
6300b9556e
Merge bitcoin/bitcoin#24357: refactor: make setsockopt() and SetSocketNoDelay() mockable/testable
a2c4a7acd1 net: use Sock::SetSockOpt() instead of standalone SetSocketNoDelay() (Vasil Dimov)
d65b6c3fb9 net: use Sock::SetSockOpt() instead of setsockopt() (Vasil Dimov)
184e56d668 net: add new method Sock::SetSockOpt() that wraps setsockopt() (Vasil Dimov)

Pull request description:

  _This is a piece of #21878, chopped off to ease review._

  Add a `virtual` (thus mockable) method `Sock::SetSockOpt()` that wraps the system `setsockopt()`.

  Convert the standalone `SetSocketNoDelay()` function to a `virtual` (thus mockable) method `Sock::SetNoDelay()`.

  This will help avoid syscalls during testing and to mock them to return whatever is suitable for the tests.

ACKs for top commit:
  laanwj:
    Code review ACK a2c4a7acd1
  jonatack:
    ACK a2c4a7acd1 change since last review is folding `Sock::SetNoDelay()` into the callers

Tree-SHA512: 3e2b016c1e4128317a28c17dc9b30472949e1ac3b071b2697c6d30cbcc830df1ee4392a4e23b2ea1ab4e3fb0f59ef450e2a4f3c1df3d8c803dd081652b6c7387
2022-04-19 16:43:47 +02:00
laanwj
f8b2e9bcfc
Merge bitcoin/bitcoin#24772: refactor: Use [[maybe_unused]] attribute
07ddecb84e refactor: Use [[maybe_unused]] attribute (Hennadii Stepanov)
55e0fc8df9 refactor: Drop unneeded workarounds aimed to silence unused warning (Hennadii Stepanov)

Pull request description:

  This change is required for bitcoin/bitcoin#24773 as it prevents MSVC yelling about "warning C4551: function call missing argument list".

  But it is useful by itself as it makes code more concise and readable.

ACKs for top commit:
  Empact:
    Code review ACK 07ddecb84e
  laanwj:
    Code review ACK 07ddecb84e
  vincenzopalazzo:
    ACK 07ddecb84e
  w0xlt:
    ACK 07ddecb

Tree-SHA512: 01791855a9ba742202d5718203303af989fcb501b7cf2a24ac8d78e87487acca38f77bef264b8e27e41ad1ccf96e426725cf65bfd96ce2ac71c46b3792bed857
2022-04-19 15:59:40 +02:00
fanquake
e0ff55a836
Merge bitcoin/bitcoin#24871: refactor: Simplify GetTime
0000a63689 Simplify GetTime (MarcoFalke)

Pull request description:

  The implementation of `GetTime` is confusing:
  * The value returned by `GetTime` is assumed to be equal to `GetTime<std::chrono::seconds>()`. Both are mockable and the only difference is return type, the value itself is equal. However, the implementation does not support this assumption.
  * On some systems, `time_t` might be a signed 32-bit integer (https://en.cppreference.com/w/c/chrono/time), thus breaking in the year 2038, whereas `GetTime<std::chrono::seconds>` does not. Also, `time_t` might be `-1` "on error", where "error" is unspecified.
  * `GetTime<std::chrono::seconds>` calls `GetTimeMicros`, which calls `GetSystemTime`, which calls `std::chrono::system_clock::now`, which doesn't have the above issues. See https://en.cppreference.com/w/cpp/chrono/system_clock/now
  * `GetTimeMicros` and the internal-only `GetSystemTime` will likely be renamed (to clarify they are the non-mockable non-monotonic system time) or removed in the future to be replaced by appropriate `std::chrono::time_point<Clock>` getters.

  Fix all issues by:
  * making `GetTime()` an alias for `GetTime<std::chrono::seconds>().count()`.
  * inlining the needed parts of `GetSystemTime` directly instead of needlessly increasing the function call stack with functions that are likely to be removed in the future.

ACKs for top commit:
  martinus:
    Code review, untested ACK 0000a63689. By the way strictly speaking `std::chrono::system_clock` is only guaranteed to be based on the unix epoch starting with C++20: https://en.cppreference.com/w/cpp/chrono/system_clock
  theStack:
    Code-review ACK 0000a63689

Tree-SHA512: f751ba740e0da65537be800e9414dd02282d9f04c0b0fb986a36546f257d0b888d8688653cdda5d355ec832c0e09d866922d9161b1ccd33485c1c92c5d1e802f
2022-04-19 13:36:50 +01:00
laanwj
b297b945f7
Merge bitcoin/bitcoin#21279: scripted-diff: Regenerate key_io data deterministically
fa506add25 scripted-diff: Regenerate key_io data deterministically (MarcoFalke)
fafb4796d3 contrib: make gen_key_io_test_vectors deterministic (MarcoFalke)

Pull request description:

ACKs for top commit:
  Sjors:
    ACK fa506add25
  laanwj:
    Tested ACK fa506add25

Tree-SHA512: 02dc56c70c53356ee8d7012b42bec56017d646790f3248fd7437b6be556903ae9511abf3803fa30c7a11c10b4e9d41a736ff927404059bcdf2e0f30b70553014
2022-04-19 13:40:47 +02:00
MarcoFalke
fa1970f075
Make BlockManager::LoadBlockIndex private 2022-04-19 11:32:49 +02:00
John Newbery
17c24d4580 [init] Add netgroupman to node.context
This is constructed before addrman and connman, and destructed afterwards.

netgroupman does not currently do anything, but will have functionality added in future commits.
2022-04-19 10:25:40 +01:00
John Newbery
9b3836710b [build] Add netgroup.cpp|h
These aren't used yet.
2022-04-19 10:25:39 +01:00
Andrew Chow
464a162817 bench: Add a benchmark for wallet loading 2022-04-18 17:02:57 -04:00
w0xlt
a237a065cc scripted-diff: rename cs_totalBytesSent -> m_total_bytes_sent_mutex
-BEGIN VERIFY SCRIPT-
sed -i 's/cs_totalBytesSent/m_total_bytes_sent_mutex/g' -- $(git grep --files-with-matches 'cs_totalBytesSent')
-END VERIFY SCRIPT-
2022-04-18 13:23:26 -03:00
Andrew Chow
2095f19db9
Merge bitcoin/bitcoin#24859: wallet: Change wallet validation order
6f29409ad1 test: Add a test that creates a wallet with invalid parameters (w0xlt)
0359d9b6a3 Change wallet validation order (w0xlt)

Pull request description:

  In the current code, the database is created before the last validation, which checks that passphrase is set and private keys are disabled.

  Therefore, if this validation fails, it will result in an empty database and the user will not be able to recreate a wallet with the same name and with the correct parameters.

  Behavior on the master branch:
  ```
  $ ./src/bitcoin-cli -regtest -named createwallet wallet_name="invalid_wallet_01" disable_private_keys=true passphrase="passphrase"
  error code: -4
  error message:
  Passphrase provided but private keys are disabled. A passphrase is only used to encrypt private keys, so cannot be used for wallets with private keys disabled.

  $ ./src/bitcoin-cli -regtest -named createwallet wallet_name="invalid_wallet_01"
  error code: -4
  error message:
  Wallet file verification failed. Failed to create database path '/home/w/.bitcoin/regtest/wallets/invalid_wallet'. Database already exists.
  ```

  Behavior on the PR branch:
  ```
  $ ./src/bitcoin-cli -regtest -named createwallet wallet_name="invalid_wallet_02" disable_private_keys=true passphrase="passphrase"
  error code: -4
  error message:
  Passphrase provided but private keys are disabled. A passphrase is only used to encrypt private keys, so cannot be used for wallets with private keys disabled.

  $ ./src/bitcoin-cli -regtest -named createwallet wallet_name="invalid_wallet_02"
  {
    "name": "invalid_wallet_01",
    "warning": ""
  }
  ```

ACKs for top commit:
  achow101:
    ACK 6f29409ad1

Tree-SHA512: d192955fc2285bf27ae5dd4c1b7cfd3d85441a7f3554b189b974aefb319c6b997543991dbb0ca2c8cb980f7058913a77cf0164c02e9b51ceb9c2cb601317c428
2022-04-18 11:29:29 -04:00
Antoine Poinsot
7417594187
miniscript: the 'd:' wrapper must not be 'u'
The value it leaves on the stack depends on the last element on the
stack. However, we can't make sure this element is OP_1 (which would
give us the 'u' property) without the MINIMALIF rule.
MINIMALIF is only policy for P2WSH, therefore giving 'd:' the 'u'
property breaks consensus soundness: it makes it possible (by consensus
but not policy) for instance to satisfy a thresh() without satisfying
at least k of its subs.

This bug was found and reported by Andrew Poelstra.
2022-04-18 16:03:29 +02:00
Martin Leitner-Ankerl
5e61532e72
util: optimizes HexStr
In my benchmark, this rewrite improves runtime 27% (g++) to 46% (clang++) for the benchmark `HexStrBench`:

g++ 11.2.0
|             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|                0.94 |    1,061,381,310.36 |    0.7% |           12.00 |            3.01 |  3.990 |           1.00 |    0.0% |      0.01 | `HexStrBench` master
|                0.68 |    1,465,366,544.25 |    1.7% |            6.00 |            2.16 |  2.778 |           1.00 |    0.0% |      0.01 | `HexStrBench` branch

clang++ 13.0.1
|             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|                0.80 |    1,244,713,415.92 |    0.9% |           10.00 |            2.56 |  3.913 |           0.50 |    0.0% |      0.01 | `HexStrBench` master
|                0.43 |    2,324,188,940.72 |    0.2% |            4.00 |            1.37 |  2.914 |           0.25 |    0.0% |      0.01 | `HexStrBench` branch

Note that the idea for this change comes from denis2342 in PR 23364. This is a rewrite so no unaligned accesses occur.

Also, the lookup table is now calculated at compile time, which hopefully makes the code a bit easier to review.
2022-04-17 14:29:52 +02:00
Martin Leitner-Ankerl
4e2b99f72a
bench: Adds a benchmark for HexStr
Benchmarks conversion of a full binary block into hex, like it is done in rest.cpp.
2022-04-17 14:29:52 +02:00
Martin Leitner-Ankerl
67c8411c37
test: Adds a test for HexStr that checks all 256 bytes
This makes sure the whole HexStr mapping table is checked.
2022-04-17 14:29:14 +02:00
MarcoFalke
2074d7df20
Merge bitcoin/bitcoin#24837: init: Prevent -noproxy and -proxy=0 from interacting with other settings
3429d67014 init: Prevent -noproxy and -proxy=0 settings from interacting with other settings (Ryan Ofsky)

Pull request description:

  Prevent `-noproxy` and `-proxy=0` settings from interacting with `-listen`, `-upnp`, and `-natpmp` settings.

  These settings started being handled inconsistently in the `AppInitMain` and `InitParameterInteraction` functions starting in commit baf05075fa from #6272:

  baf05075fa/src/init.cpp (L990-L991)
  baf05075fa/src/init.cpp (L687)

  This commit changes both functions to handle proxy arguments the same way so
  there are not side effects from specifying a proxy=0 setting.

  This change was originally part of #24830 but really is independent and makes more sense as a separate PR

ACKs for top commit:
  hebasto:
    ACK 3429d67014, tested on Ubuntu 22.04.

Tree-SHA512: c4c6b4aeb3c07321700e974c16fd47a1bd3d469f273a6b308a69638db81c88c4e67208fddc96fcda9c8bd85f3ae22c98ca131c9622895edaa34eb65c194f35db
2022-04-17 13:41:16 +02:00
Hennadii Stepanov
6958a26aa1
Revert "qt: Add ObjectInvoke template function"
This reverts commit 5659e73493.
2022-04-16 19:18:54 +02:00
Hennadii Stepanov
249984f4f9
qt: Replace GUIUtil::ObjectInvoke() with QMetaObject::invokeMethod()
The `GUIUtil::ObjectInvoke()` template function was a replacement of
the `QMetaObject::invokeMethod()` functor overload which is available
in Qt 5.10+.

No behavior change.
2022-04-16 19:18:25 +02:00
Hennadii Stepanov
bcbf982553
qt, doc: Remove unneeded comments
Function names are self-described.
2022-04-16 18:59:17 +02:00
Hennadii Stepanov
9bd1565f65
qt: Revamp ClientModel code to handle {Block|Header}Tip core signals
No behavior change.
2022-04-16 18:59:17 +02:00
Hennadii Stepanov
48f6d39659
qt: Revamp ClientModel code to handle BannedListChanged core signal
No behavior change.
2022-04-16 18:59:02 +02:00
Hennadii Stepanov
36b12af7ee
qt: Revamp ClientModel code to handle AlertChanged core signal
No behavior change.
2022-04-16 18:50:20 +02:00
Aurèle Oulès
ee02c8bd9a util/check: Add CHECK_NONFATAL identity function, NONFATAL_UNREACHABLE AND UNREACHABLE macros 2022-04-16 15:07:41 +02:00
Shashwat
e71c51b27d refactor: rename command -> message type in comments in the src/net* files
Co-authored-by: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
2022-04-16 16:57:26 +05:30
MarcoFalke
0000a63689
Simplify GetTime 2022-04-16 13:15:14 +02:00
fanquake
d1b3dfb275
Merge bitcoin/bitcoin#24855: rpc: Fix setwalletflag disabling of flags
88376c623c test: Test for disabling wallet flags (Andrew Chow)
17ab31aa46 rpc, wallet: setwalletflags warnings are optional (Andrew Chow)

Pull request description:

  Trying to disable a wallet flag with `setwalletflag` results in `Internal bug detected: 'std::any_of(m_results.m_results.begin(), m_results.m_results.end(), [ret](const RPCResult& res) { return res.MatchesType(ret); })'`. This occurs because the `warnings` field was not marked as optional. This PR makes `warnings` optional to avoid this error.

  Also added a test case because apparently we didn't already have one.

ACKs for top commit:
  w0xlt:
    ACK 88376c6

Tree-SHA512: 4f5d3bebf0d022a5ad0f75d70c6562a43c7da6e39e9c3118733327d015c435e2c8d5004fdb039d42407dde5b21231a0f8827623d718abf611a1f06c15af5c806
2022-04-16 10:45:15 +01:00
MarcoFalke
6be319beb8
Merge bitcoin/bitcoin#24841: test: fix connman UB by calling derived constructor
c848a45101 test: fix connman UB by calling derived constructor (chinggg)

Pull request description:

  Hopefully closes #24373 by calling `ConnmanTestMsg` test-constructor to avoid undefined behavior in process_message.cpp after casting `g_setup->m_node.connman`.

Top commit has no ACKs.

Tree-SHA512: c3dce9dcce33614c7b739edf28e416b600ab3d38d16cdb0430490e8ffc9b64aff9292006ae6fe7c636ab0627893bb21f69435893bdfb129a9a865be92baa6f17
2022-04-16 09:10:29 +02:00
chinggg
c848a45101 test: fix connman UB by calling derived constructor 2022-04-16 11:16:32 +08:00
Hennadii Stepanov
f3e0ace8ec
Merge bitcoin-core/gui#579: Getting ready to Qt 6 (2/n). Remove QApplication::globalStrut()
3eaf5dbfe0 qt: Remove `QApplication::globalStrut()` call (Hennadii Stepanov)

Pull request description:

  This function has been deprecated in Qt 5.15.0, and has been [removed](033d01bd6e) in Qt 6.

ACKs for top commit:
  jarolrod:
    ACK 3eaf5dbfe0
  luke-jr:
    utACK 3eaf5dbfe0

Tree-SHA512: 71ee539b6ffa3755f7e6beaa72a8937886471e298830878def6dd9f48c601611d94d52c638bc1602f938df2ba84ff8b130ea8da8e6c08ae7146173fa613a5003
2022-04-15 12:00:53 +02:00
Hennadii Stepanov
72477ebb11
Merge bitcoin-core/gui#556: refactor: Make BitcoinUnits::Unit a scoped enum
0e5dedbc9e qt/wallettests: sort includes (William Casarin)
0554251d66 qt: Skip displayUnitChanged signal if unit is not actually changed (Hennadii Stepanov)
ffbc2fe459 qt, refactor: Remove default cases for scoped enum (Hennadii Stepanov)
152d5bad50 qt, refactor: Remove BitcoinUnits::valid function (Hennadii Stepanov)
aa23960fdf qt, refactor: Make BitcoinUnits::Unit a scoped enum (Hennadii Stepanov)
75832fdc37 qt: Use QVariant instead of int for BitcoinUnit in QSettings (Hennadii Stepanov)

Pull request description:

  This is a rebased version of #60

  Since Qt 5.5 there are [means](https://doc.qt.io/qt-5/qobject.html#Q_ENUM) to register an enum type with the meta-object system (such enum still lacks an ability to interact with [QSettings::setValue()](https://doc.qt.io/qt-5/qsettings.html#setValue) and [QSettings::value()](https://doc.qt.io/qt-5/qsettings.html#value) without defined stream operators).

  In order to reduce global namespace polluting and to force strong type checking, this PR makes BitcoinUnits::Unit a scoped enum (typedef BitcoinUnits::Unit BitcoinUnit;).

  No behavior change.

ACKs for top commit:
  jonatack:
    ACK 0e5dedbc9e, review and debug build of each commit after rebase on current master, lightly tested running the GUI, changing units a few times, and verifying persistence after restarting
  promag:
    Code review ACK 0e5dedbc9e

Tree-SHA512: 39ec0d7e4f0b9b25be287888121a8db6b282339674e37ec3a3554da63a9e22d6fe079e8310ca289b2a0356a19b3c7e55afa17d09dd34e0f222177f603bb053a3
2022-04-15 11:51:22 +02:00
Hennadii Stepanov
7190de9fb8
Merge bitcoin-core/gui#552: Refactor TransactionDesc::FormatTxStatus and TransactionStatus
343f83d088 qt, refactor: Use member initializers in TransactionStatus (w0xlt)
66d58ad7a9 qt, refactor: remove unused field `qint64 TransactionStatus::open_for` (w0xlt)
ad6adedb46 qt, refactor: remove unused parameters in `TransactionDesc::FormatTxStatus()` (w0xlt)
045f8d0310 scripted-diff: rename nDepth -> depth (w0xlt)
b1bc1431db qt, refactor: remove redundant scope in `TransactionDesc::FormatTxStatus()` (w0xlt)

Pull request description:

  This PR implements the changes suggested in https://github.com/bitcoin-core/gui/issues/538#issuecomment-1021913294 .

  . remove redundant scope, rename `nDepth` -> `depth`, remove unused parameters and add translator comments in `TransactionDesc::FormatTxStatus()`
  .  Use member initializers and remove unused field `qint64 TransactionStatus::open_for` in `TransactionStatus`.

  Closes https://github.com/bitcoin-core/gui/issues/538

ACKs for top commit:
  hebasto:
    ACK 343f83d088, I have reviewed the code and it looks OK, I agree it can be merged.
  jarolrod:
    Code Review ACK 343f83d088

Tree-SHA512: cc7333d85b7eb731aa8cdd2d8dfc707341532c93e1b5e3858e8341446cf055ba055b601f9662e8d4602726b1bedf13149c46256a60a0ce1a562f94c9986d945a
2022-04-15 11:36:54 +02:00
Vasil Dimov
a2c4a7acd1
net: use Sock::SetSockOpt() instead of standalone SetSocketNoDelay()
Since the former is mockable, this makes it easier to test higher level
code that sets the TCP_NODELAY flag.
2022-04-15 09:39:25 +02:00
Vasil Dimov
d65b6c3fb9
net: use Sock::SetSockOpt() instead of setsockopt() 2022-04-15 09:19:05 +02:00
Vasil Dimov
184e56d668
net: add new method Sock::SetSockOpt() that wraps setsockopt()
This will help to increase `Sock` usage and make more code mockable.
2022-04-15 09:14:49 +02:00
w0xlt
0359d9b6a3 Change wallet validation order
In the current code, the database is created before the last validation,
which checks that passphrase is set and private keys are disabled.

Therefore, if this validation fails, it will result in an empty database
and the user will not be able to recreate a wallet with the same name
and with the correct parameters.
2022-04-15 03:48:33 -03:00
Andrew Chow
17ab31aa46 rpc, wallet: setwalletflags warnings are optional
Without this, trying to disable a wallet flag results in an Internal bug
detected.
2022-04-14 14:39:21 -04:00
Andrew Chow
8e3f39e4fa wallet: Add some tracepoints for coin selection 2022-04-14 13:41:36 -04:00
MarcoFalke
fad6d4f952
Remove not needed ArithToUint256 roundtrips in tests 2022-04-14 19:29:52 +02:00
MarcoFalke
fa456ccb22
Remove duplicate static_asserts
One should be enough. Can be reviewed with
--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2022-04-14 19:26:22 +02:00
Andrew Chow
15b58383d0 wallet: compute waste for SelectionResults of preset inputs
When we use only manually specified inputs, we should still calculate
the waste so that if anything later on calls GetWaste (in order to log
it), there won't be an error.
2022-04-14 12:40:36 -04:00
Andrew Chow
912f1ed181 wallet: track which coin selection algorithm produced a SelectionResult 2022-04-14 12:40:36 -04:00
laanwj
b69fd5eaa9
Merge bitcoin/bitcoin#22052: net: remove non-blocking bool from interface
c71117fcb0 net: remove non-blocking bool from interface (Bushstar)

Pull request description:

  SetSocketNonBlocking was added in 0.11 in the PR below with a second argument to toggle non-blocking mode for the socket. That argument has always been set to true in all subsequent releases and I'm not sure why it is present.

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

ACKs for top commit:
  promag:
    Code review ACK c71117fcb0.
  lsilva01:
    Code review ACK c71117fcb0
  vasild:
    ACK c71117fcb0

Tree-SHA512: feebfcfa75d997460a0ba42ffe1e0c25a7e0bfcad12510ad73ea4942cc1c653f9ad429adbbb00b9288fe319009552906fcb635a14dfd7dcbde3853baab6be065
2022-04-14 10:16:01 +02:00
laanwj
1e3ed01faa
Merge bitcoin/bitcoin#23416: doc: Remove fee delta TODO from txmempool.cpp
fa32cc0682 doc: Remove fee delta TODO from txmempool.cpp (MarcoFalke)

Pull request description:

  This refactor request was added in commit eb306664e7, though it didn't explain why the refactor is needed and what the goal is. Given that this wasn't touched for more than 5 years, it doesn't seem critical. Generally, non-trivial `TODO`s make more sense as GitHub issues, so that they can be discussed and triaged more easily.

ACKs for top commit:
  laanwj:
    Code review ACK fa32cc0682

Tree-SHA512: 6629fef543e815136c82c38aa8ba2c4de68a5fe94c6954f2559e468f7e59052e02dd7c221d3b159be0314eaf0dbb18f74814297c58f76e2289c47e8d4f49be4e
2022-04-14 09:42:22 +02:00
laanwj
8e3c266a4f
Merge bitcoin/bitcoin#24077: util: Make base_uint::GetHex() and base_uint::SetHex() not depend on uint256
a4f4f89815 Replace uint256 specific implementations of base_uint::GetHex() and base_uint::SetHex() with proper ones that don't depend on uint256 and replace template methods instantiations of base_uint with template class instantiation (Samer Afach)

Pull request description:

  The current implementations of `SetHex()` and `GetHex()` in `base_uint` use `arith_uint256`'s implementations. Which means, any attempt to create anything other than `arith_uint256` (say `arith_uint512`) and using any of these functions (which is what I needed in my application) will just not work and will cause compilation errors (besides the immediate linking errors due to templates being in source files instantiated only for 256) because there's no viable conversion from `arith_uint256` and any of the other possible types. Besides that these function will yield wrong results even if the conversion is possible depending on the size. This is fixed in this PR.

ACKs for top commit:
  laanwj:
    re-ACK a4f4f89815

Tree-SHA512: 92a930fb7ddec5a5565deae2386f7d2d84645f9e8532f8d0c0178367ae081019b32eedcb59cc11028bac0cb15d9883228e016a466b1ee8fc3c6377b4df1d4180
2022-04-14 07:15:22 +02:00
laanwj
decde9bba6
Merge bitcoin/bitcoin#24355: util, refactor: Add UNIQUE_NAME helper macro
1633f5ec88 util, refactor: Add UNIQUE_NAME helper macro (Hennadii Stepanov)

Pull request description:

  This PR replaces repetitive code with a helper macro.

ACKs for top commit:
  laanwj:
    Tested ACK 1633f5ec88

Tree-SHA512: 5f04e472c5f3184c0a9df75395377c6744bfb2cd8f95f8427c1c5e20daa7d6a9b29e45424b88391fc6326d365907a750ab50fda534b49d1df80dccf0e18467a4
2022-04-13 22:59:33 +02:00
laanwj
3bbc46ddaf
Merge bitcoin/bitcoin#24632: add (none) in -getinfo Warnings: if no warning returned
0cea7b10f1 print `(none)` if no warnings in -getinfo (/dev/fd0)

Pull request description:

  Adds `(none)` in warnings when no warnings returned by -getinfo

  Reviewers can test this by making the following change in `/src/warnings.cpp`:

  ```diff
  bilingual_str GetWarnings(bool verbose)
  {
      bilingual_str warnings_concise;
      std::vector<bilingual_str> warnings_verbose;

      LOCK(g_warnings_mutex);

      // Pre-release build warning
      if (!CLIENT_VERSION_IS_RELEASE) {
  -        warnings_concise = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");;
  +        warnings_concise = _("");;
  ```

  Before this pull request:

  ```
  $ bitcoin-cli -getinfo
  Chain: regtest
  Blocks: 0
  Headers: 0
  Verification progress: 100.0000%
  Difficulty: 4.656542373906925e-10

  Network: in 0, out 0, total 0
  Version: 239900
  Time offset (s): 0
  Proxies: n/a
  Min tx relay fee rate (BTC/kvB): 0.00001000

  Warnings:
  ```

  After this pull request:

  ```diff
  $ bitcoin-cli -getinfo
  Chain: regtest
  Blocks: 0
  Headers: 0
  Verification progress: 100.0000%
  Difficulty: 4.656542373906925e-10

  Network: in 0, out 0, total 0
  Version: 239900
  Time offset (s): 0
  Proxies: n/a
  Min tx relay fee rate (BTC/kvB): 0.00001000

  Warnings: (none)
  ```

ACKs for top commit:
  jonatack:
    ACK 0cea7b10f1
  laanwj:
    Tested ACK 0cea7b10f1

Tree-SHA512: a12499d11ff84bc954db354f968eb1f5ee4999d8b80581fe0bdf604732b2e2f608cb5c35c4ca8cb5a430f3991954a6207f0758302618662e6b9505044cf2dc95
2022-04-13 21:49:22 +02:00
Hennadii Stepanov
3ec6504a2e
qt: Do not use QKeyEvent copy constructor
This change is preparation for Qt 6, and it fixes an experimental build
with Qt 6.2.4 as copying of `QEvent` has been disabled in Qt 6.0.0 (see
19f9b0d5f54379151eb71e98555b203ad6756276 upstream commit).
2022-04-13 20:55:01 +02:00
Hennadii Stepanov
6cf4dc7f64
qt: Do not assume qDBusRegisterMetaType return type
`qDBusRegisterMetaType` returns:
 - `int` in Qt 5
 - `QMetaType` in Qt 6
2022-04-13 20:44:23 +02:00
w0xlt
343f83d088 qt, refactor: Use member initializers in TransactionStatus 2022-04-13 12:24:37 -03:00
w0xlt
66d58ad7a9 qt, refactor: remove unused field qint64 TransactionStatus::open_for 2022-04-13 12:24:37 -03:00
Hennadii Stepanov
f60a63cc5f
Merge bitcoin-core/gui#577: Getting ready to Qt 6 (1/n)
63125752a9 qt: Update deprecated enum value (Hennadii Stepanov)
c7add881a6 qt: Use `|` instead of `+` for key modifiers (Hennadii Stepanov)
6f1e162fe1 qt: Fix headers (Hennadii Stepanov)

Pull request description:

  For Qt 5 all changes in this PR are refactoring. But for [Qt 6](https://github.com/bitcoin/bitcoin/pull/24798) they are real bugfixes :)

  As I do not provide anyway way to build `bitcoin-qt` against Qt 6.2.4 fir now, suggesting to reviewers to verify changes for Qt 5 only.

ACKs for top commit:
  shaavan:
    ACK 63125752a9
  jarolrod:
    tACK 63125752a9

Tree-SHA512: ceee983192ddf62f09c1305458af3447ff0e3bd90311fa6328b139673bcaed3407dc0ce0b275028d4e0ca251d6b54dad40b48049211aeb251f65cbb4f5330834
2022-04-13 01:27:16 +02:00
Hennadii Stepanov
f509760026
Merge bitcoin-core/gui#576: Add qt unit test runner summary
d025d7f025 gui, refactor: rename fInvalid to num_test_failures in test_main.cpp (Jon Atack)
2489b6fe9c gui: count test failures in test runner summary (Jon Atack)
ba44aae768 gui: add test runner summary (Jon Atack)

Pull request description:

  Append a one-line summary to the output of running `./src/qt/test/test_bitcoin-qt` indicating that all tests passed or showing the number of failing tests. It's currently a bit inconvenient to see this result by eyeballing all of the output.

ACKs for top commit:
  shaavan:
    ACK d025d7f025
  jarolrod:
    tACK d025d7f025

Tree-SHA512: 981c5daa13db127d38167bcf78b296b1a7e5b2d12e65f364ec6382b24f1008a223521d3b6c56e920bcd037479da5414e43758794688019d09e9aa696f3964746
2022-04-13 01:17:30 +02:00
Hennadii Stepanov
0f46e73c74
Merge bitcoin-core/gui#543: peers-tab: add connection duration column to tableview
51708c4516 gui: peersWidget - ResizeToContents Age and IP/Netmask columns (randymcmillan)
209301a442 gui: add Age column to peers tab (randymcmillan)
127de22c5f gui: add FormatPeerAge() utility helper (Jon Atack)

Pull request description:

  This change adds an "Age" column to the peers table view,
  which displays the duration of each peer's connection.

ACKs for top commit:
  jonatack:
    re-ACK  51708c4516
  Jamewood:
    > re-ACK 51708c4
  shaavan:
    reACK 51708c4516
  hebasto:
    ACK 51708c4516, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: 27323f7080ec0d3fcdbf1b190fba1cd2d7406840ab6607c221cf8af950db9134e22721cc5a88f4fc4f390d8b05e98bc4b7521661a31fadad9e2c6c6390e71788
2022-04-13 01:11:55 +02:00
Carl Dong
5d670173a3 validation: Load pindexBestHeader in ChainMan
Now BlockManager::LoadBlockIndex() will ACTUALLY only load BlockMan
members.

[META] In a later commit, pindexBestHeader will be moved to ChainMan as
       a member

-----

Code Reviewer Notes

Call graph of relevant functions:

ChainstateManager::LoadBlockIndex() <-- Moved to
    calls BlockManager::LoadBlockIndexDB()
        which calls BlockManager::LoadBlockIndex() <-- Moved from

There is only one call to each of inner functions, meaning that no
behavior is changing.
2022-04-12 14:37:27 -04:00
Ryan Ofsky
3429d67014 init: Prevent -noproxy and -proxy=0 settings from interacting with other settings
Prevent -noproxy and -proxy=0 settings from interacting with -listen, -upnp,
and -natpmp settings.

These settings started being handled inconsistently in the `AppInitMain` and
`InitParameterInteraction` functions starting in commit
baf05075fa from #6272:

baf05075fa/src/init.cpp (L990-L991)
baf05075fa/src/init.cpp (L687)

This commit changes both functions to handle proxy arguments the same way so
there are not side effects from specifying a proxy=0 setting.
2022-04-12 03:00:28 -04:00
Carl Dong
64caf94479 build: Remove vestigial LIBLEVELDB_SSE42
- LIBLEVELDB_SSE42_INT was defined, but never referenced anywhere
- LIBLEVELDB_SSE42 is referenced, but never defined anywhere

Apparently leveldb used to have platform-specific crc32 code before it
got split off into a separate lib.
2022-04-11 16:56:34 -04:00
Carl Dong
1392e8e2d8 build: Don't add unrelated libs to LIBTEST_*
This was used to, in effect, manually emulate --start-group/--end-group.
However, we can just order the libraries correctly and avoid specifying
libraries multiple times on the link line.

Note: lld (not ld.bfd) knows how to resolve out-of-order references and
      doesn't seem to need the reodering
2022-04-11 16:56:34 -04:00
MarcoFalke
a62e84438d fuzz: add SplitString fuzz target 2022-04-11 22:19:50 +02:00
Kiminuo
4fad7e46d9 test: add unit tests for SplitString helper 2022-04-11 22:19:50 +02:00
Sebastian Falbesoner
9cc8e876e4 refactor: introduce single-separator split helper SplitString
This helper uses spanparsing::Split internally and enables to replace
all calls to boost::split where only a single separator is passed.

Co-authored-by: Martin Ankerl <Martin.Ankerl@gmail.com>
Co-authored-by: MarcoFalke <falke.marco@gmail.com>
2022-04-11 22:19:46 +02:00
Hennadii Stepanov
bfe5140c50
qt: Revamp ClientModel code to handle NetworkActiveChanged core signal
No behavior change.
2022-04-10 18:56:29 +02:00
Hennadii Stepanov
639563d7fe
qt: Revamp ClientModel code to handle NumConnectionsChanged core signal
No behavior change.
2022-04-10 18:56:20 +02:00
Hennadii Stepanov
508e2dca5e
qt: Revamp ClientModel code to handle ShowProgress core signal
No behavior change.
2022-04-10 18:56:09 +02:00
fanquake
747cdf1d65
Merge bitcoin/bitcoin#24792: Update libsecp256k1 subtree to current master
404c53062b key: use secp256k1_schnorrsig_sign32 over deprecated secp256k1_schnorrsig_sign (fanquake)
ee30bf7c01 build: remove some no-longer-needed var unexporting from configure (fanquake)
2656629767 build: remove --enable-experimental from libsecp256k1 configure (fanquake)
d960d4fd3a build: fix MSVC build after subtree update (dhruv)
afb7a6fe06 Squashed 'src/secp256k1/' changes from 0559fc6e41..8746600eec (fanquake)

Pull request description:

  The motivation for this bump is some small build cleanups, including [dropping the `--enable-experimental`](80cf4eea5f) flag from the libsecp configure  invocation, as well as some [now-redundant](https://github.com/bitcoin-core/secp256k1/pull/1090) `pkg-config` variable exporting from our own configure. We also get the benefit of a slightly more efficient libsecp configure due to https://github.com/bitcoin-core/secp256k1/pull/1088.

  This also includes a change in our code to migrate from using the [now deprecated](99e6568fc6) `secp256k1_schnorrsig_sign` to `secp256k1_schnorrsig_sign32`.

  Guix Build (on x86_64):
  ```bash
  b9f6ad90c75f7edd7c4444c6c3401d8b6ab29a8da22ae22ddaedd94688227b5d  guix-build-404c53062bb8/output/aarch64-linux-gnu/SHA256SUMS.part
  250d47ae299d8385d5590518fa2adaabde76e2566fd27e12bf36b62663d13e13  guix-build-404c53062bb8/output/aarch64-linux-gnu/bitcoin-404c53062bb8-aarch64-linux-gnu-debug.tar.gz
  48d610dc6f5169f925f782571dac2f082695f89008beadad4adef4c1b583a612  guix-build-404c53062bb8/output/aarch64-linux-gnu/bitcoin-404c53062bb8-aarch64-linux-gnu.tar.gz
  8f04ee26e4079719e3935bd0e4287cc11a2a16875bf01e2a63d67492a1fa5367  guix-build-404c53062bb8/output/arm-linux-gnueabihf/SHA256SUMS.part
  7d7d7fcfb032bda92e53abd8d608257f0ef17b1e3e52a1414260b896786fb2dc  guix-build-404c53062bb8/output/arm-linux-gnueabihf/bitcoin-404c53062bb8-arm-linux-gnueabihf-debug.tar.gz
  30bae2ff3d044f4e39f992a68f6b296b7be2aea350bca4a0415c739a32c20bd9  guix-build-404c53062bb8/output/arm-linux-gnueabihf/bitcoin-404c53062bb8-arm-linux-gnueabihf.tar.gz
  5f550fb0b950250eeffce3480ec6403530b0880570a5860ef6c32a3e92eac92f  guix-build-404c53062bb8/output/arm64-apple-darwin/SHA256SUMS.part
  c10664d13aeec8c860bf72be833c738973ae18e4d28cdf08b2f9bee960ebff1d  guix-build-404c53062bb8/output/arm64-apple-darwin/bitcoin-404c53062bb8-arm64-apple-darwin-unsigned.dmg
  becab75b11cf4ca6f559f8eef835f3574629f6eb932ac716ed4f8c044a85831f  guix-build-404c53062bb8/output/arm64-apple-darwin/bitcoin-404c53062bb8-arm64-apple-darwin-unsigned.tar.gz
  bc86433652fe3552f6a13088191364ae7514c9fe3a244da86a6db096bb4922fc  guix-build-404c53062bb8/output/arm64-apple-darwin/bitcoin-404c53062bb8-arm64-apple-darwin.tar.gz
  1f585cb9a1356343df4b2726ecfe2598c9903304afb047c047c2cef318555dd3  guix-build-404c53062bb8/output/dist-archive/bitcoin-404c53062bb8.tar.gz
  9ede534ba2c6cecb550473eead195627327e826ebb0118e23d60ab482d40e241  guix-build-404c53062bb8/output/powerpc64-linux-gnu/SHA256SUMS.part
  77ddb7d7d639b1dd4508468a8ef27e45b35c8b2f8624584a70e6b64798a4ea7a  guix-build-404c53062bb8/output/powerpc64-linux-gnu/bitcoin-404c53062bb8-powerpc64-linux-gnu-debug.tar.gz
  36178c1f1c12942ff05275daa3570f8b45419ee8d9f391d750afb405219986f0  guix-build-404c53062bb8/output/powerpc64-linux-gnu/bitcoin-404c53062bb8-powerpc64-linux-gnu.tar.gz
  8a15a4da7a9a5e00c49d9aeedf3c6fc666c0d230be1369eac7caf4571d5905e0  guix-build-404c53062bb8/output/powerpc64le-linux-gnu/SHA256SUMS.part
  400c58113f2d07c87e03c8528b292c6aca808a2bccae4b041cad3a26a05b6aad  guix-build-404c53062bb8/output/powerpc64le-linux-gnu/bitcoin-404c53062bb8-powerpc64le-linux-gnu-debug.tar.gz
  3b9f9d8614ac3a27416e53354b2b0a64d364f91493e9d0f41583a6f492546824  guix-build-404c53062bb8/output/powerpc64le-linux-gnu/bitcoin-404c53062bb8-powerpc64le-linux-gnu.tar.gz
  98506b23ee08ad8af958f816da2e4518d661e88d5c6308de1f5e3b2fc787b86c  guix-build-404c53062bb8/output/riscv64-linux-gnu/SHA256SUMS.part
  c701a7b77cea4fdc2588b511f1b2c71b89c83bfba19fdb2ac113a5a4b14ac392  guix-build-404c53062bb8/output/riscv64-linux-gnu/bitcoin-404c53062bb8-riscv64-linux-gnu-debug.tar.gz
  34d58e6392cd58b3c76e30cd8600c0dbefba7e9c6d5df78c3ef23e81c4e4d26a  guix-build-404c53062bb8/output/riscv64-linux-gnu/bitcoin-404c53062bb8-riscv64-linux-gnu.tar.gz
  92fa30e9c6d81dd1e1514b65d3e1abe68ded897237cd99f66aa760d445109c04  guix-build-404c53062bb8/output/x86_64-apple-darwin/SHA256SUMS.part
  bee180b02f178ae9980ef159f65913a71cbd037c4aff5f2906af5f174a677da3  guix-build-404c53062bb8/output/x86_64-apple-darwin/bitcoin-404c53062bb8-x86_64-apple-darwin-unsigned.dmg
  ad7d18d779ab7a7944817d1f368d0a6bdd174bf1211b0f90180c8ccf04ec4062  guix-build-404c53062bb8/output/x86_64-apple-darwin/bitcoin-404c53062bb8-x86_64-apple-darwin-unsigned.tar.gz
  7489d1d5d48ad95cf58bb11b5fdeccadac6fa758784fb498529fca2330abe069  guix-build-404c53062bb8/output/x86_64-apple-darwin/bitcoin-404c53062bb8-x86_64-apple-darwin.tar.gz
  74660fb0ebce2a08b03980a57bffcad62e078dc967a74d2395660ff51c019640  guix-build-404c53062bb8/output/x86_64-linux-gnu/SHA256SUMS.part
  cd377fa6b46276c2f8a32e199e6f9adf6aa67315688656709d6dc0744d54a837  guix-build-404c53062bb8/output/x86_64-linux-gnu/bitcoin-404c53062bb8-x86_64-linux-gnu-debug.tar.gz
  919c521950369d8ad46db2d15b00abb488abfb080d157a41b2db429122a428ed  guix-build-404c53062bb8/output/x86_64-linux-gnu/bitcoin-404c53062bb8-x86_64-linux-gnu.tar.gz
  2debca995d432965a8786b6ff74aed42e9e2f1cb0fecbe2d9fc5b850c192fcff  guix-build-404c53062bb8/output/x86_64-w64-mingw32/SHA256SUMS.part
  e33169f684fb031ec18ed39812617d3eb263257f6c7564b8f4c974ad05fe672c  guix-build-404c53062bb8/output/x86_64-w64-mingw32/bitcoin-404c53062bb8-win64-debug.zip
  029d0a4180cb908d517fcf689dcf46d42fbf383e11dc609711617066ae039ab0  guix-build-404c53062bb8/output/x86_64-w64-mingw32/bitcoin-404c53062bb8-win64-setup-unsigned.exe
  7e349c688cac66436562c4805f420b0536db5a3b3abf54d0e8c7752f59874a5c  guix-build-404c53062bb8/output/x86_64-w64-mingw32/bitcoin-404c53062bb8-win64-unsigned.tar.gz
  1bff98e82e95c93d6060227408502f5e2d8597d526b912cb6dc0a90ae3094a8f  guix-build-404c53062bb8/output/x86_64-w64-mingw32/bitcoin-404c53062bb8-win64.zip
  ```

ACKs for top commit:
  laanwj:
    Code review ACK 404c53062b, I checked the changes to our tree thoroughly but didn't review all upstream secp256k1 changes in detail.
  gruve-p:
    ACK 404c53062b
  real-or-random:
    utACK 404c53062b I reviewed the diff to Core, I'm with updating to libsecp256k1 master, but I haven't verified that the libsecp256k1 tree here has been updated correctly

Tree-SHA512: e6a6db93ea60ed500df5065178784a915da94adfa7bd45fdbd7b19d701154987ff38c1df7f318119e6c2cb98e28e1ea2eb725bef93d4088403e14537ebffb032
2022-04-09 20:18:54 +01:00
Hennadii Stepanov
3eaf5dbfe0
qt: Remove QApplication::globalStrut() call
This function has been deprecated in Qt 5.15.0, and has been removed in
Qt 6 (see 033d01bd6e2aef740ad1408a04d3ca0ae3b9ba9b upstream commit).
2022-04-09 01:54:38 +02:00
Hennadii Stepanov
63125752a9
qt: Update deprecated enum value
This change is preparation for Qt 6, and it fixes an experimental build
with Qt 6.2.4.
The `Qt::ItemIsTristate` value has been deprecated since 5.6.0 (see
ae8406d82f541f6d9112bdac192e5e4e114d56aa upstream commit).
2022-04-09 01:13:35 +02:00
Hennadii Stepanov
c7add881a6
qt: Use | instead of + for key modifiers
This change is preparation for Qt 6 where `+` has been deprecated, and
it fixes an experimental build with Qt 6.2.4.
2022-04-09 01:12:06 +02:00
Hennadii Stepanov
6f1e162fe1
qt: Fix headers
This change is preparation for Qt 6, and it fixes an experimental build
with Qt 6.2.4.
2022-04-09 01:11:02 +02:00
/dev/fd0
0cea7b10f1 print (none) if no warnings in -getinfo 2022-04-08 20:33:07 +05:30
fanquake
e0680bbce8
Merge bitcoin/bitcoin#24806: RPC: Switch getblockfrompeer back to standard param name blockhash
88917f93cc RPC: Switch getblockfrompeer back to standard param name blockhash (Luke Dashjr)

Pull request description:

  This commit partially reverts 923312fbf6.

  Portion of #24294.

ACKs for top commit:
  MarcoFalke:
    review ACK 88917f93cc
  ajtowns:
    ACK 88917f93cc
  jonatack:
    Review-and-grep-only ACK 88917f93cc

Tree-SHA512: e42497ea6162623e449c5e60b83a5abbef568f226edc022aa14bbc1f1921618255d593968cf43f7a6d2c0bfd84cdd4b05fbce5c724759b20035e6eead758d443
2022-04-08 13:43:18 +01:00
fanquake
c1059c9fef
Merge bitcoin/bitcoin#24770: Put lock logging behind DEBUG_LOCKCONTENTION preprocessor directive
4394733331 Add DEBUG_LOCKCONTENTION documentation to the developer notes (Jon Atack)
39a34b6877 Put lock logging behind DEBUG_LOCKCONTENTION preprocessor directive (Jon Atack)

Pull request description:

  This is a more minimal, no-frills version of #24734 for backport. The other fixes and improvements in that pull can be done after.

  *Copy of the PR 24734 description:*

  PRs #22736, #22904 and #23223 changed lock contention logging from a `DEBUG_LOCKCONTENTION` compile-time preprocessor directive to a runtime `lock` log category and improved the logging output. This changed the locking from using `lock()` to `try_lock()`:

  - `void Mutex::UniqueLock::lock()` acquires the mutex and blocks until it gains access to it

  - `bool Mutex::UniqueLock::try_lock()` doesn't block but instead immediately returns whether it acquired the mutex; it may be used by `lock()` internally as part of the deadlock-avoidance algorithm

  In theory the cost of `try_lock` might be essentially the [same](https://www.erisian.com.au/bitcoin-core-dev/log-2022-03-31.html#l-697) relative to `lock`. The test-and-set logic of these calls is purported to be ~ constant time, optimised and light/quick if used carefully (i.e. no mutex convoying), compared to system calls, memory/cache coherency and fences, wait queues, and (particularly) lock contentions. See the discussion around https://github.com/bitcoin/bitcoin/pull/22736#issuecomment-902851054 and after with respect to performance/cost aspects.  However, there are reasonable concerns (see [here](https://github.com/bitcoin/bitcoin/pull/22736#discussion_r691277896) and [here](https://www.erisian.com.au/bitcoin-core-dev/log-2022-03-31.html#l-620)) that `Base::try_lock()` may be potentially [costly](https://www.erisian.com.au/bitcoin-core-dev/log-2022-03-31.html#l-700) or [risky](https://github.com/bitcoin/bitcoin/pull/22904#issuecomment-930484001) compared to `Base::lock()` in this very frequently called code.

  One alternative to keep the run-time lock logging would be to gate the `try_lock` call behind the logging conditional, for example as proposed in ccd73de1dd and ACKed [here](https://github.com/bitcoin/bitcoin/pull/22736#issuecomment-901980815). However, this would add the [cost](https://github.com/bitcoin/bitcoin/pull/22736#issuecomment-910102353) of `if (LogAcceptCategory(BCLog::LOCK))` to the hotspot, instead of replacing `lock` with `try_lock`, for the most frequent happy path (non-contention).

  It turns out we can keep the advantages of the runtime lock contention logging (the ability to turn it on/off at runtime) while out of prudence putting the `try_lock()` call and `lock` logging category behind a  `DEBUG_LOCKCONTENTION` compile-time preprocessor directive, and also still retain the lock logging enhancements of the mentioned PRs, as suggested in https://github.com/bitcoin/bitcoin/pull/24734#issuecomment-1085785480 by W. J. van der Laan, in https://github.com/bitcoin/bitcoin/pull/22736#discussion_r691280693, and in the linked IRC discussion.

  Proposed here and for backport to v23.

ACKs for top commit:
  laanwj:
    Code review ACK 4394733331

Tree-SHA512: 89b1271cae1dca0eb251914b1a60fc5b68320aab4a3939c57eec3a33a3c8f01688f05d95dfc31f91d71a6ed80cfe2d67b77ff14742611cc206175e47b2e5d3b1
2022-04-08 13:30:24 +01:00
Luke Dashjr
88917f93cc
RPC: Switch getblockfrompeer back to standard param name blockhash
This commit partially reverts 923312fbf6.
2022-04-08 13:22:46 +01:00
fanquake
404c53062b
key: use secp256k1_schnorrsig_sign32 over deprecated secp256k1_schnorrsig_sign
The renaming occured in
https://github.com/bitcoin-core/secp256k1/pull/1089.
2022-04-07 22:24:44 +01:00
Shashwat
2b09593bdd scripted-diff: Rename message command to message type
-BEGIN VERIFY SCRIPT-

 s1() { sed -i "s/$1/$2/g" $(git grep -l "$1" ./); }

 s1 'NET_MESSAGE_COMMAND_OTHER' 'NET_MESSAGE_TYPE_OTHER'
 s1 'mapMsgCmdSize' 'mapMsgTypeSize'
 s1 'mapRecvBytesPerMsgCmd' 'mapRecvBytesPerMsgType'
 s1 'mapSendBytesPerMsgCmd' 'mapSendBytesPerMsgType'
 s1 'recvPerMsgCmd' 'recvPerMsgType'
 s1 'sendPerMsgCmd' 'sendPerMsgType'

-END VERIFY SCRIPT-
2022-04-07 17:22:36 +05:30
fanquake
f87f25948a
refactor: fixup named args in txpackage tests
Regression in #24152.
2022-04-07 12:50:54 +01:00
fanquake
eaf712c801
lint: codespell 2.1.0 2022-04-07 12:49:51 +01:00
MarcoFalke
323d4c09c0
Merge bitcoin/bitcoin#24784: refactor: deduplicate integer serialization in RollingBloom benchmark
fff91418ff refactor: Remove deduplication of data in rollingbloom bench (phyBrackets)

Pull request description:

  Fixed up #24088.

ACKs for top commit:
  vincenzopalazzo:
    ACK fff91418ff

Tree-SHA512: 9fef617bceb74a1aec4f4a1e7c4732c4764af3e8ac2fc02b84ce370e8b97431957ca17ee8f44fb96765f7304f8d7e5bfb951440db98ba40f240612f2232d215e
2022-04-07 11:53:20 +02:00
fanquake
5c80d9b72d
Merge bitcoin/bitcoin#24790: lint: remove qt SIGNAL/SLOT lint
b72925e7ce lint: remove qt SIGNAL/SLOT lint (fanquake)

Pull request description:

  I think we are past the point where we need to lint for this, the CPU
  can probably be better utilized.

ACKs for top commit:
  laanwj:
    ACK b72925e7ce

Tree-SHA512: 3da6e4811cdd16ff64c7e26f641f7b24f0405cc86cec36666de58691d447eca8662c924df31c6c60b3523c13590bdc62205a3237b1b1794dd8cdef35519309b3
2022-04-07 10:07:11 +01:00
fanquake
d844b5e799
Merge bitcoin/bitcoin#24152: policy / validation: CPFP fee bumping within packages
9bebf35e26 [validation] don't package validate if not policy or missing inputs (glozow)
51edcffa0e [unit test] package feerate and package cpfp (glozow)
1b93748c93 [validation] try individual validation before package validation (glozow)
17a8ffd802 [packages/policy] use package feerate in package validation (glozow)
09f32cffa6 [docs] package feerate (glozow)

Pull request description:

  Part of #22290, aka [Package Mempool Accept](https://gist.github.com/glozow/dc4e9d5c5b14ade7cdfac40f43adb18a).

  This enables CPFP fee bumping in child-with-unconfirmed-parents packages by introducing [package feerate](https://gist.github.com/glozow/dc4e9d5c5b14ade7cdfac40f43adb18a#fee-related-checks-use-package-feerate) (total modified fees divided by total virtual size) and using it in place of individual feerate. We also always [validate individual transactions first](https://gist.github.com/glozow/dc4e9d5c5b14ade7cdfac40f43adb18a#always-try-individual-submission-first) to avoid incentive-incompatible policies like "parents pay for children" or "siblings pay for siblings" behavior.

ACKs for top commit:
  instagibbs:
    reACK 9bebf35e26
  mzumsande:
    Code review ACK 9bebf35e26
  t-bast:
    ACK 9bebf35e26

Tree-SHA512: 5117cfcc3ce55c00384d9e8003a0589ceac1e6f738b1c299007d9cd9cdd2d7c530d31cfd23658b041a6604d39073bcc6e81f0639a300082a92097682a6ea8c8f
2022-04-07 10:05:43 +01:00
Jon Atack
d025d7f025
gui, refactor: rename fInvalid to num_test_failures in test_main.cpp 2022-04-06 23:52:34 +02:00
Jon Atack
2489b6fe9c
gui: count test failures in test runner summary 2022-04-06 23:52:05 +02:00
Jon Atack
ba44aae768
gui: add test runner summary 2022-04-06 23:45:46 +02:00
fanquake
2619657c99
Update secp256k1 subtree to latest upstream master 2022-04-06 20:20:30 +01:00
fanquake
afb7a6fe06 Squashed 'src/secp256k1/' changes from 0559fc6e41..8746600eec
8746600eec Merge bitcoin-core/secp256k1#1093: hash: Make code agnostic of endianness
37d36927df tests: Add tests for _read_be32 and _write_be32
912b7ccc44 Merge bitcoin-core/secp256k1#1094: doc: Clarify configure flags for optional modules
55512d30b7 doc: clean up module help text in configure.ac
d9d94a9969 doc: mention optional modules in README
616b43dd3b util: Remove endianness detection
8d89b9e6e5 hash: Make code agnostic of endianness
d0ad5814a5 Merge bitcoin-core/secp256k1#995: build: stop treating schnorrsig, extrakeys modules as experimental
1ac7e31c5b Merge bitcoin-core/secp256k1#1089: Schnorrsig API improvements
587239dbe3 Merge bitcoin-core/secp256k1#731: Change SHA256 byte counter from size_t to uint64_t
f8d9174357 Add SHA256 bit counter tests
7f09d0f311 README: mention that ARM assembly is experimental
b8f8b99f0f docs: Fix return value for functions that don't have invalid inputs
f813bb0df3 schnorrsig: Adapt example to new API
99e6568fc6 schnorrsig: Rename schnorrsig_sign to schnorsig_sign32 and deprecate
fc94a2da44 Use SECP256K1_DEPRECATED for existing deprecated API functions
3db0560606 Add SECP256K1_DEPRECATED attribute for marking API parts as deprecated
80cf4eea5f build: stop treating schnorrsig, extrakeys modules as experimental
e0508ee9db Merge bitcoin-core/secp256k1#1090: configure: Remove redundant pkg-config code
21b2ebaf74 configure: Remove redundant pkg-config code
0e5cbd01b3 Merge bitcoin-core/secp256k1#1088: configure: Use modern way to set AR
0d253d52e8 configure: Use modern way to set AR
9b514ce1d2 Add test vector for very long SHA256 messages
8e3dde1137 Simplify struct initializer for SHA256 padding
eb28464a8b Change SHA256 byte counter from size_t to uint64_t
ac83be33d0 Merge bitcoin-core/secp256k1#1079: configure: Add hidden --enable-dev-mode to enable all the stuff
e0838d663d configure: Add hidden --enable-dev-mode to enable all the stuff
fabd579dfa configure: Remove redundant code that sets _enable variables
0d4226c051 configure: Use canonical variable prefix _enable consistently
64b34979ed Merge bitcoin-core/secp256k1#748: Add usage examples
7c9502cece Add a copy of the CC0 license to the examples
42e03432e6 Add usage examples to the readme
517644eab1 Optionally compile the examples in autotools, compile+run in travis
422a7cc86a Add a ecdh shared secret example
b0cfbcc143 Add a Schnorr signing and verifying example
fee7d4bf9e Add an ECDSA signing and verifying example
1253a27756 Merge bitcoin-core/secp256k1#1033: Add _fe_half and use in _gej_add_ge and _gej_double
3ef94aa5ba Merge bitcoin-core/secp256k1#1026: ecdh: Add test computing shared_secret=basepoint with random inputs
3531a43b5b ecdh: Make generator_basepoint test depend on global iteration count
c881dd49bd ecdh: Add test computing shared_secret=basepoint with random inputs
077528317d Merge bitcoin-core/secp256k1#1074: ci: Retry brew update a few times to avoid random failures
e51ad3b737 ci: Retry `brew update` a few times to avoid random failures
b1cb969e8a ci: Revert "Attempt to make macOS builds more reliable"
5dcc6f8dbd Merge bitcoin-core/secp256k1#1069: build: Replace use of deprecated autoconf macro AC_PROG_CC_C89
59547943d6 Merge bitcoin-core/secp256k1#1072: ci: Attempt to make macOS builds more reliable
85b00a1c65 Merge bitcoin-core/secp256k1#1068: sage: Fix incompatibility with sage 9.4
ebb1beea78 sage: Ensure that constraints are always fastfracs
d8d54859ed ci: Run sage prover on CI
77cfa98dbc sage: Normalize sign of polynomial factors in prover
eae75869cf sage: Exit with non-zero status in case of failures
d9396a56da ci: Attempt to make macOS builds more reliable
e0db3f8a25 build: Replace use of deprecated autoconf macro AC_PROG_CC_C89
e848c3799c Update sage files for new formulae
d64bb5d4f3 Add fe_half tests for worst-case inputs
b54d843eac sage: Fix printing of errors
4eb8b932ff Further improve doubling formula using fe_half
557b31fac3 Doubling formula using fe_half
2cbb4b1a42 Run more iterations of run_field_misc
9cc5c257ed Add test for secp256k1_fe_half
925f78d55e Add _fe_half and use in _gej_add_ge
e108d0039c sage: Fix incompatibility with sage 9.4
d8a2463246 Merge bitcoin-core/secp256k1#899: Reduce stratch space needed by ecmult_strauss_wnaf.
0a40a4861a Merge bitcoin-core/secp256k1#1049: Faster fixed-input ecmult tests
070e772211 Faster fixed-input ecmult tests
c8aa516b57 Merge bitcoin-core/secp256k1#1064: Modulo-reduce msg32 inside RFC6979 nonce fn to match spec. Fixes #1063
b797a500ec Create a SECP256K1_ECMULT_TABLE_VERIFY macro.
a731200cc3 Replace ECMULT_TABLE_GET_GE_STORAGE macro with a function.
fe34d9f341 Eliminate input_pos state field from ecmult_strauss_wnaf.
0397d00ba0 Eliminate na_1 and na_lam state fields from ecmult_strauss_wnaf.
7ba3ffcca0 Remove the unused pre_a_lam allocations.
b3b57ad6ee Eliminate the pre_a_lam array from ecmult_strauss_wnaf.
ae7ba0f922 Remove the unused prej allocations.
e5c18892db Eliminate the prej array from ecmult_strauss_wnaf.
c9da1baad1 Move secp256k1_fe_one to field.h
45f37b6506 Modulo-reduce msg32 inside RFC6979 nonce fn to match spec. Fixes #1063.
a1102b1219 Merge bitcoin-core/secp256k1#1029: Simpler and faster ecdh skew fixup
e82144edfb Fixup skew before global Z fixup
40b624c90b Add tests for _gej_cmov
8c13a9bfe1 ECDH skews by 0 or 1
1515099433 Simpler and faster ecdh skew fixup
39a36db94a Merge bitcoin-core/secp256k1#1054: tests: Fix test whose result is implementation-defined
a310e79ee5 Merge bitcoin-core/secp256k1#1052: Use xoshiro256++ instead of RFC6979 for tests
423b6d19d3 Merge bitcoin-core/secp256k1#964: Add release-process.md
9281c9f4e1 Merge bitcoin-core/secp256k1#1053: ecmult: move `_ecmult_odd_multiples_table_globalz_windowa`
77a19750b4 Use xoshiro256++ PRNG instead of RFC6979 in tests
5f2efe684e secp256k1_testrand_int(2**N) -> secp256k1_testrand_bits(N)
05e049b73c ecmult: move `_ecmult_odd_multiples_table_globalz_windowa`
3d7cbafb5f tests: Fix test whose result is implementation-defined
3ed0d02bf7 doc: add CHANGELOG template
6f42dc16c8 doc: add release_process.md
0bd3e4243c build: set library version to 0.0.0 explicitly
b4b02fd8c4 build: change libsecp version from 0.1 to 0.1.0-pre
09971a3ffd Merge bitcoin-core/secp256k1#1047: ci: Various improvements
0b83b203e1 Merge bitcoin-core/secp256k1#1030: doc: Fix upper bounds + cleanup in field_5x52_impl.h comment
1287786c7a doc: Add comment to top of field_10x26_impl.h
58da5bd589 doc: Fix upper bounds + cleanup in field_5x52_impl.h comment
b39d431aed Merge bitcoin-core/secp256k1#1044: Add another ecmult_multi test
b4ac1a1d5f ci: Run valgrind/memcheck tasks with 2 CPUs
e70acab601 ci: Use Cirrus "greedy" flag to use idle CPU time when available
d07e30176e ci: Update brew on macOS
22382f0ea0 ci: Test different ecmult window sizes
a69df3ad24 Merge bitcoin-core/secp256k1#816: Improve checks at top of _fe_negate methods
22d25c8e0a Add another ecmult_multi test
515e7953ca Improve checks at top of _fe_negate methods
26a022a3a0 ci: Remove STATICPRECOMPUTATION
10461d8bd3 precompute_ecmult: Always compute all tables up to default WINDOW_G
be6944ade9 Merge bitcoin-core/secp256k1#1042: Follow-ups to making all tables fully static
e05da9e480 Fix c++ build
c45386d994 Cleanup preprocessor indentation in precompute{,d}_ecmult{,_gen}
19d96e15f9 Split off .c file from precomputed_ecmult.h
1a6691adae Split off .c file from precomputed_ecmult_gen.h
bb36331412 Simplify precompute_ecmult_print_*
38cd84a0cb Compute ecmult tables at runtime for tests_exhaustive
e458ec26d6 Move ecmult table computation code to separate file
fc1bf9f15f Split ecmult table computation and printing
31feab053b Rename function secp256k1_ecmult_gen_{create_prec -> compute}_table
725370c3f2 Rename ecmult_gen_prec -> ecmult_gen_compute_table
075252c1b7 Rename ecmult_static_pre_g -> precomputed_ecmult
7cf47f72bc Rename ecmult_gen_static_prec_table -> precomputed_ecmult_gen
f95b8106d0 Rename gen_ecmult_static_pre_g -> precompute_ecmult
bae77685eb Rename gen_ecmult_gen_static_prec_table -> precompute_ecmult_gen

git-subtree-dir: src/secp256k1
git-subtree-split: 8746600eec5e7fcd35dabd480839a3a4bdfee87b
2022-04-06 20:20:30 +01:00
fanquake
b72925e7ce
lint: remove qt SIGNAL/SLOT lint
I think we are past the point where we need to lint for this, the CPU
can probably be better utilized.
2022-04-06 19:47:16 +01:00
MarcoFalke
fa506add25
scripted-diff: Regenerate key_io data deterministically
-BEGIN VERIFY SCRIPT-
 ./contrib/testgen/gen_key_io_test_vectors.py valid 70 > ./src/test/data/key_io_valid.json
 ./contrib/testgen/gen_key_io_test_vectors.py invalid 70 > ./src/test/data/key_io_invalid.json
-END VERIFY SCRIPT-
2022-04-06 17:08:07 +02:00
Martin Zumsande
62e14285f9 doc: Add note that -reindex will rebuild optional indexes 2022-04-06 17:06:16 +02:00
MarcoFalke
ffffb7a25a
doc: Convert remaining comments to clang-tidy format 2022-04-06 15:37:07 +02:00
phyBrackets
fff91418ff
refactor: Remove deduplication of data in rollingbloom bench 2022-04-06 13:57:31 +01:00
fanquake
d906329c28
Merge bitcoin/bitcoin#24681: build: Bump libevent minimum version up to 2.1.8
e40779a4fe refactor: Remove outdated libevent logging code (Fabian Jahr)
0598f36852 refactor: account for requiring libevent 2.1.8+ (fanquake)
aaf72d62c1 build: Bump libevent minimum version up to 2.1.8 (Hennadii Stepanov)

Pull request description:

  Required to support new functionality in bitcoin/bitcoin#19420.

  `libevent` availability: https://repology.org/project/libevent/versions

ACKs for top commit:
  laanwj:
    Code review ACK e40779a4fe
  fanquake:
    ACK e40779a4fe

Tree-SHA512: ccb14ea2f591484a3df5bc4a19f4f5400ef6b1cfb7dc45dd99f96cb948748215ed3b5debc34869763c91b8c7a26993fdb9b870950c0743c4d01038ab27c5e4e2
2022-04-06 13:19:36 +01:00
laanwj
bbb83f0b2b
Merge bitcoin/bitcoin#24145: mempool: Clear vTxHashes when mapTx is cleared
9d65ad365c Clear vTxHashes when mapTx is cleared (Peter Bushnell)

Pull request description:

  vTxHashes is a vector of all entries in mapTx, if you clear one you should clear the other, lest someone try to use the txiter in vTxHashes which would result in a segfault.

ACKs for top commit:
  laanwj:
    Code review ACK 9d65ad365c

Tree-SHA512: 6832755e43ab7f528b46817aeadcb6ffdc965b97f59ab96bb053dedbb7e68155ba3db52286355dca33b509237f80eda249760b26db493762bc50d8e2cef16d8f
2022-04-06 14:05:52 +02:00
laanwj
c5c4fb3182
Merge bitcoin/bitcoin#24758: Disable the syscall sandbox for bitcoin-qt and remove gui-related syscalls
fabdf9f870 Remove gui-only syscalls (MarcoFalke)
fa0c2aa826 init: Disable syscall sandbox in the bitcoin-qt process (MarcoFalke)

Pull request description:

  It is basically impossible (and a bit out of scope) for us to maintain a sandbox for the qt library. I am not sure if it is possible to only sandbox a few threads in a process, but I doubt this will add no practical benefit anyway, so I am disabling the sandbox for the whole bitcoin-qt process.

  See also https://github.com/bitcoin/bitcoin/pull/24690#issuecomment-1084372400

ACKs for top commit:
  laanwj:
    Code review ACK fabdf9f870

Tree-SHA512: 944ded03ee25f7dfd0bfeea9c3f97f575f2d470aa03b387b07f3e3bec5cb886e4aaa17e4a9fb359d3e670e6da69adc9111673d13e6561ec55b3161bb67dfe760
2022-04-06 11:57:08 +02:00
MarcoFalke
79bf1a0fa2
Merge bitcoin/bitcoin#24732: Remove buggy and confusing IncrementExtraNonce
cccc4e879a Remove nHeightEnd and nHeight in generateBlocks helper (MarcoFalke)
fa38b1c8bd Remove buggy and confusing IncrementExtraNonce (MarcoFalke)

Pull request description:

  IncrementExtraNonce has many issues:

  * It is test-only code, but part of bitcoind
  * It is using the block height of the tip, as opposed to the block's previous block as reference for the new height. See https://github.com/bitcoin/bitcoin/issues/24730#issuecomment-1085586193
  * It has no use case in regtest testing. With a low difficulty the extra nonce won't be incremented. With a high difficulty the test-only functions are clumsy to handle anyway. For example, the generate* RPCs will return an empty array once they reached `maxtries`, as opposed to an error. Also the calls can't be aborted early unless the node shuts down completely. So I think it is fine to just remove the extra nonce functionality and leave it to the outside to implement, if needed. For example, a wrapper script can call the `generate*` RPCs once every second, to use the timestamp as extra nonce.

ACKs for top commit:
  ajtowns:
    ACK cccc4e879a

Tree-SHA512: d8a3989ad280ebd4b1b574159b3a396b8a42134347e6be3c88445162d86624d221c416456f45ae75aea62ed8c8a1a9bb3a2532924abca2ef7a879cb8e6b15654
2022-04-06 11:12:10 +02:00
MarcoFalke
27cfaeed1e
Merge bitcoin/bitcoin#24098: rest: Use query parameters to control resource loading
54b39cfb34 Add release notes (stickies-v)
f959fc0397 Update /<count>/ endpoints to use a '?count=' query parameter instead (stickies-v)
a09497614e Add GetQueryParameter helper function (stickies-v)
fff771ee86 Handle query string when parsing data format (stickies-v)
c1aad1b3b9 scripted-diff: rename RetFormat to RESTResponseFormat (stickies-v)
9f1c54787c Refactoring: move declarations to rest.h (stickies-v)

Pull request description:

  In RESTful APIs, [typically](https://rapidapi.com/blog/api-glossary/parameters/query/) path parameters  (e.g. `/some/unique/resource/`) are used to represent resources, and query parameters (e.g. `?sort=asc`) are used to control how these resources are being loaded through e.g. sorting, pagination, filtering, ...

  As first [discussed in #17631](https://github.com/bitcoin/bitcoin/pull/17631#discussion_r733031180), the [current REST api](https://github.com/bitcoin/bitcoin/blob/master/doc/REST-interface.md) contains two endpoints `/headers/` and `/blockfilterheaders/` that rather unexpectedly use path parameters to control how many (filter) headers are returned in the response. While this is no critical issue, it is unintuitive and we are still early enough to easily phase this behaviour out and ensure new endpoints (if any) do not have to stick to non-standard behaviour just for internal consistency.

  In this PR, a new `HTTPRequest::GetQueryParameter` method is introduced to easily parse query parameters, as well as two new `/headers/` and `/blockfilterheaders/` endpoints that use a count query parameter are introduced. The old path parameter-based endpoints are kept without too much overhead, but the documentation now points to the new query parameter-based endpoints as the default interface to encourage standardness.

  ## Behaviour change
  ### New endpoints and default values
  `/headers/` and `/blockfilterheaders/` now have 2 new endpoints that contain query parameters (`?count=<count>`) instead of path parameters (`/<count>/`), as described in REST-interface.md. Since query parameters can easily have default values, I have set this at 5 for both endpoints.

  **headers**
  `GET /rest/headers/<BLOCK-HASH>.<bin|hex|json>?count=<COUNT=5>`
  should now be used instead of
  `GET /rest/headers/<COUNT>/<BLOCK-HASH>.<bin|hex|json>`

  **blockfilterheaders**
  `GET /rest/blockfilterheaders/<FILTERTYPE>/<BLOCK-HASH>.<bin|hex|json>?count=<COUNT=5>`
  should now be used instead of
  `GET /rest/blockfilterheaders/<FILTERTYPE>/<COUNT>/<BLOCK-HASH>.<bin|hex|json>`

  ### Some previously invalid API calls are now valid
  API calls that contained query strings in the URI could not be parsed prior to this PR. This PR changes behaviour in that previously invalid calls (e.g. `GET /rest/headers/5/somehash.json?someunusedparam=foo`) would now become valid, as the query parameters are properly parsed, and discarded if unused.
  For example, prior to this PR, adding an irrelevant `someparam` parameter would be illegal:
  ```
  GET /rest/headers/5/0000004c6aad0c89c1c060e8e116dcd849e0554935cd78ff9c6a398abeac6eda.json?someparam=true
  ->
  Invalid hash: 0000004c6aad0c89c1c060e8e116dcd849e0554935cd78ff9c6a398abeac6eda.json?someparam=true
  ```
  **This behaviour change affects all rest endpoints, not just the 2 new ones introduced here.**

  *(Note: I'd be open to implementing additional logic to refuse requests containing unrecognized query parameters to minimize behaviour change, but for the endpoints that we currently have I don't really see the point for that added complexity. E.g. I don't see any scenarios where misspelling a parameter could lead to harmful outcomes)*

  ## Using the REST API

  To run the API HTTP server, start a bitcoind instance with the `-rest` flag enabled. To use the
  `blockfilterheaders` endpoint, you'll also need to set `-blockfilterindex=1`:
  ```
  ./bitcoind -signet -rest -blockfilterindex=1
  ```

  As soon as bitcoind is fully up and running, you should be able to query the API, for example by
  using curl on the command line: ```curl "127.0.0.1:38332/rest/chaininfo.json"```.
  To more easily parse the JSON output, you can also use tools like 'jq' or `json_pp`, e.g.:
  ```
  curl -s "localhost:38332/rest/blockfilterheaders/basic/0000004c6aad0c89c1c060e8e116dcd849e0554935cd78ff9c6a398abeac6eda.json?count=2" | json_pp .
  ```

  ## To do
  - [x] update `doc/release-notes`

  ## Feedback
  This is my first PR (hooray!). Please don't hold back on any feedback/comments/nits/... you may have, big or small, whether they are code, process, language, ... related. I welcome private messages too if there's anything you don't want to clutter the PR with. I'm here to learn and am grateful for everyone's input.

ACKs for top commit:
  stickies-v:
    I've had to push a tiny doc update to `REST-interface.md` (`git range-diff 219d728 9aac438 54b39cf`) since this was not merged for v23, but since there are no significant changes beyond theStack and jnewbery's ACKs I think this PR is now ready to be considered for merging? @MarcoFalke
  jnewbery:
    ACK 54b39cfb34
  theStack:
    re-ACK 54b39cfb34

Tree-SHA512: 3b393ffde34f25605ca12c0b1300799a19684b816a1d03aed38b0f5439df47bfe6a589ffbcd7b83fd2def6c9d00a1bae5e45b1d18df4ae998c617c709990f83f
2022-04-06 09:25:56 +02:00
glozow
9bebf35e26 [validation] don't package validate if not policy or missing inputs
Package validation policy only differs from individual policy in its
evaluation of feerate. Minimize DoS surface; don't validate all over
again if we know the result will be the same.
2022-04-05 18:51:37 -04:00
glozow
51edcffa0e [unit test] package feerate and package cpfp 2022-04-05 18:51:37 -04:00
glozow
1b93748c93 [validation] try individual validation before package validation
This avoids "parents pay for children" and "siblings pay for siblings"
behavior, since package feerate is calculated with totals and is
topology-unaware.

It also ensures that package validation never causes us to reject a
transaction that we would have otherwise accepted in single-tx
validation.
2022-04-05 18:51:37 -04:00
glozow
17a8ffd802 [packages/policy] use package feerate in package validation
This allows CPFP within a package prior to submission to mempool.
2022-04-05 18:51:37 -04:00
stickies-v
f959fc0397
Update /<count>/ endpoints to use a '?count=' query parameter instead
In most RESTful APIs, path parameters are used to represent resources, and
query parameters are used to control how these resources are being filtered/sorted/...

The old /<count>/ functionality is kept alive to maintain backwards compatibility,
but new paths with query parameters are introduced and documented as the default
interface so future API methods don't break consistency by using query parameters.
2022-04-05 13:19:37 -04:00
Samer Afach
a4f4f89815
Replace uint256 specific implementations of base_uint::GetHex() and base_uint::SetHex() with proper ones that don't depend on uint256 and replace template methods instantiations of base_uint with template class instantiation 2022-04-05 17:26:31 +02:00
laanwj
9ce1c506a3
Merge bitcoin/bitcoin#24216: validation: improve connect bench logging
304ef73c83 validation: improve connect bench logging (Sjors Provoost)

Pull request description:

  * mention when we're using a cached block rather than actually loading it from disk
  * add ms/blk to load block from disk
  * log writing of Undo data, so it's tracked separate from writing indexes

  Example outputs from `src/bitcoind -debug=bench` during IBD.

  When the pass the block in memory:

  ```
  2022-01-31T14:21:35Z - Connect block: 251.79ms [59.59s (419.65ms/blk)]
  2022-01-31T14:21:35Z   - Using cached block
  2022-01-31T14:21:35Z   - Load block from disk: 0.07ms [9.67s (68.12ms/blk)]
  2022-01-31T14:21:35Z     - Sanity checks: 0.00ms [0.27s (1.87ms/blk)]
  2022-01-31T14:21:35Z     - Fork checks: 0.02ms [0.26s (1.84ms/blk)]
  2022-01-31T14:21:35Z       - Connect 597 transactions: 154.84ms (0.259ms/tx, 0.022ms/txin) [34.89s (243.96ms/blk)]
  2022-01-31T14:21:35Z     - Verify 7043 txins: 169.60ms (0.024ms/txin) [35.67s (249.46ms/blk)]
  2022-01-31T14:21:35Z     - Write undo data: 19.72ms [10.68s (74.68ms/blk)]
  2022-01-31T14:21:35Z     - Index writing: 0.05ms [0.73s (5.12ms/blk)]
  2022-01-31T14:21:35Z   - Connect total: 189.66ms [48.18s (336.93ms/blk)]
  2022-01-31T14:21:35Z   - Flush: 5.23ms [1.19s (8.30ms/blk)]
  2022-01-31T14:21:35Z   - Writing chainstate: 0.04ms [0.58s (4.03ms/blk)]
  2022-01-31T14:21:35Z UpdateTip: new best=0000000000000000000b94a079a58d64f640f66b0cc338b5831b94c8739439a6 height=660135 version=0x20a00000 log2_work=92.494955 tx=593512887 date='2020-12-06T01:43:07Z' progress=0.850804 cache=138.8MiB(1031560txo)
  2022-01-31T14:21:35Z   - Connect postprocess: 0.26ms [0.17s (1.17ms/blk)]
  ```

  When we have to load the block from disk (when blocks are received out of order, they are saved after initial validation steps and then loaded again for the final validation steps and connecting to tip):

  ```
  2022-01-31T14:21:35Z - Connect block: 195.27ms [59.79s (418.08ms/blk)]
  2022-01-31T14:21:38Z   - Load block from disk: 23.35ms [9.70s (67.80ms/blk)]
  2022-01-31T14:21:38Z     - Sanity checks: 1.96ms [0.27s (1.87ms/blk)]
  2022-01-31T14:21:38Z     - Fork checks: 0.05ms [0.26s (1.83ms/blk)]
  2022-01-31T14:21:38Z       - Connect 404 transactions: 116.03ms (0.287ms/tx, 0.017ms/txin) [35.00s (243.07ms/blk)]
  2022-01-31T14:21:38Z     - Verify 7031 txins: 119.58ms (0.017ms/txin) [35.79s (248.56ms/blk)]
  2022-01-31T14:21:38Z     - Write undo data: 23.54ms [10.70s (74.33ms/blk)]
  2022-01-31T14:21:38Z     - Index writing: 1.42ms [0.73s (5.09ms/blk)]
  2022-01-31T14:21:38Z   - Connect total: 146.84ms [48.33s (335.61ms/blk)]
  2022-01-31T14:21:38Z   - Flush: 4.84ms [1.19s (8.28ms/blk)]
  2022-01-31T14:21:38Z   - Writing chainstate: 0.04ms [0.58s (4.00ms/blk)]
  2022-01-31T14:21:38Z UpdateTip: new best=00000000000000000004c2cad14fec645807ce236f8e1cc43fe106ee4f27692e height=660136 version=0x2000e000 log2_work=92.494972 tx=593513291 date='2020-12-06T01:46:08Z' progress=0.850804 cache=139.4MiB(1036010txo)
  2022-01-31T14:21:38Z   - Connect postprocess: 0.16ms [0.17s (1.16ms/blk)]
  ```

ACKs for top commit:
  laanwj:
    Code review ACK 304ef73c83
  theStack:
    Concept and code-review ACK 304ef73c83
  jonatack:
    re-ACK 304ef73c83 per `git range-diff 4faf7a1d8 cfb027d 304ef7` rebase only since my last review

Tree-SHA512: 2009e1db3c30eacd15c11629903334eda4f016da614afe2a1275d00c2a80d42e37edb10e79ceb58b3bd8855e7c6915e67d455aec15f73a25f48f48f64aa51a29
2022-04-05 16:18:42 +02:00
laanwj
f421de5be6
Merge bitcoin/bitcoin#24236: Remove utxo db upgrade code
fa9112aac0 Remove utxo db upgrade code (MarcoFalke)

Pull request description:

  It is not possible to upgrade Bitcoin Core pre-segwit (pre-0.13.1) to a recent version without a full IBD from scratch after  commit 19a56d1519 (released in version 22.0).

  Any Bitcoin Core version with the new database format after commit 1088b02f0c (released in version 0.15), can upgrade to any version that is supported as of today.

  This leaves the versions 0.13.1-0.14.x. Even though those versions are unsupported, some users with an existing datadir may want to upgrade to a recent version. However, it seems reasonable to simply ask them to `-reindex` to run a full IBD from scratch. This allows us to remove the utxo db upgrade code.

ACKs for top commit:
  Sjors:
    re-ACK fa9112aac0
  laanwj:
    Code review ACK fa9112aac0

Tree-SHA512: 4243bb35df9ac4892f9fad30fe486d338745952bcff4160bcb0937c772d57b13b800647da14695e21e3655e85ee0d95fa3dc7789ee309d59ad84f422297fecb8
2022-04-05 15:38:14 +02:00
Hennadii Stepanov
07ddecb84e
refactor: Use [[maybe_unused]] attribute 2022-04-05 13:53:09 +02:00
Hennadii Stepanov
55e0fc8df9
refactor: Drop unneeded workarounds aimed to silence unused warning
All of the touched symbols are indeed used regardless of any macros.
2022-04-05 13:53:09 +02:00
MarcoFalke
fabdf9f870
Remove gui-only syscalls
* Revert "util: Add inotify_rm_watch to syscall sandbox (AllowFileSystem)"
  This reverts commit f05a4cdf5a.

* Revert "util: add linkat to syscall sandbox (AllowFileSystem)"
  This reverts commit 9809db3577.
2022-04-05 13:30:06 +02:00
MarcoFalke
fa0c2aa826
init: Disable syscall sandbox in the bitcoin-qt process 2022-04-05 13:29:42 +02:00
laanwj
d492dc1cda
Merge bitcoin/bitcoin#24147: Miniscript integration
2da94a4c6f fuzz: add a fuzz target for Miniscript decoding from Script (Antoine Poinsot)
f8369996e7 Miniscript: ops limit and stack size computation (Pieter Wuille)
2e55e88f86 Miniscript: conversion from script (Pieter Wuille)
1ddaa66eae Miniscript: type system, script creation, text notation, tests (Pieter Wuille)
4fe29368c0 script: expose getter for CScriptNum, add a BuildScript helper (Antoine Poinsot)
f4e289f384 script: move CheckMinimalPush from interpreter to script.h (Antoine Poinsot)
31ec6ae92a script: make IsPushdataOp non-static (Antoine Poinsot)

Pull request description:

  Miniscript is a language for writing (a subset of) Bitcoin Scripts in a structured way.

  Miniscript permits:
  - To safely extend the Output Descriptor language to many more scripting features thanks to the typing system (composition).
  - Statical analysis of spending conditions, maximum spending cost of each branch, security properties, third-party malleability.
  - General satisfaction of any correctly typed ("valid" [0]) Miniscript. The satisfaction itself is also analyzable.
  - To extend the possibilities of external signers, because of all of the above and since it carries enough metadata.

  Miniscript guarantees:
  - That for any statically-analyzed as "safe" [0] Script, a witness can be constructed in the bounds of the consensus and standardness rules (standardness complete).
  - That unless the conditions of the Miniscript are met, no witness can be created for the Script (consensus sound).
  - Third-party malleability protection for the satisfaction of a sane Miniscript, which is too complex to summarize here.

  For more details around Miniscript (including the specifications), please refer to the [website](https://bitcoin.sipa.be/miniscript/).

  Miniscript was designed by Pieter Wuille, Andrew Poelstra and Sanket Kanjalkar.
  This PR is an updated and rebased version of #16800. See [the commit history of the Miniscript repository](https://github.com/sipa/miniscript/commits/master) for details about the changes made since September 2019 (TL;DR: bugfixes, introduction of timelock conflicts in the type system, `pk()` and `pkh()` aliases, `thresh_m` renamed to `multi`, all recursive algorithms were made non-recursive).

  This PR is also the first in a series of 3:
  - The first one (here) integrates the backbone of Miniscript.
  - The second one (#24148) introduces support for Miniscript in Output Descriptors, allowing for watch-only support of Miniscript Descriptors in the wallet.
  - The third one (#24149) implements signing for these Miniscript Descriptors, using Miniscript's satisfaction algorithm.

  Note to reviewers:
  - Miniscript is currently defined only for P2WSH. No Taproot yet.
  - Miniscript is different from the policy language (a high-level logical representation of a spending policy). A policy->Miniscript compiler is not included here.
  - The fuzz target included here is more interestingly extended in the 3rd PR to check a script's satisfaction against `VerifyScript`. I think it could be further improved by having custom mutators as we now have for multisig (see https://github.com/bitcoin/bitcoin/issues/23105). A minified corpus of Miniscript Scripts is available at https://github.com/bitcoin-core/qa-assets/pull/85.

  [0] We call "valid" any correctly-typed Miniscript. And "safe" any sane Miniscript, ie one whose satisfaction isn't malleable, which requires a key for any spending path, etc..

ACKs for top commit:
  jb55:
    ACK 2da94a4c6f
  laanwj:
    Light code review ACK 2da94a4c6f (mostly reviewed the changes to the existing code and build system)

Tree-SHA512: d3ef558436cfcc699a50ad13caf1e776f7d0addddb433ee28ef38f66ea5c3e581382d8c748ccac9b51768e4b95712ed7a6112b0e3281a6551e0f325331de9167
2022-04-05 13:22:09 +02:00
MarcoFalke
cccc4e879a
Remove nHeightEnd and nHeight in generateBlocks helper 2022-04-05 13:05:14 +02:00
Jon Atack
39a34b6877
Put lock logging behind DEBUG_LOCKCONTENTION preprocessor directive 2022-04-05 12:49:48 +02:00
fanquake
0baf6aded5
Merge bitcoin/bitcoin#24391: build: stop overriding user autoconf flags
7b00595d33 build: stop overriding user CXXFLAGS (fanquake)
3e2ef23c3e build: stop overriding user LDFLAGS (fanquake)
35c3fd43c3 build: stop overriding user CPPFLAGS (fanquake)
bc7cc57607 doc: explain why we clear CXXFLAGS with enable-debug (fanquake)

Pull request description:

  Historically our build system has hijacked `CXXFLAGS` and friends, and this has always been a source of complaints from users and developers. With this PR, we move away from using `CXXFLAGS`, `CPPFLAGS` and `LDFLAGS`, and instead use `CORE_*FLAGS` variables for our flags / options, leaving autoconfs `FLAG` vars to the user.

  Note that there are currently two cases where we will at least clear `CXXFLAGS` (if not alreaddy overridden by the user), when doing debugging or when coverage is enabled, to avoid Autoconfs `-g -O2` CXXFLAG default.

ACKs for top commit:
  hebasto:
    ACK 7b00595d33

Tree-SHA512: bda936a7aa8f98a1bf1552306845cb4bbab54e19a7a0b9ce3210e10fef70db146e9fe42a0cc8c50b2908506771b5b96f39c334e41323b70ec878e4010373096c
2022-04-05 09:33:58 +01:00
Anthony Towns
c4c5b9ca6e consensus/params: set default values for BIP9Deployment
While chainparams should explicilty set values for each possible
entry in vDeployments, in the past that has been missed resulting
in potential undefined behaviour due to accessing unitinitialized
data. Reduce the severity of future bugs of that nature by providing
benign default values. Adds a unit test to alert if the default value
is not overwritten for the real chains (NEVER_ACTIVE/NEVER_ACTIVE rather
than NEVER_ACTIVE/NO_TIMEOUT).
2022-04-05 14:35:15 +10:00
MarcoFalke
d0f7493b6c
Merge bitcoin/bitcoin#24849: lint: Convert lint-logs.sh to Python
e9d277131c lint: Convert lint-logs.sh to Python (Dimitri)

Pull request description:

  A  port of `/test/lint/lint-logs.sh` to a Python-script as part of the request of #24783 . Checked for output-consistency.

  Removed all non-explicit exceptions (i.e. `...`, `LogPrint()`, and `LogPrintf()`) because they weren't needed anymore, except for one single case in a comment in `/src/random.cpp` which I removed because it was quite useless anyway (the comment, not the file).

ACKs for top commit:
  laanwj:
    Code review ACK e9d277131c

Tree-SHA512: ae4d2a341a13ccd9f40e8fcde35e1f392d9995131be005b809cbf8f283f28a7c34ea3cf9c13d3564d13809ae3f5889260fa5d6302370dc79c3226389974d947c
2022-04-04 18:23:16 +02:00
Dimitri
e9d277131c lint: Convert lint-logs.sh to Python 2022-04-14 02:43:31 +02:00
Hennadii Stepanov
47bac475f0
Merge bitcoin-core/gui#569: test: add regression test for #567
4d4dca43fc test: add regression test for bitcoin-core/gui/issues/567 (Vasil Dimov)
3b82608dd1 options: add a comment for -listenonion and dedup a long expression (Vasil Dimov)

Pull request description:

  Add a test that would fail, should https://github.com/bitcoin-core/gui/issues/567 resurface.

  Also, add a comment and dedup a long expression.

ACKs for top commit:
  jarolrod:
    reACK 4d4dca43fc
  jonatack:
    ACK 4d4dca43fc
  hebasto:
    ACK 4d4dca43fc, tested with reverting changes from bitcoin-core/gui#568, and getting an expected test failure.
  shaavan:
    ACK 4d4dca43fc

Tree-SHA512: 59f069bdaa84586bb599e9372f89e4e66a3cafcbf58677fdf913d685c17dfa9c3d5b118829d81021a9a33b4fd8e46d4c7eb68c1dd902cf1c44a41b8e66e2967b
2022-04-04 16:01:24 +02:00
MarcoFalke
4faf7a1d86
Merge bitcoin/bitcoin#24729: util/check: avoid unused parameter warnings
0add4dbadb util/check: avoid unused parameter warnings (Anthony Towns)

Pull request description:

  Add `[[maybe_unused]]` annotations to avoid warnings from gcc 9.4 and earlier which don't analyse `if constexpr` properly.

ACKs for top commit:
  MarcoFalke:
    review ACK 0add4dbadb
  jonatack:
    ACK 0add4dbadb review and debug build on clang 15
  shaavan:
    ACK 0add4dbadb

Tree-SHA512: 3ba490d74d91692c1d22b927da43a130c92cd6a20ed168573e4fbe1f4675fef7e05ebf0b11f2bbd15da3c606fea1f8e6403cfca347009b8b6acc1e77bbee9963
2022-04-04 13:44:10 +02:00
laanwj
6348bc61b5
Merge bitcoin/bitcoin#24746: refactor: remove macOS MAP_ANONYMOUS work around
112a7ab9a8 refactor: remove macOS MAP_ANONYMOUS work around (fanquake)

Pull request description:

  This was added to support compilation on macOS 10.10, our minimum
  required macOS is now 10.15. macOS has also supported it since 10.11.

  See https://github.com/bitcoin/bitcoin/pull/9063.

  macOS 12.3 manpage for mmap:
  ```bash
       MAP_ANONYMOUS     Synonym for MAP_ANON.

       MAP_ANON          Map anonymous memory not associated with any specific file.
  ```

ACKs for top commit:
  laanwj:
    Code review ACK 112a7ab9a8
  jarolrod:
    ACK 112a7ab9a8

Tree-SHA512: 920744c755d05d813ab312ff27e42eacb27b1297972800e6fb64bbaad1ea14258751a7dd80c07bfa554a172f36960b26a07505f67e82885253c8bf551073c38e
2022-04-04 12:55:22 +02:00
fanquake
37a16ffd70
refactor: fix clang-tidy named args usage 2022-04-04 09:01:19 +01:00
fanquake
7b00595d33
build: stop overriding user CXXFLAGS
Let users have the final say in regards to CXXFLAGS.
2022-04-03 19:36:17 +01:00
fanquake
3e2ef23c3e
build: stop overriding user LDFLAGS
Let the user have the final say in regards to LDFLAGS.
2022-04-03 19:36:17 +01:00
fanquake
35c3fd43c3
build: stop overriding user CPPFLAGS
Let the user have the final say in regards to CPPFLAGS
2022-04-03 19:36:11 +01:00
fanquake
112a7ab9a8
refactor: remove macOS MAP_ANONYMOUS work around
This was added to support compilation on macOS 10.10, our minimum
required macOS is now 10.15. macOS has also supported it since 10.11.

See https://github.com/bitcoin/bitcoin/pull/9063.
2022-04-03 13:04:29 +01:00
Hennadii Stepanov
31b1c67cf6
Merge bitcoin-core/gui#557: Revert "qt: Do not use QObject::tr plural syntax for numbers with a unit symbol"
0c64401324 Revert "qt: Do not use QObject::tr plural syntax for numbers with a unit symbol" (Luke Dashjr)

Pull request description:

  Apparently this got forgotten. Maybe too late for 23.x (it's a bugfix, but changes translation strings).

  This reverts commit 3adde72bc9 (#296)

  per [GChuf](https://github.com/bitcoin-core/gui/pull/296#issuecomment-962516055)

  >I can confirm for slovenian and other slavic languages that we do have 3 or 4 different ways of saying "%n GB needed%, depending on the actual number of gigabytes. Similar to english "is/are". There's no way to cover all cases ... this is exactly why transifex allows you to have more than 2 options.

ACKs for top commit:
  hebasto:
    ACK 0c64401324, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: c01bae44a32b3ec324f2f9b8e4923bbb2e83bbd1460b745c5c911b98a9b2806fcbf815cfb19a1f1a7038c5c14312e102e7df8744c9002ef784b36d158e08eb14
2022-04-03 10:10:54 +02:00
Fabian Jahr
e40779a4fe
refactor: Remove outdated libevent logging code
The removed code was intended to catch issues with event_enable_debug_logging which was not available prior to libevent 2.1.1. This is not necessary since the minimum libevent version was bumped to 2.1.8.
2022-04-02 19:26:46 +02:00
fanquake
e8fc236da7
refactor: add missing std:: includes to threadnames.cpp 2022-04-01 14:49:13 +01:00
fanquake
87f3c04cc5
doc: remove incorrect mention of PR_GET_NAME
By removing the whole comment. These #include // For comments are near impossible
to maintain, pollute diffs, and generally don't add a lot of value.
2022-04-01 14:48:47 +01:00
MarcoFalke
fa38b1c8bd
Remove buggy and confusing IncrementExtraNonce 2022-04-01 11:00:42 +02:00
Vasil Dimov
4d4dca43fc
test: add regression test for bitcoin-core/gui/issues/567 2022-04-01 10:32:07 +02:00
MarcoFalke
7ab9fc32d6
Merge bitcoin/bitcoin#24724: test: fix incorrect named args in txpackage tests
bf77fea3c1 test: fix incorrect named args in txpackage tests (fanquake)

Pull request description:

  Final non-scripted-diff commit split from #24661.

  Could be tested with: `./autogen.sh && ./configure CC=clang-12 CXX=clang++-12 && make clean && bear make -j9 && ( cd ./src/ && run-clang-tidy-12 -j9 )`.

  Motivation:
  > Incorrect named args are source of bugs, like https://github.com/bitcoin/bitcoin/pull/22979.

  > To allow them being checked by clang-tidy, use a format it can understand.

ACKs for top commit:
  ajtowns:
    ACK bf77fea3c1

Tree-SHA512: a13bfb5fc70424b13fbeec7f164d7a0d3b72b27ebec11dfd4115b7782a0037f26e9349e06eef8a6b17b8f529e0c7f43ae37a9c252bde65706dd164704d207d5f
2022-04-01 08:44:14 +02:00
Anthony Towns
0add4dbadb util/check: avoid unused parameter warnings 2022-04-01 14:10:46 +10:00
Andrew Chow
1021e4cc68
Merge bitcoin/bitcoin#24602: fuzz: add target for coinselection algorithms
21520b9551 fuzz: add target for coinselection (Martin Zumsande)

Pull request description:

  This adds a fuzz target for the coinselection algorithms by creating random `OutputGroup`s and running all three coin selection algorithms for them.
  It does not fuzz higher-level wallet logic for selecting eligible coins (as in `SelectCoins()`), thought it probably would make sense to have a fuzz target for that too.

ACKs for top commit:
  achow101:
    ACK 21520b9551
  vasild:
    ACK 21520b9551

Tree-SHA512: c763003cf5ff5317f929d3d0b2f06fa739ae41dd642042d9a5c5c96e6cb9b349a6c7aeabc77bc2b846d12c8bcb60e07ee20a9f38539429c65723ab76aeee6b2e
2022-03-31 13:09:17 -04:00
Andrew Chow
b7d78e6244
Merge bitcoin/bitcoin#24711: wallet: Postpone wallet loading notification for encrypted wallets
0c12f0116c wallet: Postpone NotifyWalletLoaded() for encrypted wallets (Hennadii Stepanov)
aeee419c6a wallet, refactor: Add wallet::NotifyWalletLoaded() function (Hennadii Stepanov)

Pull request description:

  Fixes bitcoin-core/gui#571.

  `CWallet::Create()` notifies about wallet loading too early, that results the notification goes before `DescriptorScriptPubKeyMan`s were created and added to an encrypted wallet.

  And `interfaces::Wallet::taprootEnabled()` in ecf692b466/src/qt/receivecoinsdialog.cpp (L100-L102) erroneously returns `false` for just created encrypted descriptor wallets.

ACKs for top commit:
  Sjors:
    utACK 0c12f0116c
  achow101:
    ACK 0c12f0116c

Tree-SHA512: 2694bacd12748cd5f6c95d9d3bf8bcf4502ee67fecd8d057f33236b72069c61401b08f49deb013fc71c3f1e51ae16bdfd827ddcbc2a083d7044589be7a78982e
2022-03-31 12:43:14 -04:00
fanquake
bf77fea3c1
test: fix incorrect named args in txpackage tests 2022-03-31 16:34:33 +01:00
Vasil Dimov
3b82608dd1
options: add a comment for -listenonion and dedup a long expression
A followup to https://github.com/bitcoin-core/gui/pull/568

Co-authored-by: Jon Atack <jon@atack.com>
2022-03-31 15:29:38 +02:00
MarcoFalke
fa58427aae
doc: Use DecodeTxDoc helper
Can be reviewed with
--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2022-03-31 11:46:20 +02:00
MarcoFalke
1a54c060b3
Merge bitcoin/bitcoin#24716: rpc: Fix documentation assertion for getrawtransaction
71038a151e rpc: Fix documentation assertion for `getrawtransaction` (laanwj)

Pull request description:

  When `getrawtransaction` is successfully used on a coinbase transaction, there is an assertion error. This is very unlikely but happens in the `interface_usdt_utxocache.py` test in #24358.

  This does the following:

  - Add missing "coinbase" documentation.

  - Synchronize documentation between `getrawtransaction` and  `decoderawtransaction`, the two users of `TxToUniv` that have detailed   documentation. `decodepsbt` and `getblock` also uses it but fortunately elides this block.

  - Change "vout[].amount" to `STR_AMOUNT` for consistency.

  - Add maintainer comment to keep the two places synchronized. It might  be possible to get smarter with deduplication, but there are some  extra fields that prevent the obvious way.

ACKs for top commit:
  jonatack:
    ACK 71038a151e

Tree-SHA512: 962236130455d805190ff9a5c971e4e25c17db35614a90ce340264ec953b0ad7fb814eb33ae430b5073955a8a350f72bdd67ba93e35f9c70e5175b836a767a35
2022-03-31 11:19:31 +02:00
MarcoFalke
a2e1590f67
Merge bitcoin/bitcoin#24673: refactor: followup of remove -deprecatedrpc=addresses flag
9563a645c2 refactor: add stdd:: includes to core_write (fanquake)
8b9efebb0a refactor: use named args when ScriptToUniv or TxToUniv are invoked (Michael Dietz)
22f25a6116 refactor: prefer snake case, TxToUniv arg hashBlock renamed block_hash (Michael Dietz)
828a094ecf refactor: merge ScriptPubKeyToUniv & ScriptToUniv into one function (Michael Dietz)

Pull request description:

  I've cherry-picked some of the commits out of #22924, and made minor changes (like fixing named args).

ACKs for top commit:
  MarcoFalke:
    re-ACK 9563a645c2 🕓

Tree-SHA512: 4f0e5b45c14cbf68b9e389bbe1211c125d95cbd3da5205b1cff6a4c44f15b15039ba2a5b25cd7e2580d9169404f1b7ff620d8a7e01f6112e3cb153ecfaef8916
2022-03-31 08:31:16 +02:00
MarcoFalke
d2b4355c58
Merge bitcoin/bitcoin#24715: build, test: Fix test logfile name
8b517fae7e build, refactor: Replace tabs with spaces (Hennadii Stepanov)
dc0774cbdf build, test: Fix test logfile name (Hennadii Stepanov)

Pull request description:

  Recently merged bitcoin/bitcoin#19385 was flawed as it tries to `cat` a non-existed logfile:
  - https://github.com/bitcoin/bitcoin/pull/19385#discussion_r835300701
  - https://github.com/bitcoin/bitcoin/pull/19385#issuecomment-1082748549

  Closes bitcoin/bitcoin#17224.

ACKs for top commit:
  luke-jr:
    utACK 8b517fae7e

Tree-SHA512: 6c6dab6d7d38b5e949f1159ddff8e431f26d7254157f8308d63383c0642154271107e384c77722b7cf77f0be204bd21d69f3a9e93a8d19cf48954ac673df6c7a
2022-03-31 08:27:15 +02:00
MarcoFalke
87dc1dc55f
Merge bitcoin/bitcoin#24714: util/check: Don't use a lambda for Assert/Assume
2ef47ba6c5 util/check: stop using lambda for Assert/Assume (Anthony Towns)
7c9fe25c16 wallet: move Assert() check into constructor (Anthony Towns)

Pull request description:

  Using a lambda creates a couple of odd namespacing issues, in particular making clang's thread safety analysis less helpful, and confusing gcc when calling member functions. Fix this by not using a lambda.

  Fixes #21596
  Fixes #24654

ACKs for top commit:
  MarcoFalke:
    ACK 2ef47ba6c5 🚢
  jonatack:
    Tested re-ACK 2ef47ba6c5

Tree-SHA512: 4bdbf3215f3d14472df0552362c5eebe8b7eea2d0928a8a41109edd4e0c5f95de6f8220eb2fee8506874e352c003907faf5ef344174795939306a618157b1bae
2022-03-31 08:18:30 +02:00
Hennadii Stepanov
0c12f0116c
wallet: Postpone NotifyWalletLoaded() for encrypted wallets
Too early NotifyWalletLoaded() call in CWallet::Create() results the
notification goes before DescriptorScriptPubKeyMans were created and
added to an encrypted wallet.

Co-authored-by: Andrew Chow <achow101-github@achow101.com>
2022-03-30 21:28:53 +02:00
fanquake
9563a645c2
refactor: add stdd:: includes to core_write 2022-03-30 20:11:15 +01:00
Michael Dietz
8b9efebb0a
refactor: use named args when ScriptToUniv or TxToUniv are invoked 2022-03-30 20:00:27 +01:00
Michael Dietz
22f25a6116
refactor: prefer snake case, TxToUniv arg hashBlock renamed block_hash 2022-03-30 20:00:27 +01:00
Michael Dietz
828a094ecf
refactor: merge ScriptPubKeyToUniv & ScriptToUniv into one function 2022-03-30 20:00:23 +01:00
Martin Zumsande
21520b9551 fuzz: add target for coinselection
This creates random OutputGroups and runs the
existing coinselection algorithms for them.
2022-03-30 17:17:37 +02:00
laanwj
71038a151e rpc: Fix documentation assertion for getrawtransaction
When `getrawtransaction` is successfully used on a coinbase transaction,
there is an assertion error. This is very unlikely but happens in the
test in #24358.

This does the following:

- Add missing "coinbase" documentation.

- Synchronize documentation between `getrawtransaction` and
  `decoderawtransaction`, the two users of `TxToUniv` that have detailed
  documentation. `decodepsbt` also uses it but fortunately elides this block.

- Change "vout[].amount" to `STR_AMOUNT` for consistency.

- Add maintainer comment to keep the two places synchronized. It might
  be possible to get smarter with deduplication, but there are some
  extra fields that prevent the obvious way.
2022-03-30 17:01:07 +02:00
Anthony Towns
2ef47ba6c5 util/check: stop using lambda for Assert/Assume 2022-03-30 23:09:13 +10:00
MarcoFalke
f4e5d704f2
Merge bitcoin/bitcoin#24118: Add 'sendall' RPC née sweep
bb84b7145b add tests for no recipient and using send_max while inputs are specified (ishaanam)
49090ec402 Add sendall RPC née sweep (Murch)
902793c777 Extract FinishTransaction from send() (Murch)
6d2208a3f6 Extract interpretation of fee estimation arguments (Murch)
a31d75e5fb Elaborate error messages for outdated options (Murch)
35ed094e4b Extract prevention of outdated option names (Murch)

Pull request description:

  Add sendall RPC née sweep

  _Motivation_
  Currently, the wallet uses a fSubtractFeeAmount (SFFO) flag on the
  recipients objects for all forms of sending calls. According to the
  commit discussion, this flag was chiefly introduced to permit sweeping
  without manually calculating the fees of transactions. However, the flag
  leads to unintuitive behavior and makes it more complicated to test
  many wallet RPCs exhaustively. We proposed to introduce a dedicated
  `sendall` RPC with the intention to cover this functionality.

  Since the proposal, it was discovered in further discussion that our
  proposed `sendall` rpc and SFFO have subtly different scopes of
  operation.
  • sendall:
    Use _given UTXOs_ to pay a destination the remainder after fees.
  • SFFO:
    Use a _given budget_ to pay an address the remainder after fees.

  While `sendall` will simplify cases of spending a given set of
  UTXOs such as paying the value from one or more specific UTXOs, emptying
  a wallet, or burning dust, we realized that there are some cases in
  which SFFO is used to pay other parties from a limited budget,
  which can often lead to the creation of change outputs. This cannot be
  easily replicated using `sendall` as it would require manual
  computation of the appropriate change amount.

  As such, sendall cannot replace all uses of SFFO, but it still has a
  different use case and will aid in simplifying some wallet calls and
  numerous wallet tests.

  _Sendall call details_
  The proposed sendall call builds a transaction from a specific
  subset of the wallet's UTXO pool (by default all of them) and assigns
  the funds to one or more receivers. Receivers can either be specified
  with a given amount or receive an equal share of the remaining
  unassigned funds. At least one recipient must be provided without
  assigned amount to collect the remainder. The `sendall` call will
  never create change. The call has a `send_max` option that changes the
  default behavior of spending all UTXOs ("no UTXO left behind"), to
  maximizing the output amount of the transaction by skipping uneconomic
  UTXOs. The `send_max` option is incompatible with providing a specific
  set of inputs.

  ---
  Edit: Replaced OP with latest commit message to reflect my updated motivation of the proposal.

ACKs for top commit:
  achow101:
    re-ACK bb84b7145b

Tree-SHA512: 20aaf75d268cb4b144f5d6437d33ec7b5f989256b3daeeb768ae1e7f39dc6b962af8223c5cb42ecc72dc38cecd921c53c077bc0ec300b994e902412213dd2cc3
2022-03-30 15:02:49 +02:00
fanquake
0598f36852
refactor: account for requiring libevent 2.1.8+ 2022-03-30 14:00:12 +02:00
Hennadii Stepanov
8b517fae7e
build, refactor: Replace tabs with spaces 2022-03-30 12:16:05 +02:00
Hennadii Stepanov
dc0774cbdf
build, test: Fix test logfile name
Co-authored-by: Luke Dashjr <luke-jr+git@utopios.org>
2022-03-30 12:15:53 +02:00
fanquake
f9aedbc300
Merge bitcoin/bitcoin#24690: util: Add inotify_rm_watch to syscall sandbox (AllowFileSystem)
f05a4cdf5a util: Add inotify_rm_watch to syscall sandbox (AllowFileSystem) (Hennadii Stepanov)

Pull request description:

  This PR fixes the current master (3297f5c11c) when running `bitcoin-qt` on Ubuntu 22.04 and quitting:
  ```
  $ ./src/qt/bitcoin-qt -signet -sandbox=log-and-abort
  Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
  ERROR: The syscall "inotify_rm_watch" (syscall number 255) is not allowed by the syscall sandbox in thread "main". Please report.
  terminate called without an active exception
  Aborted (core dumped)
  ```

  Also see https://github.com/bitcoin/bitcoin/pull/24659#discussion_r835747166

ACKs for top commit:
  fanquake:
    ACK f05a4cdf5a - checked that qt is using this in it's filesystem watcher code.

Tree-SHA512: 9c7920a25422cd3a040bc1cbc487c12c3dc2b91358c3757f1030d6a1ff12c18c688a8e5b7466f683da88a5e4f5f15d442975660022d706e47021253c24c58f4a
2022-03-30 10:19:25 +01:00
Anthony Towns
7c9fe25c16 wallet: move Assert() check into constructor
This puts it in a function body, so that __func__ is available
for reporting any assertion failure.
2022-03-30 17:07:28 +10:00
MarcoFalke
f4fba57829
Merge bitcoin/bitcoin#24704: compat: remove strnlen back-compat code
d4ba2b2cbc compat: remove strnlen back-compat code (fanquake)

Pull request description:

  This was needed for mingw (not mingw-w64), and some older versions of
  macOS, which we no-longer support.

ACKs for top commit:
  hebasto:
    ACK d4ba2b2cbc

Tree-SHA512: d1beb9df58464feea3076091361d7d46e4a8901e347644a5fa6f24e052ca24ee0c7c0dd3f2a3d682b0204bf50430fa89eac62121691ea08af6dcf6b907bdec87
2022-03-30 08:19:09 +02:00
fanquake
f089a0802c
Merge bitcoin/bitcoin#24692: refactoring: [Net Processing] Follow-ups to #21160
a40978dcbd [fuzz] Assert that Peer.m_tx_relay.m_relay_txs has been set correctly (John Newbery)
0bca5f2b46 [net processing] PushNodeVersion() takes a const Peer& (John Newbery)
21154ff927 net_processing: move CNode data access out of lock (John Newbery)

Pull request description:

  #21160 ([net/net processing]: Move tx inventory into net_processing) had some unaddressed review comments when it was merged. This branch addresses those comments.

ACKs for top commit:
  MarcoFalke:
    review ACK a40978dcbd
  dergoegge:
    ACK a40978dcbd
  ajtowns:
    ACK a40978dcbd

Tree-SHA512: 46624e275f918c5f32d0adab0766e9b3ef8ebdbc74a3c8886d8a2e2ff1079029dcc371b40ef0d787609e9c05219b7456f3e2dfe4fb0cb7bf23ef966769aef1a1
2022-03-30 07:13:52 +01:00
Murch
49090ec402
Add sendall RPC née sweep
_Motivation_
Currently, the wallet uses a fSubtractFeeAmount (SFFO) flag on the
recipients objects for all forms of sending calls. According to the
commit discussion, this flag was chiefly introduced to permit sweeping
without manually calculating the fees of transactions. However, the flag
leads to unintuitive behavior and makes it more complicated to test
many wallet RPCs exhaustively. We proposed to introduce a dedicated
`sendall` RPC with the intention to cover this functionality.

Since the proposal, it was discovered in further discussion that our
proposed `sendall` rpc and SFFO have subtly different scopes of
operation.
• sendall:
  Use _specific UTXOs_ to pay a destination the remainder after fees.
• SFFO:
  Use a _specific budget_ to pay an address the remainder after fees.

While `sendall` will simplify cases of spending from specific UTXOs,
emptying a wallet, or burning dust, we realized that there are some
cases in which SFFO is used to pay other parties from a limited budget,
which can often lead to the creation of change outputs. This cannot be
easily replicated using `sendall` as it would require manual computation
of the appropriate change amount.

As such, sendall cannot replace all uses of SFFO, but it still has a
different use case and will aid in simplifying some wallet calls and
numerous wallet tests.

_Sendall call details_
The proposed sendall call builds a transaction from a specific subset of
the wallet's UTXO pool (by default all of them) and assigns the funds to
one or more receivers. Receivers can either be specified with a specific
amount or receive an equal share of the remaining unassigned funds. At
least one recipient must be provided without assigned amount to collect
the remainder. The `sendall` call will never create change. The call has
a `send_max` option that changes the default behavior of spending all
UTXOs ("no UTXO left behind"), to maximizing the output amount of the
transaction by skipping uneconomic UTXOs. The `send_max` option is
incompatible with providing a specific set of inputs.
2022-03-29 16:37:47 -04:00
Hennadii Stepanov
aeee419c6a
wallet, refactor: Add wallet::NotifyWalletLoaded() function
This change is a prerequisite for the following bugfix.
2022-03-29 22:33:58 +02:00
John Newbery
a40978dcbd [fuzz] Assert that Peer.m_tx_relay.m_relay_txs has been set correctly 2022-03-29 15:54:22 +01:00
John Newbery
0bca5f2b46 [net processing] PushNodeVersion() takes a const Peer&
The peer object is not mutated by PushNodeVersion, so pass a const reference
2022-03-29 15:54:16 +01:00
laanwj
9e32adbb5c
Merge bitcoin/bitcoin#24523: build: Fix Boost.Process test for Boost 1.78
532c64a726 build: Fix Boost.Process test for Boost 1.78 (Hennadii Stepanov)

Pull request description:

  Rebased #24415 with Luke's suggestion.

  Fixes #24413.

ACKs for top commit:
  hebasto:
    ACK 532c64a726, tested on Mac mini (M1, 2020) + macOS Monterey 12.3 (21E230).

Tree-SHA512: 74f779695f6bbc45a2b7341a1402f747cc0d433d74825c7196cb9f156db0c0299895365f01665bd0bff12a8ebb5ea33a29b9a52f5eac0007ec35d1dca6544705
2022-03-29 13:36:45 +02:00
fanquake
d4ba2b2cbc
compat: remove strnlen back-compat code
This was needed for mingw (not mingw-w64), and some older versions of
macOS, which we no-longer support.
2022-03-29 10:15:33 +01:00
MarcoFalke
9d00406dc9
Merge bitcoin/bitcoin#24677: refactor: fix wallet and related named args
21db4eb3ff test: fix incorrect named args in wallet tests (fanquake)
8b0e776718 test: fix incorrect named args in coin_selection tests (fanquake)
6fc00f7331 bench: fix incorrect named args in coin_selection bench (fanquake)

Pull request description:

  Should be one of the last changes split from #24661.

  Motivation:
  > Incorrect named args are source of bugs, like https://github.com/bitcoin/bitcoin/pull/22979.

  > To allow them being checked by clang-tidy, use a format it can understand.

ACKs for top commit:
  MarcoFalke:
    Concept ACK 21db4eb3ff

Tree-SHA512: c29743a70f6118cf73dc37b56b30f45da55b7d7b3b8ed36859ad59f602c3e6692eb755e05d9a4dd17f05085bcd6cb5b8c4007090a76e4fbfb053f925322cf985
2022-03-28 14:56:46 +02:00
fanquake
a13946b822
Merge bitcoin/bitcoin#23083: rpc: Fail to return undocumented or misdocumented JSON
fc892c3a80 rpc: Fail to return undocumented or misdocumented JSON (MarcoFalke)
f4bc4a705a rpc: Add m_skip_type_check to RPCResult (MarcoFalke)

Pull request description:

  This avoids documentation shortcomings such as the ones fixed in commit e7b6272b30, 138d55e6a0, 577bd51a4b, f8c84e047c, 0ee9a00f90, 13f41855c5, or faecb2ee0a

ACKs for top commit:
  fanquake:
    ACK fc892c3a80 - tested that this catches issue, i.e #24691:

Tree-SHA512: 9d0d7e6291bfc6f67541a4ff746d374ad8751fefcff6d103d8621c0298b190ab1d209ce96cfc3a0d4a6a5460a9f9bb790eb96027b16e5ff91f2512e40c92ca84
2022-03-28 12:16:42 +01:00
MarcoFalke
faac877ffd
doc: Fix getpeerinfo doc 2022-03-28 10:00:45 +02:00
John Newbery
21154ff927 net_processing: move CNode data access out of lock
CNode::m_relays_tx and CNode::m_bloom_filter_loaded access don't require
the Peer::TxRelay::m_bloom_filter_mutex lock, so move them out of the
lock scope.

See https://github.com/bitcoin/bitcoin/pull/21160#discussion_r736785417
and https://github.com/bitcoin/bitcoin/pull/21160#discussion_r736785662.
2022-03-28 08:23:32 +01:00
Hennadii Stepanov
f05a4cdf5a
util: Add inotify_rm_watch to syscall sandbox (AllowFileSystem) 2022-03-28 09:14:29 +02:00
MarcoFalke
dc0ba8ce9f
Merge bitcoin/bitcoin#24659: util: add linkat to syscall sandbox (AllowFileSystem)
9809db3577 util: add linkat to syscall sandbox (AllowFileSystem) (fanquake)

Pull request description:

  Should fix #24536.

ACKs for top commit:
  MarcoFalke:
    cr ACK 9809db3577
  Rspigler:
    Tested ACK (commit 9809db3577) - this fixes https://github.com/bitcoin/bitcoin/issues/24536

Tree-SHA512: 2642f7dfa806e166fb32639a29b509b2edc8b919516c1f12430fc96f9887952395e157d71ef99fbaef8f7bcce1920530c24ecbce605b8a374b05d586f1f22a24
2022-03-28 09:04:38 +02:00
MarcoFalke
3d2f24bb38
Merge bitcoin/bitcoin#24656: refactor: Move mempool RPCs to rpc/mempool
fac5a51c47 Move mempool RPCs to rpc/mempool (MarcoFalke)
fa0f666dd7 style: Add static keyword where possible in rpc/mempool (MarcoFalke)

Pull request description:

  This moves the remaining mempool RPCs to `rpc/mempool`. Previously all mempool RPCs from the `blockchain` category have been moved. This patch moves the ones from the `rawtransactions` category.

  In the future, as a follow-up to this refactoring patch, it could be considered whether a new `mempool` category should be introduced.

  Beside a clearer code organization, this pull request should also reduce the compile time and space of the `rawtransactions.cpp` file.

ACKs for top commit:
  promag:
    Code review ACK fac5a51c47.

Tree-SHA512: 5578b894b68d0595869a9b03ed8dceebe3366f73dec5f090ccc36ff4002b1bc4d58af77546c2d71537c1be03694d9a28c4b1bfbb3569560997879293c5c0301e
2022-03-28 08:53:48 +02:00
fanquake
21db4eb3ff
test: fix incorrect named args in wallet tests 2022-03-25 21:27:57 +00:00
fanquake
8b0e776718
test: fix incorrect named args in coin_selection tests 2022-03-25 21:27:40 +00:00
fanquake
6fc00f7331
bench: fix incorrect named args in coin_selection bench 2022-03-25 21:27:39 +00:00
fanquake
2f0f056e08
Merge bitcoin/bitcoin#24665: doc: document clang tidy named args
7e22d80af3 addrman: fix incorrect named args (fanquake)
67f654ef61 doc: Document clang-tidy in dev notes (MarcoFalke)

Pull request description:

  The documentation, and a single commit extracted from #24661.

  Motivation:
  > Incorrect named args are source of bugs, like https://github.com/bitcoin/bitcoin/pull/22979.

  > To allow them being checked by clang-tidy, use a format it can understand.

ACKs for top commit:
  glozow:
    ACK 7e22d80af3

Tree-SHA512: 4037fcea59fdf583b171bce7ad350299fe5f9feb3c398413432168f3b9a185e51884d5b30e4b4ab9c6c5bb896c178cfaee1d78d5b4f0034cd70121c9ea4184b7
2022-03-25 21:04:51 +00:00
fanquake
6d5771ba07
Merge bitcoin/bitcoin#24494: wallet: generate random change target for each tx for better privacy
9053f64fcb [doc] release notes for random change target (glozow)
46f2fed6c5 [wallet] remove MIN_CHANGE (glozow)
a44236addd [wallet] randomly generate change targets (glozow)
1e52e6bd0a refactor coin selection for parameterizable change target (glozow)

Pull request description:

  Closes #24458 - the wallet always chooses 1 million sats as its change target, making it easier to fingerprint transactions created by the Core wallet. Instead of using a fixed value, choose one randomly each time (within a range). Using 50ksat (around $20) as the lower bound and `min(1 million sat, 2 * average payment value)` as the upper bound.
  RFC: If the payment is <25ksat, this doesn't work, so we're using the range (payment amount, 50ksat) instead.

ACKs for top commit:
  achow101:
    ACK 9053f64fcb
  Xekyo:
    reACK 9053f64fcb

Tree-SHA512: 45ce5d064697065549473347648e29935733f3deffc71a6ab995449431f60302d1f9911a0994dfdb960b48c48b5d8859f168b396ff2a62db67d535a7db041d35
2022-03-25 21:03:32 +00:00
MarcoFalke
f66c827c2d
Merge bitcoin/bitcoin#24502: wallet: don't create long chains by default
da2bc865d6 [wallet] don't create long chains by default (glozow)

Pull request description:

  Default mempool policy doesn't let you have chains longer than 25 transactions. This is locally configurable of course, but it's not really safe to assume that a chain longer than 25 transactions will propagate. Thus, the wallet should probably avoid creating such transactions by default; set `DEFAULT_WALLET_REJECT_LONG_CHAINS` to true.

  Closes #9752
  Closes #10004

ACKs for top commit:
  MarcoFalke:
    re-ACK da2bc865d6 only change is fixing typos in tests 🎏

Tree-SHA512: 65d8e4ec437fe928adf554aa7e819a52e0599b403d5310895f4e371e99bbc838219b3097c4d2f775bc870ac617ef6b4227b94291f2b376f824f14e8f2b152f31
2022-03-25 17:16:13 +01:00
glozow
da2bc865d6 [wallet] don't create long chains by default 2022-03-25 16:02:37 +00:00
MarcoFalke
7878c8655c
Merge bitcoin/bitcoin#24674: refactor: remove unused boost include in bitcoin-util.cpp
3bb9627463 refactor: remove unused boost header include in bitcoin-util.cpp (Sebastian Falbesoner)

Pull request description:

  This header was included since the introduction of bitcoin-util in
  commit 13762bcc96, but boost was
  actually never used (see `git log -S boost ./src/bitcoin-util.cpp`).

  Cherry-picked out of #22953, which currently needs rebase. This commit could just be merged on its own.

ACKs for top commit:
  MarcoFalke:
    review ACK 3bb9627463

Tree-SHA512: 201ee1aa4d49074056654203db73a473479c2b92c49df8dbf8e35979f85178013c66540a665f0f6dc0a2efef88eb091e2b088bebff85d840033dffd8ae719349
2022-03-25 16:44:28 +01:00
fanquake
6b1f93700c
Merge bitcoin/bitcoin#24666: refactor: Fix coinselection.h include, Make COutput a struct
fab287cedd Clarify that COutput is a struct, not a class (MarcoFalke)
fa61cdf464 wallet: Fix coinselection include (MarcoFalke)

Pull request description:

  * Fix include (see commit message)
  * `{}`-init, see https://github.com/bitcoin/bitcoin/pull/24091#discussion_r831193284
  * `struct`, see https://github.com/bitcoin/bitcoin/pull/24091#discussion_r831192702

ACKs for top commit:
  theStack:
    Code-review ACK fab287cedd

Tree-SHA512: dd2cfb9c06a92295dbd8fbb6d56afcf00ebda2a0440e301d392cd183d1b9cd87626311d539e302a9e6c6521d69d6183c74a51934e3fc16e64a5dcaba60c7e3ce
2022-03-25 15:36:14 +00:00
Sebastian Falbesoner
3bb9627463
refactor: remove unused boost header include in bitcoin-util.cpp
This header was included since the introduction of bitcoin-util in
commit 13762bcc96, but boost was
actually never used (see `git log -S boost ./src/bitcoin-util.cpp`).
2022-03-25 15:30:20 +00:00
MarcoFalke
f10b24ad29
Merge bitcoin/bitcoin#24672: init: add missing cs_main lock
0346c26fca init: add missing cs_main lock (Anthony Towns)

Pull request description:

  `BlockManager::m_block_tree_db` is protected by `cs_main`, so take the
  `cs_main` lock while accessing it.

ACKs for top commit:
  jonatack:
    Code review ACK 0346c26fca

Tree-SHA512: d6dff0b2d58871c7fbb281558b59fa9ad26fa75b3ceca9232277fc49ab795325e5ac3d266db49e7bda33da6de0b014b1bdebdf2c2c4347d43e50c0433a2cf06c
2022-03-25 16:20:53 +01:00
Murch
902793c777
Extract FinishTransaction from send()
The final step of send either produces a PSBT or the final transaction.
We extract these steps to a new helper function `FinishTransaction()` to
reuse them in `sendall`.
2022-03-25 11:16:46 -04:00
Murch
6d2208a3f6
Extract interpretation of fee estimation arguments
This will be reused in `sendall`, so we extract a method to prevent
duplication.
2022-03-25 11:16:44 -04:00
Murch
a31d75e5fb
Elaborate error messages for outdated options 2022-03-25 11:16:42 -04:00
Murch
35ed094e4b
Extract prevention of outdated option names
This will be reused in `sendall` so we extract it to avoid
duplication.
2022-03-25 11:16:38 -04:00
fanquake
9344697e57
Merge bitcoin/bitcoin#21160: net/net processing: Move tx inventory into net_processing
1066d10f71 scripted-diff: rename TxRelay members (John Newbery)
575bbd0dea [net processing] Move tx relay data to Peer (John Newbery)
785f55f7ee [net processing] Move m_wtxid_relay to Peer (John Newbery)
36346703f8 [net] Add CNode.m_relays_txs and CNode.m_bloom_filter_loaded (John Newbery)

Pull request description:

  This continues the work of moving application layer data into net_processing, by moving all tx data into the new Peer object added in #19607.

  For motivation, see #19398.

ACKs for top commit:
  dergoegge:
    ACK 1066d10f71 - This is a good layer separation improvement with no behavior changes.
  glozow:
    utACK 1066d10f71

Tree-SHA512: 0c9d6b8a0a05e2d816b6d6588b7df133842ec960ae67667813422aa7bd8eb5308599c714f3822a98ddbdf364ffab9050b055079277ba4aff24092557ff99ebcc
2022-03-25 15:16:00 +00:00
Anthony Towns
0346c26fca init: add missing cs_main lock
BlockManager::m_block_tree_db is protected by cs_main, so take the
cs_main lock while accessing it.
2022-03-26 00:04:07 +10:00
laanwj
7c08d81e11
Merge bitcoin/bitcoin#23536: Enforce Taproot script flags whenever WITNESS is set
cccc1e70b8 Enforce Taproot script flags whenever WITNESS is set (MarcoFalke)
fa42299411 Remove nullptr check in GetBlockScriptFlags (MarcoFalke)
faadc606c7 refactor: Pass const reference instead of pointer to GetBlockScriptFlags (MarcoFalke)

Pull request description:

  Now that Taproot is active, it makes sense to enforce its rules on all blocks, even historic ones, regardless of the deployment status.

  ### Benefits:

  (With "script flags" I mean "taproot script verification flags".)

  * Script flags are known ahead for all blocks (even blocks not yet created) and do not change. This may benefit static analysis, code review, and development of new script features that build on Taproot.
  * Any future bugs introduced in the deployment code won't have any effect on the script flags, as they are independent of deployment.
  * Enforcing the taproot rules regardless of the deployment status makes testing easier because invalid blocks after activation are also invalid before activation. So there is no need to differentiate the two cases.
  * It gives belt-and-suspenders protection against a practically expensive and theoretically impossible IBD reorg attack where the node is eclipsed. While `nMinimumChainWork` already protects against this, the cost for a few months worth of POW might be lowered until a major version release of Bitcoin Core reaches EOL. The needed work for the attack is the difference between `nMinimumChainWork` and the work at block 709632.

  For reference, previously the same was done for P2SH and WITNESS in commit 0a8b7b4b33.

  ### Implementation:

  I found one block which fails verification with the flags applied, so I added a `TaprootException`, similar to the `BIP16Exception`.

  For reference, the debug log:

  ```
  ERROR: ConnectBlock(): CheckInputScripts on b10c007c60e14f9d087e0291d4d0c7869697c6681d979c6639dbd960792b4d41 failed with non-mandatory-script-verify-flag (Witness program was passed an empty witness)
  BlockChecked: block hash=0000000000000000000f14c35b2d841e986ab5441de8c585d5ffe55ea1e395ad state=non-mandatory-script-verify-flag (Witness program was passed an empty witness)
  InvalidChainFound: invalid block=0000000000000000000f14c35b2d841e986ab5441de8c585d5ffe55ea1e395ad  height=692261  log2_work=92.988459  date=2021-07-23T08:24:20Z
  InvalidChainFound:  current best=0000000000000000000067b17a4c0ffd77c29941b15ad356ca8f980af137a25d  height=692260  log2_work=92.988450  date=2021-07-23T07:47:31Z
  ERROR: ConnectTip: ConnectBlock 0000000000000000000f14c35b2d841e986ab5441de8c585d5ffe55ea1e395ad failed, non-mandatory-script-verify-flag (Witness program was passed an empty witness)
  ```

  Hint for testing, make sure to set `-noassumevalid`.

  ### Considerations

  Obviously this change can lead to consensus splits on the network in light of massive reorgs. Currently the last block before Taproot activation, that is the last block without the Taproot script flags set, is only buried by a few days of POW. However, when and if this patch is included in the next major release, it will be buried by a few months of POW. BIP90 considerations apply when looking at reorgs this large.

ACKs for top commit:
  Sjors:
    tACK cccc1e70b8
  achow101:
    ACK cccc1e70b8
  laanwj:
    Code review ACK cccc1e70b8
  ajtowns:
    ACK cccc1e70b8 ; code review; wrote a "getblockscriptflags" rpc to quickly check that blocks just had bit 17 (taproot) added; review of earlier revisions had established non-exception blocks do validate with taproot rules enabled.
  jamesob:
    ACK cccc1e70b8 ([`jamesob/ackr/23536.1.MarcoFalke.enforce_taproot_script_f`](https://github.com/jamesob/bitcoin/tree/ackr/23536.1.MarcoFalke.enforce_taproot_script_f))

Tree-SHA512: 00044de68939caef6420ffd588c1291c041a8b397c80a3df1e3e3487fbeae1821d23975c51c95e44e774558db76f943b00b4e27cbd0213f64a9253116dc6edde
2022-03-25 14:11:18 +01:00
MarcoFalke
d2615312c1
Merge bitcoin/bitcoin#19385: test: Change default test logging directory
f8cba0d911 test: Change default test logging directory (Yancy Ribbens)

Pull request description:

  This PR changes the default test log location request here: https://github.com/bitcoin/bitcoin/issues/17224.  Instead of using the location of the makefile [automatic variable](https://www.gnu.org/software/make/manual/make.html#Automatic-Variables) `$<` I extract just the basename and then prepend a new location `./test`.  This is done because `$<` represents the variable name AND location of the prerequisite here.

Top commit has no ACKs.

Tree-SHA512: f0fbc530cf0e14c284b4bbf6671c145b1d7a2e1f5561f5c5d09f0cbe88b98e620e763bbbf2dfa9aeeec3dcc9b0127939e105e14c7e4f6660c7c19663622a393d
2022-03-25 13:30:26 +01:00
glozow
46f2fed6c5 [wallet] remove MIN_CHANGE 2022-03-25 11:57:51 +00:00
glozow
a44236addd [wallet] randomly generate change targets
If the wallet always chooses 1 million sats as its change target, it is
easier to fingerprint transactions created by the Core wallet.
2022-03-25 11:56:46 +00:00
glozow
1e52e6bd0a refactor coin selection for parameterizable change target
no behavior changes, since the target is always MIN_CHANGE
2022-03-25 11:56:46 +00:00
MarcoFalke
fab287cedd
Clarify that COutput is a struct, not a class
Also, use {}-initialization
2022-03-25 09:58:36 +01:00
MarcoFalke
fa61cdf464
wallet: Fix coinselection include
coinselection.h is not used by wallet.h but by qt/coincontroldialog.cpp
2022-03-25 09:57:42 +01:00
fanquake
7e22d80af3
addrman: fix incorrect named args 2022-03-25 08:22:24 +00:00
MarcoFalke
56c8658700
Merge bitcoin/bitcoin#24663: doc, init: add links to doc/cjdns.md
daae28885f doc, init: add links to doc/cjdns.md (Jon Atack)

Pull request description:

  Follow-up to #24555.

ACKs for top commit:
  jessebarton:
    ACK [daae288](daae28885f)

Tree-SHA512: eb8f4324f182f7917ddafa9b88ad753fe8f890c1c883c1342768ed9eac998c422ecd9e998fc977e72e26bc87f6aed295940b522187190481889255c8b2e05311
2022-03-25 07:27:29 +01:00
fanquake
3740cdd125
Merge bitcoin/bitcoin#24091: wallet: Consolidate CInputCoin and COutput
049003fe68 coinselection: Remove COutput operators == and != (Andrew Chow)
f6c39c6adb coinselection: Remove CInputCoin (Andrew Chow)
70f31f1a81 coinselection: Use COutput instead of CInputCoin (Andrew Chow)
14fbb57b79 coinselection: Add effective value and fees to COutput (Andrew Chow)
f0821230b8 moveonly: move COutput to coinselection.h (Andrew Chow)
42e974e15c wallet: Remove CWallet and CWalletTx from COutput's constructor (Andrew Chow)
14d04d5ad1 wallet: Replace CWalletTx in COutput with COutPoint and CTxOut (Andrew Chow)
0ba4d1916e wallet: Provide input bytes to COutput (Andrew Chow)
d51f27d3bb wallet: Store whether a COutput is from the wallet (Andrew Chow)
b799814bbd wallet: Store tx time in COutput (Andrew Chow)
46022953ee wallet: Remove use_max_sig default value (Andrew Chow)
10379f007f scripted-diff: Rename COutput member variables (Andrew Chow)
c7c64db41e wallet: cleanup COutput constructor (Andrew Chow)

Pull request description:

  While working on coin selection code, it occurred to me that `CInputCoin` is really a subset of `COutput` and the conversion of a `COutput` to a `CInputCoin` does not appear to be all that useful. So this PR adds fields that are present in `CInputCoin` to `COutput` and replaces the usage of `CInputCoin` with `COutput`.

  `COutput` is also moved to coinselection.h. As part of this move, the usage of `CWalletTx` is removed from `COutput`. It is instead replaced by storing a `COutPoint` and the `CTxOut` rather than the entire `CWalletTx` as coin selection does not really need the full `CWalletTx`. The `CWalletTx` was only used for figuring out whether the transaction containing the output was from the current wallet, and for the transaction's time. These are now parameters to `COutput`'s constructor.

ACKs for top commit:
  ryanofsky:
    Code review ACK 049003fe68, just adding comments and removing == operators since last review
  w0xlt:
    reACK 049003f
  Xekyo:
    reACK 049003fe68

Tree-SHA512: 048b4cd620a0415e1d9fe8597257ee4bc64656566e1d28a9bdd147d6d72dc87c3f34a3339fa9ab6acf42c388df7901fc4ee900ccaabc3de790ffad162b544c15
2022-03-24 20:46:43 +00:00
MarcoFalke
f0c9ba2b48
Merge bitcoin/bitcoin#24205: init, test: improve network reachability test coverage and safety
58a14795b8 test: passing -onlynet=onion with -onion=0/-noonion raises expected init error (Jon Atack)
7000f66d36 test: passing -onlynet=onion without -proxy/-onion raises expected init error (Jon Atack)
8332e6e4cf test: passing invalid -onion raises expected init error (Jon Atack)
d5edb08708 test: passing invalid -proxy raises expected init error (Jon Atack)
bd57dcbaf2 test: hoist proxy out of 2 network loops in feature_proxy.py (Jon Atack)
afdf2de282 test: add CJDNS to LimitedAndReachable_Network unit tests (Jon Atack)
2b7a8180a9 net, init: assert each network reachability is true by default (Jon Atack)

Pull request description:

  Adds missing network reachability test coverage and an assertion during init, noticed while reviewing #22834:

  - assert during init that each network reachability is  true by default
  - add CJDNS to the `LimitedAndReachable_Network` unit tests
  - hoist proxy out of two network loops in feature_proxy.py
  - test that passing invalid `-proxy` raises expected init error
  - test that passing invalid `-onion` raises expected init error
  - test that passing `-onlynet=onion` without `-proxy` and `-onion` raises expected init error
  - test that passing `-onlynet=onion` with `-onion=0` and with `-noonion` raises expected init error

ACKs for top commit:
  vasild:
    ACK 58a14795b8
  brunoerg:
    ACK 58a14795b8
  dongcarl:
    Code Review ACK 58a14795b8

Tree-SHA512: bdee6dd0c12bb63591ce7c9321fe77b509ab1265123054e774adc38a187746dddafe1627cbe89e990bcc78b45e194bfef8dc782710d5b217e2e2106ab0158827
2022-03-24 21:17:46 +01:00
Jon Atack
daae28885f
doc, init: add links to doc/cjdns.md 2022-03-24 20:12:32 +01:00
fanquake
0a14a16efe
Merge bitcoin/bitcoin#24625: Replace struct update_fee_delta with lambda
fa84a49526 Use CAmount for fee delta and modified fee (MarcoFalke)
fa8857c3f7 Replace struct update_fee_delta with lambda (MarcoFalke)

Pull request description:

  The same was done for another struct in e177fcab38.

  Also, change type of feeDelta from int64_t to CAmount.

ACKs for top commit:
  hebasto:
    re-ACK fa84a49526
  promag:
    Code review ACK fa84a49526.

Tree-SHA512: 2b9ee449d348b0f685793a35c6dd3c57ed97fdf707a89495a0518bb332f407303b48723e667351e96f2b698e0a2ade27095517a3accd926d4ec85e58d6fd441f
2022-03-24 16:58:06 +00:00
MarcoFalke
fc892c3a80 rpc: Fail to return undocumented or misdocumented JSON 2022-03-24 14:30:13 +01:00
MarcoFalke
f4bc4a705a rpc: Add m_skip_type_check to RPCResult
Used in the next commit.
2022-03-24 14:30:13 +01:00
MarcoFalke
4a0ab355b3
Merge bitcoin/bitcoin#24626: init: disallow reindex-chainstate when pruning
b2813980b8 init: disallow reindex-chainstate when pruning (Martin Zumsande)

Pull request description:

  The combination of `-reindex-chainstate` and `-prune` currently makes the node stuck in an endless loop:

  - `LoadChainstate()` will wipe the existing chainstate (so we have no genesis block anymore). It won't clean up unusable block files by calling `CleanupBlockRevFiles()` as for full `-reindex`.
  - `ThreadImport()` has [logic](91d12344b1/src/node/blockstorage.cpp (L855)) of reloading Genesis after reindexing. This is what makes full `-reindex` work with `-prune` but it's not executed for `-reindex-chainstate`.
  - Since we still don't have a genesis block, init will wait for it forever in an endless loop ([code](91d12344b1/src/init.cpp (L1630-L1640))).

  Fix this by disallowing `-reindex-chainstate` together with `-prune`. This is discouraged in the help for `-reindex-chainstate` anyway ("When in pruning mode or if blocks on disk might be corrupted, use full -reindex instead.") but wasn't enforced.

  Fixes #24242

ACKs for top commit:
  MarcoFalke:
    cr ACK b2813980b8

Tree-SHA512: 7220842daaf9a4f972d82b13b81fdeac2833bf5e665c5b0f8eaf6a4bcd0725c8e97d19ec956ca4b730065a983475bb3a2732713d338f4caf8666ccbf63d4d988
2022-03-24 14:27:13 +01:00
fanquake
213e98ca82
Merge bitcoin/bitcoin#24169: build: Add --enable-c++20 option
999982b06c build: Add --enable-c++20 option (MarcoFalke)
fae679065e Add CSerializedNetMsg::Copy() helper (MarcoFalke)
fabb7c4ba6 Make fs.h C++20 compliant (MarcoFalke)
fae2220f4e scheduler: Capture ‘this’ explicitly in lambda (MarcoFalke)

Pull request description:

  This is for CI and devs only and doesn't change that C++17 is the standard we are currently using. The option `--enable-c++20` allows CI to check that the C++17 code in the repo is  also valid C++20. (There are some cases where valid C++17 doesn't compile under C++20).

  Also, it allows developers to easily play with C++20 in the codebase.

ACKs for top commit:
  ryanofsky:
    Code review ACK 999982b06c. Since last review was rebased, and enum-conversion change was dropped, and CSerializedNetMsg copy workaround was added
  fanquake:
    utACK 999982b06c

Tree-SHA512: afc95ba03ea2b937017fc8e2b1449379cd2b6f7093c430d2e344c665a00c51e402d6651cbcbd0be8118ea1e54c3a86e67d2021d19ba1d4da67168e9fcb6b6f83
2022-03-24 13:01:01 +00:00
fanquake
e7b6272b30
Merge bitcoin/bitcoin#24636: rpc: Exclude descriptor when address is excluded
faf37c217a rpc: Exclude descriptor when address is excluded (MarcoFalke)

Pull request description:

  I don't think output descriptors should be used to describe redeem scripts and witness scripts.

  Fix this by excluding them when it doesn't make sense.

  This should only affect the `decodepsbt` RPC.

  Found by https://github.com/bitcoin/bitcoin/pull/23083

ACKs for top commit:
  achow101:
    ACK faf37c217a
  jonatack:
    ACK faf37c217a

Tree-SHA512: ebd581ad639e70080e26028723fed287caa3fa4d7b836936645020d6cd9b7586585d7113b043442c444a9dc90c23b93efd7f8b8a7d6cf5db1e42137b67c497c3
2022-03-24 12:15:19 +00:00
Martin Zumsande
b2813980b8 init: disallow reindex-chainstate when pruning
This fixes a bug where the node would be stuck in an
endless loop when combining these parameters.
2022-03-24 13:03:40 +01:00
fanquake
9809db3577
util: add linkat to syscall sandbox (AllowFileSystem) 2022-03-24 11:48:36 +00:00
MarcoFalke
fae679065e
Add CSerializedNetMsg::Copy() helper
This makes code that uses the helper less verbose.

Moreover, this makes net_processing C++20 compliant. Otherwise, it would
lead to a compile error (see below). C++20 disables aggregate
initialization when any constructor is declared. See
http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p1008r1.pdf

net_processing.cpp:1627:42: error: no matching constructor for initialization of 'CSerializedNetMsg'
            m_connman.PushMessage(pnode, CSerializedNetMsg{ser_cmpctblock.data, ser_cmpctblock.m_type});
                                         ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-03-24 11:37:34 +01:00
MarcoFalke
fabb7c4ba6 Make fs.h C++20 compliant
Without the changes, the file will fail to compile under C++20 because
char8_t can not be converted to char implicitly.
2022-03-24 11:36:37 +01:00
MarcoFalke
fae2220f4e
scheduler: Capture ‘this’ explicitly in lambda
Without the changes, g++ will warn to compile under C++20:

scheduler.cpp:114:21: warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated]
  114 |     scheduleFromNow([=] { Repeat(*this, f, delta); }, delta);
      |                     ^
scheduler.cpp:114:21: note: add explicit ‘this’ or ‘*this’ capture
2022-03-24 11:36:37 +01:00
MarcoFalke
fac5a51c47
Move mempool RPCs to rpc/mempool
Can be reviewed with
--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2022-03-24 08:55:13 +01:00
MarcoFalke
fa0f666dd7
style: Add static keyword where possible in rpc/mempool 2022-03-24 08:21:32 +01:00
MarcoFalke
98e9d8e8e2
Merge bitcoin/bitcoin#23732: refactor: Remove gArgs from bdb.h and sqlite.h
39b1763730 Replace use of `ArgsManager` with `DatabaseOptions` (Kiminuo)

Pull request description:

  Contributes to #21005.

  The goal of this PR is to remove `gArgs` from database classes (i.e. `bdb.h` and `sqlite.h`) so that they can be tested without relying on `gArgs` in tests.

  Notes:

  * My goal is to enable unit-testing without relying on `gArgs` as much as possible. Global variables are hard to reason about which in turn makes it slightly harder to contribute to this codebase. When the compiler does the heavy lifting for us and allows us only to construct an object (or call a method) with valid parameters, we may also save some time in code reviews. The cost for this is passing an argument which is not for free but the cost is very miniscule compared to benefits, I think.
      * GUI code is an exception because it seems fine to have `gArgs` there so I don't plan to make changes in `src/qt` folder, for example.
  * My approach to removal of `gArgs` uses is moving from lower levels to upper ones and pass `ArgsManager` as an argument as needed. The approach is very similar to what #20158.

ACKs for top commit:
  achow101:
    ACK 39b1763730
  ryanofsky:
    Code review ACK 39b1763730. Just the two small ReadDatabaseArgs and Berkeley open changes that were discussed since the last review

Tree-SHA512: aa066b314db593e46c18698fe8cdd500f558b405dc04e4a9a3ff57b52b5b3a81a6cb090e0e661785d1d02c1bf18958c1f4cd715ff233aab63381e3f80960622d
2022-03-24 07:40:42 +01:00
pasta
3ae7791bca refactor: use Span in random.* 2022-03-23 17:36:33 -05:00
fanquake
cea230eec4
Merge bitcoin/bitcoin#24562: Remove unused feebumper code
fae5d06eed Remove unused feebumper code (MarcoFalke)

Pull request description:

  This was accidentally added in commit 0ea47ba7b3. Presumably due to a copy-paste error, as `CreateTransaction` already takes care of the rbf-signal.

ACKs for top commit:
  achow101:
    ACK fae5d06eed
  promag:
    Code review ACK fae5d06eed

Tree-SHA512: 81aaf9c6bd9a4e2ad1789880bd8f2191f0ae9ba0a02794aa5db523236ea7df1c0dca078563219d293c694373c0a63c5bf168a85443e86556453ae5439791a618
2022-03-23 20:12:04 +00:00
fanquake
30041261a3
Merge bitcoin/bitcoin#24582: Move txoutproof RPCs to txoutproof.cpp
fa2d176016 Move txoutproof RPCs to txoutproof.cpp (MarcoFalke)

Pull request description:

  The txoutproof RPCs don't really fit into `rawtransaction.cpp`, as they deal with txids, not with raw transactions. As they are placed in the `blockchain` RPC category, they could be moved there. However, `blockchain.cpp` already takes about 20 seconds to compile (and `rawtransaction.cpp` even longer), so move them to a separate file.

  Can be reviewed with `--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space`.

ACKs for top commit:
  achow101:
    ACK fa2d176016
  theStack:
    Concept and code-review ACK fa2d176016

Tree-SHA512: 6250e5f87b6237f604d69643f9a809b238702d73f041792c537aeadeafdb60ab8e0dca1d83347d0d6c85900ce179df14365ae303ca3930ed33a528a862f85aa3
2022-03-23 20:01:02 +00:00
Andrew Chow
049003fe68 coinselection: Remove COutput operators == and !=
These operators are used only by the tests in std::mismatch. As
std::mismatch can take a binary predicate, we can use a lambda that
achieves the same instead.
2022-03-23 15:01:39 -04:00
Andrew Chow
f6c39c6adb coinselection: Remove CInputCoin
It is no longer needed as everything it was doing is now done by COutput
2022-03-23 15:01:39 -04:00
Andrew Chow
70f31f1a81 coinselection: Use COutput instead of CInputCoin
Also rename setPresetCoins to preset_coins
2022-03-23 15:01:39 -04:00
Andrew Chow
14fbb57b79 coinselection: Add effective value and fees to COutput 2022-03-23 15:01:38 -04:00
Andrew Chow
f0821230b8 moveonly: move COutput to coinselection.h 2022-03-23 14:32:07 -04:00
Andrew Chow
42e974e15c wallet: Remove CWallet and CWalletTx from COutput's constructor 2022-03-23 14:32:07 -04:00
Andrew Chow
14d04d5ad1 wallet: Replace CWalletTx in COutput with COutPoint and CTxOut
Instead of having a pointer to the CWalletTx in COutput, we can just
store the COutPoint and the CTxOut as those are the only things we need
from the CWalletTx. Other things CWalletTx used to provide were time and
fIsFromMe but these are also being stored by COutput.
2022-03-23 14:32:07 -04:00
Andrew Chow
0ba4d1916e wallet: Provide input bytes to COutput 2022-03-23 14:32:05 -04:00
Andrew Chow
3ab96f2945
Merge bitcoin/bitcoin#24560: wallet: Use single FastRandomContext when creating a wallet tx
fa7deaa046 wallet: Pass FastRandomContext& to coin selection (MarcoFalke)
77773b061c wallet: Pass FastRandomContext& to DiscourageFeeSniping (MarcoFalke)

Pull request description:

  Passing around a single randomness context shouldn't come with any downsides, but documents better where randomness is used and allows the unit test to be deterministic, if they wish to be so.

ACKs for top commit:
  achow101:
    ACK fa7deaa046
  promag:
    Code review ACK fa7deaa046.
  glozow:
    light code review ACK fa7deaa046

Tree-SHA512: c16287708cc82ce58311710595d0127af42fb156c93fbcaa5bde634ce323d325f4d8c99a74af24423ab22b5ad58163dd771e8b1a0e7d6bff39c9fb2a1cb21bc7
2022-03-23 13:50:57 -04:00
Vasil Dimov
7f90dc26c8
options: flip listenonion to false if not listening
If the user has unchecked "Allow incoming connections" in
`Settings->Options...->Network` then `fListen=false` is saved in
`~/.config/Bitcoin/Bitcoin-Qt.conf`. This flips `-listen` to `false`
during startup, but leaves `-listenonion` to `true`.

This flipping of `-listen` is done in `OptionsModel::Init()` after
`InitParameterInteraction()` has been executed which would have flipped
`-listenonion`, should it have seen `-listen` being `false`
(this is a difference between `bitcoind` and `bitcoin-qt`).

Fixes: https://github.com/bitcoin-core/gui/issues/567
2022-03-23 11:34:05 +01:00
MarcoFalke
faf37c217a
rpc: Exclude descriptor when address is excluded 2022-03-23 11:09:34 +01:00
MarcoFalke
d6f225f5c9
Merge bitcoin/bitcoin#24462: For descriptor pubkey parse errors, include context information
9b52672700 For descriptor pubkey parse errors, include context information (Ben Woosley)

Pull request description:

  This adds readily-available context information to the error string, for further disambiguation.

  This is a revival of #16123 which was largely addressed in #16542.

  Note 'Multi:' is used rather than 'multi():' as it also encompasses 'sortedmulti():'

ACKs for top commit:
  achow101:
    ACK 9b52672700
  theStack:
    ACK 9b52672700

Tree-SHA512: 96533ea8c3ac7010f9b62e75b4bd20b65aff843030eb91c7a88312975acecaaf17909b7d1841f45edc86dbf7fa402d208adb85f0673bd79b857dbebacb8c9395
2022-03-23 09:38:54 +01:00
Luke Dashjr
06822f8654 Bugfix: RPC/blockchain: Correct description of getblockchaininfo's pruneheight result
It is possible that lower blocks are complete due to being stored in the same file as blocks not yet eligible for pruning.
2022-03-22 13:41:04 +00:00
MarcoFalke
f05cf59d91
Merge bitcoin/bitcoin#24624: qt: Avoid potential -Wdeprecated-enum-enum-conversion warnings
acd98adaf1 qt: Avoid potential -Wdeprecated-enum-enum-conversion warning (Hennadii Stepanov)
d8641f04e4 qt: Use human-readable strings in preference to hard-coded integers (Hennadii Stepanov)

Pull request description:

  This PR is related to bitcoin/bitcoin#24169. It adjusts code in order to avoid `-Wdeprecated-enum-enum-conversion` warnings instead of disabling them.

  Could be tested with gcc 11.2.

ACKs for top commit:
  MarcoFalke:
    Approach ACK acd98adaf1
  fanquake:
    untested ACK acd98adaf1 - thanks.
  promag:
    Code review ACK acd98adaf1.

Tree-SHA512: e8043d997d85f8dba0f37ca02f1c60eb756a1732cf76a75908b01eb2cf7a4c6d4aaf6007271a929c213de37a0c1d96bc25280f0ee9eca488f370904461222ede
2022-03-22 13:39:55 +01:00
Hennadii Stepanov
acd98adaf1
qt: Avoid potential -Wdeprecated-enum-enum-conversion warning 2022-03-22 12:36:25 +01:00
laanwj
2948d6dea0
Merge bitcoin/bitcoin#15423: torcontrol: Query Tor for correct -onion configuration
b2774fc0be torcontrol: Query Tor for correct -onion configuration (Luke Dashjr)

Pull request description:

  Currently, we just assume any running Tor instance provides localhost port 9050 for SOCKS, and configure `-onion` accordingly when we get a Tor control connection.

  This actually queries the Tor node for its SOCKS listeners, and uses the configured port instead.

  For backward compatibility, it falls back to localhost:9050 if it can't get any better port info. I'm not sure if that's the correct action to take when the Tor daemon explicitly says there are no ports listening...

ACKs for top commit:
  laanwj:
    Tested ACK (FreeBSD) b2774fc0be
  vasild:
    ACK b2774fc0be
  jonatack:
    ACK b2774fc0be review, rebased to master, debug build, ran unit tests, tested happy path only

Tree-SHA512: 2fa93a3cf0cb675801d1b51322ce953ea9b2317f78154a53b603244d74252f434cc1eaa5ae48cb3fe6bdc4ce984a6d976ff95bb046f7933b9740332942378c02
2022-03-22 11:57:14 +01:00
fanquake
44dbf918d3
Merge bitcoin/bitcoin#24627: test: Limit scope of id global which is shared between subtests
fa9086d085 test: Limit scope of id global which is shared between subtests (MarcoFalke)

Pull request description:

  Globals aren't too nice when testing, as leak state between subtests run in the same process. For example, when checking peer ids in the tests, they might pass/fail depending on other tests run in the same process.

  Fix this by making `id` not a global.

ACKs for top commit:
  promag:
    Code review ACK fa9086d085.

Tree-SHA512: 0a53dde428570086f4557b23112e6460d6413bedf6ef487bd56e88f83cd5f4526f44effa8076cdeaf4761ecc062c346948e0bff434808bbf9b558eabd81328e3
2022-03-22 09:02:34 +00:00
MarcoFalke
138d55e6a0
Merge bitcoin/bitcoin#24579: doc: Fix getblockchaininfo/getdeploymentinfo RPC docs
facd5d92e1 doc: Fix getblockchaininfo/getdeploymentinfo RPC docs (MarcoFalke)

Pull request description:

  Also, fix whitespace to be `4` spaces. Can be reviewed with `--ignore-all-space --word-diff-regex=.`.

  Found by https://github.com/bitcoin/bitcoin/pull/23083

ACKs for top commit:
  luke-jr:
    crACK facd5d92e1

Tree-SHA512: 113228a6b140009cecd9068fb634d352148670589f647350e41c02a35e0ca306b4a2d3f2588cd9ef14a2ab7d1f23d0d2f83b5ebb00b60f17a1d16a8d71386fd2
2022-03-22 09:16:24 +01:00
Hennadii Stepanov
d8641f04e4
qt: Use human-readable strings in preference to hard-coded integers
This is recommended by Qt docs.
See: https://doc.qt.io/qt-5/qkeysequence.html#details

Also this change avoids -Wdeprecated-enum-enum-conversion warnings.
2022-03-22 08:58:25 +01:00
Andrew Chow
e66630cc87
Merge bitcoin/bitcoin#13226: Optimize SelectCoinsBnB by tracking the selection by index rather than by position
9d2005285c doc: Revise comments and whitespace to clarify (Ben Woosley)
def43a4d88 refactor: Rename i to curr_try in SelectCoinsBnB (Ben Woosley)
1dd0923677 refactor: Track BnB selection by index (Ben Woosley)

Pull request description:

  This is prompted by #13167 and presented as a friendly alternative to it.

  IMO you can improve code readability and performance by about 20% by tracking the selected utxos by index, rather than by position. This reduces the storage access complexity from roughly O(utxo_size) to O(selection_size).

  On my machine (median of 5 trials):
  ```
  BnBExhaustion, 5, 650, 2.2564, 0.000672999, 0.000711565, 0.000693112 - master
  BnBExhaustion, 5, 650, 1.76232, 0.000528563, 0.000568806, 0.000539147 - this PR
  ```

ACKs for top commit:
  achow101:
    reACK 9d2005285c
  glozow:
    code review ACK 9d2005285c
  Xekyo:
    reACK 9d2005285c

Tree-SHA512: 453ea11ad58c48928dc76956e3e98916f6924e95510eb02fe89a899ff102fe9cc08a04d557f381ad0218a210275e5383101d971c1ffad38b06b1c57d81144315
2022-03-21 17:44:54 -04:00
Hennadii Stepanov
532c64a726 build: Fix Boost.Process test for Boost 1.78 2022-03-21 16:52:27 +00:00
MarcoFalke
fa9086d085
test: Limit scope of id global which is shared between subtests
This is needed to use ASSERT_DEBUG_LOG, which may include a fixed node
number
2022-03-21 16:27:44 +01:00
MarcoFalke
fa84a49526
Use CAmount for fee delta and modified fee 2022-03-21 13:38:08 +01:00
MarcoFalke
fa8857c3f7
Replace struct update_fee_delta with lambda 2022-03-21 11:38:44 +01:00
MarcoFalke
6c72f3192a
Merge bitcoin/bitcoin#23880: p2p: Serialize cmpctblock at most once in NewPoWValidBlock
fa61dd44f9 p2p: Serialize cmpctblock at most once in NewPoWValidBlock (MarcoFalke)

Pull request description:

  Instead of serializing for each peer, serialize at most once and copy the raw data for each peer.

ACKs for top commit:
  shaavan:
    reACK fa61dd44f9
  theStack:
    Code-review ACK fa61dd44f9

Tree-SHA512: ed029aeaea67fdac8ddb865069f8166bc0dd8480418c405628e3e1a43b61161584a09a1814668bcd220602e8732e188be2bfed9242aa81bdbd92c64c702ed138
2022-03-21 10:00:40 +01:00
Hennadii Stepanov
ae005a647f
Merge bitcoin-core/gui#554: Add and improve translator comments and tooltips for peers tab address fields
4d2b503d6c gui: improve "Addresses Rate-Limited" translator comments and tooltip in peers tab (Jon Atack)
81ef1f7ef1 gui: improve "Addresses Processed" translator comments and tooltip in peers tab (Jon Atack)
77f24aac52 gui: improve "Address Relay" translator comments and tooltip in peers tab (Jon Atack)

Pull request description:

  Per translator feedback in this thread: https://github.com/bitcoin-core/gui/pull/526#discussion_r809237830

  *"The lack of string context in Transifex is a real problem for this project, as proper context (dev notes and/or screenshots) are essential to achieve quality translations."*

  This pull adds developer notes for transifex translators via `extracomment` tags, and it improves the existing ones and their tooltips with more context, clarity and completeness for the following peer tab fields as a follow-up to bitcoin-core/gui#526:

  - address relay
  - addresses processed
  - addressed rate-limited

  It looks like only six lines of diff, but they are loooong lines.

  If this is the right direction, the same can be done for other fields in follow-ups.

ACKs for top commit:
  jarolrod:
    re-ACK [4d2b503](4d2b503d6c)
  hebasto:
    ACK 4d2b503d6c, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: a185f46a66375a5fd6854640745b7d1d00740cf7be58db03256f44d71acc351e1770de137cb3bc9c1f0ea3cabd7cfa1cb1ccb87ec0df222680924ca3dab6c8bf
2022-03-20 09:38:41 +01:00
John Newbery
1066d10f71 scripted-diff: rename TxRelay members
-BEGIN VERIFY SCRIPT-
ren() { sed -i "s:\<$1\>:$2:g" $(git grep -l "\<$1\>" ./src ./test); }

ren cs_filter             m_bloom_filter_mutex
ren fRelayTxes            m_relay_txs
ren pfilter               m_bloom_filter
ren cs_tx_inventory       m_tx_inventory_mutex
ren filterInventoryKnown  m_tx_inventory_known_filter
ren setInventoryTxToSend  m_tx_inventory_to_send
ren fSendMempool          m_send_mempool
ren nNextInvSend          m_next_inv_send_time
ren minFeeFilter          m_fee_filter_received
ren lastSentFeeFilter     m_fee_filter_sent
-END VERIFY SCRIPT-
2022-03-18 11:35:58 +00:00
John Newbery
575bbd0dea [net processing] Move tx relay data to Peer 2022-03-18 11:35:56 +00:00
Jon Atack
1bba72d824
Clarify in -maxtimeadjustment that only outbound peers influence time data 2022-03-18 12:32:34 +01:00
John Newbery
785f55f7ee [net processing] Move m_wtxid_relay to Peer
Also, remove cs_main guard from m_wtxid_relay_peers and make it atomic.
This should be fine since we don't need m_wtxid_relay_peers to be
synchronized with m_wtxid_relay exactly at all times.

After this change, RelayTransaction no longer requires cs_main.
2022-03-18 11:21:48 +00:00
John Newbery
36346703f8 [net] Add CNode.m_relays_txs and CNode.m_bloom_filter_loaded
We'll move the transaction relay data into Peer in subsequent commits,
but the inbound eviction logic needs to know if the peer is relaying
txs and if the peer has loaded a bloom filter.

This is currently redundant information with m_tx_relay->fRelayTxes,
but when m_tx_relay is moved into net_processing, then we'll need these
separate fields in CNode.
2022-03-18 11:21:48 +00:00
Andrew Chow
d51f27d3bb wallet: Store whether a COutput is from the wallet
Instead of determining whether the containing transaction is from the
wallet dynamically as needed, just pass it in to COutput and store it.
The transaction ownership isn't going to change.
2022-03-17 11:04:22 -04:00
Andrew Chow
b799814bbd wallet: Store tx time in COutput 2022-03-17 11:00:45 -04:00
Andrew Chow
46022953ee wallet: Remove use_max_sig default value
As we change the constructor for COutput, it becomes somewhat dangerous
if there are default values.
2022-03-17 10:57:08 -04:00
Andrew Chow
10379f007f scripted-diff: Rename COutput member variables
Update the member variables to match the new style

-BEGIN VERIFY SCRIPT-
sed -i 's/fSpendableIn/spendable/' $(git grep -l "fSpendableIn")
sed -i 's/fSpendable/spendable/' $(git grep -l "fSpendable")
sed -i 's/fSolvableIn/solvable/' $(git grep -l "fSolvableIn")
sed -i 's/fSolvable/solvable/' $(git grep -l "fSolvable")
sed -i 's/fSafeIn/safe/' $(git grep -l "fSafeIn")
sed -i 's/fSafe/safe/' $(git grep -l "fSafe")
sed -i 's/nInputBytes/input_bytes/' $(git grep -l "nInputBytes")
sed -i 's/nDepthIn/depth/' $(git grep -l "nDepthIn" src/wallet src/bench)
sed -i 's/nDepth/depth/' src/wallet/spend.h
sed -i 's/\.nDepth/.depth/' $(git grep -l "\.nDepth" src/wallet/)
sed -i 's/nDepth, FormatMoney/depth, FormatMoney/' src/wallet/spend.cpp
-END VERIFY SCRIPT-
2022-03-17 10:53:30 -04:00
Andrew Chow
c7c64db41e wallet: cleanup COutput constructor 2022-03-17 10:49:16 -04:00
Antoine Poinsot
2da94a4c6f
fuzz: add a fuzz target for Miniscript decoding from Script 2022-03-17 14:09:09 +01:00
Pieter Wuille
f8369996e7
Miniscript: ops limit and stack size computation
Co-Authored-By: Antoine Poinsot <darosior@protonmail.com>
2022-03-17 14:09:08 +01:00
Pieter Wuille
2e55e88f86
Miniscript: conversion from script
Co-Authored-By: Antoine Poinsot <darosior@protonmail.com>
Co-Authored-By: Samuel Dobson <dobsonsa68@gmail.com>
2022-03-17 14:09:08 +01:00
Pieter Wuille
1ddaa66eae
Miniscript: type system, script creation, text notation, tests
More information about Miniscript can be found at https://bitcoin.sipa.be/miniscript/ (the
website source is hosted at https://github.com/sipa/miniscript/).
This commit defines all fragments, their composition, parsing from
string representation and conversion to Script.

Co-Authored-By: Antoine Poinsot <darosior@protonmail.com>
Co-Authored-By: Sanket Kanjalkar <sanket1729@gmail.com>
Co-Authored-By: Samuel Dobson <dobsonsa68@gmail.com>
2022-03-17 14:09:07 +01:00
Antoine Poinsot
4fe29368c0
script: expose getter for CScriptNum, add a BuildScript helper
Some prep work for Miniscript. BuildScript is an efficient way to build
Scripts in a generic manner (by concatenating OPs, data, and other
Scripts).

Co-Authored-By: Pieter Wuille <pieter@wuille.net>
2022-03-17 14:09:07 +01:00
Antoine Poinsot
f4e289f384
script: move CheckMinimalPush from interpreter to script.h
It is used by Miniscript.
2022-03-17 14:09:06 +01:00
Antoine Poinsot
31ec6ae92a
script: make IsPushdataOp non-static
We'll need it for Miniscript
2022-03-17 14:09:06 +01:00
MarcoFalke
fa2d176016
Move txoutproof RPCs to txoutproof.cpp 2022-03-17 08:42:14 +01:00
MarcoFalke
bf2c0fb2a2
Merge bitcoin/bitcoin#24472: fuzz: execute each file in dir without fuzz engine
f59bee3fb2 fuzz: execute each file in dir without fuzz engine (Anthony Towns)

Pull request description:

  Phony fuzzing (phuzzing)! Run the fuzz testing code against known inputs to detect errors. Advantage is you can easily test using the existing qa-assets datasets without having to compile with fuzzing enabled; disadvantage is that it doesn't do any actual fuzzing.

  Example usage:

  ```
  $ for a in ${QA_ASSETS}/fuzz_seed_corpus/*; do echo ${a##*/}; done | xargs -P8 -I {} /bin/sh -c "FUZZ={} test/fuzz/fuzz ${QA_ASSETS}/fuzz_seed_corpus/{}"
  No fuzzer for address_deserialize.
  No fuzzer for addrdb.
  No fuzzer for banentry_deserialize.
  addition_overflow: succeeded against 848 files in 0s.
  asmap: succeeded against 981 files in 0s.
  checkqueue: succeeded against 211 files in 0s.
  ...
  ```

  (`-P8` says run 8 of the tasks in parallel)

  If there are failures, the first one will be reported and the program will abort with output like:

  ```
  fuzz: test/fuzz/versionbits.cpp:336: void (anonymous namespace)::versionbits_fuzz_target(FuzzBufferType): Assertion `exp_state != ThresholdState::FAILED' failed.
  Error processing seed "corpus/versionbits/35345ae8e722234095810b1117a29b63af7621af"
  ```

  Rebase of #22763, which was a rebase of #21496, but also reports the name of the fuzzer and the time taken.

  Fixes #21461

Top commit has no ACKs.

Tree-SHA512: d8d046d4a309652eb13de42116276bf992480bc887ad3535a8ff18b354cb24826bc562b06af63802ec945c637f046563b6a5601d6321b46a5543127daafea09b
2022-03-17 08:26:57 +01:00
MarcoFalke
601bfc417d
Merge bitcoin/bitcoin#24515: Only load BlockMan in BlockMan member functions
f865cf8ded Add and use BlockManager::GetAllBlockIndices (Carl Dong)
28ba0313ea Add and use CBlockIndexHeightOnlyComparator (Carl Dong)
12eb05df63 move-only: Move CBlockIndexWorkComparator to blockstorage (Carl Dong)
c600ee3816 Only load BlockMan in BlockMan member functions (Carl Dong)
42e56d9b18 style-only: No need for std::pair for vSortedByHeight (Carl Dong)
3bbb6fea05 style-only: Various blockstorage.cpp cleanups (Carl Dong)
5be9ee3c54 refactor: more const annotations for uses of CBlockIndex* (Anthony Towns)

Pull request description:

  The only important commit is "Only load BlockMan in BlockMan member functions", everything else is all just small style changes.

  Here's the commit message, reproduced:
  ```
  This commit effectively splits the "load block index itself" logic from
  "derive Chainstate variables from loaded block index" logic.

  This means that BlockManager::LoadBlockIndex{,DB} will only load what's
  relevant to the BlockManager.
  ```

ACKs for top commit:
  ajtowns:
    ACK f865cf8ded ; code review only
  MarcoFalke:
    review ACK f865cf8ded 🗂

Tree-SHA512: 7b204d782834e06fd7329d022e2ae860181b4e8105c33bfb928539a4ec24161dc7438a9c4d4ee279dcad77de310c160b997bb8aa18923243d0fd55ccf4ad7c3a
2022-03-17 07:23:43 +01:00
Hennadii Stepanov
aece566249
Merge bitcoin-core/gui#555: Restore Send button when using external signer
2efdfb88aa gui: restore Send for external signer (Sjors Provoost)
4b5a6cd149 refactor: helper function signWithExternalSigner() (Sjors Provoost)
026b5b4523 move-only: helper function to present PSBT (Sjors Provoost)

Pull request description:

  Fixes #551

  For the simplest use case of a wallet with one external signer and "PSBT Controls" disabled in settings (the default), the send dialog will behave the same as when using a wallet with private keys. I.e. there's no "Create Unsigned" button.

  When PSBT controls are turned on, you can now actually make a PSBT with signing it; before this PR that button would trigger a sign event and would broadcast the transaction.

  In case a multisig, the Send button will sign on the device, and then fall back to presenting a PSBT (same behavior as before #441).

  This PR starts with two refactoring commits to move some stuff into a helper function for improved readability in general, and to make the main commit easier to review.

ACKs for top commit:
  jonatack:
    utACK 2efdfb88aa diff review since my last review, code re-review, rebased to current master, verified clean debug build of each commit
  luke-jr:
    utACK 2efdfb88aa

Tree-SHA512: e8731a0ef9e87564b2676c7b022b742d9621bba964c19dba9fd9f6961eb608737a9e1a22c0a3c8b2f2f6d583bba067606ee8392422e82082deefb20ea7b88c7c
2022-03-17 07:21:07 +01:00
Anthony Towns
f59bee3fb2 fuzz: execute each file in dir without fuzz engine
Co-Authored-By: Anthony Ronning <anthonyronning@gmail.com>
2022-03-17 07:27:00 +10:00
Michael Folkson
9a5b4d7892 doc: Delete old line of code that was commented out 2022-03-16 19:33:52 +00:00
MarcoFalke
3617d22562
Merge bitcoin/bitcoin#14752: tests: Unit tests for IsPayToWitnessScriptHash and IsWitnessProgram
bce9aaf31e Unit tests for IsWitnessProgram and IsP2WSH. (Daniel Kraft)

Pull request description:

  This adds basic unit tests for `CScript::IsPayToWitnessScriptHash` and `CScript::IsWitnessProgram`, similar to the existing tests for `CScript::IsPayToScriptHash`.  These tests are probably not super important given the other existing tests for segwit related code, but may be useful in catching some errors early.

  This implements #14737.

ACKs for top commit:
  aureleoules:
    tACK bce9aaf31e (`make check)`.

Tree-SHA512: 3cff5efc4ac53079289c72bfba8b1937bc103baadd32bb1fba41e78017f65f9cca17678c3202ad0711eae42b351d4132d9ed9b4e2dc07d138298691a09c4e822
2022-03-16 17:47:56 +01:00
MarcoFalke
e4d61d9759
Merge bitcoin/bitcoin#18815: bench: Add logging benchmark
fafe06c379 bench: Sort bench_bench_bitcoin_SOURCES (MarcoFalke)
fa31dc9b71 bench: Add logging benchmark (MarcoFalke)

Pull request description:

  Might make finding performance bottlenecks or regressions (https://github.com/bitcoin/bitcoin/pull/17218) easier.

  For example, fuzzing relies on disabled logging to be as fast as possible.

ACKs for top commit:
  dergoegge:
    ACK fafe06c379

Tree-SHA512: dd858f3234a4dfb00bd7dec4398eb076370a4b9746aa24eecee7da86f6882398a2d086e5ab0b7c9f7321abcb135e7ffc54cc78e60d18b90379c6dba6d613b3f7
2022-03-16 16:56:29 +01:00
Sjors Provoost
2efdfb88aa
gui: restore Send for external signer
Before this change the send confirmation dialog would keep the Send option disabled. The Create Unsigned choice would actually send. This is potentially confusing.

With this change the Create Unsigned button will not attempt to sign and always produce a PSBT. The Send button will attempt to sign, and only return a PSBT if more signatures are needed.

When using an external signer, the Create Unsigned option only appears when PSBT controls are enabled in the wallet settings.

This commit maintains the pre-existing behavior of filling the PSBT (without signing) even when not using an external signer.

Closes #551

Co-authored-by: Jon Atack <jon@atack.com>
2022-03-16 10:28:39 +01:00
Sjors Provoost
4b5a6cd149
refactor: helper function signWithExternalSigner()
Does not change behavior.

Review hint:
git show --color-moved --color-moved-ws=allow-indentation-change
2022-03-16 10:28:37 +01:00
randymcmillan
51708c4516
gui: peersWidget - ResizeToContents Age and IP/Netmask columns
Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2022-03-16 04:54:52 -04:00
randymcmillan
209301a442
gui: add Age column to peers tab
Co-authored-by: Jon Atack <jon@atack.com>
2022-03-16 04:54:52 -04:00
Jon Atack
127de22c5f
gui: add FormatPeerAge() utility helper
Co-authored-by: randymcmillan <randy.lee.mcmillan@gmail.com>
2022-03-16 04:54:52 -04:00
MarcoFalke
310ba92494
Merge bitcoin/bitcoin#24537: rpc: Split mempool RPCs from blockchain.cpp
fad4c8934c Add RegisterMempoolRPCCommands helper (MarcoFalke)
fafd40b541 refactor: Avoid int64_t -> size_t -> int64_t conversion (MarcoFalke)
fa2a5f301a rpc: Move mempool RPCs to new file (MarcoFalke)

Pull request description:

  The `blockchain.cpp` file is quite large. This makes it harder to navigate and increases the memory required to compile.

  Improve on both issues by splitting up the mempool RPCs to a separate file.

ACKs for top commit:
  promag:
    Code review ACK fad4c8934c.
  theStack:
    Code-review ACK fad4c8934c 🏞️

Tree-SHA512: 7f13168ea2cbea51eaef05ca1604fddc919480a2128ec7fa6b1f9365ec5e4822c3df93eb408a19f038c627f2309fa282b9f7f7ec45e5e661fc728f6b33157f89
2022-03-16 09:26:19 +01:00
MarcoFalke
facd5d92e1
doc: Fix getblockchaininfo/getdeploymentinfo RPC docs 2022-03-16 09:17:35 +01:00
Kiminuo
39b1763730 Replace use of ArgsManager with DatabaseOptions
Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
2022-03-16 08:26:28 +01:00
Carl Dong
f865cf8ded Add and use BlockManager::GetAllBlockIndices 2022-03-15 19:42:43 -04:00
Carl Dong
28ba0313ea Add and use CBlockIndexHeightOnlyComparator
...also use std::sort for clarity
2022-03-15 19:42:43 -04:00
Carl Dong
12eb05df63 move-only: Move CBlockIndexWorkComparator to blockstorage
...it's declared in blockstorage.h
2022-03-15 19:42:43 -04:00
Carl Dong
c600ee3816 Only load BlockMan in BlockMan member functions
This commit effectively splits the "load block index itself" logic from
"derive Chainstate variables from loaded block index" logic.

This means that BlockManager::LoadBlockIndex{,DB} will only load what's
relevant to the BlockManager.

I strongly recommend reviewing with the following git-diff flags:
  --color-moved=dimmed_zebra --color-moved-ws=allow-indentation-change
2022-03-15 19:42:41 -04:00
Carl Dong
42e56d9b18 style-only: No need for std::pair for vSortedByHeight
...since the height information in already in CBlockIndex* and we can
use an easy custom sorter.
2022-03-15 19:40:51 -04:00
MarcoFalke
fad4c8934c
Add RegisterMempoolRPCCommands helper 2022-03-15 19:29:59 +01:00
Luke Dashjr
b2774fc0be torcontrol: Query Tor for correct -onion configuration 2022-03-15 01:33:52 +00:00
glozow
e4303c337c [unit test] prioritisation in mining 2022-03-14 16:03:10 +00:00
glozow
7a8d60676b [miner] bug fix: update for parent inclusion using modified fee 2022-03-14 16:02:53 +00:00
glozow
0f9a44461c MOVEONLY: group miner tests into MinerTestingSetup functions
No behavior changes. Recommend using --color-moved=dimmed_zebra.
2022-03-14 16:02:51 +00:00
MarcoFalke
28bdaa3f76
Merge bitcoin/bitcoin#24080: policy: Remove unused locktime flags
fa8d4d9128 scripted-diff: Clarify CheckFinalTxAtTip name (MarcoFalke)
fa4e30b0f3 policy: Remove unused locktime flags (MarcoFalke)

Pull request description:

  The locktime flags have many issues:
  * They are passed in by a default argument, which is fragile. It has already lead to bugs like the one fixed in commit e30b6ea194.
  * They are negative (signed), which doesn't make sense for flags (unsigned in general). According to the review comments when the code was added: "The max on the flags is a fairly weird operation." (https://github.com/bitcoin/bitcoin/pull/6566#issuecomment-150310861)
  * No call site relies on the default argument and they all pass in a single compile-time constant, rendering most of the code dead and untested.
  * The dead code calls `GetAdjustedTime` (network adjusted time), which has its own issues. See https://github.com/bitcoin/bitcoin/issues/4521

  Fix all issues by removing them

ACKs for top commit:
  ajtowns:
    ACK  fa8d4d9128
  theStack:
    Code-review ACK fa8d4d9128
  glozow:
    ACK fa8d4d9128, agree the default arg `flags` is a massive footgun and just setting max flags is weird. Adding `AtTip` to the names makes sense to me, since they're both testing for *next* block and only ever used for {,re}addition to mempool.

Tree-SHA512: 79f4a52f34909eb598d88bbae7afe8abe5f85f45c128483d16aa83dacd0e5579e561b725d01b1e9a931d1821012a51ad2bc6fb2867f8d09ee541f9d234d696f8
2022-03-14 16:32:23 +01:00
MarcoFalke
fae5d06eed
Remove unused feebumper code 2022-03-14 16:05:42 +01:00
MarcoFalke
fa7deaa046
wallet: Pass FastRandomContext& to coin selection 2022-03-14 15:17:04 +01:00
Ben Woosley
9d2005285c
doc: Revise comments and whitespace to clarify 2022-03-14 12:20:09 +00:00
Ben Woosley
def43a4d88
refactor: Rename i to curr_try in SelectCoinsBnB
Clarifies purpose and removes name collisions with other indicies.
2022-03-14 12:20:08 +00:00
Ben Woosley
1dd0923677
refactor: Track BnB selection by index
This is a performance optimization - rather than track all visited values
in a bool vector, track the selected index in a vector. This results in a
complexity reduction of O(utxo_size) to O(selection_size).
2022-03-14 12:19:51 +00:00
MarcoFalke
77773b061c
wallet: Pass FastRandomContext& to DiscourageFeeSniping 2022-03-14 12:11:33 +01:00
Andrew Chow
25d045a9ec
Merge bitcoin/bitcoin#24225: wallet: Add sanity checks to DiscourageFeeSniping
fa8e76bb90 wallet: Add sanity checks to AntiFeeSnipe (MarcoFalke)

Pull request description:

  I added those sanity checks as part of implementing BIP 326, but I think they make sense on their own. The checks require the transaction to be passed in to `DiscourageFeeSniping`. Also, replace `(int)locktime` cast with the equivalent `int(locktime)` cast.

ACKs for top commit:
  chris-belcher:
    ACK fa8e76bb90
  S3RK:
    Code review ACK fa8e76bb90
  achow101:
    ACK fa8e76bb90
  w0xlt:
    Code Review ACK fa8e76bb90

Tree-SHA512: 6fe37c85f074851ef09cae8addcb836257089290fecec515c129c3180e9ccb64740aaac76043af10ce7c213e5001568ca6b4b62ae9631f0994ed676b07118074
2022-03-14 10:31:25 +00:00
MarcoFalke
e0881aa5f0
Merge bitcoin/bitcoin#24505: wallet: Add a deprecation warning for newly created legacy wallets
61152183ab wallet: Add a deprecation warning for newly created legacy wallets (Andrew Chow)

Pull request description:

  As we slowly deprecate legacy wallets, we need to warn users that are making new legacy wallets that their wallet type is going to be unsupported in the future.

ACKs for top commit:
  jonatack:
    ACK 61152183ab
  S3RK:
    reACK 61152183ab
  theStack:
    ACK 61152183ab

Tree-SHA512: e89bfb8168869542498958f0c9a2ab302dfd43287f8a49e7d9e09f60438a567bb8b7219a4e569797ee819b30b624f532fcc0b70c6aa0edcb392a301b8ce8b541
2022-03-14 08:37:46 +01:00
Gleb Naumenko
77ccb7fce1
Use std::chrono for salting when randomizing ADDR destination 2022-03-13 16:40:36 +01:00
MarcoFalke
e04720ec33
Merge bitcoin/bitcoin#24528: rpc: rename getdeploymentinfo status-next to status_next
5d7c69b887 rpc: rename getdeploymentinfo status-next to status_next (Jon Atack)

Pull request description:

  Rename the `status-next` field to `status_next` in getdeploymentinfo before the RPC is released in v23.

  Before
  ```
  Result:
  {                                       (json object)
    "hash" : "str",                       (string) requested block hash (or tip)
    "height" : n,                         (numeric) requested block height (or tip)
    "deployments" : {                     (json object)
      "xxxx" : {                          (json object) name of the deployment
        "type" : "str",                   (string) one of "buried", "bip9"
        "height" : n,                     (numeric, optional) height of the first block which the rules are or will be enforced (only for "buried" type, or "bip9" type with "active" status)
        "active" : true|false,            (boolean) true if the rules are enforced for the mempool and the next block
        "bip9" : {                        (json object, optional) status of bip9 softforks (only for "bip9" type)
          "bit" : n,                      (numeric, optional) the bit (0-28) in the block version field used to signal this softfork (only for "started" and "locked_in" status)
          "start_time" : xxx,             (numeric) the minimum median time past of a block at which the bit gains its meaning
          "timeout" : xxx,                (numeric) the median time past of a block at which the deployment is considered failed if not yet locked in
          "min_activation_height" : n,    (numeric) minimum height of blocks for which the rules may be enforced
          "status" : "str",               (string) status of deployment at specified block (one of "defined", "started", "locked_in", "active", "failed")
          "since" : n,                    (numeric) height of the first block to which the status applies
          "status-next" : "str",          (string) status of deployment at the next block
          "statistics" : {                (json object, optional) numeric statistics about signalling for a softfork (only for "started" and "locked_in" status)
            "period" : n,                 (numeric) the length in blocks of the signalling period
            "threshold" : n,              (numeric, optional) the number of blocks with the version bit set required to activate the feature (only for "started" status)
            "elapsed" : n,                (numeric) the number of blocks elapsed since the beginning of the current period
            "count" : n,                  (numeric) the number of blocks with the version bit set in the current period
            "possible" : true|false       (boolean, optional) returns false if there are not enough blocks left in this period to pass activation threshold (only for "started" status)
          },
          "signalling" : "str"            (string) indicates blocks that signalled with a # and blocks that did not with a -
        }
      }
    }
  }
  ```
  After
  ```
  Result:
  {                                       (json object)
    "hash" : "str",                       (string) requested block hash (or tip)
    "height" : n,                         (numeric) requested block height (or tip)
    "deployments" : {                     (json object)
      "xxxx" : {                          (json object) name of the deployment
        "type" : "str",                   (string) one of "buried", "bip9"
        "height" : n,                     (numeric, optional) height of the first block which the rules are or will be enforced (only for "buried" type, or "bip9" type with "active" status)
        "active" : true|false,            (boolean) true if the rules are enforced for the mempool and the next block
        "bip9" : {                        (json object, optional) status of bip9 softforks (only for "bip9" type)
          "bit" : n,                      (numeric, optional) the bit (0-28) in the block version field used to signal this softfork (only for "started" and "locked_in" status)
          "start_time" : xxx,             (numeric) the minimum median time past of a block at which the bit gains its meaning
          "timeout" : xxx,                (numeric) the median time past of a block at which the deployment is considered failed if not yet locked in
          "min_activation_height" : n,    (numeric) minimum height of blocks for which the rules may be enforced
          "status" : "str",               (string) status of deployment at specified block (one of "defined", "started", "locked_in", "active", "failed")
          "since" : n,                    (numeric) height of the first block to which the status applies
          "status_next" : "str",          (string) status of deployment at the next block
          "statistics" : {                (json object, optional) numeric statistics about signalling for a softfork (only for "started" and "locked_in" status)
            "period" : n,                 (numeric) the length in blocks of the signalling period
            "threshold" : n,              (numeric, optional) the number of blocks with the version bit set required to activate the feature (only for "started" status)
            "elapsed" : n,                (numeric) the number of blocks elapsed since the beginning of the current period
            "count" : n,                  (numeric) the number of blocks with the version bit set in the current period
            "possible" : true|false       (boolean, optional) returns false if there are not enough blocks left in this period to pass activation threshold (only for "started" status)
          },
          "signalling" : "str"            (string) indicates blocks that signalled with a # and blocks that did not with a -
        }
      }
    }
  }
  ```

Top commit has no ACKs.

Tree-SHA512: 4facfd7af3cfb7b6f5495758c4387602802f5e39d9270b162d17350a7f954eab0b74d895f17f0d8dfbc7814d36db7cff56d08c42728432885ea6f4e37aea4aa8
2022-03-13 10:23:20 +01:00
MarcoFalke
2860a91df0
Merge bitcoin/bitcoin#24527: test: set segwit height back to 0 on regtest
5ce3057c8e test: set segwit height back to 0 on regtest (Martin Zumsande)

Pull request description:

  The change of `consensus.SegwitHeight` from 0 to 1 for regtest in #22818 had the effect that if I create a regtest enviroment with  current master (or 23.x), and then try to load this chain with an older version (22.x), I get an InitError
  `Witness data for blocks after height 0 requires validation. Please restart with -reindex`
  and have to reindex because `BLOCK_OPT_WITNESS` is no longer set for the Genesis block and `NeedsRedownload()` in validation returns `true` with an older version.
  That might be a bit annoying for tests that use a shared regtest dir with different versions.

  If people think this is enough of an issue to be worth fixing, I think it should also make it into 23.x

ACKs for top commit:
  theStack:
    Concept and code-review ACK 5ce3057c8e

Tree-SHA512: b0e89ff7fc953bc0ae929d2da44cde7149321d987fb4763934f6c9635d00d807129a50b459cc5e69e86bb1819e4b063b969486e8016a1cb8db8f905fa315653d
2022-03-13 10:20:15 +01:00
MarcoFalke
e7db4e245a
Merge bitcoin/bitcoin#24164: build: Bump minimum required clang/libc++ to 8.0
fae20e6b50 Revert "Avoid the use of P0083R3 std::set::merge" (MarcoFalke)
fab53b5fd4 ci/doc: Set minimum required clang/libc++ version to 8.0 (MarcoFalke)

Pull request description:

  This is not for 23.0, but for 24.0. It comes with the following benefits:

  * Can use C++17 P0083R3 std::set::merge from libc++ 8.0
  * No longer need to provide support for clang-7, which already fails to compile on some architectures (https://github.com/bitcoin/bitcoin/issues/21294#issuecomment-998098483)

  This should be fine, given that all supported operating systems ship with at least clang-10:

  * CentOS 8: clang-12
  * Stretch: https://packages.debian.org/stretch/clang-11
  * Buster: https://packages.debian.org/buster-backports/clang-11
  * Bionic: https://packages.ubuntu.com/bionic-updates/clang-10
  * Focal: https://packages.ubuntu.com/focal/clang-10

ACKs for top commit:
  fanquake:
    ACK fae20e6b50 - I think this is fine to do. I would be surprised if in another 6 months time someone was stuck on a system we supported, needing to compile Core, and only had access to Clang 7 or older. As mentioned in the PR description, all systems we currently support, already support multiple newer versions of Clang.
  hebasto:
    ACK fae20e6b50, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: 3b4c6c130ff40dd7e84934af076863415e5dd661d823c72e3e3832566c65be6e877a7ef9164bbcf394bcea4b897fc29a48db0f231c22ace0e2c9b5638659a628
2022-03-12 10:37:05 +01:00
MarcoFalke
fafd40b541
refactor: Avoid int64_t -> size_t -> int64_t conversion 2022-03-11 17:52:48 +01:00
MarcoFalke
fa2a5f301a
rpc: Move mempool RPCs to new file
Can be reviewed with:
--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2022-03-11 17:46:58 +01:00
Andrew Chow
c109e7d51c
Merge bitcoin/bitcoin#24530: wallet: assert BnB's internally calculated waste is the same as GetSelectionWaste
ec7d73628a [wallet] assert BnB internally calculated waste is the same as GetSelectionWaste() (glozow)

Pull request description:

  #22009 introduced a `GetSelectionWaste()` function to determine how much "waste" a coin selection solution has, and is a mirror of the waste calculated inside of `SelectCoinsBnB()`. It would be bad for these two waste metrics to deviate, since it could negatively affect how often we select the BnB solution. Add an assertion to help tests catch a potential accidental change.

ACKs for top commit:
  achow101:
    ACK ec7d73628a
  Xekyo:
    ACK ec7d73628a

Tree-SHA512: 3ab7ad45ae92e7ce3f21824fb975105b6be8382edf47c252df5d13d973a3abdcb675132d223b42fcbb669cca879672c904b8a58d0676e12bf381a9219f4db37c
2022-03-11 16:40:17 +00:00
MarcoFalke
a81717443f
Merge bitcoin/bitcoin#24453: Bugfix: doc: Correct change_address/changeAddress in wallet RPC help
e8272024ab doc: Use human-friendly DefaultHint for change_address/changeAddress in wallet RPC help (Luke Dashjr)
9d5e693c9d Bugfix: doc: Correct type of change_address/changeAddress in wallet RPC help (STR, not STR_HEX) (Luke Dashjr)

Pull request description:

ACKs for top commit:
  achow101:
    ACK e8272024ab

Tree-SHA512: da4db2b241160c93ea66f8c572c69d4688f52a5fd8c32b66b1192925fcb360baf91be9771eaca178f5b08e1920559174260ed57caddcffade48156ec0c83c0bc
2022-03-11 16:11:17 +01:00
fanquake
23e8c702bc
Merge bitcoin/bitcoin#24421: miner: always assume we can build witness blocks
40e871d9b4 [miner] always assume we can create witness blocks (glozow)

Pull request description:

  Given the low possibility of a reorg reverting the segwit soft fork, there is no longer a need to check whether segwit is active to see if it's okay to add to the block template (see also #23512, #21009, etc). `TestBlockValidity()` is also run on the block template at the end of `CreateNewBlock()`, so any invalid block would be caught there.

ACKs for top commit:
  gruve-p:
    ACK 40e871d9b4
  jnewbery:
    utACK 40e871d9b4, although I disagree about changing the test for segwit transaction in mempool before activagtion, instead of just removing it: https://github.com/bitcoin/bitcoin/pull/24421#discussion_r822933721.
  achow101:
    ACK 40e871d9b4
  theStack:
    Code-review ACK 40e871d9b4

Tree-SHA512: bf4860bf2bed8339622d05228d11d60286edb0c32a9a3c434b8d154913c07ea56e50649f4af7009c2a1c6a58a81d2299ab43b41a6f16dee7d08cc89cc1603019
2022-03-11 15:00:38 +00:00
glozow
ec7d73628a [wallet] assert BnB internally calculated waste is the same as GetSelectionWaste()
These two implementations of waste calculation should never deviate.
Still keep the SelectCoinsBnB internal calculation because incremental
calculate-as-you-go is much more performant than calling
GetSelectionWaste() over and over again.
2022-03-11 12:22:34 +00:00
Jon Atack
5d7c69b887
rpc: rename getdeploymentinfo status-next to status_next 2022-03-11 10:21:48 +01:00
Martin Zumsande
5ce3057c8e test: set segwit height back to 0 on regtest
This was changed in #22818 from 0 to 1. Since it changes
BLOCK_OPT_WIT of the genesis block, older versions of bitcoin
core would not read regtest directories created with newer versions
without a reindex.
2022-03-10 20:24:11 +01:00
Hennadii Stepanov
93feabcb30
Merge bitcoin-core/gui#563: qt: Remove network detection based on address in BIP21
b7dbc83f23 qt: Remove network detection based on address in BIP21 (laanwj)

Pull request description:

  This is removes some ugly and brittle code that switches the global network to testnet based on a provided address. I think in practice it's very unlikely for testnet BIP21 payment URIs to be used, and if so it's for testing so it's easy enough to manually copy it. Or to specify `-testnet` explicitly.

  There is already no such case for `-regtest` or `-signet`.

  After this change it will only accept addresses for the explicitly selected network. Others will result in a "wrong network" popup.

  There is also a possibility for refactor after this as the initialization order of `PaymentServer::ipcParseCommandLine` isn't important anymore (well, it still has to be before `PaymentServer::ipcSendCommandLine`, maybe even merged with it), but I have not done so here.

ACKs for top commit:
  jonatack:
    ACK  b7dbc83f23
  achow101:
    ACK b7dbc83f23

Tree-SHA512: ebc77c0e5c98f53fe254bcd0f94c9d1c06937b794346e95b14158860d5c607515e71d73b782d2726674dce86d6d4001085d473c6d1bc11c5e6c25ff3fb3cfa22
2022-03-10 15:57:03 +01:00
fanquake
6c37eae0ad
Merge bitcoin/bitcoin#24404: refactor: Remove confusing P1008R1 violation in ATMPArgs
faa1aec26b Remove confusing P1008R1 violation in ATMPArgs (MarcoFalke)

Pull request description:

  The `= delete` doesn't achieve the stated goal and it is also redundant, since it is not possible to default construct the `ATMPArgs` type.

  This can be tested with:

  ```diff
  diff --git a/src/validation.cpp b/src/validation.cpp
  index 2813b62462..1c939c0b8a 100644
  --- a/src/validation.cpp
  +++ b/src/validation.cpp
  @@ -519,6 +519,7 @@ public:
           /** Parameters for child-with-unconfirmed-parents package validation. */
           static ATMPArgs PackageChildWithParents(const CChainParams& chainparams, int64_t accept_time,
                                                   std::vector<COutPoint>& coins_to_uncache) {
  +            ATMPArgs{};
               return ATMPArgs{/* m_chainparams */ chainparams,
                               /* m_accept_time */ accept_time,
                               /* m_bypass_limits */ false,
  ```

  Which fails on current master *and* this pull with the following error:

  ```
  validation.cpp:525:22: error: reference member of type 'const CChainParams &' uninitialized
              ATMPArgs{};
                      ~^
  validation.cpp:470:29: note: uninitialized reference member is here
          const CChainParams& m_chainparams;
                              ^
  1 error generated.
  ```

  Further reading (optional):
  * http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p1008r1.pdf

ACKs for top commit:
  achow101:
    ACK faa1aec26b
  glozow:
    code review ACK faa1aec26b

Tree-SHA512: 16db2c9959a1996eafbfa533dc4d1483761b9d28295aed5a82b86abd7268da37c51c59ddc67c205165ecb415dbe637b12a0e1b3234d50ab0b3b79de66d7bd73e
2022-03-10 13:57:36 +00:00
fanquake
4f5d3ce5a0
Merge bitcoin/bitcoin#24486: wallet: refactor: dedup sqlite blob binding
8ea6167099 wallet: refactor: dedup sqlite blob binding (Sebastian Falbesoner)

Pull request description:

  This refactoring PR deduplicates repeated SQLite blob binding to a statement with a newly introduced helper function `BindBlobToStatement`, abstracting away the calls to `sqlite3_bind_blob(...)`.
  This should be more readable and less error-prone, e.g. in case that the error handling has to be adapted. As a slight drawback, the function where the binding happens is not printed anymore (`__func__`), i.e. one could argue this is not strictly a refactoring, but IMHO the advantages of deduplication outweigh this; binding errors are purely internal logic errors (wrong use of the sqlite API) rather than something that is dependend on external data like DB content.

ACKs for top commit:
  laanwj:
    Code review ACK 8ea6167099
  achow101:
    ACK 8ea6167099
  klementtan:
    ACK 8ea6167099

Tree-SHA512: 1de0d214f836bc405a01e98a3a2d71f2deaddc7d23c31cad80219d1614bec92619c06d9a4a091dd563d3e95ffb879649c29745d8f89669b2a5330552c212af3f
2022-03-10 12:40:20 +00:00
Andrew Chow
61152183ab wallet: Add a deprecation warning for newly created legacy wallets 2022-03-10 07:32:02 -05:00
MarcoFalke
fa9112aac0
Remove utxo db upgrade code 2022-03-10 13:05:29 +01:00
laanwj
b7dbc83f23 qt: Remove network detection based on address in BIP21
This is some very ugly and brittle code that switches the global network
based on a provided address, remove it. I think in practice it's very
unlikely for testnet BIP21 payment URIs to be used, and if so it's for
testing so it's easy enough to manually copy it. Or to specify
`-testnet` explicitly.

There is already no case for `-regtest` or `-signet`.
2022-03-10 12:56:19 +01:00
MarcoFalke
76d44e832f
Merge bitcoin/bitcoin#24469: test: Correctly decode UTF-8 literal string paths
2f5fd3cf92 test: Correctly decode UTF-8 literal string paths (Ryan Ofsky)

Pull request description:

  Call `fs::u8path()` to convert some UTF-8 string literals to paths, instead of relying on the implicit conversion. Fake Macro pointed out in https://github.com/bitcoin/bitcoin/pull/24306#discussion_r818566106 that `fs_tests` are incorrectly decoding some literal UTF-8 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 under.

  The `fs::path` class exists to avoid problems like this, but because it is lenient with `const char*` conversions, under assumption that they are ["safe as long as the literals are ASCII"](727b0cb592/src/fs.h (L39)), bugs like this are still possible.

  If we think this is a concern, followup options to try to prevent this bug in the future are:

  0. Do nothing
  1. Improve the "safe as long as the literals are ASCII" comment. Make it clear that non-ASCII strings are invalid.
  2. Drop the implicit `const char*` conversion functions. This would be nice because it would simplifify the `fs::path` class a little, while making it safer. Drawback is that it would require some more verbosity from callers. For example, instead of `GetDataDirNet() / "mempool.dat"` they would have to write `GetDataDirNet() / fs::u8path("mempool.dat")`
  3. Keep the implicit `const char*` conversion functions, but make them call `fs::u8path()` internally. Change the "safe as long as the literals are *ASCII*" comment to "safe as long as the literals are *UTF-8*".

  I'd be happy with 0, 1, or 2. I'd be a little resistant to 3 even though it was would add more safety, because it would slightly increase complexity, and because I think it would encourage representing paths as strings, when I think there are so many footguns associated with paths as strings, that it's best to convert strings to paths at the earliest point possible, and convert paths to strings at the latest point possible.

ACKs for top commit:
  laanwj:
    Code review ACK 2f5fd3cf92
  w0xlt:
    crACK 2f5fd3c

Tree-SHA512: 9c56714744592094d873b79843b526d20f31ed05eff957d698368d66025764eae8bfd5305d5f7b6cc38803f0d85fa5552003e5c6cacf1e076ea6d313bcbc960c
2022-03-10 12:49:50 +01:00
stickies-v
a09497614e
Add GetQueryParameter helper function
Easily get the query parameter from the URI, with optional default value.
2022-03-10 12:01:54 +01:00
stickies-v
fff771ee86
Handle query string when parsing data format
URLs may contain a query string (prefixed with '?') and this should be ignored when parsing
the data format.

To facilitate testing this functionality, ParseDataFormat has been made non-static.
2022-03-10 12:01:53 +01:00
stickies-v
c1aad1b3b9
scripted-diff: rename RetFormat to RESTResponseFormat
As RetFormat is now exposed in a header, it is renamed to the more
understandable RESTResponseFormat
-BEGIN VERIFY SCRIPT-
s() { sed -i 's/RetFormat/RESTResponseFormat/g' $1; }
s src/rest.cpp
s src/rest.h
-END VERIFY SCRIPT-
2022-03-10 11:29:09 +01:00
stickies-v
9f1c54787c
Refactoring: move declarations to rest.h
This facilitates unit testing
2022-03-10 11:24:15 +01:00
MarcoFalke
5e33620ad8
Merge bitcoin/bitcoin#24371: util: Fix ReadBinaryFile reading beyond maxsize
a84650ebd5 util: Fix ReadBinaryFile reading beyond maxsize (klementtan)

Pull request description:

  Currently `ReadBinaryFile` will read beyond `maxsize` if `maxsize` is not a multiple of `128` (size of buffer)

  This is due to `fread` being called with `count = 128` instead of `count = min(128, maxsize - retval.size()` at every iteration

  The following unit test will fail:
  ```cpp
  BOOST_AUTO_TEST_CASE(util_ReadWriteFile)
  {
    fs::path tmpfolder = m_args.GetDataDirBase();
    fs::path tmpfile = tmpfolder / "read_binary.dat";
    std::string expected_text(300,'c');
    {
        std::ofstream file{tmpfile};
        file << expected_text;
    }
    {
        // read half the contents in file
        auto [valid, text] = ReadBinaryFile(tmpfile, expected_text.size() / 2);
        BOOST_CHECK_EQUAL(text.size(), 150);
    }
  }
  ```
  Error:
  ```
  test/util_tests.cpp:2593: error: in "util_tests/util_ReadWriteFile": check text.size() == 150 has failed [256 != 150]
  ```

ACKs for top commit:
  laanwj:
    Code review ACK a84650ebd5
  theStack:
    Code-review ACK a84650ebd5

Tree-SHA512: 752eebe58bc2102dec199b6775f8c3304d899f0ce36d6a022a58e27b076ba945ccd572858b19137b769effd8c6de73a9277f641be24dfb17657fb7173ea0eda0
2022-03-10 10:24:05 +01:00
Carl Dong
3bbb6fea05 style-only: Various blockstorage.cpp cleanups 2022-03-09 14:32:49 -05:00
Anthony Towns
5be9ee3c54 refactor: more const annotations for uses of CBlockIndex* 2022-03-09 14:32:47 -05:00
Andrew Chow
47bbd3ff4f
Merge bitcoin/bitcoin#24498: qt: Avoid crash on startup if int specified in settings.json
5b1aae12ca qt: Avoid crash on startup if int specified in settings.json (Ryan Ofsky)
84b0973e35 test: Add tests for GetArg methods / settings.json type coercion (Ryan Ofsky)

Pull request description:

  Should probably add this change to 23.x as suggested by Luke https://github.com/bitcoin/bitcoin/issues/24457#issuecomment-1059825678. If settings like `prune` are added to `settings.json` in the future, it would be preferable for 23.x releases to respect the setting instead of crash.

  ---

  Fix GUI startup crash reported by Rspigler in https://github.com/bitcoin/bitcoin/issues/24457 that happens if `settings.json` contains an integer value for any of the configuration options which GUI settings can currently clash with (-dbcache, -par, -spendzeroconfchange, -signer, -upnp, -natpmp, -listen, -server, -proxy, -proxy, -onion, -onion, -lang, and -prune).

  The fix is a one-line change in `ArgsManager::GetArg`. The rest of the PR just adds a regression test for the GUI and unit tests for ArgsManager::GetArg methods.

ACKs for top commit:
  laanwj:
    Code review ACK 5b1aae12ca
  achow101:
    ACK 5b1aae12ca
  jonatack:
    Code review ACK 5b1aae12ca

Tree-SHA512: 958991b4bead9b82a3879fdca0f8d6405e2a212b7c46cf356f078843a4f156e27fd75fc46e2013aa5159582ead06d343c1ed248d678b3e5bbd312f247e37894c
2022-03-09 10:54:48 -05:00
MarcoFalke
7003b6ab24
Merge bitcoin/bitcoin#24138: index: Commit MuHash and best block together for coinstatsindex
691d45fdc8 Add coinstatsindex_unclean_shutdown test (Ryan Ofsky)
eb6cc05da3 index: Commit DB_MUHASH and DB_BEST_BLOCK to disk together (Martin Zumsande)

Pull request description:

  Fixes #24076

  Coinstatsindex currently writes the MuHash (`DB_MUHASH`) to disk in `CoinStatsIndex::WriteBlock()` and `CoinStatsIndex::ReverseBlock()`, but the best synced block is written in `BaseIndex::Commit()`. These are called at different points in time, both during the ThreadSync phase, and also after the initial sync is finished and validation callbacks (`BlockConnected()` vs `ChainStateFlushed()`) perform the syncing.

  As a result, the index DB is temporarily in an inconsistent state, and if bitcoind is terminated uncleanly (so that there is no time to call `Commit()` by receiving an interrupt or by flushing the chainstate) this leads to problems:
  On the next startup, `Init()` will read the best block and a MuHash that corresponds to a different (higher) block. Indexing will  be picked up at the the best block processing some blocks again, but since MuHash is a rolling hash, it will process some utxos twice and the muhashes for all future blocks will be wrong, as was observed in #24076.

  Fix this by always committing `DB_MUHASH` together with `DB_BEST_BLOCK`.

  Note that the block data for the index is still written at different times, but this does not corrupt the index - at worst, these entries will be processed another time and overwritten after an unclean shutdown and restart.

ACKs for top commit:
  ryanofsky:
    Code review ACK 691d45fdc8. Only change since last review is adding test
  fjahr:
    ACK 691d45fdc8

Tree-SHA512: e1c3b5f06fa4baacd1b070abb0f8111fe2ea4a001ca8b8bf892e96597cf8b5d5ea10fa8fb837cfbf46648f052c742d912add4ce26d4406294fc5fc20809a0e1b
2022-03-09 11:43:13 +01:00
laanwj
05e5af5a6c
Merge bitcoin/bitcoin#24507: fix CI: bitcoin-chainstate: Lock cs_main to UnloadBlockIndex
7a68fe4831 bitcoin-chainstate: Lock cs_main to UnloadBlockIndex (Carl Dong)

Pull request description:

  This was introduced because of a silent merge conflict.

ACKs for top commit:
  promag:
    ACK 7a68fe4831
  jonatack:
    ACK  7a68fe4831

Tree-SHA512: 4c135efd68604452485a129e731675ff5917c157a70c77dd702211d9902c21b3b29380a881723f43ecba4762bc864b036881bb502b3b792e581565dcaa7a7ed4
2022-03-09 11:16:50 +01:00
Carl Dong
7a68fe4831 bitcoin-chainstate: Lock cs_main to UnloadBlockIndex
This was introduced because of a silent merge conflict.
2022-03-08 16:12:03 -05:00
Andrew Chow
9d22dbe2e1
Merge bitcoin/bitcoin#24198: wallet, rpc: add wtxid in WalletTxToJSON
7abd8b21ba doc: include wtxid in TransactionDescriptionString (brunoerg)
2d596bce6f doc: add wtxid info in release-notes (brunoerg)
a5b66738f1 test: add wtxid in expected_fields for wallet_basic (brunoerg)
e8c659a297 wallet: add wtxid in WalletTxToJSON (brunoerg)
7482b6f895 wallet: add GetWitnessHash() (brunoerg)

Pull request description:

  This PR add `wtxid` in `WalletTxToJSON` which allows to return this field in `listsinceblock`, `listtransactions` and `gettransaction` (RPCs).

ACKs for top commit:
  achow101:
    re-ACK 7abd8b21ba
  w0xlt:
    crACK 7abd8b2
  luke-jr:
    re-utACK 7abd8b21ba

Tree-SHA512: f86f2dbb5e38e7b19932006121802f47b759d31bdbffe3263d1db464f6a3a30fddd68416f886a44f6d3a9fd570f7bd4f8d999737ad95c189e7ae5e8ec1ffbdaa
2022-03-08 14:32:10 -05:00
MarcoFalke
b07fdd7f9e
Merge bitcoin/bitcoin#24312: addrman: Log too low compat value
fa097d074b addrman: Log too low compat value (MarcoFalke)

Pull request description:

  Before this patch, when writing a negative `lowest_compatible` value, it would be read as a positive value. For example `-32` will be read as `224`. There is generally nothing wrong with that. Though, similarly there shouldn't be anything wrong with refusing to read a negative value. I find the code after this patch more logical than before. Also, this allows dropping a file-wide sanitizer suppression.

  In practice none of this should ever happen. Bitcoin Core would never write a negative `lowest_compatible` in normal operation, unless the file storage is later corrupted by external influence.

ACKs for top commit:
  mzumsande:
    re-ACK fa097d074b

Tree-SHA512: 9aae7b8fe666f52f667f149667025e0160cef1a793cc4d392e36608f65c2bee8096da429235118f40a3368f327aabe30f3732ae78c5874648ea6f423f2687b65
2022-03-08 16:48:22 +01:00
Ryan Ofsky
5b1aae12ca qt: Avoid crash on startup if int specified in settings.json
Fix GUI startup crash reported by Rspigler in
https://github.com/bitcoin/bitcoin/issues/24457 that happens if
settings.json contains an integer value for any of the configuration
options which GUI settings can currently clash with (-dbcache, -par,
-spendzeroconfchange, -signer, -upnp, -natpmp, -listen, -server, -proxy,
-proxy, -onion, -onion, -lang, and -prune).

Fix is a one-line change in ArgsManager::GetArg.
2022-03-07 13:29:46 -05:00
Ryan Ofsky
84b0973e35 test: Add tests for GetArg methods / settings.json type coercion
Just add tests. No changes to application behavior. Tests will be
updated in the next commit changing & improving current behavior.

Include a Qt test for GUI startup crash reported by Rspigler in
https://github.com/bitcoin/bitcoin/issues/24457 caused by GetArg
behavior that happens if settings.json contains an integer value for any
of the configuration options which GUI settings can currently clash with
(-dbcache, -par, -spendzeroconfchange, -signer, -upnp, -natpmp, -listen,
-server, -proxy, -proxy, -onion, -onion, -lang, and -prune).
2022-03-07 13:29:46 -05:00
fanquake
c9ed9927bb
Merge bitcoin/bitcoin#24132: build: Bump minimum Qt version to 5.11.3
956f7322f6 build: Bump minimum Qt version to 5.11.3 (Hennadii Stepanov)
e22d10b936 ci: Switch from bionic to buster (Hennadii Stepanov)

Pull request description:

  The current minimum Qt version is 5.9.5 which has been set in bitcoin/bitcoin#21286.

  Distro support:
  - centos 7 -- unsupported since bitcoin/bitcoin#23511
  - centos 8 -- [5.15.2](http://mirror.centos.org/centos/8/AppStream/x86_64/os/Packages/qt5-qtbase-5.15.2-3.el8.x86_64.rpm)
  - buster -- [5.11.3](https://packages.debian.org/buster/libqt5core5a)
  - bullseye  -- [5.15.2](https://packages.debian.org/bullseye/libqt5core5a)
  - _bionic_ -- [5.9.5](https://packages.ubuntu.com/bionic/libqt5core5a)
  - focal -- [5.12.8](https://packages.ubuntu.com/focal/libqt5core5a)

  As another Ubuntu LTS is coming soon, it seems unreasonable to stick to Qt 5.9 which support [ended](https://www.qt.io/blog/2017/06/07/renewed-qt-support-services) on 2020-05-31. Anyway, it's still possible to build Bitcoin Core GUI with depends on bionic system.

  Bumping the minimum Qt version allows to make code safer and more reliable, e.g.:
  - functor-parameter overload of [`QMetaObject::invokeMethod`](https://doc.qt.io/qt-5/qmetaobject.html#invokeMethod-4)
  - fixed https://bugreports.qt.io/browse/QTBUG-10907

  An example of the patch using the functor-overload of `QMetaObject::invokeMethod`:
  ```diff
  --- a/src/qt/walletmodel.cpp
  +++ b/src/qt/walletmodel.cpp
  @@ -349,7 +349,7 @@ bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureStri
   static void NotifyUnload(WalletModel* walletModel)
   {
       qDebug() << "NotifyUnload";
  -    bool invoked = QMetaObject::invokeMethod(walletModel, "unload");
  +    bool invoked = QMetaObject::invokeMethod(walletModel, &WalletModel::unload);
       assert(invoked);
   }

  ```
  It uses the same new syntax as signal-slot connection with compile-time check. Also see bitcoin/bitcoin#16348.

  This PR is intended to be merged early [after](https://github.com/bitcoin/bitcoin/issues/22969) branching `23.x` off.

ACKs for top commit:
  MarcoFalke:
    cr ACK 956f7322f6
  fanquake:
    ACK 956f7322f6

Tree-SHA512: 3d652bcdcd990ce785ad412ed70234d4f27743895e535a53ed44b35d4afc3052e066c4c84f417e30bc53d0a3dd9ebed62444c57b7c765cb1e9aa687fbf866877
2022-03-07 14:53:23 +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
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
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
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
Sebastian Falbesoner
8ea6167099 wallet: refactor: dedup sqlite blob binding 2022-03-06 20:43:16 +01:00
Jon Atack
4d2b503d6c
gui: improve "Addresses Rate-Limited" translator comments and tooltip in peers tab 2022-03-06 17:49:20 +01:00
Jon Atack
81ef1f7ef1
gui: improve "Addresses Processed" translator comments and tooltip in peers tab 2022-03-06 17:49:01 +01:00
Jon Atack
77f24aac52
gui: improve "Address Relay" translator comments and tooltip in peers tab 2022-03-06 17:48:26 +01: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
MarcoFalke
fae20e6b50
Revert "Avoid the use of P0083R3 std::set::merge"
This reverts commit 6cf4ea7187.
2022-03-04 14:13:55 +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
Ben Woosley
9b52672700
For descriptor pubkey parse errors, include context information
Note 'Multi:' is used rather than 'multi():' as it also encompasses 'sortedmulti():'
2022-03-03 17:09:56 +00: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
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
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
Jon Atack
afdf2de282
test: add CJDNS to LimitedAndReachable_Network unit tests 2022-03-01 21:03:21 +01:00
Jon Atack
2b7a8180a9
net, init: assert each network reachability is true by default
The default network reachability values are implicitly set
by this line in net.cpp:

static bool vfLimited[NET_MAX] GUARDED_BY(g_maplocalhost_mutex) = {};

This commit asserts that each network is reachable during
the first loop through them during bitcoind init.
2022-03-01 21:03:18 +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
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
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
MarcoFalke
c7da61dcc3
Merge bitcoin/bitcoin#24403: Avoid implicit-integer-sign-change in VerifyLoadedChainstate
fa7991601c Fixup style of VerifyDB (MarcoFalke)
fa462ea787 Avoid implicit-integer-sign-change in VerifyLoadedChainstate (MarcoFalke)

Pull request description:

  This happens when checking all blocks (`-1`).

  To test:

  ```
  ./configure CC=clang CXX=clang++ --with-sanitizers=undefined,integer
  make
  UBSAN_OPTIONS="suppressions=$(pwd)/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1" ./test/functional/rpc_blockchain.py

ACKs for top commit:
  theStack:
    Code-review ACK fa7991601c
  brunoerg:
    crACK fa7991601c

Tree-SHA512: bcbe6becf2fbedd21bbde83a544122e79465937346802039532143b2e4165784905a8852c0ccb088b964874df5e5550931fdde3629cbcee3ae237f2f63c43a8e
2022-02-28 12:33:32 +01:00
fanquake
b71a07778f
Merge bitcoin/bitcoin#24417: net: Update hardcoded seeds for 23.x
d80dc12097 net: Update hardcoded seeds for 23.x (laanwj)
9f27157894 contrib: make-seeds updates for 23.x (laanwj)

Pull request description:

  Update hardcoded P2P network seeds for 23.x, and update the generation script and documentation as necessary

  Tool output:
  ```
    IPv4   IPv6  Onion Pass
  469910  72944      0 Initial
  469910  72944      0 Skip entries with invalid address
  469910  72944      0 After removing duplicates
  469909  72944      0 Skip entries from suspicious hosts
  165760  65113      0 Enforce minimal number of blocks
  160668  63183      0 Require service bit 1
    4951   1376      0 Require minimum uptime
    4406   1051      0 Require a known and recent user agent
    4307   1031      0 Filter out hosts with multiple bitcoin ports
  ERR: Could not resolve ASN for "2001:678:7dc:8::2": The DNS query name does not exist: 8.0.0.0.c.d.7.0.8.7.6.0.1.0.0.2.origin6.asn.cymru.com.
     512    134      0 Look up ASNs and limit results per ASN and per net
  ```.

ACKs for top commit:
  achow101:
    ACK d80dc12097
  jonatack:
    ACK d80dc12097 reviewed the changes and ran the README steps

Tree-SHA512: c651b0501cc28d397cc0778eff6aed4273669082d6ef207ce58ce198b443be66532bf1e8d618ccae3ba671ae4cccfd9b4dd2dfebacc97f3c3bd4e9fa58a3d7a3
2022-02-28 11:20:51 +00:00
MarcoFalke
40ab879f11
Merge bitcoin/bitcoin#24418: Chainparams update for 23.x
dca693e08e Update nMinimumChainWork, defaultAssumeValid for 23.x (laanwj)
85e71a3baa Update chainTxData for 23.x (laanwj)
37282dcf78 Update m_assumed_* chain parameters for 23.x (laanwj)

Pull request description:

  Update chain parameters for upcoming major release. See [doc/release-process.md](https://github.com/bitcoin/bitcoin/blob/master/doc/release-process.md) for review instructions.

  - `m_assumed_blockchain_size`, `m_assumed_chain_state_size`:

  ```
  bitcoin$ du -h .
  105M    ./blocks/index
  415G    ./blocks
  4.5G    ./chainstate
  420G    .
  bitcoin$ python3
  Python 3.9.10 (main, Jan 16 2022, 17:12:18)
  [GCC 11.2.0] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> 420 * 1.1
  462.00000000000006
  >>> 5 * 1.1
  5.5
  ```

  - `chainTxData`:
  ```
  cli getchaintxstats 4096 000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091
  {
    "time": 1645542140,
    "txcount": 712531200,
    "window_final_block_hash": "000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091",
    "window_final_block_height": 724466,
    "window_block_count": 4096,
    "window_tx_count": 6950257,
    "window_interval": 2404071,
    "txrate": 2.891036496010309
  }
  ```

  - `nMinimumChainWork`, `defaultAssumeValid`:

  ```
  $ cli getblockhash 724466 # was two from the tip at the time
  000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091
  $ cli getblockheader 000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091
  {
    "hash": "000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091",
    "confirmations": 3,
    "height": 724466,
    "version": 939515908,
    "versionHex": "37ffe004",
    "merkleroot": "35a08d9647972e7c3ec39ee7f4ab434f03445de7c446a4d1acc1254b4546bbbe",
    "time": 1645542140,
    "mediantime": 1645539567,
    "nonce": 188699556,
    "bits": "170a1078",
    "difficulty": 27967152532434.23,
    "chainwork": "00000000000000000000000000000000000000002927cdceccbd5209e81e80db",
    "nTx": 1948,
    "previousblockhash": "000000000000000000075e26c23c2ecec4e34699411ccd712ff6f2d252f65a78",
    "nextblockhash": "0000000000000000000905369cd69f68323e3e8da2933a78bea0b2cdb8baa89f"
  }
  ```

ACKs for top commit:
  Sjors:
    ACK dca693e08e
  achow101:
    ACK dca693e08e
  prayank23:
    ACK dca693e08e
  darosior:
    ACK dca693e08e -- only checked mainnet (on muliple nodes). Didn't do a reindex.

Tree-SHA512: 6d5d59f00717fce5f7ce10ec8d59f806ef11b0af21440cec112f70c8e13ebb884ba6c70e744e691fcc31fe7aec7aae968268c9207ccc820d64fdf7e7f98f0cff
2022-02-28 12:09:41 +01:00
eugene
fc471814dc
fuzz: FuzzedFileProvider::write should not return negative value
Doing so can lead to a glibc crash. Also the manpage for fopencookie
warns against this: https://man7.org/linux/man-pages/man3/fopencookie.3.html
2022-02-27 17:03:35 -05:00
Ryan Ofsky
691d45fdc8 Add coinstatsindex_unclean_shutdown test 2022-02-25 16:06:27 -05:00
MarcoFalke
bbbbeaf9c8
fuzz: Limit script_format to 100kB 2022-02-25 17:09:37 +01:00
MarcoFalke
fa097d074b
addrman: Log too low compat value
Also remove uint8_t{} casts from values that are already of the same
type.
2022-02-25 14:16:32 +01:00
MarcoFalke
aaaa4dbab4
Avoid implicit-integer-sign-change in bech32.cpp 2022-02-25 09:43:54 +01:00
MarcoFalke
b00b60ed4f
Merge bitcoin/bitcoin#24201: p2p: Avoid InitError when downgrading peers.dat
d41ed32153 p2p: Avoid InitError when downgrading peers.dat (junderw)

Pull request description:

  fixes #24188 (also see https://github.com/bitcoin/bitcoin/pull/22762#issuecomment-951063826)
  When downgrading, a peers.dat with a future version that has a minimum
  required version larger than the downgraded Bitcoin Core version would cause an InitError.

  This commit changes this behavior to overwrite the existing peers.dat with
  a new empty one.

ACKs for top commit:
  prayank23:
    reACK d41ed32153
  kallewoof:
    reACK d41ed32153

Tree-SHA512: c8e625fe36ce0b1aab6c8ef7241c8954038bb856f2de27bdc4814dc9a60e51be28815c7d77d0f96eace49687a0cea02deb713978bbd3a5add742f50a675f2a40
2022-02-25 08:45:11 +01:00
junderw
d41ed32153
p2p: Avoid InitError when downgrading peers.dat
fixes #24188
When downgrading, a peers.dat with a future version that has a minimum
required version larger than the downgraded version would cause an InitError.

This commit changes this behavior to overwrite the existing peers.dat with
a new empty one, while creating a backup in peers.dat.bak.
2022-02-25 09:53:10 +09:00
w0xlt
ad6adedb46 qt, refactor: remove unused parameters in TransactionDesc::FormatTxStatus() 2022-02-24 13:47:53 -03:00
w0xlt
045f8d0310 scripted-diff: rename nDepth -> depth
-BEGIN VERIFY SCRIPT-
s() { sed -i -e 's/nDepth/depth/g' $(git grep -l 'nDepth' $1); }
s src/qt/transactiondesc.cpp
-END VERIFY SCRIPT-
2022-02-24 13:47:53 -03:00
w0xlt
b1bc1431db qt, refactor: remove redundant scope in TransactionDesc::FormatTxStatus() 2022-02-24 13:47:53 -03:00
laanwj
dca693e08e Update nMinimumChainWork, defaultAssumeValid for 23.x
Co-authored-by: Suhas Daftuar <sdaftuar@gmail.com>
2022-02-24 16:19:09 +01:00
laanwj
85e71a3baa Update chainTxData for 23.x
Co-authored-by: Suhas Daftuar <sdaftuar@gmail.com>
2022-02-24 16:19:09 +01:00
laanwj
37282dcf78 Update m_assumed_* chain parameters for 23.x
- `m_assumed_chain_state_size` doesn't seem to need to be changed for mainnet.
- No change needed for testnet/signet.

Co-authored-by: Suhas Daftuar <sdaftuar@gmail.com>
2022-02-24 14:06:53 +01:00
Sjors Provoost
026b5b4523
move-only: helper function to present PSBT
This commit does not change behavior.

Review hint:
git show --color-moved --color-moved-ws=allow-indentation-change
2022-02-24 12:41:47 +01:00
laanwj
38020c4f2e qt: English (source) translations update
Last-minute update for bitcoin/bitcoin#24434 and bitcoin/bitcoin#24401.
2022-02-24 12:40:00 +01:00
Hennadii Stepanov
ff33c5ae63
Add missed word to error message 2022-02-24 02:59:38 +02:00