Skip to content

feat(wallet): declare control.wallet.resetCoinDb, discarding the cached coin database - #48

Merged
MichaelTaylor3d merged 1 commit into
mainfrom
loop/295-reset-coin-db
Sep 4, 2026
Merged

feat(wallet): declare control.wallet.resetCoinDb, discarding the cached coin database#48
MichaelTaylor3d merged 1 commit into
mainfrom
loop/295-reset-coin-db

Conversation

@MichaelTaylor3d

Copy link
Copy Markdown
Contributor

What changed

dig-app#295 (a reset-coin-db button) needs a typed way to call dig-node's already-shipped
control.wallet.resetCoinDb (dig-node PR #543 / dig-node#384). The node dispatches the raw
JSON-RPC method by string already, but this crate's ControlMethod catalog -- the single
source of truth every client and server reads -- had no entry for it, so no typed client
(dig-app, dign, the extension) could call it.

Adds ControlMethod::WalletResetCoinDb:

  • category Wallet, routing Delegated (alongside every other wallet.* method)
  • ordinary token tier (not master), never an open read -- it mutates local state
  • WalletResetCoinDbParams { confirm: bool } (defaults false on omission, so a client that
    forgot the flag gets the same refusal as one that typed it explicitly)
  • WalletResetCoinDbResult { coins_dropped: u64, staged_dropped: u64 }, matching
    dig_wallet::sage::db::ResetReport field-for-field

Extends ControlHandler's trait + its dispatch() match arm (both exhaustive over
ControlMethod, so required for the crate to compile). The mock KAT node reproduces the real
node's confirm-required refusal, so a client that forgets the flag fails its own KATs rather
than passing them.

Docs

SPEC.md and README.md both gain the method row --
the_spec_and_readme_name_every_catalogued_method enforces this and was red until both were
updated.

Tests

  • 3 existing catalog-exhaustiveness tests (hardcoded expected sets, by the file's own design)
    updated to include the new method -- was RED (3 failing) before, confirmed for the right
    reason.
  • 3 new tests: refuses without confirm (explicit false and omitted field, both), and the
    success path's byte-identical round trip. Verified red-for-the-right-reason by temporarily
    neutering the guard (if false && !params.confirm), watching both refusal tests fail with
    unwrap_err() on an Ok value, then reverting.
  • cargo test --lib: 196 passed, 0 failed (up from 190/3-failed pre-fix).
  • cargo fmt --check + cargo clippy --all-targets: clean on touched files.

Version

0.31.0 -> 0.32.0 (minor): purely additive, no existing wire shape changed.

Blast radius

Additive-only to a catalog crate with three exhaustive-match sites (routing(), category(),
dispatch()) and one exhaustiveness test file (kats.rs) plus two docs. All four were touched;
cargo build/clippy/fmt confirm nothing else references ControlMethod non-exhaustively in
this crate. Downstream (dig-node, dig-app, dign, the extension) is unaffected until each bumps
its dependency -- release-first (CLAUDE.md §4.1).

DO NOT MERGE yet

This is the release-first prerequisite for dig-app#295. Sequence: this PR merges + publishes
to crates.io first, then dig-app bumps its dig-node-control-interface dependency and builds
the reset-coin-db button against the new typed method.

Closes nothing on its own (dig-node#384 and its dig-app companion are tracked separately).

…ed coin database

dig-app#295 needs a typed way to drive dig-node's already-shipped
control.wallet.resetCoinDb (dig-node PR #543, dig-node#384) -- the server dispatches
the raw JSON-RPC method by string already, but this crate's ControlMethod catalog,
the single source of truth every client/server reads, had no entry for it.

Adds WalletResetCoinDb: category Wallet, routing Delegated (alongside every other
wallet.* method), ordinary token tier (not master), never an open read. Params carry
one field, confirm:bool (defaults false on omission so a forgotten flag reads exactly
like an explicit false), bound to a WalletResetCoinDbResult{coins_dropped, staged_dropped}
matching dig-wallet's ResetReport (both u64) byte-for-byte. Extends the ControlHandler
trait + its dispatch() match arm (exhaustive over ControlMethod, so this was required
for the crate to compile), and the MockNode KAT fixture reproduces the real node's own
confirm-required refusal so a client that forgot the flag fails its own KATs rather than
passing them.

SPEC.md + README.md gain the method row (the_spec_and_readme_name_every_catalogued_method
enforces this). Three existing catalog-exhaustiveness tests updated to include the new
method in their hardcoded expected sets, by design (method.rs's own doc: "a method
joining the gated side is a deliberate edit here"). Three new tests assert the
confirm-required refusal (both an explicit false and an omitted field) and the
success path's byte-identical round trip.

Minor bump (0.31.0 -> 0.32.0): purely additive, no existing wire shape changed.

Co-Authored-By: Claude <noreply@anthropic.com>
@MichaelTaylor3d
MichaelTaylor3d marked this pull request as ready for review September 4, 2026 01:57
@MichaelTaylor3d
MichaelTaylor3d merged commit 7db97d1 into main Sep 4, 2026
8 checks passed
@MichaelTaylor3d
MichaelTaylor3d deleted the loop/295-reset-coin-db branch September 4, 2026 01:57
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