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

walllet: use CoinsResult instead of PreSelectedInputs

Public commit record

What the developer wrote

Authored by stratospher

85/100 · Strong
walllet: use CoinsResult instead of PreSelectedInputs

PreSelectedInputs is confusing to use. it's `total_amount`
might store total amount or effective amount based on SFFO.
ex: we might accidentally sum preselected inputs effective
amount (named `total_amount`) with automatically selected
inputs actual total amount.

CoinsResult has a cleaner interface with separate fields
for both these amounts.

2 behavioural changes:

1. no more default assert error if effective value is unset
- previously PreSelectedInputs::Insert() called
COutput::GetEffectiveValue() which assert failed
if the optional was unset.
- now we don't default assert anymore.
* in GUI/getAvailableBalance better not to assert.
* SelectCoins's preselected inputs always contain a
feerate, so effective amount should be set.
explicitly added an assertion to ensure this.

2. FetchSelectedInputs uses OutputType::UNKNOWN as key to
populate CoinsResult's coins map. it's discarded later.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode
The short version

What changed, and why it matters

This is a Bitcoin Core wallet code cleanup that replaces an internal data structure called PreSelectedInputs with a cleaner one called CoinsResult. The commit message says the old structure was confusing because a field named total_amount could hold two different kinds of amounts, which could lead to accidentally mixing them. The patch separates those amounts and adds an explicit safety check where it matters. It is a defensive refactor rather than a fix for a known live bug or exploit.

Recommended action

Treat as a normal code-quality and defensive-correctness change. Reviewers should verify that GetAppropriateTotal() is used consistently wherever preset or available coin totals feed into selection_target calculations, and that the new assertion in SelectCoins cannot be triggered by valid wallet states.

Security signals we found

01

Mixing of total_amount and effective_amount in legacy PreSelectedInputs struct

02

Removal of default assertion on unset effective value

03

Addition of explicit assertion in SelectCoins for preset total

04

Refactor of coin selection arithmetic around subtract-fee-from-outputs

05

No explicit bug, CVE, or exploit described in commit or references

Risk score

Why this scored 27/100

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