Skip to content

refactor: carry the coin type in CoinSelectionParams - #7651

Open
knst wants to merge 3 commits into
dashpay:developfrom
knst:refactor-coinselection-cj
Open

refactor: carry the coin type in CoinSelectionParams#7651
knst wants to merge 3 commits into
dashpay:developfrom
knst:refactor-coinselection-cj

Conversation

@knst

@knst knst commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

CoinType is threaded through AttemptSelection and ChooseSelectionResult as a defaulted trailing parameter. Upstream keeps rewriting exactly these signatures (bitcoin#26661, bitcoin#27183), so every backport has to re-resolve the Dash-only argument, and a resolution that drops the trailing argument silently falls back to CoinType::ALL_COINS, losing the fully-mixed selection restrictions.

What was done?

Store the coin type in CoinSelectionParams instead, which is built once per selection request and already flows through the whole pipeline. The enum moves from coincontrol.h to coinselection.h so the field can be declared there without pulling the much heavier coincontrol.h into the selection module; coin control is a consumer of the selection layer, so the include direction stays sound.

It drops CoinType threading from AttemptSelection/ChooseSelectionResult

How Has This Been Tested?

Run unit & fuctional tests

Breaking Changes

N/A

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

knst added 3 commits August 30, 2026 18:32
CoinType is threaded through AttemptSelection and ChooseSelectionResult
as a defaulted trailing parameter. Upstream keeps rewriting exactly
these signatures (bitcoin#26661, bitcoin#27183), so every backport has
to re-resolve the Dash-only argument, and a resolution that drops the
trailing argument silently falls back to CoinType::ALL_COINS, losing
the fully-mixed selection restrictions.

Store the coin type in CoinSelectionParams instead, which is built once
per selection request and already flows through the whole pipeline. The
enum moves from coincontrol.h to coinselection.h so the field can be
declared there without pulling the much heavier coincontrol.h into the
selection module; coin control is a consumer of the selection layer, so
the include direction stays sound.
…onResult

The coin type now travels in CoinSelectionParams, so the Dash-only
trailing parameter and its eleven call-site arguments are dead weight.
Removing them restores both signatures to their upstream Bitcoin Core
shape, which lets future coin-selection backports (bitcoin#26661,
bitcoin#27183) apply without Dash-specific conflicts and removes the
failure mode where a conflict resolution drops the trailing argument
and silently selects with CoinType::ALL_COINS.
The three-argument overload only forwards to the four-argument one with
CoinType::ONLY_READY_TO_MIX; a default argument expresses the same
without a second method. Also include coincontrol.h directly in
wallet/coinjoin.cpp, which uses CCoinControl but only received it
transitively.
@thepastaclaw

thepastaclaw commented Aug 30, 2026

Copy link
Copy Markdown

🕓 Ready for review — 3 ahead in queue (commit 22441a3)
Queue position: 4/10 · 3 reviews active
ETA: start ~08:29 UTC · complete ~09:04 UTC (median 34m across 30 recent reviews; 3 slots)
Queued 19h 55m ago · Last checked: 2026-08-31 07:50 UTC

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4ff7ee49-7d8e-4abf-af5a-149b4442063d

📥 Commits

Reviewing files that changed from the base of the PR and between d11736d and 22441a3.

📒 Files selected for processing (6)
  • src/wallet/coincontrol.h
  • src/wallet/coinjoin.cpp
  • src/wallet/coinselection.h
  • src/wallet/spend.cpp
  • src/wallet/spend.h
  • src/wallet/wallet.h

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

The change moves CoinType from coincontrol.h to coinselection.h and stores it in CoinSelectionParams. Transaction creation copies the value from coin_control, and selection solvers read it from the parameter object. AttemptSelection and ChooseSelectionResult no longer accept a separate coin type argument. SelectTxDSInsByDenomination uses one declaration with ONLY_READY_TO_MIX as its default.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 22441

The refactor carries CoinType through per-request selection parameters while preserving ready-to-mix and fully-mixed policies and existing validation and locking behavior; no actionable merge-blocking risk remains, so it is merge-ready after normal checks and review.

Suggested reviewers: udjinm6

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the CoinType refactor, its purpose, affected selection APIs, include changes, and testing.
Title check ✅ Passed The title clearly and concisely identifies the main change: carrying CoinType in CoinSelectionParams.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants