Commit graph

25046 commits

Author SHA1 Message Date
Jon Atack
21d9aaae32 p2p, bugfix: detect addnode cjdns peers in GetAddedNodeInfo()
Addnode (manual) peers connected to us via the cjdns network are currently not
detected by CConnman::GetAddedNodeInfo(), i.e. fConnected is always false.

This causes the following issues:

- RPC `getaddednodeinfo` incorrectly shows them as not connected

- CConnman::ThreadOpenAddedConnections() continually retries to connect them

Github-Pull: #30085
Rebased-From: 684da97070
2024-05-23 17:05:57 +01:00
MarcoFalke
96d0e818c5 rpc: Reword SighashFromStr error message
Github-Pull: #29870
Rebased-From: fa6ab0d020
2024-05-23 17:05:57 +01:00
willcl-ark
6685affe92 rpc: move UniValue in blockToJSON
Without explicitly declaring the move, these UniValues get copied,
causing increased memory usage. Fix this by explicitly moving the
UniValue objects.

Used by `rest_block` and `getblock` RPC.

Github-Pull: #30094
Rebased-From: b77bad309e
2024-05-23 17:05:57 +01:00
Antoine Poinsot
d9ef6cf934 sign: don't assume we are parsing a sane Miniscript
The script provided for signature might be externally provided, for
instance by way of 'finalizepsbt'. Therefore the script might be
ill-crafted, so don't assume pubkeys are always 32 bytes.

Thanks to Niklas for finding this.

Github-Pull: #29853
Rebased-From: 4d8d21320e
2024-05-23 17:05:57 +01:00
nanlour
bb46b90b2e Fix #29767, set m_synced = true after Commit()
Github-Pull: #29776
Rebased-From: bbe82c116e
2024-05-23 17:05:22 +01:00
Jameson Lopp
bf5b6fc8a7 Throw error if invalid parameters passed to getnetworkhashps RPC endpoint
Github-Pull: #28554
Rebased-From: 9ac114e5cd
2024-04-17 13:47:50 +01:00
dergoegge
a81a9228fb [rpc, bugfix] Enforce maximum value for setmocktime
Github-Pull: #29869
Rebased-From: c2e0489b71
2024-04-17 13:28:13 +01:00
Luke Dashjr
d39ea519c7 Change Luke Dashjr seed to dashjr-list-of-p2p-nodes.us
To avoid issues with DNS blacklisting, I've setup a separate domain for my DNS seed.

Github-Pull: #29691
Rebased-From: 4f273ab436
2024-04-17 13:28:13 +01:00
fanquake
fce992b38e fuzz: restrict fopencookie usage to Linux & FreeBSD
Should fix the GCC compilation portion of #29517:
https://github.com/bitcoin/bitcoin/issues/29517#issuecomment-1973573314.

See also:
https://www.gnu.org/software/gnulib/manual/html_node/fopencookie.html
but note that FreeBSD has supported this function since 11.x.

Github-Pull: #29529
Rebased-From: 312f3381a2
2024-03-07 10:45:14 +00:00
UdjinM6
7c82b2758c wallet: Avoid updating ReserveDestination::nIndex when GetReservedDestination fails
Github-Pull: #29510
Rebased-From: 367bb7a80c
2024-03-05 10:49:41 +00:00
Greg Sanders
b5419ce6b6 p2p: Don't consider blocks mutated if they don't connect to known prev block
Github-Pull: #29524
Rebased-From: a1fbde0ef7
2024-03-05 10:47:50 +00:00
dergoegge
0535c253fe [test] IsBlockMutated unit tests
Github-Pull: #29412
Rebased-From: d8087adc7e
2024-03-05 10:46:15 +00:00
dergoegge
8141498f3a [validation] Cache merkle root and witness commitment checks
Slight performance improvement by avoiding duplicate work.

Github-Pull: #29412
Rebased-From: 1ec6bbeb8d
2024-03-05 10:24:35 +00:00
dergoegge
24736350e9 [net processing] Don't process mutated blocks
We preemptively perform a block mutation check before further processing
a block message (similar to early sanity checks on other messsage
types). The main reasons for this change are as follows:

- `CBlock::GetHash()` is a foot-gun without a prior mutation check, as
  the hash returned only commits to the header but not to the actual
  transactions (`CBlock::vtx`) contained in the block.
- We have observed attacks that abused mutated blocks in the past, which
  could have been prevented by simply not processing mutated blocks
  (e.g. https://github.com/bitcoin/bitcoin/pull/27608).

Github-Pull: #29412
Rebased-From: 49257c0304
2024-03-05 10:24:17 +00:00
dergoegge
50c0b61a9d [validation] Merkle root malleation should be caught by IsBlockMutated
Github-Pull: #29412
Rebased-From: 2d8495e080
2024-03-05 10:24:16 +00:00
dergoegge
aff368fa81 [validation] Introduce IsBlockMutated
Github-Pull: #29412
Rebased-From: 66abce1d98
2024-03-05 10:21:16 +00:00
dergoegge
076c67c3aa [refactor] Cleanup merkle root checks
Github-Pull: #29412
Rebased-From: e7669e1343
2024-03-01 16:28:19 +00:00
dergoegge
97a1d0a459 [validation] Isolate merkle root checks
Github-Pull: #29412
Rebased-From: 95bddb930a
2024-03-01 16:27:43 +00:00
Hennadii Stepanov
4ac0eb543d test: Drop x modifier in fsbridge::fopen call for mingw builds
The MinGW-w64 toolchain links executables to the old msvcrt C Runtime
Library that does not support the `x` modifier for the _wfopen()
function.

Github-Pull: #29357
Rebased-From: d2fe90571e
2024-02-28 22:21:25 +00:00
Roman Zeyde
1e956439eb
rpc: keep .cookie if it was not generated
Otherwise, starting bitcoind twice may cause the `.cookie`
file generated by the first instance to be deleted by the
second instance shutdown (after failing to obtain a lock).

Github-Pull: bitcoin/bitcoin#28784
Rebased-From: 7cb9367157
2024-02-28 11:19:27 +01:00
Hennadii Stepanov
c27793891a qt: 26.1rc1 translations update
This change is a result if pulling the recent translations
from the Transifex website using the
bitcoin-maintainer-tools/update-translations.py tool.

A few manual adjustments were made:
- skipped removing of `bitcoin_af.ts`
- skipped removing of `bitcoin_ar.ts`
- skipped adding of `bitcoin_ru_RU.ts` (`bitcoin_ru.ts` is already
present)
2024-02-16 17:29:46 +00:00
Mark Friedenbach
438ac2947d
snapshots: don't core dump when running -checkblockindex after loadtxoutset
Github-Pull: #28791
Rebased-From: cdc6ac4126
2024-01-19 16:13:05 +00:00
glozow
7ec34554af
[log] mempool loading
Log at the top before incrementing so that this log isn't printed when
there's only 1 tx.

Github-Pull: #29227
Rebased-From: eb78ea4eeb
2024-01-19 16:12:57 +00:00
Jon Atack
fe0f8fe8aa
net: create I2P sessions with both ECIES-X25519 and ElGamal encryption
A Bitcoin Core node may only connect to a peer destination via I2P if both sides
have sessions with the same encryption type.  The encryption type is a property
of the session, not the destination.  Sessions may support multiple encryption
types.

As Bitcoin Core is not currently setting the I2P encryption type when creating
sessions, it is using the older default, ElGamal (type 0).

This pull updates Bitcoin Core to use both ECIES-X25519 and ElGamal (types 4 and
0, respectively).  This allows to connect to I2P peers with either type, and the
newer, faster ECIES-X25519 will be preferred.

See also the recently updated section "Signature and Encryption Types" in
https://geti2p.net/en/docs/api/samv3

Thanks and credit to zzzi2p (https://github.com/zzzi2p) for reporting.

Closes https://github.com/bitcoin/bitcoin/issues/29197.

Github-Pull: #29200
Rebased-From: 9d728916b2
2024-01-19 16:12:47 +00:00
stickies-v
fc62271015
[refactor] Add helper for iterating through mempool entries
Instead of reaching into the mapTx data structure, use a helper method
that provides the required vector of CTxMemPoolEntry pointers.

Github-Pull: #28391
Rebased-From: 453b4813eb
2024-01-19 16:12:23 +00:00
MarcoFalke
ccf00b1e6e
wallet: Fix use-after-free in WalletBatch::EraseRecords
Github-Pull: #29176
Rebased-From: faebf1df2a
2024-01-04 16:21:37 +00:00
furszy
b06b14e68d
rpc: getwalletinfo, return wallet 'birthtime'
And add coverage for it

Github-Pull: #28920
Rebased-From: 1ce45baed7
2024-01-04 16:21:37 +00:00
furszy
0fa47e2569
wallet: fix legacy spkm default birth time
To avoid scanning blocks, as assumed by a wallet with no
generated keys or imported scripts, the default value for
the birth time needs to be set to the maximum int64_t value.

Once the first key is generated or the first script is imported,
the legacy SPKM will update the birth time automatically.

Github-Pull: #28920
Rebased-From: 6f497377aa
2024-01-04 16:21:37 +00:00
furszy
84f4a6c145
wallet: birth time update during tx scanning
As the user could have imported a descriptor with
a newer timestamp (by blindly setting 'timestamp=now'),
the wallet needs to update the birth time when it detects
a transaction older than the oldest descriptor timestamp.

Github-Pull: #28920
Rebased-From: 75fbf444c1
2024-01-04 16:21:37 +00:00
furszy
074296dd60
refactor: rename FirstKeyTimeChanged to MaybeUpdateBirthTime
In the following-up commit, the wallet birth time will also
be modified by the transactions scanning process. When a tx
older than all descriptor's timestamp is detected.

Github-Pull: #28920
Rebased-From: b4306e3c8d
2024-01-04 16:21:37 +00:00
furszy
35039ac3cc
fuzz: disable BnB when SFFO is enabled
Github-Pull: #28994
Rebased-From: 576bee88fd
2024-01-04 16:21:36 +00:00
furszy
903b4623d3
test: add coverage for BnB-SFFO restriction
Verify the transaction creation process does not produce
a BnB solution when SFFO is enabled.
This is currently problematic because it could require a
change output. And BnB is specialized on changeless solutions.

Co-authored-by: Andrew Chow <achow101@gmail.com>
Co-authored-by: Murch <murch@murch.one>

Github-Pull: #28994
Rebased-From: 05e5ff194c
2024-01-04 16:21:36 +00:00
furszy
05d0576d3c
wallet: create tx, log resulting coin selection info
Useful for understanding what is going on internally
when the software is running. Debug issues, and provide
more accurate feedback to users.

Github-Pull: #28994
Rebased-From: 0c5755761c
2024-01-04 16:21:36 +00:00
Murch
5493ebbe74
wallet: skip BnB when SFFO is active
Co-authored-by: furszy <matiasfurszyfer@protonmail.com>

Github-Pull: #28994
Rebased-From: 5cea25ba79
2024-01-04 16:21:36 +00:00
Martin Zumsande
5097bb3389
rpc: fix getrawtransaction segfault
The crash would happen when querying a mempool transaction with verbosity=2, while pruning.

Github-Pull: #29003
Rebased-From: 494a926d05
2024-01-04 16:21:36 +00:00
Jon Atack
55af112565
p2p: do not make automatic outbound connections to addnode peers
to allocate our limited outbound slots correctly, and to ensure addnode
connections benefit from their intended protections.

Our addnode logic usually connects the addnode peers before the automatic
outbound logic does, but not always, as a connection race can occur.  If an
addnode peer disconnects us and if it was the only one from its network, there
can be a race between reconnecting to it with the addnode thread, and it being
picked as automatic network-specific outbound peer.  Or our internet connection
or router, or the addnode peer, could be temporarily offline, and then return
online during the automatic outbound thread.  Or we could add a new manual peer
using the addnode RPC at that time.

The race can be more apparent when our node doesn't know many peers, or with
networks like cjdns that currently have few bitcoin peers.

When an addnode peer is connected as an automatic outbound peer and is the only
connection we have to a network, it can be protected by our new outbound
eviction logic and persist in the "wrong role".

Examples on mainnet using logging added in the same pull request:

2023-08-12T14:51:05.681743Z [opencon] [net.cpp:1949] [ThreadOpenConnections]
[net:debug] Not making automatic network-specific outbound-full-relay connection
to i2p peer selected for manual (addnode) connection: [geh...odq.b32.i2p]:0

2023-08-13T03:59:28.050853Z [opencon] [net.cpp:1949] [ThreadOpenConnections]
[net:debug] Not making automatic block-relay-only connection to onion peer
selected for manual (addnode) connection: kpg...aid.onion:8333

2023-08-13T16:21:26.979052Z [opencon] [net.cpp:1949] [ThreadOpenConnections]
[net:debug] Not making automatic network-specific outbound-full-relay connection
to cjdns peer selected for manual (addnode) connection: [fcc...8ce]:8333

2023-08-14T20:43:53.401271Z [opencon] [net.cpp:1949] [ThreadOpenConnections]
[net:debug] Not making automatic network-specific outbound-full-relay connection
to cjdns peer selected for manual (addnode) connection: [fc7...59e]:8333

2023-08-15T00:10:01.894147Z [opencon] [net.cpp:1949] [ThreadOpenConnections]
[net:debug] Not making automatic feeler connection to i2p peer selected for
manual (addnode) connection: geh...odq.b32.i2p:8333

Finally, there does not seem to be a reason to make block-relay or short-lived
feeler connections to addnode peers, as the addnode logic will ensure we connect
to them if they are up, within the addnode connection limit.

Fix these issues by checking if the address is an addnode peer in our automatic
outbound connection logic.

Github-Pull: #28895
Rebased-From: cc62716920
2023-11-22 11:53:27 +00:00
Martin Leitner-Ankerl
1488648104
pool: change memusage_test to use int64_t, add allocation check
If alignment of the PoolAllocator would be insufficient, then the test would fail. This also catches the issue with ARM 32bit,
where int64_t is aligned to 8 bytes but void* is aligned to 4 bytes. The test adds a check to ensure the pool has allocated
a minimum number of chunks

Github-Pull: #28913
Rebased-From: d5b4c0b69e
2023-11-22 11:33:12 +00:00
Martin Leitner-Ankerl
bcc183ccce
pool: make sure PoolAllocator uses the correct alignment
This changes the PoolAllocator to default the alignment to the given type. This makes the code simpler, and most importantly
fixes a bug on ARM 32bit that caused OOM: The class CTxOut has a member CAmount which is an int64_t and on ARM 32bit int64_t
are 8 byte aligned which is larger than the pointer alignment of 4 bytes. So for CCoinsMap to be able to use the pool, we
need to use the alignment of the member instead of just alignof(void*).

Github-Pull: #28913
Rebased-From: ce881bf9fc
2023-11-22 11:33:01 +00:00
fanquake
5845331a6c
doc: rewrite explanation for -par=
The negative bound for script threads comes from the machine which
generates the man pages, so may only be correct for that machine. Any
other placeholder value will also be wrong for some machines. Fix this
be removing the value. This also fixes help2man incorrectly bolding the
value, as if it were a paramater.

Closes #28850.

Github-Pull: #28858
Rebased-From: d799ea26ed
2023-11-14 15:46:10 +00:00
Sebastian Falbesoner
e097d4cb53
gui: fix crash on selecting "Mask values" in transaction view
This commits fixes a crash bug that can be caused with the following steps:
- change to the "Transactions" view
- right-click on an arbitrary transaction -> "Show transaction details"
- close the transaction detail window again
- select "Settings" -> "Mask values"

The problem is that the list of opened dialogs, tracked in the member
variable `m_opened_dialogs`, is only ever appended with newly opened
transaction detail dialog pointers, but never removed. This leads to
dangling pointers in the list, and if the "Mask values" menu item is
selected, a crash is caused in the course of trying to close the opened
transaction detail dialogs (see `closeOpenedDialogs()` method). Fix this
by removing the pointer from the list if the corresponding widget is
destroyed.

Github-Pull: https://github.com/bitcoin-core/gui/pull/774
Rebased-From: e26e665f9f
2023-11-01 10:01:05 +00:00
pablomartin4btc
b761a58171
assumeutxo, blockstorage: prevent core dump on invalid hash
Github-Pull: #28698
Rebased-from: 4a5be10b92
2023-10-31 17:07:52 +00:00
Vasil Dimov
d3ebf6e9fc
[test] Test i2p private key constraints
Github-Pull: #28695
Rebased-From: 5cf4d266d9
2023-10-31 17:07:52 +00:00
dergoegge
1f11784aac
[net] Check i2p private key constraints
Co-authored-by: Vasil Dimov <vd@FreeBSD.org>

GitHub-Pull: #28695
Rebased-From: cf70a8d565
2023-10-31 17:07:52 +00:00
MarcoFalke
6544ffa01f
bugfix: Mark CNoDestination and PubKeyDestination constructor explicit
This should fix the bug reported in
https://github.com/bitcoin/bitcoin/pull/28246#discussion_r1371640502,
which caused the GUI to not detect the destination type of recipients,
thus picking the wrong change destination type.

Also, add missing lifetimebound attribute to a getter method.

GitHub-Pull: #28728
Rebased-From: 1111475b41
2023-10-31 17:07:52 +00:00
Hennadii Stepanov
1695c4801c
qt: 26.0rc2 translations update 2023-10-31 16:53:32 +00:00
Hennadii Stepanov
74604662f3
qt: 26.0rc1 translations update 2023-10-24 11:01:03 +01:00
Ryan Ofsky
d724bb5291
Merge bitcoin/bitcoin#28609: wallet: Reload watchonly and solvables wallets after migration
4814e4063e test: Check tx metadata is migrated to watchonly (Andrew Chow)
d616d30ea5 wallet: Reload watchonly and solvables wallets after migration (Andrew Chow)
118f2d7d70 wallet: Copy all tx metadata to watchonly wallet (Andrew Chow)
9af87cf348 test: Check that a failed wallet migration is cleaned up (Andrew Chow)

Pull request description:

  Some incomplete/incorrect state as a result of migration can be mitigated/cleaned up by simply restarting the migrated wallets. We already do this for a wallet when it is migrated, but we do not for the new watchonly and solvables wallets that may be created. This PR introduces this behavior, in addition to creating those wallets initially without an attached chain.

  While implementing this, I noticed that not all `CWalletTx` metadata was being copied over to the watchonly wallet and so some data, such as time received, was being lost. This PR fixes this as a side effect of not having a chain attached to the watchonly wallet. A test has also been added.

ACKs for top commit:
  ishaanam:
    light code review ACK 4814e4063e
  ryanofsky:
    Code review ACK 4814e4063e. Just implemented the suggested orderpos, copyfrom, and path set comments since last review
  furszy:
    ACK 4814e406

Tree-SHA512: 0b992430df9f452cb252c2212df8e876613f43564fcd1dc00c6c31fa497adb84dfff6b5ef597590f9b288c5f64cb455f108fcc9b6c9d1fe9eb2c39e7f2c12a89
2023-10-23 17:35:36 -04:00
Andrew Chow
da8e397e4a
Merge bitcoin/bitcoin#28685: coinstats, assumeutxo: fix hash_serialized2 calculation
4bfaad4eca chainparams, assumeutxo: Fix signet txoutset hash (Fabian Jahr)
a503cd0f0b chainparams, assumeutxo: Fix testnet txoutset hash (Fabian Jahr)
f6213929c5 assumeutxo: Check deserialized coins for out of range values (Fabian Jahr)
66865446a7 docs: Add release notes for #28685 (Fabian Jahr)
cb0336817e scripted-diff: Rename hash_serialized_2 to hash_serialized_3 (Fabian Jahr)
351370a1d2 coinstats: Fix hash_serialized2 calculation (Fabian Jahr)

Pull request description:

  Closes #28675

  The last commit demonstrates that theStack's analysis [here](https://github.com/bitcoin/bitcoin/issues/28675#issuecomment-1770389468) seems to be correct. There will be more changes needed for the rest of the test suite but the `feature_assumeutxo.py` with my additional tests pass.

ACKs for top commit:
  achow101:
    ACK 4bfaad4eca
  theStack:
    Code-review ACK 4bfaad4eca
  ryanofsky:
    Code review ACK 4bfaad4eca

Tree-SHA512: 2f6abc92b282f7c5da46391803cf0804d13978d191d541f2509b532c538abccd0a081e46cda23d80d47206a05fa2b5d41b7ab246e6a263db7a7461d6292116ef
2023-10-23 15:16:08 -04:00
Hennadii Stepanov
f09bfab4af
Revert "gui: provide wallet controller context to wallet actions"
This reverts commit 7066e8996d.
2023-10-23 12:14:37 +01:00
fanquake
0046f3dc27
Merge bitcoin/bitcoin#28693: build: Include config/bitcoin-config.h explicitly in util/trace.h
6bdff429ec build: Include `config/bitcoin-config.h` explicitly in `util/trace.h` (Hennadii Stepanov)

Pull request description:

  The `ENABLE_TRACING` macro is expected to be defined in the `config/bitcoin-config.h` header.

  Therefore, the current code is error-prone as it depends on whether the `config/bitcoin-config.h` header was included before or not.

  This bug was noticed while working on CMake [stuff](https://github.com/hebasto/bitcoin/pull/37).

ACKs for top commit:
  fanquake:
    ACK 6bdff429ec

Tree-SHA512: 22c4fdeb51628814050eb99a83db4268a4f3106207eeef918a07214bbc52f2b22490f6b05fcb96216f147afa4197c51102503738131e2583e750b6d195747a49
2023-10-23 11:32:43 +01:00