AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 18 Bitcoin

Merge bitcoin/bitcoin#35930: wallet: post-#35501 cleanups in CWalletTx

Public commit record

What the developer wrote

Authored by Ava Chow

91/100 · Strong
Merge bitcoin/bitcoin#35930: wallet: post-#35501 cleanups in CWalletTx

4ca182ca4028b9e681d65ec21f79fd7fed3ce215 doc: clarify alternate_wtxids is empty when only one witness variant (pablomartin4btc)
fa48b5d28eb5c326115af246b12ff644279172c4 test: assert listsinceblock "removed" reports current canonical wtxid (pablomartin4btc)
9b96ee12881ef38a221f34ce26a3b4fcb5622b4b wallet, test: add unit test for variant txid validation in CWalletTx deserializer (pablomartin4btc)
9de6543cb55ff43aea950712a3148fed9d4a7e13 wallet: post-#35501 cleanup in CWalletTx (pablomartin4btc)

Pull request description:

Follow-up cleanups and clarifications after #35501 was merged.

Commit breakdown:

1. _post-[#35501](https://github.com/bitcoin/bitcoin/pull/35501) cleanup in_ `CWalletTx`
- Rename `arg_state` → `new_state` in `Update()` for consistency
- Simplify `RecomputeCanonical()` using `std::ranges::min_element` with a projection lambda (14 lines → 3 lines)
- Add variant txid validation in the `CWalletTx` deserialise constructor: throws `std::runtime_error` if any variant's txid doesn't match the canonical txid deserialized from the stream
- Move `Init()` to `private` and extend it to clear `m_txs` and reset `m_canonical_wtxid`, so a full re-deserialise via `Unserialize()` starts from a clean state

All [suggested](https://github.com/bitcoin/bitcoin/pull/35501#pullrequestreview-4854519083) by ajtowns.

2. _add unit test for variant txid validation in_ `CWalletTx` _deserializer_

3. _assert_ `listsinceblock` "removed" _reports current canonical wtxid_
Documents that removed entries reflect the wallet's current `CWalletTx` state, not a snapshot of the detached block. A future followup could improve this (requires per-block tracking of which witness variant was included).
[Suggested](https://github.com/bitcoin/bitcoin/pull/35501#discussion_r3632044472) by w0xlt.

4. _clarify_ `alternate_wtxids` _is empty when only one witness variant_
[Suggested](https://github.com/bitcoin/bitcoin/pull/35501#discussion_r3632113003) by polespinasa.

ACKs for top commit:
jeanpablojp:
re-ACK 4ca182ca4028b9e681d65ec21f79fd7fed3ce215
achow101:
ACK 4ca182ca4028b9e681d65ec21f79fd7fed3ce215
polespinasa:
ACK 4ca182ca4028b9e681d65ec21f79fd7fed3ce215

Tree-SHA512: 64eadeb11372d904c79edbfd264c4d8dc1b4fe4ce5e3acc301bfeba9e556efb5dce2c684f0e58c7b74e2c687cc7dd77389970662b3fd629ed034a97bcfdfb71c
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This is a follow-up cleanup and hardening patch for the Bitcoin Core wallet's handling of transactions that have multiple possible witness versions (same transaction ID but different witness data). It renames a variable, simplifies a helper function, adds validation so a corrupted wallet database cannot load a mismatched transaction variant, and improves documentation and tests. There is no direct evidence this fixes an active exploit, but it adds a defensive check against a potential data-integrity failure.

Recommended action

Treat as a routine defensive hardening patch. Reviewers should verify that the new deserialization invariant (all variant txids must equal the canonical txid) cannot be triggered by legitimate wallet states or migration paths. No urgent deployment action is indicated.

Security signals we found

01

Added input-validation during wallet transaction deserialization

02

New unit test specifically exercises rejection of mismatched variant txid

03

Follow-up to PR #35501 which introduced witness-variant tracking in the wallet

04

No CVE, advisory, or vendor security disclosure referenced in commit materials

Risk score

Why this scored 18/100

Our methodology →
Potential impact 2/30
Exploitability 1/25
Stealth signal 1/15
Affected reach 2/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.