feat(wallet): declare control.wallet.resetCoinDb, discarding the cached coin database - #48
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
dig-app#295(a reset-coin-db button) needs a typed way to call dig-node's already-shippedcontrol.wallet.resetCoinDb(dig-node PR #543 / dig-node#384). The node dispatches the rawJSON-RPC method by string already, but this crate's
ControlMethodcatalog -- the singlesource 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:Wallet, routingDelegated(alongside every otherwallet.*method)WalletResetCoinDbParams { confirm: bool }(defaultsfalseon omission, so a client thatforgot the flag gets the same refusal as one that typed it explicitly)
WalletResetCoinDbResult { coins_dropped: u64, staged_dropped: u64 }, matchingdig_wallet::sage::db::ResetReportfield-for-fieldExtends
ControlHandler's trait + itsdispatch()match arm (both exhaustive overControlMethod, so required for the crate to compile). The mock KAT node reproduces the realnode's confirm-required refusal, so a client that forgets the flag fails its own KATs rather
than passing them.
Docs
SPEC.mdandREADME.mdboth gain the method row --the_spec_and_readme_name_every_catalogued_methodenforces this and was red until both wereupdated.
Tests
updated to include the new method -- was RED (3 failing) before, confirmed for the right
reason.
confirm(explicitfalseand omitted field, both), and thesuccess 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 withunwrap_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/fmtconfirm nothing else referencesControlMethodnon-exhaustively inthis crate. Downstream (dig-node, dig-app,
dign, the extension) is unaffected until each bumpsits 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 + publishesto crates.io first, then dig-app bumps its
dig-node-control-interfacedependency and buildsthe 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).