Skip to content

feat(key-wallet): canonical is_contact_owned predicate on account types - #952

Merged
QuantumExplorer merged 1 commit into
devfrom
feat/contact-owned-account-predicate
Aug 11, 2026
Merged

feat(key-wallet): canonical is_contact_owned predicate on account types#952
QuantumExplorer merged 1 commit into
devfrom
feat/contact-owned-account-predicate

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

The policy "a contact's watch-only DashPay chain is not this wallet's money" currently has two independent enforcement sites, each hardcoding its own account-type list:

Nothing ties those lists together: a future contact-owned account type (e.g. an anonymous-contact chain) added to AccountType would compile cleanly while silently drifting past both filters.

What was done?

  • Added AccountType::is_contact_owned() as the canonical predicate. The match is deliberately exhaustive — adding a new account type won't compile until the author decides whether its coins are the wallet's or a contact's.
  • Added a delegating ManagedAccountType::is_contact_owned().
  • Pointed the all_funding_accounts doc at the predicate, and extended the fix(key-wallet): stop counting a contact's watch-only coins as the wallet's #926 funding-scope test to assert all_funding_accounts agrees with it.
  • Unit test asserting DashpayExternalAccount is the only contact-owned type — in particular that DashpayReceivingFunds (our xpub, contact pays in) stays ours.

No behavior change; this is policy consolidation. Once platform picks up a pin containing this, is_contact_watch_only in rs-platform-wallet can delegate to it.

A possible follow-up (not in scope): surfacing the flag on FFITransactionRecord, since any direct dash-spv-ffi consumer that persists per-account records keyed by txid faces the same clobbering hazard platform#4363 fixed.

How Has This Been Tested?

cargo test -p key-wallet --lib (638 passed), cargo clippy -p key-wallet --all-targets and --all-features --tests clean, cargo fmt --all.

Breaking Changes

None.

🤖 Generated with Claude Code

A DashpayExternalAccount derives its addresses from the contact's xpub,
so its coins are the contact's, never this wallet's. That policy now has
two enforcement sites — balance/UTXO aggregation dropped the accounts
from all_funding_accounts (#926), and dashpay/platform#4363 filters the
same records out of its persistence projection — but each site hardcodes
its own account-type list, which can silently drift when a new
contact-owned account type is added.

Give the policy one canonical home: AccountType::is_contact_owned(),
with an exhaustive match so a new account type cannot compile without
deciding whether its coins are the wallet's or a contact's, plus a
delegating ManagedAccountType::is_contact_owned(). The #926 funding-
scope test now asserts all_funding_accounts agrees with the predicate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@QuantumExplorer, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 05a23cc0-c832-4c94-8e15-0c51294d0883

📥 Commits

Reviewing files that changed from the base of the PR and between 5a80bd7 and 39e6ada.

📒 Files selected for processing (3)
  • key-wallet/src/account/account_type.rs
  • key-wallet/src/managed_account/managed_account_collection.rs
  • key-wallet/src/managed_account/managed_account_type.rs

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

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.39%. Comparing base (5a80bd7) to head (39e6ada).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #952      +/-   ##
==========================================
- Coverage   75.40%   75.39%   -0.01%     
==========================================
  Files         328      328              
  Lines       78541    78600      +59     
==========================================
+ Hits        59222    59264      +42     
- Misses      19319    19336      +17     
Flag Coverage Δ
core 77.29% <ø> (ø)
ffi 49.04% <ø> (ø)
rpc 20.00% <ø> (ø)
spv 91.33% <ø> (-0.14%) ⬇️
wallet 77.46% <100.00%> (+0.09%) ⬆️
Files with missing lines Coverage Δ
key-wallet/src/account/account_type.rs 69.96% <100.00%> (+6.87%) ⬆️
.../src/managed_account/managed_account_collection.rs 65.06% <100.00%> (+0.33%) ⬆️
...wallet/src/managed_account/managed_account_type.rs 80.88% <100.00%> (+2.39%) ⬆️

... and 6 files with indirect coverage changes

@QuantumExplorer
QuantumExplorer merged commit 9c0e874 into dev Aug 11, 2026
35 checks passed
@QuantumExplorer
QuantumExplorer deleted the feat/contact-owned-account-predicate branch August 11, 2026 09:26
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.

1 participant