8000 wallet: skip APS when no partial spend exists by 8144225309 · Pull Request #34405 · bitcoin/bitcoin · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@8144225309
Copy link

Fixes #25150

APS (Avoid Partial Spends) runs a second coin selection pass to fully spend
UTXOs sharing a scriptPubKey. This currently runs unconditionally, even when
the first selection has no partial spend. Running APS unnecessarily wastes
computation and can produce a worse result when there was nothing to fix.

Detect partial spends by comparing selected vs available UTXO counts per
scriptPubKey, reusing available_coins. Skip APS if none found.

Test updated to create partial spend scenarios so tracepoints fire.


Supersedes #34362 which was corrupted by a shallow clone force-push.

@DrahtBot
Copy link
Contributor
DrahtBot commented Jan 26, 2026

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34405.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #34075 (fees: Introduce Mempool Based Fee Estimation to reduce overestimation by ismaelsadeeq)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@8144225309 8144225309 force-pushed the aps-skip-no-partial-spend branch 3 times, most recently from b686262 to d6edd15 Compare January 26, 2026 10:50
APS runs a second coin selection to fully spend UTXOs sharing a
scriptPubKey. Currently runs unconditionally, even when the first
selection has no partial spend and APS cannot help.

Detect partial spends by comparing selected vs available UTXO counts
per scriptPubKey inside CreateTransactionInternal, reusing available_coins.
Add has_partial_spend to CreatedTransactionResult. Skip APS if false.

Update interface_usdt_coinselection test to expect APS to be skipped
when no partial spend exists. Add new test that creates a partial spend
scenario so the full APS tracepoint flow is verified.

Fixes bitcoin#25150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coin Selection tracepoint overreports use of APS

2 participants

0