Skip to content

refactor(key-wallet): drop unused is_watch_only from ManagedCoreAccount#718

Merged
QuantumExplorer merged 2 commits intov0.42-devfrom
drop-managed-is-watch-only
May 6, 2026
Merged

refactor(key-wallet): drop unused is_watch_only from ManagedCoreAccount#718
QuantumExplorer merged 2 commits intov0.42-devfrom
drop-managed-is-watch-only

Conversation

@QuantumExplorer
Copy link
Copy Markdown
Member

@QuantumExplorer QuantumExplorer commented May 3, 2026

Summary

The mutable ManagedCoreAccount carries an is_watch_only: bool that's just propagated from the immutable parent Account. Nothing in the workspace reads it for any decision — every if watch-only { deny } check (key-wallet-ffi/src/keys.rs:85, key-wallet-ffi/src/account_derivation.rs:41,231,262) reads FFIAccount.inner().is_watch_only, i.e. the immutable Account, not the managed copy. The denormalized field exists only as test assertions and an #[no_mangle] getter (managed_core_account_get_is_watch_only) that nothing in this repo invokes.

This drops:

  • The is_watch_only field on ManagedCoreAccount
  • The is_watch_only parameter on ManagedCoreAccount::new and the create_managed_account_from_* helpers
  • ManagedAccountTrait::is_watch_only
  • The managed_core_account_get_is_watch_only FFI export

ManagedPlatformAccount.is_watch_only and managed_platform_account_get_is_watch_only are unchanged.

Breaking change

Any out-of-tree C/Swift consumer of managed_core_account_get_is_watch_only will need to switch to either:

  • account_get_is_watch_only on the parent FFIAccount, or
  • wallet_is_watch_only for the wallet-level status.

Test plan

  • cargo check --all — clean
  • cargo test -p key-wallet --lib — 461 passed
  • cargo test -p key-wallet-ffi --lib — 217 passed
  • cargo test -p key-wallet-manager --lib — 31 passed
  • cargo clippy --all-features --all-targets — clean
  • cargo fmt

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Simplified managed account creation by removing the watch-only flag parameter from account initialization. Watch-only account detection and handling logic has been streamlined across the wallet's account management system.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 3, 2026

Warning

Rate limit exceeded

@QuantumExplorer has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 40 minutes and 30 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c37df4af-6fea-4bd7-850a-0ababad2d00d

📥 Commits

Reviewing files that changed from the base of the PR and between ca8c528 and c63c160.

📒 Files selected for processing (1)
  • key-wallet-ffi/FFI_API.md
📝 Walkthrough

Walkthrough

This PR removes the is_watch_only flag from the managed account system across trait definitions, constructors, struct fields, and all call sites. The parameter and related assertions are eliminated from both library code and FFI test code.

Changes

Managed Account Watch-Only Flag Removal

Layer / File(s) Summary
Trait & Struct Definitions
key-wallet/src/managed_account/managed_account_trait.rs, key-wallet/src/managed_account/managed_core_keys_account.rs
ManagedAccountTrait removes the is_watch_only(&self) -> bool method. ManagedCoreKeysAccount struct removes the is_watch_only: bool field.
Constructor Signatures
key-wallet/src/managed_account/managed_core_funds_account.rs, key-wallet/src/managed_account/managed_core_keys_account.rs
ManagedCoreFundsAccount::new and ManagedCoreKeysAccount::new drop the is_watch_only: bool parameter, now taking only (managed_account_type, network).
Factory & Helper Methods
key-wallet/src/managed_account/managed_core_keys_account.rs, key-wallet/src/managed_account/managed_account_collection.rs
Factory methods (from_account, from_bls_account, from_eddsa_account) and create_managed_account_from_account_type helper updated to call constructors without the is_watch_only argument.
Call Site Updates
key-wallet/src/managed_account/managed_account_collection.rs, key-wallet/src/test_utils/account.rs, key-wallet-ffi/src/managed_wallet.rs, key-wallet-ffi/src/utxo_tests.rs
All ManagedCoreFundsAccount::new(...) calls remove the trailing boolean argument; create_managed_account_from_account_type calls drop the is_watch_only parameter.
Test Assertions & Setups
key-wallet-ffi/src/managed_account.rs
Assertions and function calls related to is_watch_only (managed_core_account_get_is_watch_only) removed from test_managed_account_basic, test_managed_account_getters, and test_managed_account_getter_edge_cases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Watch-only flags hop away into the sunset,
Simpler constructors dance in their place,
One by one, the assertions fade,
No more booleans guard the gate—
The managed account finds its lighter pace! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor(key-wallet): drop unused is_watch_only from ManagedCoreAccount' clearly and accurately summarizes the main change—removal of the unused is_watch_only field and parameter from managed core account types.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch drop-managed-is-watch-only

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 and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 3, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.16%. Comparing base (806ec4d) to head (c63c160).
⚠️ Report is 1 commits behind head on v0.42-dev.

Files with missing lines Patch % Lines
...t/src/managed_account/managed_core_keys_account.rs 50.00% 2 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           v0.42-dev     #718      +/-   ##
=============================================
- Coverage      71.17%   71.16%   -0.02%     
=============================================
  Files            320      320              
  Lines          68610    68577      -33     
=============================================
- Hits           48836    48802      -34     
- Misses         19774    19775       +1     
Flag Coverage Δ
core 76.19% <ø> (ø)
ffi 45.76% <100.00%> (+0.01%) ⬆️
rpc 20.00% <ø> (ø)
spv 87.42% <ø> (-0.11%) ⬇️
wallet 69.77% <71.42%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
key-wallet-ffi/src/managed_account.rs 52.13% <100.00%> (+0.19%) ⬆️
key-wallet-ffi/src/managed_wallet.rs 81.34% <ø> (ø)
.../src/managed_account/managed_account_collection.rs 55.40% <100.00%> (-0.26%) ⬇️
...allet/src/managed_account/managed_account_trait.rs 37.24% <ø> (ø)
.../src/managed_account/managed_core_funds_account.rs 76.13% <100.00%> (+0.34%) ⬆️
...t/src/managed_account/managed_core_keys_account.rs 54.28% <50.00%> (-0.85%) ⬇️

... and 3 files with indirect coverage changes

@github-actions github-actions Bot added the merge-conflict The PR conflicts with the target branch. label May 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

…ccounts

The `is_watch_only` field on `ManagedCoreKeysAccount` (and its mirror through
`ManagedCoreFundsAccount`) is just propagated from the immutable parent
`Account`. Nothing in the workspace reads it for any decision — every
`if watch-only { deny }` check (`key-wallet-ffi/src/keys.rs:85`,
`key-wallet-ffi/src/account_derivation.rs:41,231,262`) reads
`FFIAccount.inner().is_watch_only`, i.e. the immutable `Account`, not the
managed copy. The denormalized field exists only as test assertions and an
`#[no_mangle]` getter (`managed_core_account_get_is_watch_only`) that nothing
in this repo invokes.

This drops:
- The `is_watch_only` field on `ManagedCoreKeysAccount`
- The `is_watch_only` parameter on `ManagedCoreKeysAccount::new`,
  `ManagedCoreFundsAccount::new`, and the
  `create_managed_account_from_*` helpers
- `ManagedAccountTrait::is_watch_only`
- The `managed_core_account_get_is_watch_only` FFI export

`ManagedPlatformAccount.is_watch_only` and
`managed_platform_account_get_is_watch_only` are unchanged.

Breaking change: any out-of-tree C/Swift consumer of
`managed_core_account_get_is_watch_only` should switch to
`account_get_is_watch_only` on the parent `FFIAccount`, or
`wallet_is_watch_only` for the wallet-level status.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@QuantumExplorer QuantumExplorer force-pushed the drop-managed-is-watch-only branch from 4173c4f to ca8c528 Compare May 5, 2026 17:39
@github-actions github-actions Bot removed the merge-conflict The PR conflicts with the target branch. label May 5, 2026
Copy link
Copy Markdown
Member Author

@QuantumExplorer QuantumExplorer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self Reviewed

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 5, 2026
The verify-ffi pre-commit hook flagged that key-wallet-ffi/FFI_API.md
still listed `managed_core_account_get_is_watch_only`, which this PR
removes. Regenerated to drop the entry.
@QuantumExplorer QuantumExplorer merged commit e8e8283 into v0.42-dev May 6, 2026
39 checks passed
@QuantumExplorer QuantumExplorer deleted the drop-managed-is-watch-only branch May 6, 2026 00:38
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