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

Merge bitcoin/bitcoin#35935: wallet: Avoid unnecessary wtxvariant rewrites

Public commit record

What the developer wrote

Authored by merge-script

81/100 · Strong
Merge bitcoin/bitcoin#35935: wallet: Avoid unnecessary wtxvariant rewrites

1548d15de61886e0b8e67801146e9c168d9d4a66 walletdb: Rename WriteTx to WriteFullTx (Ava Chow)
9a0628d9320d2275d922d70d1a87573091840293 wallet: Write tx to database during CWalletTx::Update (Ava Chow)
1c557a380288df661e13e88f5d9c7c27b9bbbefb wallet: Add WriteTxMetadata to write just the tx record (Ava Chow)

Pull request description:

`wtxvariant` records should never change, so it is unnecessary for us to be rewriting all `wtxvariants` in a `CWalletTx` every time the `CWalletTx`'s state changes. Likewise, every time there is a new variant, `CWalletTx` states may not change so do not need to always be unconditionally written.

This PR adds a `WalletBatch::WriteTxMetadata` to write just the `tx` record (the former behavior of `WriteTx`) and renames `WriteTx` to `WriteFullTx` to indicate that it will write all relevant records for a `CWalletTx`. Most uses of `WriteTx` become `WriteTxMetadata`, except in migration and watch only export.

`AddToWallet` is changed to use `WriteFullTx` only for new transactions, and to do so immediately after the transaction is inserted to the wallet. `CWalletTx::Update` takes the `WalletBatch` now and will write the correct records according to what is actually being updated.

ACKs for top commit:
polespinasa:
re-ACK 1548d15de61886e0b8e67801146e9c168d9d4a66
pablomartin4btc:
ACK 1548d15de61886e0b8e67801146e9c168d9d4a66
rkrux:
lgtm ACK 1548d15de61886e0b8e67801146e9c168d9d4a66

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

What changed, and why it matters

This is a Bitcoin Core wallet code cleanup, not a security fix. It changes how transaction records are written to the wallet database so that the program only rewrites the parts that actually changed, rather than rewriting everything each time. This reduces unnecessary disk writes and may lower the chance of database corruption during crashes, but it does not close a known vulnerability that an attacker could exploit.

Recommended action

No urgent action required. Treat as a normal code-quality/robustness improvement. Standard review and testing before deployment is sufficient.

Security signals we found

01

Refactor of wallet persistence layer to avoid redundant database writes

02

Adds explicit error handling for database write failures in CWalletTx::Update

03

No change to cryptographic validation, consensus rules, or network handling

04

No mention of vulnerability, CVE, bug bounty, or security advisory in commit or PR description

Risk score

Why this scored 19/100

Our methodology →
Potential impact 2/30
Exploitability 1/25
Stealth signal 1/15
Affected reach 3/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.