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

descriptors: add HavePrivateKeys()

Public commit record

What the developer wrote

Authored by Novo

63/100 · Adequate
descriptors: add HavePrivateKeys()

Previously, to determine if a desc is watchonly, `ToPrivateString()`, was used.
It returns `false` if there is at least one pubkey in the descriptor for which
the provider does not have a private key.

ToPrivateString() behaviour will change in the following commits to only
return `false` if no priv keys could be found for the pub keys in the descriptor.

HavePrivateKeys() is added here to replace the use of ToPrivateString() for determining
if a descriptor is 'watchonly'.

Co-authored-by: rkrux <rkrux.connect@gmail.com>
✓ Descriptive subject✓ Provides detailed explanatory context✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit adds a new helper function called HavePrivateKeys() to Bitcoin Core's descriptor system. It is a preparatory refactor: it gives the code a clearer way to check whether a wallet descriptor is 'watch-only' (has no private keys) before an upcoming change to ToPrivateString(). The commit itself does not change user-visible behavior; it only introduces the new check and updates tests to use it. There is no direct evidence in the commit that this fixes an active security bug, but it is clearly related to correctly identifying whether private keys are present, which can affect wallet security logic.

Recommended action

Treat as a low-risk refactor commit. Review the subsequent commits that change ToPrivateString() behavior to ensure the new HavePrivateKeys() check is actually used in all security-relevant watch-only decisions, particularly in wallet import and descriptor wallet loading paths.

Security signals we found

01

Refactor of private-key presence detection logic

02

Preparation for semantic change in ToPrivateString()

03

Watch-only descriptor classification may affect wallet security decisions

04

No direct vulnerability or exploit mechanism visible in diff

Risk score

Why this scored 28/100

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