Skip to content

Conversation

@8144225309
Copy link

Skip the APS coin selection pass when the initial selection contains no partial
spend—APS cannot improve privacy in this case.

Detection compares selected vs available UTXO counts per scriptPubKey, reusing
available_coins. Test updated to create an actual partial spend scenario.

Fixes #25150

Compute has_partial_spend inside CreateTransactionInternal using the
available_coins that are already fetched for coin selection. This avoids
a redundant AvailableCoins call compared to checking after the fact.

The check determines if the selection spends some but not all UTXOs from
any scriptPubKey. If no partial spend exists, APS cannot improve privacy,
so we skip the second coin selection attempt entirely.

Benefits:
- Avoids unnecessary double coin selection when APS provides no benefit
- Eliminates misleading tracepoint data
- Prevents potential disimprovement of selection results
- No extra AvailableCoins call (uses existing data)

Add has_partial_spend field to CreatedTransactionResult to communicate
this information from CreateTransactionInternal to CreateTransaction.

Update interface_usdt_coinselection test to set up partial spend scenarios
so APS tracepoints fire as expected.

Fixes bitcoin#25150
@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 21, 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/34362.

Reviews

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

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