Internal monitoring for a Lightning node (LND) and a Cashu mint (CDK). It watches whether the value backing the mint still matches the ecash the mint has issued, and alerts on discrepancies, stuck operations and node problems.
- SPEC.md — specification and reconciliation model.
- AGENTS.md — invariants and rationale to respect when changing the code.
Read-only by design. The watchdog never writes to LND or the mint. It uses LND's
readonly.macaroonand aSELECT-only Postgres role.
Reserves = LND channel local + LND on-chain + limbo
+ cold storage (declared) + mint on-chain wallet
Own capital = Reserves − Ecash issued + Unspendable ecash (declared)
+ Proofs pending
Remaining delta = Δ Own capital − Δ Unclaimed − Δ Deposits awaiting credit
− Δ Dust received − Δ Cold storage − Δ Unspendable ecash
− Δ Mint fees
Own capital is the mint's equity — reserves beyond what it owes. It is a level, and
only its change carries signal.
Remaining delta is the alertable number: every subtracted term is an explained
change, so what remains is unaccounted for.
Unclaimed (paid on Lightning or on-chain, ecash not yet issued) is counted as own
capital, with the net-of-unclaimed figure shown alongside it. See SPEC.md §3.
⚠ Alert thresholds are not calibrated. The
reserve_drift_*rules andmint_proofs_pending_highuse hand-picked numbers. Calibrate against real history before trusting them.
backend/ Fastify + Prisma. Collector, rules, notifiers, API.
backend/scripts/ Operational tooling (SQL runner, LND probe, backfill).
frontend/ Next 14 + Tailwind. Dashboard, SSH-tunnel only.
scripts/ Read-only SQL for inspecting the mint database.
Two screens. / is the reconciliation dashboard. /channels, reached by clicking the
LND badge in the header, lists the node's Lightning channels: status badge (active,
inactive, opening, closing, force closing), capacity, the local/remote split drawn to
scale, in-flight HTLCs by direction, and the outbound fee policy per channel.
The balance bar is drawn as a fraction of capacity rather than of local + remote, so the
commitment fee and any in-flight HTLCs appear as the gap they are — those sats belong to
neither side yet. In-flight HTLCs are worth reading here: they leave channelLocal the
moment they lock and arrive nowhere reserves counts, which is the largest source of
tick-to-tick noise in the reserve figures.
Forwarding income is shown node-wide because FeeReport reports it that way; attributing
it per channel needs ForwardingHistory, which is not collected. Its three sums are
rolling windows ending now — lnd's proto defines them as revenue collected "over the
past 24 hrs / 1 week / 1 month" — not calendar periods, so they are labelled for the
window they cover. The 7-day figure is the headline: a day is too short to be a trend and
a month too slow to notice a channel going inactive.
Requires Node 24, yarn 1.x (classic), and a Postgres instance for the watchdog's own data — separate from the mint's.
On-chain deposit attribution reads quote_id from WalletTransaction.outputs, which
that release added. Older mints do not send the field.
The failure is safe but silent, and worth understanding before pointing this at an
older mint. proto3 drops unknown fields on decode, so an older mint is indistinguishable
from a transaction with no non-change outputs — the collector cannot tell them apart and
deliberately does not guess. Such deposits stay PENDING, which is reported as awaiting
credit: the mint is assumed to owe the value. Reserves stay correct and no false
shortfall is possible, but operator liquidity sits in the liabilities and own capital
reads low for as long as it holds.
yarn --cwd backend probe:wallet-attribution distinguishes the two. A non-zero no
data count on a mint you believe is current means the vendored proto is stale — re-diff
backend/proto/cdk-mint-wallet.proto against crates/cdk-mint-rpc/src/proto/wallet.proto.
The floor is effectively v0.17.6 either way: WalletService itself — balance,
transaction history, addresses — arrived one release earlier in v0.17.5, so a mint
old enough to lack quote_id is at most one release away from lacking the whole endpoint.
Below that the collector falls back to the LEDGER basis (see On-chain reserves: two
bases). The mint-database side has no version floor.
backend/yarn.lock and frontend/yarn.lock are committed; package-lock.json is
gitignored.
A root package.json delegates to both packages via yarn --cwd. It is a task runner
only — not a yarn workspace, so each package keeps its own node_modules.
yarn # installs backend + frontend (root postinstall)
yarn db:push # create/update the watchdog schema
yarn build # build both
yarn typecheck # typecheck both
yarn start:backend # or start:frontend
yarn dev # both in watch mode, one terminal
yarn dev:stop # stop whatever this repo has running locally
yarn reset:data --yes --rules-only # args pass through, no `--` needed
yarn sql ../scripts/verify-mint-light.sql
yarn probe:lndArguments are forwarded through both yarn levels, so no -- separator is required.
yarn setup is an alias for the install step.
dev:stop kills node processes running this project's entrypoints from a working
directory inside this repository. It does not kill by port.
In production run the two processes under separate service units rather than yarn dev.
cd backend
cp .env.example .env # every option is documented inline
yarn install
yarn prisma:updateDb # push schema to the watchdog database
yarn start:devcd frontend
cp .env.example .env.local
yarn install
yarn build
yarn start # http://localhost:3006PORT and BACKEND_URL are read at server start, so a second instance alongside a
tunnelled production one needs no rebuild:
PORT=3016 BACKEND_URL=http://127.0.0.1:3015 yarn startCREATE ROLE watchdog_ro LOGIN PASSWORD '...';
GRANT CONNECT ON DATABASE <mintdb> TO watchdog_ro;
GRANT USAGE ON SCHEMA public TO watchdog_ro;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO watchdog_ro;
-- Survives future CDK migrations that add tables.
ALTER DEFAULT PRIVILEGES FOR ROLE <mint-owner> IN SCHEMA public
GRANT SELECT ON TABLES TO watchdog_ro;
ALTER ROLE watchdog_ro SET default_transaction_read_only = on;
ALTER ROLE watchdog_ro SET statement_timeout = '30s';⚠ Dropping and recreating the mint database destroys these grants. Roles and
pg_hba.confare cluster-level and survive; table grants and default privileges do not. Put these statements in the migration script. WithoutALTER DEFAULT PRIVILEGES, a future migration adds a table the watchdog cannot read.
Both processes bind to loopback. The dashboard has no authentication — reach it over an SSH tunnel:
ssh -L 3006:127.0.0.1:3006 <host>One port only: the dashboard proxies /api/* to the backend server-side
(frontend/src/pages/api/[...path].ts), so the browser never contacts the API directly.
Everything is documented inline in backend/.env.example. The options most worth knowing:
| Variable | Purpose |
|---|---|
ENABLED_SOURCES |
lnd,mint. Credentials are required only for enabled sources. |
ENABLED_NOTIFIERS |
ntfy,email. A send succeeds if any transport does; partial failure is recorded. |
NTFY_REDACT_AMOUNTS, EMAIL_REDACT_AMOUNTS |
Strip figures from outbound alerts, per transport. Severity and subject survive. Both default to true. |
COLD_STORAGE_RESERVES |
Operator-declared reserves held outside the node. Treated as a declared movement and excluded from drift. |
PROVABLY_UNSPENDABLE_ECASH |
Operator-declared issued ecash that can never be redeemed. Added to own capital rather than deducted from ecash issued. Excluded from drift. |
MINT_RPC_HOST |
CDK management gRPC. Enables the WALLET basis for on-chain reserves (below). |
MINT_ONCHAIN_MIN_RECEIVE_SAT |
Must match the mint's [bdk] min_receive_amount_sat. Deposits below it are booked to own capital. |
INFLIGHT_MELT_MAX_AGE_SEC |
24h. Beyond this an in-flight melt is no longer subtracted on the LEDGER basis. |
HEARTBEAT_URL |
Optional. Log markers work without it. |
Frontend (frontend/.env.local), read at server start — restart, no rebuild:
| Variable | Default | Purpose |
|---|---|---|
PORT |
3006 |
Dashboard port |
BACKEND_URL |
http://127.0.0.1:3005 |
Where /api/* is proxied |
The mint's own on-chain (BDK) wallet balance comes from one of two sources. Which one is
in use is printed in the startup banner and recorded on every row in
Reconciliation.mintOnchainBasis.
WALLET (MINT_RPC_HOST set) |
LEDGER (fallback) | |
|---|---|---|
| Source | WalletService.GetBalance over CDK's management gRPC |
Paid on-chain mint quotes, less booked payouts |
| Measures | the wallet | CDK's books |
| Detects an unbooked outflow | yes | no |
Configure MINT_RPC_HOST. The LEDGER basis verifies internal consistency, not
custody — it moves only when CDK writes a row, so coins leaving the wallet by a route CDK
did not book do not move it at all.
The WALLET basis uses trusted_spendable (confirmed + own unconfirmed change).
Run yarn probe:mint-rpc before deploying: it prints the wallet balance beside the ledger
estimate. Their difference lands as a one-off step in own capital at the changeover, and
above ~96,000 sat it trips reserve_drift_long once before ageing out of the 48h window.
On the WALLET basis the ledger estimate is still collected, into
Reconciliation.mintOnchainLedger; mint_wallet_ledger_divergence watches the change
in the gap between the two. If the wallet RPC is configured but does not answer, no
reconciliation row is written for that tick and mint_wallet_rpc_unreachable fires
CRITICAL.
Any change to what
Reservesincludes creates a step that reads as unexplained drift. Either backfill history (backend/scripts/backfill-onchain.mjs) or record the change as a declared term.
Value entering the wallet is one of three things:
| Origin | Liability | Treatment | |
|---|---|---|---|
| A | User paying an on-chain mint quote | ecash owed | counts to unclaimed until issued |
| B | Operator, from outside the monitored perimeter | none | raises own capital |
| C | Operator, from the monitored LND on-chain wallet | none | nets to zero across the two pools, less fee |
CDK reports a quote_id on each non-change wallet transaction output (v0.17.6+, see
Setup), so the join comes from the mint itself. A quote id that the mint still has a row for is
A; an absent id is B/C, which never touches unclaimed.
The existence check is not defensive padding. The BDK wallet keeps its address-to-quote
association in its own metadata, so a quote deleted from mint_quote — an operator
correcting a mis-sent deposit — still comes back on the output and never ages out.
Trusting the id alone would undo the correction and re-book the deposit as owed.
Deposits below MINT_ONCHAIN_MIN_RECEIVE_SAT are never credited by CDK and are booked
straight to own capital. They are tracked as a live set, so if CDK does credit one it
leaves the set as it enters unclaimed. Ages are measured from confirmation time, not from
when the watchdog first saw the transaction.
An on-chain deposit taking hours to be booked and issued is normal, and nothing warns on
it above the minimum. Such deposits are never released on a timer; the moment the mint
legitimately stops owing them is a keyset phase-out, declared through
PROVABLY_UNSPENDABLE_ECASH.
| Script | Purpose |
|---|---|
scripts/introspect-mint-db.sql |
Schema discovery via psql. Catalog-only, safe on a live mint. |
scripts/introspect-mint-db-beekeeper.sql |
Same, as a single query for GUI clients. |
scripts/verify-mint-light.sql |
The per-tick query set. Index-assisted, negligible cost. |
scripts/explain-mint-queries.sql |
EXPLAIN without ANALYZE. Nothing executed. |
scripts/verify-mint-accounting.sql |
Full ledger cross-check. Scans the two largest tables. |
scripts/verify-wallet-ledger-gap.sql |
Decomposes mint_wallet_ledger_divergence per tick. Runs against DATABASE_URL, not the mint. |
scripts/verify-drift-window.sql |
Why a reserve_drift_* alert fired. Drift level per tick, with each tick's excursion from its neighbours. Runs against DATABASE_URL, not the mint. |
backend/scripts/run-sql.mjs |
Runs a single-statement .sql file through the app's read-only path. |
backend/scripts/probe-lnd.ts |
yarn probe:lnd — reads LND through the real collector code path. |
backend/scripts/probe-mint-rpc.ts |
yarn probe:mint-rpc — BDK wallet balance beside the ledger estimate. |
backend/scripts/probe-wallet-attribution.ts |
yarn probe:wallet-attribution — cross-checks CDK's per-output quote_id against the stored classifications. Flags quote ids the mint no longer has. |
backend/scripts/backfill-onchain.mjs |
One-off. Repairs history after a change to what Reserves includes. Dry-run by default. |
backend/scripts/reset-data.ts |
yarn reset:data — clear gathered data and/or reseed rule defaults. Dry-run by default. |
backend/scripts/check-funding-address.ts |
yarn check-funding-address <addr> — pre-flight before sending operator liquidity to the mint's wallet. |
The watchdog is a derived store, not a system of record. Everything it holds
comes from LND, the mint database, the BDK wallet or the chain, so clearing it is
a recovery option rather than a loss — yarn reset:data exists for exactly that.
Nothing should ever exist only here.
What a reset reconstructs on the following ticks:
| Rebuilt from | How complete |
|---|---|
| Reserve balances | Immediately — read live from LND and the wallet |
unclaimed, ledger estimate |
Fully — accumulator watermarks restart at 0, so on-chain quote discovery rescans from genesis |
| Wallet transaction cache | Fully — the build paginates when it is behind the wallet's reported total, rather than taking one page |
| Deposit classification | Fully — attribution comes from the wallet's own transaction list, at any age |
Two things do not come back, and both are history rather than state: the
observation series behind the charts and delta windows, and alert history.
Drift rules need two observations and a full window before they mean anything
again, so expect a warm-up period. Clearing AlertState also means any condition
still true re-fires and re-notifies on the next tick.
There is no longer an age constraint. Attribution used to come from bitcoind, which
bounded it at the prune horizon (~39 days) and made a deposit older than that
permanently PENDING — and an uncredited inbound deposit in that state is counted as
owed. Since CDK reports the quote per output, a reset reclassifies the whole history.
- Run
scripts/verify-mint-accounting.sqlonce. Section G verifies that CDK's runningkeyset_amountshas not drifted from the underlying rows, and settles whether the+ Proofs pendingterm is correct (SPEC.md §3.1). - Re-grant after any database recreate (above).
- Compare the first production
Own capitalagainst your tracking spreadsheet.
22 rules, all tunable at runtime without a redeploy — see Editing rule
configuration. Logic lives in backend/src/rules/; only the
thresholds live in the database.
for is how many consecutive evaluations the condition must hold before firing (one
evaluation per collection tick, 5 minutes by default). Kind is state when the
condition is ongoing and its clearing is worth a notification, event when something
merely happened and there is nothing to clear.
| Rule | Severity | for | Kind | Fires when |
|---|---|---|---|---|
lnd_unreachable |
CRITICAL | 2 | state | LND did not respond to the collector |
lnd_not_synced |
WARNING | 3 | state | Not synced to chain or graph |
lnd_force_close |
WARNING | 1 | state | Channels force-closing, or funds in limbo |
lnd_inactive_channels |
WARNING | 3 | state | More than maxInactive (3) channels inactive |
| Rule | Severity | for | Kind | Fires when |
|---|---|---|---|---|
mint_unreachable |
CRITICAL | 2 | state | The mint database read failed. Names the actual failure — permission, timeout, unreachable |
mint_over_issued |
CRITICAL | 1 | state | amount_issued > amount_paid: ecash created against an unpaid quote. A hard invariant; must always be zero |
mint_schema_access |
WARNING | 1 | state | A required table is unreadable, or an unrecognised one appeared |
mint_keyset_change |
INFO | 1 | event | Keyset count changed |
mint_proofs_pending_high |
WARNING | 3 | state | Proofs locked in PENDING above thresholdSat (500,000). Uncalibrated |
mint_melt_requests_stuck |
WARNING | 3 | state | More than maxRows (25) rows in the transient melt_request table |
mint_onchain_melt_stuck |
WARNING | 2 | state | A committed on-chain melt is unsettled past 24h, so it is no longer subtracted. Degrades the ledger cross-check, not reserves |
Only evaluated when MINT_RPC_HOST is set; they return "not evaluable" otherwise.
| Rule | Severity | for | Kind | Fires when |
|---|---|---|---|---|
mint_wallet_rpc_unreachable |
CRITICAL | 3 | state | The wallet balance could not be read. No reconciliation row is written while it holds, so reserve drift is not being evaluated |
mint_wallet_ledger_divergence |
WARNING | 3 | state | The wallet-versus-ledger gap moved more than thresholdSat (50,000) over windowHours (24). Deposits awaiting credit, dust and operator liquidity are all subtracted, so the gap starts at zero and is unaffected by a deposit being reclassified |
mint_wallet_sync |
WARNING / CRITICAL | 3 | state | The wallet is more than maxBlocksBehind (6) behind LND's height, or on a network other than expectedNetwork (CRITICAL) |
| Rule | Severity | for | Kind | Fires when |
|---|---|---|---|---|
mint_onchain_large_mint |
INFO | 1 | event | A deposit against a mint quote exceeds fractionPct (20) of the pre-movement wallet balance. Keyed on the payment, not the quote |
mint_onchain_large_melt |
INFO | 1 | event | A net outflow exceeds fractionPct (20) of the pre-movement balance. Keyed on the transaction |
mint_onchain_deposit_unattributed |
WARNING | 1 | event | A confirmed deposit paid no mint quote address. The mint owes no ecash for it, so it is excluded from unclaimed |
mint_onchain_dust_deposit |
WARNING | 1 | event | A confirmed deposit below MINT_ONCHAIN_MIN_RECEIVE_SAT, which CDK can never credit. Fires once on arrival |
mint_onchain_dust_cospent |
WARNING | 1 | event | The wallet spent a deposit it never credited, linking every co-input address to the mint via common-input-ownership |
| Rule | Severity | for | Kind | Fires when |
|---|---|---|---|---|
reserve_drift_short |
CRITICAL | 2 | state | Remaining delta falls below −20,000 sat/h over 6h |
reserve_drift_long |
WARNING | 3 | state | Remaining delta falls below −2,000 sat/h over 48h |
Both are rates computed from the window endpoints, not sums of per-tick deltas. Value
hysteresis: the bar to clear is higher than the bar to fire.
expectedDriftSatPerHour accounts for a non-zero baseline.
Each endpoint is the median row of a block at each end of the window, not the
outermost row — firstBlockMinutes and lastBlockMinutes, capped at a third of the
window so the blocks never overlap. The median row is a real observation, so the
breakdown the alert quotes still adds up and can be looked up in the dashboard.
This is needed because own capital moves on a tick timescale for reasons that are not errors, and two raw endpoints reject none of it:
- An outgoing HTLC with no proofs behind it — a forward, a rebalance, an operator
payment. It leaves
channelLocalthe moment it locks and arrives nowheretotalNodeBalance()counts, so reserves dip until it settles or fails. - A melt in flight. The wallet hands over proofs covering
amount + fee_reserve, and denominations mean it usually hands over more; the overshoot returns to it as fresh change proofs only once the HTLC settles.+ Proofs pendingmeanwhile adds the inputs back at face value, so own capital over-reads by everything the mint owes back. Proofs that go PENDING without an HTLC ever locking (a stalled melt, or a failed one not yet returned as UNSPENT) over-read by their full value, since there is nochannelLocaldrop for the add-back to cancel.
A median rejects a transient only while it is a minority of its block, so each block must be wider than twice the longest transient that can move the rate. The two are different widths because they cost different things: the leading block costs only span, which the rate divides out, while the trailing block is the only one that delays detection — a loss is not visible until it covers more than half of it. So the leading block is bought generously and the trailing one sparingly.
| Rule | firstBlockMinutes |
lastBlockMinutes |
|---|---|---|
reserve_drift_short |
90 | 30 |
reserve_drift_long |
240 | 30 |
The 48h rule's leading block clears the observed transient ceiling with margin. The 6h rule's cannot, because the no-overlap cap binds first, so it keeps a small residual rate of false firings.
The trailing endpoint is not a median. Both transients announce themselves —
channelUnsettledRemote > 0 for an in-flight HTLC, proofsPending above its residue
floor for a melt — so rather than filtering a busy tick out statistically, the rule
declines it as an endpoint and takes the newest quiet row in the block, falling back to
the block median when the whole block was busy. A median cannot see a loss until it
covers half the block; a quiet row sees it on the next tick. That removes the entire
latency cost of the 6h rule — detection of a sudden loss goes back to one tick — with the
false-firing count and worst case unchanged. The 48h rule is unaffected, its delay being
forEvaluations rather than the endpoint.
A row with no LND snapshot is never quiet: absent is not zero, and the question was never
answered for that tick. The residue floor is measured over a trailing
floorWindowMinutes (360) rather than the whole window: over 48h the residue reliably
steps up when a melt stalls, and measured against the whole window no recent tick could
equal the old minimum, so nothing read as quiet and the 48h rule silently fell back to
the median for two days. Six hours is far longer than the 1.5h ceiling on a live melt, so
a melt can never set the floor itself.
Only an instantaneous loss was ever delayed; a steady drain is not, because the median row sits at its block's midpoint and the span shortens with it.
min(unsettledLocal, unsettledRemote) is the amount the node is forwarding — both
legs of an HTLC pair open at once. It has left channelLocal and will arrive on the other
leg, so it is an asset in transit and sits inside Reserves as inflightForwarding,
shown as its own line on the reserves card. Without it a forward reads as a reserves loss
that reverses a tick later; the dashboard's 24h figure exceeded ±50,000 sat on 7.6% of
ticks, and 4.3% with the term in.
Only the matched part. An unmatched outgoing HTLC is a melt that + Proofs pending
already covers — adding it again double counts and made false firings worse, measured. An
unmatched incoming HTLC is a mint quote arriving, and recognising it before unclaimed
books the liability manufactures drift; incoming reaches 8,411,763 sat on this node.
One other correction was tried and rejected: swapping + proofsPending for
+ unsettledRemote, which is exactly neutral across a melt's whole lifecycle on paper,
made false firings six times worse — it trades an almost-constant term for one that moves
on a third of all ticks.
Do not add unsettledLocal to totalNodeBalance() to chase the first transient. It
recognises inbound value before unclaimed books the matching liability, which makes
the worst case substantially worse — see the note in lndSource.ts.
Its signature, if it recurs: a firing that clears well inside the window length. Real
drift cannot do that. The alert context carries firstAt / lastAt — the two
observations actually compared — so bracket those in
scripts/verify-drift-window.sql, which prints the drift level per tick beside
proofs_pending and unsettled_out and flags each tick's excursion from its
neighbours. A negative excursion tracking unsettled_out with proofs flat is an HTLC
with no proofs behind it; a positive one moving with d_proofs_pending is a melt.
| Rule | Severity | for | Kind | Fires when |
|---|---|---|---|---|
collector_observation_gap |
WARNING | 1 | event | The interval between observations exceeded toleranceMultiple (3) × the collection interval |
This rule is not a deadman's switch: it needs a later observation to notice the gap. See Deadman's switch.
The watchdog emits single-line JSON markers to stdout on every tick, written directly
rather than through the logger so LOG_LEVEL cannot suppress them:
{"marker":"WATCHDOG_HEARTBEAT_OK","ts":"…","observationId":20,"lnd":"OK","mint":"OK","durationMs":955}
{"marker":"WATCHDOG_HEARTBEAT_FAIL","ts":"…","detail":"…"}Configure two rules in the log analyser:
| Rule | Match | Severity |
|---|---|---|
| Absence | no WATCHDOG_HEARTBEAT_OK in 15 min (3× the 5-min cadence) |
CRITICAL |
| Presence | any WATCHDOG_HEARTBEAT_FAIL |
CRITICAL |
The absence rule is the deadman's switch. A crashed, hung or OOM-killed watchdog emits no log line at all. The FAIL marker covers only what the watchdog is still alive enough to report.
| Endpoint | Purpose |
|---|---|
GET /health |
Liveness |
GET /api/collector/status |
Recency of last successful read per source |
GET /api/observations/latest |
Most recent observation with all snapshots |
GET /api/observations?from&to&limit |
Full observations over a range |
GET /api/timeseries?hours= |
Compact series for charting |
GET /api/deltas?minutes= |
Change in each term over a window, computed from endpoints |
POST /api/collector/run |
Trigger a tick manually |
GET /api/alerts?status=FIRING|RESOLVED|ALL |
Alert states |
GET /api/alerts/events |
Transition and delivery history |
GET /api/rules |
Registered rules and current tuning |
PATCH /api/rules/:ruleId |
Tune thresholds without a redeploy |
POST /api/notify/test |
Exercise every transport individually |
POST /api/heartbeat/test |
Verify the deadman's switch |
Monetary values are msat, serialised as strings — msat totals will outgrow a JS double.
RuleConfig rows are seeded once from the code defaults in backend/src/rules/*.ts and
never updated afterwards, so tuning is never clobbered. The consequence is that editing
a default in source has no effect on an existing database.
On a running deployment — PATCH /api/rules/:ruleId:
curl -s http://127.0.0.1:3005/api/rules | jq # current tuning for all rules
curl -s -X PATCH http://127.0.0.1:3005/api/rules/reserve_drift_short \
-H 'content-type: application/json' \
-d '{"params": {"toleranceSatPerHour": 50000}}'
curl -s -X PATCH http://127.0.0.1:3005/api/rules/lnd_inactive_channels \
-H 'content-type: application/json' -d '{"enabled": false}'Accepted fields: enabled, severity, forEvaluations, clearEvaluations,
cooldownSeconds, notifyOnResolve, params. Changes take effect on the next tick — no
restart.
params is stored wholesale rather than merged; the engine overlays stored params on the
rule's code defaults at evaluation time, so sending only the keys you want to override
works.
For fresh deployments — edit the rule module. That changes what new databases seed with, and nothing else.
To make changed code defaults apply to an existing database, reseed the rules while leaving the measurement history alone:
yarn reset:data --yes --rules-onlyIt truncates RuleConfig and reseeds by calling the engine's own loadConfigs, then
prints the resulting table. This discards any tuning done through the API. To reseed a
single rule instead, delete just its row and let the next tick recreate it.