feat(key-wallet): canonical is_contact_owned predicate on account types - #952
Conversation
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>
|
Warning Review limit reached
Next review available in: 29 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
|
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:
dashpay_external_accountsfromManagedAccountCollection::all_funding_accounts, coveringbalance,account_balances,utxosandget_spendable_utxos.TransactionRecords out of platform-wallet's persistence projection (itstransactionsrow is keyed by txid alone, so the watch-only record — emitted last — was clobbering the funding account's outgoing row).Nothing ties those lists together: a future contact-owned account type (e.g. an anonymous-contact chain) added to
AccountTypewould compile cleanly while silently drifting past both filters.What was done?
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.ManagedAccountType::is_contact_owned().all_funding_accountsdoc 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 assertall_funding_accountsagrees with it.DashpayExternalAccountis the only contact-owned type — in particular thatDashpayReceivingFunds(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_onlyinrs-platform-walletcan 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-targetsand--all-features --testsclean,cargo fmt --all.Breaking Changes
None.
🤖 Generated with Claude Code