#34405 wallet: skip APS when no partial spend exists
https://github.com/bitcoin/bitcoin/pull/34405 · · +62/-16 in 3 files, 1 commits · labels: Wallet, Needs rebase
Goal
- Avoid running an extra coin selection pass when partial spends are already absent
- Saves computation, avoids worse coin selection results, and prevents false tracepoint reporting
Skips the Avoid Partial Spends (APS) second coin selection pass when the initial coin selection already leaves no partial spends for any scriptPubKey. Adds has_partial_spend detection to CreatedTransactionResult and updates the USDT coin selection test.
Problem: APS currently runs unconditionally even when the initial selection does not partially spend any scriptPubKey, which wastes computation, can produce a worse coin selection outcome, and causes the coin selection tracepoint to falsely report APS usage (issue #25150).
Category: Wallet (#46 of 84)
P3 · speedup
- P3 because it avoids redundant computation and worse coin selection results in standard wallet spending
- Fixes inaccurate reporting in the coin selection tracepoint when partial spends are already absent
Eliminates unnecessary coin selection passes when Avoid Partial Spends cannot improve the selection. As the author states, 'Running APS unnecessarily wastes computation and can produce a worse result when there was nothing to fix.' It also fixes issue #25150 where the coin selection tracepoint overreports APS use.
Membership: Modifies coin selection and transaction creation logic in src/wallet/spend.cpp.
Factors: security/stability 0, bug 1, performance 1, user value 1, leverage 0
Reviewability: Stale: Needs rebase
- Needs rebase due to merge conflicts before review is worthwhile
- The author has been inactive for over 200 days
The PR has merge conflicts and the author has been inactive for more than 200 days.
Author status: silent since 2026-02-15
Resolved concerns:
- achow101 requested grouping condition checks and using default wallet name in the functional test; author addressed both with rationale and a code update.
Agreement: Neutral
- Minor test and syntax comments addressed without explicit approval (achow101)
- No reviewers have posted an explicit concept or code ACK
Nonblocking test and syntax comments were addressed, but no explicit approval was given (achow101)
achow101 reviewed minor code and test details which were resolved by the author, but no reviewer has posted an explicit Concept ACK or ACK.
- achow101 provided inline comments on condition grouping and test arguments on 2026-02-02
- author responded and force-pushed resolutions on 2026-02-03
Review verdicts (DrahtBot): 0
Files
File list not available for this run.
Card
This PR optimizes wallet coin selection by skipping the Avoid Partial Spends (APS) pass when no partial spends are present in the primary selection. Skipping the unconditional second pass saves computation, avoids potentially worse coin selections, and resolves issue #25150 regarding inaccurate USDT tracepoint reporting. Only minor test and style comments were left by achow101, which the author addressed. The PR has been inactive since February 2026 and currently requires a rebase.