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

wallet_db: convert PaymentInfo amounts from 0 to None

Public commit record

What the developer wrote

Authored by SomberNight

93/100 · Strong
wallet_db: convert PaymentInfo amounts from 0 to None

When creating a "zero-amount" payment request, currently we save a PaymentInfo with a "None" amount.
I think there were a few releases in 2023 that saved PaymentInfos with a `0` amount instead. This was changed in #8659 [0], but as said there [1], a DB upgrade was not done.
Now an assert added in [2] is failing due to this inconsistency, for affected old wallets.
- I think to trigger that, one needs a wallet that has a payment request (with a `0` amount) created around that time, which is still unpaid.

This patch tries to restore consistency by enforcing None amounts.

fixes https://github.com/spesmilo/electrum/issues/10501

[0]: https://github.com/spesmilo/electrum/pull/8659
[1]: https://github.com/spesmilo/electrum/pull/8659#issuecomment-1777101285
[2]: https://github.com/spesmilo/electrum/commit/286fc4b86e4d23cb9af15b9061b3d709e7592bcb
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a wallet-crash bug, not a security vulnerability. Some older Electrum wallets created 'zero-amount' Lightning payment requests in 2023 that were stored with an amount of 0 instead of the special 'no amount' marker (None). A later code change added a rule that received payment amounts cannot be 0, causing those older wallets to crash or fail to open. The patch converts the stored 0 values back to None during wallet database upgrade and prevents new 0 values from being created.

Recommended action

No security action required; this is a bug-fix/data-migration patch. Users with affected wallets should upgrade Electrum to a version containing this commit so the database migration runs and restores consistency.

Security signals we found

01

Data-consistency hardening: converts legacy 0 amounts to None to satisfy new invariant

02

Defensive validation added: ValueError on creation of amount_msat==0 payment info

03

Database upgrade bump from seed version 68 to 69

Risk score

Why this scored 22/100

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