21216 Commits

Author SHA1 Message Date
Anthony Towns
06731d19bc net_processing: Boost inv trickle rate
If transactions are being added to the mempool at a rate faster than 7tx/s
(INVENTORY_BROADCAST_PER_SECOND) then peers' inventory_to_send queue can
become relatively large. If this happens, increase the number of txids
we include in an INV message (normally capped at 35) by 5 for each 1000
txids in the queue.

This will tend to clear a temporary excess out reasonably quickly; an
excess of 4000 invs to send will be cleared down to 1000 in about 30
minutes, while an excess of 20000 invs would be cleared down to 1000 in
about 60 minutes.

Github-Pull: #27610
Rebased-From: 5b3406094f
2023-05-11 17:20:38 +01:00
Anthony Towns
d0a2c87214 txmempool: have CompareDepthAndScore sort missing txs first
We use CompareDepthAndScore to choose an order of txs to inv. Rather
than sorting txs that have been evicted from the mempool at the end
of the list, sort them at the beginning so they are removed from
the queue immediately.

Github-Pull: #27610
Rebased-From: 228e9201ef
2023-05-11 17:12:11 +01:00
Suhas Daftuar
ce8f812b0a p2p: Avoid prematurely clearing download state for other peers
Github-Pull: #27608
Rebased-From: 52e52071e0
2023-05-11 10:21:18 +01:00
fanquake
af86266165 23.x Add missing includes to fix gcc-13 compile error
Additional include fixes are required to make the 23.x branch compile
using GCC 13.
2023-01-20 11:55:29 +00:00
MarcoFalke
398768769f Add missing includes to fix gcc-13 compile error
Github-Pull: #26924
Rebased-From: fadeb6b103
2023-01-20 10:29:35 +00:00
Martin Zumsande
412cd1a34e addrdb: Only call Serialize() once
The previous logic would call it once for serializing into the filestream,
and then again for serializing into the hasher. If AddrMan was changed
in between these calls by another thread, the resulting peers.dat would
be corrupt with non-matching checksum and data.
Fix this by using HashedSourceWriter, which writes the data
to the underlying stream and keeps track of the hash in one go.

Github-Pull: #26909
Rebased-From: 5eabb61b23
2023-01-19 15:13:39 +00:00
Martin Zumsande
fd94befbc6 hash: add HashedSourceWriter
This class is the counterpart to CHashVerifier, in that it
writes data to an underlying source stream,
while keeping a hash of the written data.

Github-Pull: #26909
Rebased-From: da6c7aeca3
2023-01-19 15:13:21 +00:00
Hennadii Stepanov
38d90bc3e3 qt: 23.1rc2 translations update 2022-11-21 11:11:03 +00:00
John Moffett
e54a4deff8 Fixes bitcoin#26490 by preventing notifications
MacOS 13 sends a window focus change notification after the main
window has been destroyed but before the QTApplication has been
destroyed. This results in the menu bar receiving a notification
despite it no longer existing. The solution is to pass the main
window as context when subscribing to the notifications. Qt
automatically unsubscribes to notifications if the sender OR
context is destroyed.

Github-Pull: bitcoin-core/gui#680
Rebased-From: 8a5014cd8a
2022-11-17 14:39:26 +00:00
Hennadii Stepanov
22ffb150ac qt: 23.1rc1 translations update 2022-11-05 08:44:20 +00:00
muxator
d9f1c89e49 rpc: fix crash in deriveaddresses when derivation index is 2147483647
2147483647 is the maximum positive value of a signed int32, and - currently -
the maximum value that the deriveaddresses bitcoin RPC call accepts as
derivation index due to its input validation routines.

Before this change, when the derivation index (and thus range_end) reached
std::numeric_limits<int_32_t>::max(), the "i" variable in the for cycle (which
is declared as int, and as such 32 bits in size on most platforms) would be
incremented at the end of the first iteration and then warp back to
-2147483648. This caused SIGABRT in bitcoind and a core dump.

This change assigns "i" an explicit size of 64 bits on every platform,
sidestepping the problem.

Fixes #26274.

Github-Pull: #26275
Rebased-From: addf9d6502
2022-10-28 18:14:51 +08:00
MacroFake
40b69fb06e Merge bitcoin/bitcoin#26033: [23.x] Prevent data race for pathHandlers
38d4601fe8 Prevent data race for `pathHandlers` (Hennadii Stepanov)

Pull request description:

  Backport of https://github.com/bitcoin/bitcoin/pull/25983 to the 23.x branch.

ACKs for top commit:
  dergoegge:
    ACK 38d4601fe8

Tree-SHA512: b235d6d2cb374baf1b54c09f4cd2feca7b6c1588d081532e987fd5def8ed0dee4b8255112b130a77aca633ec6a63cfd81f215b2e7a403c213eb6048a54774d26
2022-10-24 11:47:03 +02:00
Hennadii Stepanov
38d4601fe8 Prevent data race for pathHandlers
Github-Pull: bitcoin/bitcoin#25983
Rebased-From: 4296dde287
2022-09-07 12:14:53 +02:00
Andrew Chow
31ca698f20 Disallow encryption of watchonly wallets
Watchonly wallets do not have any private keys to encrypt. It does not
make sense to encrypt such wallets, so disable the option to encrypt
them.

This avoids an assertion that can be hit when encrypting watchonly descriptor
wallets.

Github-Pull: bitcoin-core/gui#631
Rebased-From: 4c495413e1
2022-08-12 10:27:56 +01:00
Martin Zumsande
4ebf6e35dc p2p: always set nTime for self-advertisements
If we self-advertised to an inbound peer with the address they gave us,
nTime was left default-initialized, so that our peer wouldn't relay it
any further along.

Github-Pull: #25314
Rebased-From: 99b9e5f3a9
2022-06-22 11:39:16 +01:00
brunoerg
7658055c4e rpc: fix inappropriate warning for address type p2sh-segwit in createmultisig and addmultisigaddress
Github-Pull: #25220
Rebased-From: eaf6f630c0
2022-06-09 12:05:04 +01:00
laanwj
c3936cc53d Merge bitcoin/bitcoin#25241: [23.x] rpc: Capture potentially large UniValue by ref for rpcdoccheck
7fcac96597 rpc: Capture potentially large UniValue by ref for rpcdoccheck (Martin Zumsande)

Pull request description:

ACKs for top commit:
  fanquake:
    ACK 7fcac96597

Tree-SHA512: 7b60d35c84a47ff2b16aed06b4ea82ff3f60cc24409e2927b9ed618f8f939252903417ef93b711171e22b15daf5d857964687fde25ec554153337c996e5e27fa
2022-05-30 19:47:36 +02:00
Martin Zumsande
7fcac96597 rpc: Capture potentially large UniValue by ref for rpcdoccheck
Github-Pull: 25237
Rebased-From: 20ff4991e5
2022-05-30 10:46:02 +02:00
laanwj
cf42ffdaca qt: 23.0rc5 translations update
Tree-SHA512: 86a246bf5a817084f077ace118edad16dc48d06ec8d39476d82d6d6c5010bde9ec91eec00d7bd9736fc3ecfd1b67629f06e38798d484e6a0f09768553a52a231
2022-04-14 18:05:02 +02:00
laanwj
d37081e483 qt: 23.0rc4 translations update
Tree-SHA512: 1bf7ac70963fc6361b5cd117612355e6d4b1862721441003eb7b11f8366a706cb83d45a46533bfad421d7ea0dd12931b4e37881818eb0f0be845de19b823f98c
2022-04-08 16:05:58 +02:00
Luke Dashjr
e3e4be9cd5 RPC: Switch getblockfrompeer back to standard param name blockhash
This commit partially reverts 923312fbf6.

Github-Pull: #24806
Rebased-From: 88917f93cc
2022-04-08 13:27:19 +01:00
Jon Atack
6374e24887 Put lock logging behind DEBUG_LOCKCONTENTION preprocessor directive
Github-Pull: #24770
Rebased-From: 39a34b6877
2022-04-08 13:26:34 +01:00
MarcoFalke
e089c68aa1 Merge bitcoin/bitcoin#24725: 23.0: rc4 backport
1448c99380 wallet: Postpone NotifyWalletLoaded() for encrypted wallets (Hennadii Stepanov)
4f3ba8517a wallet, refactor: Add wallet::NotifyWalletLoaded() function (Hennadii Stepanov)

Pull request description:

ACKs for top commit:
  Sjors:
    ACK 1448c99380
  hebasto:
    ACK 1448c99380
  jarolrod:
    ACK 1448c99380

Tree-SHA512: 84d908ff40f0048394f74499a9640904eb244bae975648221a883ab6ef6c5d5d7c178c17e5e420b565000c6d9cea26769fa9dd7c53ae10e32fa15748940ea796
2022-04-01 08:48:42 +02:00
Hennadii Stepanov
1448c99380 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>

Github-Pull: bitcoin/bitcoin#24711
Rebased-From: 0c12f0116c
2022-03-31 19:04:04 +02:00
Hennadii Stepanov
4f3ba8517a wallet, refactor: Add wallet::NotifyWalletLoaded() function
This change is a prerequisite for the following bugfix.

Github-Pull: bitcoin/bitcoin#24711
Rebased-From: aeee419c6a
2022-03-31 19:04:02 +02:00
laanwj
752c9d82a6 qt: 23.0rc3 translations update
Tree-SHA512: 110fab39faae351f10a9bb3a8a852d29f1e8e4bae27b790a52198fc39c5e1a2261c0fe8f0289f4c626e3d39f237c9410ae80f311bdcf446f778c680bc0fdc367
2022-03-31 16:13:38 +02:00
fanquake
c243e08351 Merge bitcoin/bitcoin#24512: 23.x backports
174af33d5d util: Add inotify_rm_watch to syscall sandbox (AllowFileSystem) (Hennadii Stepanov)
ded10fe3ea build: Fix Boost.Process test for Boost 1.78 (Hennadii Stepanov)
26c2f23f36 build: Fix Boost.Process detection on macOS arm64 (Hennadii Stepanov)
85f85c7e5f util: add linkat to syscall sandbox (AllowFileSystem) (fanquake)
eaa04194b9 contrib: fix signet miner (sighash mismatch) (Sebastian Falbesoner)
235b042594 rpc: Exclude descriptor when address is excluded (MarcoFalke)
b05a59b69f ci: Temporarily use clang-13 to work around clang-14 TSan bug (MarcoFalke)
65b966743c doc, init: add links to doc/cjdns.md (Jon Atack)
7a553d4e65 doc: update i2p.md with cjdns, improve local addresses section (Jon Atack)
4148396229 doc: update tor.md with cjdns and getnodeaddresses, fix tor grep, (Jon Atack)
4690e8af13 doc: create initial doc/cjdns.md for cjdns how-to documentation (Jon Atack)
5d24f612d1 Clarify in -maxtimeadjustment that only outbound peers influence time data (Jon Atack)
b1646f1bb5 test: set segwit height back to 0 on regtest (Martin Zumsande)
ef6a37b7c4 rpc: rename getdeploymentinfo status-next to status_next (Jon Atack)
2a6fcf9c13 init, doc: improve -onlynet help and tor/i2p documentation (Jon Atack)

Pull request description:

  Backport the following to 23.x:

  - #24468
  - #24528
  - #24527
  - #24609
  - #24555
  - #24663
  - #24572
  - #24636
  - #24553
  - #24659
  - #24521
  - #24523
  - #24690
  - #24710

  Possibly also:
  - #24579
  - #24691

ACKs for top commit:
  laanwj:
    List-of-commits ACK 174af33d5d, I think we should merge this and move forward with rc3..
  hebasto:
    ACK 174af33d5d

Tree-SHA512: 5a493e1652b780b527767d6ca9e67012abd2fa5573496e85e0d8aa4bed3eb332bfcd72610b8dfb954ff274d42450623233c96c479de2085b9c8344ba5abf1935
2022-03-31 12:19:22 +01:00
Hennadii Stepanov
174af33d5d util: Add inotify_rm_watch to syscall sandbox (AllowFileSystem)
Github-Pull: bitcoin#24690
Rebased-From: f05a4cd
2022-03-31 10:38:11 +02:00
Hennadii Stepanov
ded10fe3ea build: Fix Boost.Process test for Boost 1.78
Github-Pull: bitcoin#24523
Rebased-From: 532c64a
2022-03-31 10:38:09 +02:00
fanquake
85f85c7e5f util: add linkat to syscall sandbox (AllowFileSystem)
Github-Pull: bitcoin#24659
Rebased-From: 9809db3
2022-03-31 10:30:14 +02:00
MarcoFalke
235b042594 rpc: Exclude descriptor when address is excluded
Github-Pull: bitcoin#24636
Rebased-From: faf37c2
2022-03-31 10:30:10 +02:00
Jon Atack
65b966743c doc, init: add links to doc/cjdns.md
Github-Pull: bitcoin#24663
Rebased-From: daae288
2022-03-31 10:30:05 +02:00
Jon Atack
5d24f612d1 Clarify in -maxtimeadjustment that only outbound peers influence time data
Github-Pull: bitcoin#24609
Rebased-From: 1bba72d
2022-03-28 12:49:51 +02:00
Vasil Dimov
70f2c579b9 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

Github-Pull: bitcoin-core/gui#568
Rebased-From: 7f90dc26c8
2022-03-23 17:26:19 +01:00
Sjors Provoost
642f2726de 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>

Github-Pull: bitcoin-core/gui#555
Rebased-From: 2efdfb88aa
2022-03-17 07:28:50 +01:00
Sjors Provoost
940694664d refactor: helper function signWithExternalSigner()
Does not change behavior.

Review hint:
git show --color-moved --color-moved-ws=allow-indentation-change

Github-Pull: bitcoin-core/gui#555
Rebased-From: 4b5a6cd149
2022-03-17 07:28:50 +01:00
Sjors Provoost
fc421d4c8c 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

Github-Pull: bitcoin-core/gui#555
Rebased-From: 026b5b4523
2022-03-17 07:28:50 +01:00
Martin Zumsande
b1646f1bb5 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.

Github-Pull: bitcoin#24527
Rebased-From: 5ce3057
2022-03-13 17:43:36 +01:00
Jon Atack
ef6a37b7c4 rpc: rename getdeploymentinfo status-next to status_next
Github-Pull: bitcoin#24528
Rebased-From: 5d7c69b
2022-03-13 17:41:05 +01:00
Jon Atack
2a6fcf9c13 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

Github-Pull: bitcoin#24468
Rebased-From: a1db99a
2022-03-13 17:35:56 +01:00
Ryan Ofsky
7e1b968f61 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.

Github-Pull: bitcoin/bitcoin#24498
Rebased-From: 5b1aae12ca
2022-03-09 11:03:05 -05:00
Ryan Ofsky
4607f700d0 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).

Github-Pull: bitcoin/bitcoin#24498
Rebased-From: 84b0973e35
2022-03-09 11:03:00 -05:00
laanwj
440fbe6dba qt: Pull translations for 0.23rc1
Tree-SHA512: 8366ebbb3603f3f021285f62df75996883458273b24db4e84ff56a3cb56b54cef474f640ea1f48ebc29dbde0593bd78256b9830555a288ba7e4a0a88e07f729e
2022-03-03 19:38:39 +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
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