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

jsonrpc: fix recover command for BIP86 wallets

Public commit record

What the developer wrote

Authored by Sangbida Chaudhuri

78/100 · Adequate
jsonrpc: fix recover command for BIP86 wallets

The recover command checks if a node has already issued bitcoin
addresses before allowing recovery. This check only looked at
bip32_max_index, but with BIP86 wallets, newaddr() increments
bip86_max_index instead.

Also, the recover test asserted on hex but now it's asserting on codex32 instead. We should probably go in and fix the end point. @rustyrussell what do you think?
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit fixes the 'recover' command in Core Lightning so it correctly detects whether a wallet has already generated Bitcoin addresses. Previously, the check only looked at one counter used by older wallets, but a newer type of wallet (BIP86) uses a separate counter. As a result, a BIP86 wallet that had already issued addresses could wrongly be allowed to run recovery, which could overwrite or confuse wallet state. The fix adds the missing check.

Recommended action

Apply the patch. Consider adding an explicit regression test that creates BIP86 addresses and then attempts recover, verifying it is rejected. Also review whether other empty-node checks elsewhere in the codebase need the same BIP86 counter treatment.

Security signals we found

01

Logic flaw in safety guard allowing recovery on non-empty wallet

02

Missing state variable check for new wallet type (BIP86)

03

Potential wallet state corruption or loss of funds if recovery proceeds on an already-used wallet

Risk score

Why this scored 34/100

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