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

wallet: use in-memory SQLite for temporary wallet in exportwatchonlywallet

Public commit record

What the developer wrote

Authored by Pablo Martin

63/100 · Adequate
wallet: use in-memory SQLite for temporary wallet in exportwatchonlywallet

The intermediate watchonly wallet created during exportwatchonlywallet is
a pure build artifact — it is always discarded once BackupWallet() copies
it to the destination. Creating it as an in-memory SQLiteDatabase
(SQLITE_OPEN_MEMORY) removes the need to write files to the wallets
directory and eliminates the cleanup handler that deleted those files on
both success and failure paths.

Introduces InMemoryWalletDatabase (a minimal SQLiteDatabase subclass) and
MakeInMemoryWalletDatabase() factory in sqlite.h/cpp, following the same
pattern as MockableSQLiteDatabase / CreateMockableWalletDatabase() in the
test utilities. MockableSQLiteDatabase now derives from InMemoryWalletDatabase,
removing its redundant Files() override.

The wallet is named after the source wallet ("<name>_watchonly_temp") so
concurrent exports of different wallets use distinct names and log lines
remain traceable to the source wallet.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification! Contains work-in-progress language
The short version

What changed, and why it matters

This change refactors how Bitcoin Core creates a temporary wallet during the exportwatchonlywallet command. Previously, the temporary wallet was written to disk in the wallets directory and then deleted afterward. Now it is kept entirely in memory using SQLite's in-memory mode, so no temporary files are created on disk. This is a cleanup and hardening improvement, not a fix for an active exploit.

Recommended action

No urgent action required. This is a defensive refactoring. Reviewers may want to confirm that BackupWallet() still works correctly when copying from an in-memory source and that concurrent exports of wallets with the same name remain safe (the patch names the in-memory wallet after the source wallet to keep concurrent exports distinct).

Security signals we found

01

Eliminates temporary wallet files written to disk during exportwatchonlywallet

02

Removes manual filesystem cleanup path that ran on both success and failure

03

Reduces attack surface related to leftover or partially-written wallet files

04

No change to cryptographic handling, key material, or network behavior

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.