1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
22pub enum Routing {
23 Owned,
25 Delegated,
27 OpenBootstrap,
29}
30
31#[non_exhaustive]
37#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
38pub enum Category {
39 Status,
41 Config,
43 Log,
45 Cache,
47 HostedStores,
49 Sync,
51 Updater,
53 Pairing,
55 Peers,
57 Subscriptions,
59 Wallet,
62 Spends,
65 Profile,
69 Collateral,
73}
74
75#[non_exhaustive]
81#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
82pub enum ControlMethod {
83 Status,
86 ConfigGet,
88 ConfigSetUpstream,
90 LogSetLevel,
92
93 CacheGet,
96 CacheSetCap,
98 CacheClear,
100
101 HostedStoresList,
104 HostedStoresPin,
106 HostedStoresUnpin,
108 HostedStoresStatus,
110 CapsuleFetch,
113
114 SyncStatus,
117 SyncTrigger,
119
120 UpdaterStatus,
123 UpdaterSetChannel,
125 UpdaterPause,
127 UpdaterResume,
129 UpdaterCheckNow,
131
132 PairingList,
135 PairingApprove,
137 PairingRevoke,
139
140 PeerStatus,
143 PeerCounts,
145 PeersConnect,
147 PeersDisconnect,
149
150 ChiaPeersAdd,
166 ChiaPeersList,
168 ChiaPeersRemove,
170
171 Subscribe,
174 Unsubscribe,
176 ListSubscriptions,
178
179 WalletBalance,
182 WalletCoins,
184 WalletCoinById,
186 WalletCoinSpend,
188 WalletCoinsByParent,
190 WalletArrivals,
192 WalletOperatorAddress,
194 WalletPeak,
196 WalletSyncStatus,
198 WalletBroadcast,
200 WalletWatch,
202 WalletUnwatch,
204 WalletWatched,
206 WalletReservationsHeld,
208 WalletReservationsReserve,
210 WalletReservationsRelease,
212
213 SpendsList,
216
217 CollateralRequirement,
220 CollateralMarginGet,
222 CollateralMarginSet,
224 CollateralBuffer,
226 MirrorBondStates,
229
230 ProfilePutBody,
233 ProfileGetBody,
235
236 PairingRequest,
239 PairingPoll,
241}
242
243impl ControlMethod {
244 pub const fn name(self) -> &'static str {
246 match self {
247 ControlMethod::Status => "control.status",
248 ControlMethod::ConfigGet => "control.config.get",
249 ControlMethod::ConfigSetUpstream => "control.config.setUpstream",
250 ControlMethod::LogSetLevel => "control.log.setLevel",
251 ControlMethod::CacheGet => "control.cache.get",
252 ControlMethod::CacheSetCap => "control.cache.setCap",
253 ControlMethod::CacheClear => "control.cache.clear",
254 ControlMethod::HostedStoresList => "control.hostedStores.list",
255 ControlMethod::HostedStoresPin => "control.hostedStores.pin",
256 ControlMethod::HostedStoresUnpin => "control.hostedStores.unpin",
257 ControlMethod::HostedStoresStatus => "control.hostedStores.status",
258 ControlMethod::CapsuleFetch => "control.capsule.fetch",
259 ControlMethod::SyncStatus => "control.sync.status",
260 ControlMethod::SyncTrigger => "control.sync.trigger",
261 ControlMethod::UpdaterStatus => "control.updater.status",
262 ControlMethod::UpdaterSetChannel => "control.updater.setChannel",
263 ControlMethod::UpdaterPause => "control.updater.pause",
264 ControlMethod::UpdaterResume => "control.updater.resume",
265 ControlMethod::UpdaterCheckNow => "control.updater.checkNow",
266 ControlMethod::PairingList => "control.pairing.list",
267 ControlMethod::PairingApprove => "control.pairing.approve",
268 ControlMethod::PairingRevoke => "control.pairing.revoke",
269 ControlMethod::PeerStatus => "control.peerStatus",
270 ControlMethod::PeerCounts => "control.peerCounts",
271 ControlMethod::PeersConnect => "control.peers.connect",
272 ControlMethod::PeersDisconnect => "control.peers.disconnect",
273 ControlMethod::ChiaPeersAdd => "control.chiaPeers.add",
274 ControlMethod::ChiaPeersList => "control.chiaPeers.list",
275 ControlMethod::ChiaPeersRemove => "control.chiaPeers.remove",
276 ControlMethod::Subscribe => "control.subscribe",
277 ControlMethod::Unsubscribe => "control.unsubscribe",
278 ControlMethod::ListSubscriptions => "control.listSubscriptions",
279 ControlMethod::WalletBalance => "control.wallet.balance",
280 ControlMethod::WalletCoins => "control.wallet.coins",
281 ControlMethod::WalletCoinById => "control.wallet.coinById",
282 ControlMethod::WalletCoinSpend => "control.wallet.coinSpend",
283 ControlMethod::WalletCoinsByParent => "control.wallet.coinsByParent",
284 ControlMethod::WalletArrivals => "control.wallet.arrivals",
285 ControlMethod::WalletOperatorAddress => "control.wallet.operatorAddress",
286 ControlMethod::WalletPeak => "control.wallet.peak",
287 ControlMethod::WalletSyncStatus => "control.wallet.syncStatus",
288 ControlMethod::WalletBroadcast => "control.wallet.broadcast",
289 ControlMethod::WalletWatch => "control.wallet.watch",
290 ControlMethod::WalletUnwatch => "control.wallet.unwatch",
291 ControlMethod::WalletWatched => "control.wallet.watched",
292 ControlMethod::WalletReservationsHeld => "control.wallet.reservations.held",
293 ControlMethod::WalletReservationsReserve => "control.wallet.reservations.reserve",
294 ControlMethod::WalletReservationsRelease => "control.wallet.reservations.release",
295 ControlMethod::SpendsList => "control.spends.list",
296 ControlMethod::CollateralRequirement => "control.collateral.requirement",
297 ControlMethod::CollateralMarginGet => "control.collateral.margin.get",
298 ControlMethod::CollateralMarginSet => "control.collateral.margin.set",
299 ControlMethod::CollateralBuffer => "control.collateral.buffer",
300 ControlMethod::MirrorBondStates => "control.mirror.bondStates",
301 ControlMethod::ProfilePutBody => "control.profile.putBody",
302 ControlMethod::ProfileGetBody => "control.profile.getBody",
303 ControlMethod::PairingRequest => "pairing.request",
304 ControlMethod::PairingPoll => "pairing.poll",
305 }
306 }
307
308 pub fn from_name(name: &str) -> Option<ControlMethod> {
310 ControlMethod::ALL
311 .iter()
312 .copied()
313 .find(|m| m.name() == name)
314 }
315
316 pub const fn requires_auth(self) -> bool {
343 !self.is_open_read()
344 && !matches!(
345 self,
346 ControlMethod::PairingRequest | ControlMethod::PairingPoll
347 )
348 }
349
350 pub const fn is_open_read(self) -> bool {
384 matches!(
385 self,
386 ControlMethod::WalletBalance
387 | ControlMethod::WalletCoins
388 | ControlMethod::WalletCoinById
389 | ControlMethod::WalletCoinSpend
390 | ControlMethod::WalletCoinsByParent
391 | ControlMethod::WalletPeak
392 | ControlMethod::WalletSyncStatus
393 | ControlMethod::PeerCounts
394 )
395 }
396
397 pub const fn is_pairing_admin(self) -> bool {
406 matches!(
407 self,
408 ControlMethod::PairingList
409 | ControlMethod::PairingApprove
410 | ControlMethod::PairingRevoke
411 )
412 }
413
414 pub const fn requires_master_token(self) -> bool {
441 self.is_pairing_admin()
442 || matches!(
443 self,
444 ControlMethod::ChiaPeersAdd | ControlMethod::ChiaPeersRemove
445 )
446 }
447
448 pub const fn routing(self) -> Routing {
450 match self {
451 ControlMethod::PeerStatus
452 | ControlMethod::PeerCounts
453 | ControlMethod::PeersConnect
454 | ControlMethod::PeersDisconnect
455 | ControlMethod::Subscribe
456 | ControlMethod::Unsubscribe
457 | ControlMethod::ListSubscriptions
458 | ControlMethod::WalletBalance
459 | ControlMethod::WalletCoins
460 | ControlMethod::WalletCoinById
461 | ControlMethod::WalletCoinSpend
462 | ControlMethod::WalletCoinsByParent
463 | ControlMethod::WalletArrivals
464 | ControlMethod::WalletPeak
465 | ControlMethod::WalletSyncStatus
466 | ControlMethod::WalletBroadcast
467 | ControlMethod::WalletWatch
468 | ControlMethod::WalletUnwatch
469 | ControlMethod::WalletWatched
470 | ControlMethod::WalletReservationsHeld
471 | ControlMethod::WalletReservationsReserve
472 | ControlMethod::WalletReservationsRelease
473 | ControlMethod::ProfilePutBody
474 | ControlMethod::ProfileGetBody => Routing::Delegated,
475 ControlMethod::PairingRequest | ControlMethod::PairingPoll => Routing::OpenBootstrap,
476 _ => Routing::Owned,
477 }
478 }
479
480 pub const fn category(self) -> Category {
482 match self {
483 ControlMethod::Status => Category::Status,
484 ControlMethod::ConfigGet | ControlMethod::ConfigSetUpstream => Category::Config,
485 ControlMethod::LogSetLevel => Category::Log,
486 ControlMethod::CacheGet | ControlMethod::CacheSetCap | ControlMethod::CacheClear => {
487 Category::Cache
488 }
489 ControlMethod::HostedStoresList
490 | ControlMethod::HostedStoresPin
491 | ControlMethod::HostedStoresUnpin
492 | ControlMethod::HostedStoresStatus
493 | ControlMethod::CapsuleFetch => Category::HostedStores,
494 ControlMethod::SyncStatus | ControlMethod::SyncTrigger => Category::Sync,
495 ControlMethod::UpdaterStatus
496 | ControlMethod::UpdaterSetChannel
497 | ControlMethod::UpdaterPause
498 | ControlMethod::UpdaterResume
499 | ControlMethod::UpdaterCheckNow => Category::Updater,
500 ControlMethod::PairingList
501 | ControlMethod::PairingApprove
502 | ControlMethod::PairingRevoke
503 | ControlMethod::PairingRequest
504 | ControlMethod::PairingPoll => Category::Pairing,
505 ControlMethod::PeerStatus
506 | ControlMethod::PeerCounts
507 | ControlMethod::PeersConnect
508 | ControlMethod::PeersDisconnect
509 | ControlMethod::ChiaPeersAdd
510 | ControlMethod::ChiaPeersList
511 | ControlMethod::ChiaPeersRemove => Category::Peers,
512 ControlMethod::Subscribe
513 | ControlMethod::Unsubscribe
514 | ControlMethod::ListSubscriptions => Category::Subscriptions,
515 ControlMethod::WalletBalance
516 | ControlMethod::WalletCoins
517 | ControlMethod::WalletCoinById
518 | ControlMethod::WalletCoinSpend
519 | ControlMethod::WalletCoinsByParent
520 | ControlMethod::WalletArrivals
521 | ControlMethod::WalletPeak
522 | ControlMethod::WalletSyncStatus
523 | ControlMethod::WalletOperatorAddress
524 | ControlMethod::WalletBroadcast
525 | ControlMethod::WalletWatch
526 | ControlMethod::WalletUnwatch
527 | ControlMethod::WalletWatched
528 | ControlMethod::WalletReservationsHeld
529 | ControlMethod::WalletReservationsReserve
530 | ControlMethod::WalletReservationsRelease => Category::Wallet,
531 ControlMethod::SpendsList => Category::Spends,
532 ControlMethod::CollateralRequirement
533 | ControlMethod::CollateralMarginGet
534 | ControlMethod::CollateralMarginSet
535 | ControlMethod::CollateralBuffer
536 | ControlMethod::MirrorBondStates => Category::Collateral,
537 ControlMethod::ProfilePutBody | ControlMethod::ProfileGetBody => Category::Profile,
538 }
539 }
540
541 pub const fn summary(self) -> &'static str {
543 match self {
544 ControlMethod::ChiaPeersAdd => "Trust a Chia full node by IP. A trusted peer BYPASSES CORROBORATION: this node normally believes a chain answer only when several independently-dialled peers agree, and a trusted peer is believed on its own -- so a wrong or hostile one can feed this node a false view of the chain. Add only a node you run yourself.",
545 ControlMethod::ChiaPeersList => "The Chia full-node peers this node tracks, each flagged user_managed: true where a person added it by hand and it is therefore trusted without corroboration.",
546 ControlMethod::ChiaPeersRemove => "Stop trusting a Chia full node, optionally banning it. Removing restores corroboration for that peer: chain answers must once again be agreed by independently-dialled peers.",
547 ControlMethod::Status => "A rich node status snapshot (version, uptime, addr, cache, hosted/pinned counts, sync availability).",
548 ControlMethod::ConfigGet => "The node's effective configuration (addr/port, upstream + override, cache dir/shared, config path, sync availability).",
549 ControlMethod::ConfigSetUpstream => "Persist an upstream-RPC override; takes effect on next node start (requires_restart).",
550 ControlMethod::LogSetLevel => "Live-swap the running node's tracing EnvFilter directive (not persisted).",
551 ControlMethod::CacheGet => "The on-disk content-cache view: cap_bytes, used_bytes, dir, shared.",
552 ControlMethod::CacheSetCap => "Set the on-disk cache size cap in bytes (floored at 64 MiB).",
553 ControlMethod::CacheClear => "Delete all locally cached DIG content.",
554 ControlMethod::HostedStoresList => "Every held/pinned store, merged, with each store's cached capsules and a pinned flag.",
555 ControlMethod::HostedStoresPin => "Pin a store (storeId[:rootHash]); pre-fetches the capsule when a root is given and §21 sync is available.",
556 ControlMethod::HostedStoresUnpin => "Unpin a store and evict its cached capsules.",
557 ControlMethod::HostedStoresStatus => "Per-store status: pinned flag, cached capsules, total bytes.",
558 ControlMethod::CapsuleFetch => "Start a P2P whole-capsule pull for one store+root over the recursive discover-then-dial path (distinct from the §21 HTTP sync `control.sync.trigger` uses). Answers `already_cached` without dialling out when the capsule is already on disk.",
559 ControlMethod::SyncStatus => "Whether authenticated §21 whole-store sync is available, plus pinned-store cache coverage.",
560 ControlMethod::SyncTrigger => "Trigger a §21 sync for one capsule (storeId + root).",
561 ControlMethod::UpdaterStatus => "The DIG auto-update beacon's current status (proxied from dig-updater).",
562 ControlMethod::UpdaterSetChannel => "Set the beacon's update channel (\"nightly\" | \"stable\").",
563 ControlMethod::UpdaterPause => "Suspend the beacon's auto-updates (optionally until a unix time).",
564 ControlMethod::UpdaterResume => "Resume the beacon's auto-updates.",
565 ControlMethod::UpdaterCheckNow => "Force an immediate beacon update check.",
566 ControlMethod::PairingList => "List pending pairing requests and issued paired tokens (MASTER token only).",
567 ControlMethod::PairingApprove => "Approve a pending pairing, minting a scoped token (MASTER token only).",
568 ControlMethod::PairingRevoke => "Revoke an issued paired token by token_id (MASTER token only).",
569 ControlMethod::PeerStatus => "Live peer-pool + relay-reservation snapshot, including the per-peer connected array; each entry carries an always-present `software` field (the peer's advertised build). Its `relay.peer_count` counts peers connected to THE RELAY, not to this node, and is never the answer to \"how many peers does this node have\" -- that is control.peerCounts.",
570 ControlMethod::PeerCounts => "READ-only: how many peers this node holds on EACH network -- dig_peer_count (DIG content/gossip, port 9445) and chia_peer_count (Chia full nodes serving the wallet chain sync). Two unrelated numbers, each named for its network.",
571 ControlMethod::PeersConnect => "Dial a peer by address, or resolve an already-connected peer_id, via the live gossip pool.",
572 ControlMethod::PeersDisconnect => "Drop a pooled peer by peer_id, closing its mTLS link (idempotent).",
573 ControlMethod::Subscribe => "Subscribe the node to a store it actively watches and gap-fills.",
574 ControlMethod::Unsubscribe => "Stop watching a store.",
575 ControlMethod::ListSubscriptions => "The node's persisted subscription set + count.",
576 ControlMethod::WalletCoins => "READ-only: the spendable coin records for an address + asset, with the tier that answered and the height they reflect.",
577 ControlMethod::WalletCoinById => "READ-only: ONE coin record by coin id, spent or unspent, with no address and no asset scope; `coin: null` means the chain holds no such coin.",
578 ControlMethod::WalletCoinSpend => "READ-only: the SPEND that spent a coin -- its puzzle reveal, its solution and the coin itself -- named by the coin's own id. `spend: null` means the consulted chain shows that coin as unspent or unknown; it NEVER means the chain could not be reached, which is an error.",
579 ControlMethod::WalletCoinsByParent => "READ-only: the DIRECT children created by spending one coin, named by that parent's coin id. ONE hop, never a recursive walk: an empty list means the parent created no known children, and a caller wanting a lineage composes hops itself.",
580 ControlMethod::WalletArrivals => "READ-only: confirmed INCOMING funds recorded since a cursor position, oldest first -- the answer to `was I just paid?`, which no balance or coin list can give. Each row is a coin the node determined ARRIVED: confirmed on chain, above the wallet's arrival baseline, not previously reported, and not the wallet's own change. Resume from `cursor` (the last row you were handed), never from `latest`.",
581 ControlMethod::WalletOperatorAddress => "READ-only: the address of the node's OWN operator wallet -- the MACHINE-custody wallet that pays mirror-coin collateral, never the user's. Returns a public address and puzzle hash and NEVER any key, seed or derivation material. TOKEN-GATED, and answered by THIS node rather than forwarded upstream.",
582 ControlMethod::WalletPeak => "READ-only: the node's current chain peak height, independent of any address.",
583 ControlMethod::WalletSyncStatus => "READ-only: whether the wallet's CHAIN replica is being kept current (not_started/syncing/synced/no_wallet_enrolled/wallet_not_unlocked), the replica's own height, and its CHIA full-node peer count -- unrelated to control.sync.status (DIG stores) and to control.peerStatus (DIG peers).",
584 ControlMethod::WalletBroadcast => "Push an ALREADY-SIGNED spend bundle to the network; the node never signs. TOKEN-GATED.",
585 ControlMethod::WalletBalance => "READ-only: the confirmed spendable balance for an address + asset (plus pending, sync freshness, and the peak height it reflects).",
586 ControlMethod::WalletWatch => "Enrol PUBLIC keys (48-byte G1, lowercase 96-hex) for the node's chain replica to follow, so their addresses are synced and readable. IDEMPOTENT: re-enrolling a key already enrolled succeeds and changes nothing. Keys, never puzzle hashes -- the node derives the addresses itself, so one derivation serves every client. TOKEN-GATED.",
587 ControlMethod::WalletUnwatch => "Deregister enrolled public keys, so the node stops following their addresses. IDEMPOTENT: a key that was never enrolled is not an error. TOKEN-GATED.",
588 ControlMethod::SpendsList => "READ-only: the record of spends this node made WITHOUT per-transaction approval -- what moved, when, on whose standing authority, and whether the chain confirmed it. It NEVER initiates, signs, cancels or alters a spend, and there is no verb here that edits an entry. A failed spend is reported WITH the stage it died at, because only a signing failure means the money definitely did not move; a broadcast or confirmation failure is an UNKNOWN outcome, as is `unresolved`. A page is bounded and says so via `complete`; `unreadable_lines` reports entries the node could not parse, so an audit trail that lost rows can never read as a tidy shorter one. TOKEN-GATED although it is a read: the caller supplies no identifier, so the answer is this node's OWN state.",
589 ControlMethod::CollateralRequirement => "READ-only: this epoch's per-store mirror-collateral requirement in DIG base units, the collateral protocol version that computed it, and the census inputs behind it (advertised stores, collateralised owners, controller multiplier, small-network handicap) so a client can show WHY the figure moved rather than only that it did. A node that has not censused the epoch, or that is inside the census finality depth, answers `unknown` WITH the reason -- never a zero, which would read as a free requirement. `stores` counts qualifying (owner, store, root) advertisements and `owners` counts distinct owner puzzle hashes: neither is a node count. It NEVER returns the local safety margin, which is not a consensus value.",
590 ControlMethod::CollateralMarginGet => "Read the node's LOCAL safety margin in BASIS POINTS over the epoch requirement (`100` is +1%). The margin is an operator preference that changes only how much THIS node chooses to lock; it is never a census input and no value derived from it reaches another node. Basis points are the unit the collateral crate's own presets and rounding use, and are never converted.",
591 ControlMethod::CollateralMarginSet => "Set the node's LOCAL safety margin in BASIS POINTS (`100` is +1%), returning the margin now in force. Bounded at 10000 bp (+100%): the margin multiplies what the node locks on every store, so an unbounded value would commit the operator to an arbitrary posting. A margin above the bound is REFUSED as -32602 INVALID_PARAMS rather than clamped, so the applied value can never differ silently from the requested one. A margin gives room if the requirement rises; it does NOT guarantee a store is counted, because the requirement is re-derived every epoch and can rise by more than any margin.",
592 ControlMethod::ProfilePutBody => "Hand the node the dig-profile BODY that a chain root commits to. The node INDEPENDENTLY resolves that root on chain and REFUSES any body whose recomputed root is not the confirmed one -- the caller's `root` is a claim to be checked, never a fact to be trusted, and dig-app is a caller like any other. Bodies are capped at MAX_BODY_BYTES (4 MiB). TOKEN-GATED.",
593 ControlMethod::ProfileGetBody => "READ-only: the dig-profile body this node holds at a given store id + root, or `body: null` when it holds none. `null` NEVER means the body could not be read, which is an error. TOKEN-GATED.",
594 ControlMethod::WalletWatched => "READ-only: the public keys currently enrolled, so a client can reconcile what it asked for against what the node holds. TOKEN-GATED although it is a read -- the caller supplies nothing, so the answer is this node's OWN key set.",
595 ControlMethod::WalletReservationsHeld => "READ-only: every coin currently committed to an in-flight spend, each with the reservation holding it and the unix second that hold lapses, plus the node's own clock. `reserved: []` means NOTHING is held; a set that cannot be read is an error, never an empty list. Narrows what a caller may SELECT; never subtract these from a balance -- the coins are still the user's money. TOKEN-GATED although it is a read: the caller supplies nothing, so the answer is this node's OWN state.",
596 ControlMethod::WalletReservationsReserve => "Atomically hold coins against further selection: EVERY named coin or none. A coin already held refuses the whole call and reserves nothing, as WALLET_COINS_RESERVED -- a WAIT, never a shortfall. Reserving an empty list succeeds with a handle that releases nothing. The requested ttl_secs is clamped by the node, which returns the lifetime it actually applied. Bookkeeping only: it holds no key and authorizes nothing (§908). TOKEN-GATED.",
597 ControlMethod::WalletReservationsRelease => "Free a hold now rather than waiting out its TTL -- call it the moment a spend is known settled or known dead. A handle that names no live reservation is a SUCCESS with released: false, because a caller releasing on confirmation cannot know whether the TTL got there first. Every hold also lapses on its own, so an abandoned reservation is recoverable and never a permanent funds lockout. TOKEN-GATED.",
598 ControlMethod::CollateralBuffer => "READ-only: the $DIG this node recommends HOLDING, in DIG base units, and the funding state it is in -- plus the working behind the figure: the (owner, store, root) pairs THIS NODE serves, the epoch's pre-margin per-store requirement, the local margin in force (BASIS POINTS, `100` is +1%, never converted), the unreclaimed transition overlap, and the escalation headroom. Amounts are DIG base units (3 decimals, one base unit is 0.001 DIG) and never mojos, which are XCH's 1e-12 unit. The HORIZON the headroom assumed travels in the payload and is never implied: escalation is bounded at +12.5% per epoch and COMPOUNDS (x1.12 at one epoch, x1.60 at four, x4.62 at thirteen), so the same buffer over a different horizon is a different claim; `escalation_ceiling_micros` is a WORST CASE, not a forecast -- in the dead band the multiplier does not move. The FUNDING STATE is carried rather than left to each client to re-derive from thresholds, because two clients deriving it will disagree and the one that disagrees about a funding warning is the one an operator acts on; `short_now` and `dangerously_low` leave an epoch uncovered, `below_recommended_buffer` covers every epoch with no cushion and is a READOUT, never a notification. A node that cannot enumerate its served set, cannot read its reclaim state, cannot see its balance, or has no requirement to scale answers `unknown` WITH the reason -- never a zero, which here reads as NO BUFFER NEEDED and would have an operator post nothing. It is a SEPARATE method from `control.collateral.requirement` because that figure is consensus-derived while this one is local: it depends on this node's own served set, an operator preference, and a horizon this node chose. TOKEN-GATED although it is a read: the caller supplies nothing, so the answer is this node's OWN served set, preference and balance.",
599 ControlMethod::MirrorBondStates => "READ-only: the state of every mirror bond this node holds, keyed per (store, root), plus the $DIG those bonds have LOCKED. Seven states, and six of them mean `no coin yet` for entirely different reasons: `bonded` (a coin id, epoch and the amount THAT COIN locks, read from the coin and not from today's requirement), `pending` (submitted, unconfirmed -- never a shortfall), `unfunded` (the ONLY genuine out-of-funds state, carrying how many DIG BASE UNITS this bond alone is short), `deferred` (the epoch requirement is unknown so no create can be priced -- the wallet may be full), `withheld` (Relayed provenance: held and deliberately never advertised), `disabled` (collateralisation is switched off node-wide) and `reclaiming` (a live coin whose money is STILL LOCKED until the reclaim confirms). Conflating `unfunded` with `withheld` or `disabled` produces hourly out-of-funds alarms about a healthy node, which is the defect this method removes. Amounts are DIG base units (3 decimals, one base unit is 0.001 DIG) and NEVER mojos, which are XCH's 1e-12 unit. `locked_dig_base_units` is the WHOLE-SET total including reclaiming coins, computed by the node: a client MUST NOT sum the page, which would under-report locked money by a page boundary and show unspendable funds as available. A node that cannot enumerate its bonds, cannot read chain, cannot see its own in-flight creates, or cannot determine the provenance of what it holds answers `unknown` for the WHOLE call WITH the reason -- there is no per-row unknown and no empty-list fallback, because a truncated list and a complete one read the same. A page is bounded, ordered by ascending (store_id, root), and says via `complete` whether it is the whole set; resume from the `cursor` key you were HANDED. TOKEN-GATED although it is a read: the caller supplies nothing, so the answer is this node's OWN bond set and funding position.",
600 ControlMethod::PairingRequest => "OPEN: request a control-token pairing; returns a pairing_id + pairing_code to compare.",
601 ControlMethod::PairingPoll => "OPEN: poll a pairing by id; once the operator approves, returns the scoped token once.",
602 }
603 }
604
605 pub const ALL: &'static [ControlMethod] = &[
608 ControlMethod::Status,
609 ControlMethod::ConfigGet,
610 ControlMethod::ConfigSetUpstream,
611 ControlMethod::LogSetLevel,
612 ControlMethod::CacheGet,
613 ControlMethod::CacheSetCap,
614 ControlMethod::CacheClear,
615 ControlMethod::HostedStoresList,
616 ControlMethod::HostedStoresPin,
617 ControlMethod::HostedStoresUnpin,
618 ControlMethod::HostedStoresStatus,
619 ControlMethod::CapsuleFetch,
620 ControlMethod::SyncStatus,
621 ControlMethod::SyncTrigger,
622 ControlMethod::UpdaterStatus,
623 ControlMethod::UpdaterSetChannel,
624 ControlMethod::UpdaterPause,
625 ControlMethod::UpdaterResume,
626 ControlMethod::UpdaterCheckNow,
627 ControlMethod::PairingList,
628 ControlMethod::PairingApprove,
629 ControlMethod::PairingRevoke,
630 ControlMethod::PeerStatus,
631 ControlMethod::PeerCounts,
632 ControlMethod::PeersConnect,
633 ControlMethod::PeersDisconnect,
634 ControlMethod::ChiaPeersAdd,
635 ControlMethod::ChiaPeersList,
636 ControlMethod::ChiaPeersRemove,
637 ControlMethod::Subscribe,
638 ControlMethod::Unsubscribe,
639 ControlMethod::ListSubscriptions,
640 ControlMethod::WalletBalance,
641 ControlMethod::WalletCoins,
642 ControlMethod::WalletCoinById,
643 ControlMethod::WalletCoinSpend,
644 ControlMethod::WalletCoinsByParent,
645 ControlMethod::WalletArrivals,
646 ControlMethod::WalletPeak,
647 ControlMethod::WalletSyncStatus,
648 ControlMethod::WalletOperatorAddress,
649 ControlMethod::WalletBroadcast,
650 ControlMethod::WalletWatch,
651 ControlMethod::WalletUnwatch,
652 ControlMethod::WalletWatched,
653 ControlMethod::WalletReservationsHeld,
654 ControlMethod::WalletReservationsReserve,
655 ControlMethod::WalletReservationsRelease,
656 ControlMethod::SpendsList,
657 ControlMethod::CollateralRequirement,
658 ControlMethod::CollateralMarginGet,
659 ControlMethod::CollateralMarginSet,
660 ControlMethod::CollateralBuffer,
661 ControlMethod::MirrorBondStates,
662 ControlMethod::ProfilePutBody,
663 ControlMethod::ProfileGetBody,
664 ControlMethod::PairingRequest,
665 ControlMethod::PairingPoll,
666 ];
667}
668
669#[cfg(test)]
670mod tests {
671 use super::*;
672 use std::collections::BTreeSet;
673
674 #[test]
675 fn every_method_has_a_unique_wire_name() {
676 let names: BTreeSet<&str> = ControlMethod::ALL.iter().map(|m| m.name()).collect();
677 assert_eq!(
678 names.len(),
679 ControlMethod::ALL.len(),
680 "duplicate or missing wire names in the catalog"
681 );
682 }
683
684 #[test]
685 fn from_name_round_trips_every_method() {
686 for &m in ControlMethod::ALL {
687 assert_eq!(ControlMethod::from_name(m.name()), Some(m));
688 }
689 assert_eq!(ControlMethod::from_name("control.nope"), None);
690 assert_eq!(ControlMethod::from_name(""), None);
691 }
692
693 #[test]
694 fn the_token_less_surface_is_exactly_the_bootstrap_plus_the_chain_reads() {
695 let expected_open: BTreeSet<&str> = [
699 "pairing.request",
700 "pairing.poll",
701 "control.wallet.balance",
702 "control.wallet.coins",
703 "control.wallet.coinById",
704 "control.wallet.coinSpend",
705 "control.wallet.coinsByParent",
706 "control.wallet.peak",
707 "control.wallet.syncStatus",
708 "control.peerCounts",
709 ]
710 .into_iter()
711 .collect();
712 assert_eq!(
713 expected_open.len(),
714 10,
715 "the open surface is ten named methods"
716 );
717 let actual_open: BTreeSet<&str> = ControlMethod::ALL
718 .iter()
719 .filter(|m| !m.requires_auth())
720 .map(|m| m.name())
721 .collect();
722 assert_eq!(actual_open, expected_open);
723 }
724
725 #[test]
734 fn the_gated_wallet_methods_are_the_push_the_cursor_and_enrolment() {
735 let gated: Vec<&str> = ControlMethod::ALL
736 .iter()
737 .filter(|m| m.category() == Category::Wallet && m.requires_auth())
738 .map(|m| m.name())
739 .collect();
740 assert_eq!(
741 gated,
742 vec![
743 "control.wallet.arrivals",
744 "control.wallet.operatorAddress",
748 "control.wallet.broadcast",
749 "control.wallet.watch",
750 "control.wallet.unwatch",
751 "control.wallet.watched",
752 "control.wallet.reservations.held",
753 "control.wallet.reservations.reserve",
754 "control.wallet.reservations.release",
755 ]
756 );
757 assert!(!ControlMethod::WalletBroadcast.is_open_read());
758 }
759
760 #[test]
772 fn the_arrival_cursor_is_not_an_open_read() {
773 assert!(
774 !ControlMethod::WalletArrivals.is_open_read(),
775 "control.wallet.arrivals discloses this node's OWN watched puzzle hashes to a caller \
776 that supplied nothing, so it MUST NOT be served token-less"
777 );
778 assert!(ControlMethod::WalletArrivals.requires_auth());
779 assert!(
780 ControlMethod::WalletCoinById.is_open_read(),
781 "the caller-addressed reads stay open -- the fix is the membership rule, not gating \
782 the wallet category"
783 );
784 }
785
786 #[test]
805 fn the_catalog_serves_every_chain_source_primitive() {
806 for wire in [
807 "control.wallet.coinById", "control.wallet.coins", "control.wallet.peak", "control.wallet.coinsByParent", "control.wallet.coinSpend", ] {
813 assert!(
814 ControlMethod::from_name(wire).is_some(),
815 "{wire} is required to implement ChainSource over the control plane"
816 );
817 }
818 }
819
820 #[test]
827 fn the_chain_primitives_are_caller_named_open_reads() {
828 for method in [
829 ControlMethod::WalletCoinSpend,
830 ControlMethod::WalletCoinsByParent,
831 ] {
832 assert!(
833 method.is_open_read(),
834 "{} names its subject in the request and discloses no node-to-address \
835 association, exactly like control.wallet.coinById",
836 method.name()
837 );
838 assert!(!method.requires_auth());
839 }
840 assert!(
841 ControlMethod::WalletArrivals.requires_auth(),
842 "the caller-supplies-nothing read stays gated -- the rule is who names the subject, \
843 not whether the bytes are on chain"
844 );
845 assert!(ControlMethod::WalletBroadcast.requires_auth());
846 }
847
848 #[test]
862 fn the_enrolment_methods_are_gated_including_the_read() {
863 for wire in [
864 "control.wallet.watch",
865 "control.wallet.unwatch",
866 "control.wallet.watched",
867 ] {
868 let method = ControlMethod::from_name(wire)
869 .unwrap_or_else(|| panic!("{wire} must be in the catalog"));
870 assert!(
871 !method.is_open_read(),
872 "{wire} either aims this node's subscriptions or names the keys it already \
873 follows, so it MUST NOT be served token-less"
874 );
875 assert!(method.requires_auth(), "{wire} must require the token");
876 assert_eq!(method.category(), Category::Wallet);
877 assert_eq!(method.routing(), Routing::Delegated);
878 }
879 assert!(
880 ControlMethod::WalletCoinById.is_open_read(),
881 "the caller-addressed reads stay open -- enrolment is gated by the membership rule, \
882 not by gating the wallet category"
883 );
884 }
885
886 #[test]
887 fn only_pairing_bootstrap_is_open_bootstrap_routed() {
888 for &m in ControlMethod::ALL {
889 let open_bootstrap = matches!(
890 m,
891 ControlMethod::PairingRequest | ControlMethod::PairingPoll
892 );
893 assert_eq!(
894 m.routing() == Routing::OpenBootstrap,
895 open_bootstrap,
896 "{} routing mismatch",
897 m.name()
898 );
899 }
900 }
901
902 #[test]
903 fn pairing_admin_methods_are_exactly_three() {
904 let admin: Vec<&str> = ControlMethod::ALL
905 .iter()
906 .filter(|m| m.is_pairing_admin())
907 .map(|m| m.name())
908 .collect();
909 assert_eq!(
910 admin,
911 vec![
912 "control.pairing.list",
913 "control.pairing.approve",
914 "control.pairing.revoke"
915 ]
916 );
917 }
918
919 #[test]
926 fn the_master_token_tier_is_pairing_admin_plus_the_trusted_peer_mutations() {
927 let master: BTreeSet<&str> = ControlMethod::ALL
928 .iter()
929 .filter(|m| m.requires_master_token())
930 .map(|m| m.name())
931 .collect();
932 let expected: BTreeSet<&str> = [
933 "control.pairing.list",
934 "control.pairing.approve",
935 "control.pairing.revoke",
936 "control.chiaPeers.add",
937 "control.chiaPeers.remove",
938 ]
939 .into_iter()
940 .collect();
941 assert_eq!(master, expected);
942
943 for &m in ControlMethod::ALL {
946 assert!(
947 !m.is_pairing_admin() || m.requires_master_token(),
948 "{} is pairing-admin but not master-tier",
949 m.name()
950 );
951 }
952 assert!(
953 master.len()
954 > ControlMethod::ALL
955 .iter()
956 .filter(|m| m.is_pairing_admin())
957 .count(),
958 "the two predicates must not be interchangeable"
959 );
960
961 for &m in ControlMethod::ALL {
963 assert!(
964 !m.requires_master_token() || m.requires_auth(),
965 "{}",
966 m.name()
967 );
968 }
969 }
970
971 #[test]
978 fn the_add_summary_authorises_only_a_node_the_operator_runs() {
979 let summary = ControlMethod::ChiaPeersAdd.summary().to_lowercase();
980 assert!(
981 summary.contains("a node you run"),
982 "add must name the operator-run scope, got: {summary}"
983 );
984 for widened in ["vouch", "otherwise trust", "trust yourself", "recommend"] {
985 assert!(
986 !summary.contains(widened),
987 "add summary widens operator trust past NC-12 with {widened:?}: {summary}"
988 );
989 }
990 }
991
992 #[test]
993 fn delegated_set_matches_the_engine_surface() {
994 let delegated: BTreeSet<&str> = ControlMethod::ALL
995 .iter()
996 .filter(|m| m.routing() == Routing::Delegated)
997 .map(|m| m.name())
998 .collect();
999 let expected: BTreeSet<&str> = [
1000 "control.wallet.coins",
1001 "control.wallet.coinById",
1002 "control.wallet.coinSpend",
1003 "control.wallet.coinsByParent",
1004 "control.wallet.arrivals",
1005 "control.wallet.peak",
1006 "control.wallet.syncStatus",
1007 "control.wallet.broadcast",
1008 "control.wallet.watch",
1009 "control.wallet.unwatch",
1010 "control.wallet.watched",
1011 "control.wallet.reservations.held",
1012 "control.wallet.reservations.reserve",
1013 "control.wallet.reservations.release",
1014 "control.profile.putBody",
1015 "control.profile.getBody",
1016 "control.peerStatus",
1017 "control.peerCounts",
1018 "control.peers.connect",
1019 "control.peers.disconnect",
1020 "control.subscribe",
1021 "control.unsubscribe",
1022 "control.listSubscriptions",
1023 "control.wallet.balance",
1024 ]
1025 .into_iter()
1026 .collect();
1027 assert_eq!(delegated, expected);
1028 }
1029
1030 #[test]
1037 fn the_trusted_chia_peer_methods_are_gated_and_disclose_the_corroboration_bypass() {
1038 let declared: BTreeSet<&str> = ControlMethod::ALL.iter().map(|m| m.name()).collect();
1039 for name in [
1040 "control.chiaPeers.add",
1041 "control.chiaPeers.list",
1042 "control.chiaPeers.remove",
1043 ] {
1044 assert!(declared.contains(name), "{name} is not in the catalog");
1045 let m = ControlMethod::from_name(name).expect("from_name round-trips");
1046 assert_eq!(m.category(), Category::Peers, "{name} is a peers method");
1047 assert_eq!(m.routing(), Routing::Owned, "{name} is served by the shell");
1048 assert!(m.requires_auth(), "{name} must require the control token");
1049 assert!(!m.is_open_read(), "{name} is not an open read");
1050 }
1051 assert!(ControlMethod::ChiaPeersAdd.requires_master_token());
1055 assert!(ControlMethod::ChiaPeersRemove.requires_master_token());
1056 assert!(
1057 !ControlMethod::ChiaPeersList.requires_master_token(),
1058 "list grants nothing that outlives the token; gating it would blind a paired client \
1059 to the trust state it is subject to"
1060 );
1061 for name in ["control.chiaPeers.add", "control.chiaPeers.remove"] {
1065 let summary = ControlMethod::from_name(name).unwrap().summary();
1066 assert!(
1067 summary.to_lowercase().contains("corroboration"),
1068 "{name} summary must name the corroboration bypass, got: {summary}"
1069 );
1070 }
1071 }
1072
1073 #[test]
1074 fn every_method_has_a_nonempty_summary() {
1075 for &m in ControlMethod::ALL {
1076 assert!(!m.summary().is_empty(), "{} has no summary", m.name());
1077 }
1078 }
1079}