Skip to content

waved: Operate native Ark channels - #1192

Open
sputn1ck wants to merge 6 commits into
kon/ark-channel-lnd-runtimefrom
kon/ark-channel-daemon
Open

sputn1ck wants to merge 6 commits into
kon/ark-channel-lnd-runtimefrom
kon/ark-channel-daemon

Conversation

@sputn1ck

@sputn1ck sputn1ck commented Aug 24, 2026 •

Copy link
Copy Markdown
Member

Integration only: do not merge on the personal lnd replacements. Land the required recovery and idle-worker behavior upstream. Select official versions of both github.com/lightningnetwork/lnd and github.com/lightningnetwork/lnd/kvdb, remove both personal replacements, and verify both resolved versions from an external main module with GOWORK=off and no replacements. Build native, mobile and WASM and run both default mixed-version directions and the enabled daemon suite on those official versions. A fork-pinned pass is not release clearance.

This is the first layer that registers the production channel RPC. It now contains its own admission and recovery rules. --swap.arkchannelsenabled defaults to false. The raw promotion and payment RPCs check it before contacting a controller. A permitted open can start a connector once; enabling the flag, listing local records, or trying to pay on an empty wallet does not start one. An ordinary payment or receive does not open a channel.

Startup first reads the local recoverable inventory. A read failure aborts startup. Existing obligations restore local protection before peer negotiation, even with new actions off. An explicit runtime disable is refused when there is live recoverable state. An empty readable inventory schedules no channel connector or supervisor.

Boundary verification: the superseded 63b29106 did not enforce this rule. At 55a9980666688e4d274bee371de9a24ef745d2e4, focused native daemon, swap-service and CLI tests, formatting, changed lint and actor checks passed. An additional raw-RPC test called promotion and payment with a dormant connector and with an already-installed controller; both returned FailedPrecondition without starting the connector.

Paired readiness: a62f10bb also waits for the authenticated hub's durable active phase before returning an active promotion, including same-key replay. If the hub is activating, the existing native status call observes the exact signed funding point; the next durable read must confirm activity. A lost or failed reply is not success. This adds no startup polling, funding replay, or protocol message. Local post-creation lookup remains available offline. The regression failed on the prior head and passed 20 times with the fix. Formatting, changed lint, actor checks, and focused daemon/CLI tests passed locally.

Base: #1191. The wallet invoice, SDK payment bridge and mobile/WASM opt-in surfaces are in #1139, not prerequisites for this daemon behavior. Ordinary-refund compatibility is reviewed separately in #1640.

Copilot AI lite review requested due to automatic review settings August 24, 2026 14:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds Ark channel daemon support and OOR recovery/export surfaces to waved/wavecli, wiring new gRPC + REST endpoints, durable channel lifecycle control, and on-chain recovery/watch infrastructure.

Changes:

  • Extend waverpc.DaemonService with Ark-channel OOR preparation/commit/abort RPCs and an OOR recovery-package export RPC (plus REST gateway + mailbox + REST client wiring).
  • Introduce Ark channel runtime/process wiring in waved (controller startup/shutdown, source archive + watcher, pre-PONR expiry maintenance) with accompanying tests.
  • Add a hidden wavecli channel subtree and update CLI docs and dev-RPC registry.

Reviewed changes

Copilot reviewed 33 out of 35 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
waverpc/daemon.yaml Add HTTP REST mappings for new daemon RPCs
waverpc/daemon.proto Add new daemon RPCs/messages; add identity_key to NewReceiveScriptRequest
waverpc/daemon.pb.gw.go Regenerated gateway handlers for new endpoints
waverpc/daemon_mailboxrpc.pb.go Regenerated mailbox RPC stubs for new methods
waverpc/daemon_grpc.pb.go Regenerated gRPC stubs for new methods
waved/vhtlc_recovery_target.go Persist ConstructionVersion in recovery descriptors
waved/server.go Wire ArkChannelService registration + runtime lifecycle/shutdown hooks
waved/rpc_oor_receive.go Support identity-key-backed receive script registration
waved/rpc_auth.go Add macaroon entity/permissions for channel RPCs
waved/rpc_auth_test.go Extend permissions test coverage for new RPC surface
waved/rpc_ark_channel_recovery.go Add daemon RPC to export local OOR recovery package
waved/rpc_ark_channel_oor.go Add daemon RPCs for preparing/validating/committing/aborting Ark-channel OOR
waved/native_ark_channel_controller_test.go Add tests for channel restore/watch/resume helpers
waved/logging.go Register additional lnd subsystems with log manager
waved/config.go Add process-wiring mailbox client for channel runtime
waved/ark_channel_source.go Implement channel recovery archive + lineage verification + descriptor reconstruction
waved/ark_channel_source_watcher.go Add passive chain-spend watcher that retries durable channel events
waved/ark_channel_source_watcher_test.go Tests for watcher coverage and retry behavior
waved/ark_channel_source_test.go Tests for recovery roots/descriptor/operator-key handling
waved/ark_channel_recovery_runtime.go Add standalone recovery runtime composition (unroll + watches)
waved/ark_channel_process.go Add Ark channel process wiring + ArkChannelService gRPC server
waved/ark_channel_process_test.go Tests for ArkChannelService RPC behavior/unavailable states
waved/ark_channel_oor.go Implement wallet selection + OOR preparation + reconciliation cleanup
waved/ark_channel_expiry.go Add pre-PONR maintenance loop to expire/abort abandoned preparations
waved/ark_channel_expiry_test.go Tests for pre-PONR expiry/abort behavior
rpc/restclient/clients.go Add REST client methods for new daemon endpoints
harness/harness.go Adjust channel setup parameters (explicit Private: false)
docs/daemon_cli_guide.md Document new hidden channel CLI subtree and behavior
cmd/wavecli/waveclicommands/root.go Register channel subtree under advanced commands
cmd/wavecli/waveclicommands/root_groups_test.go Update tests for advanced command visibility/grouping
cmd/wavecli/waveclicommands/devrpc/registry_generated.go Regenerate dev-rpc registry for new daemon methods
cmd/wavecli/waveclicommands/cmd_channel.go Add wavecli channel commands and channel-id parsing
cmd/wavecli/waveclicommands/cmd_channel_test.go Tests for channel-id and amount parsing
Files not reviewed (1)
  • cmd/wavecli/waveclicommands/devrpc/registry_generated.go: Generated file
Suppressed comments (2)

waved/ark_channel_oor.go:211

  • When PrepareChannel reports Existing=true, the selected VTXOs should be unlocked even if the request ctx is already canceled. Using ctx here can prevent the unlock Tell from being delivered, leaving locks behind.
	if prepared.Existing {
		rpcServer.unlockSelectedVTXOsBestEffort(ctx, locked)
	}

waved/rpc_ark_channel_oor.go:62

  • This gRPC handler returns a plain fmt.Errorf for invalid request terms, which maps to codes.Unknown. Prefer returning codes.InvalidArgument via status.Error/status.Errorf for consistent client-visible semantics.
	if terms.Funder != arkchannel.PartyHub ||
		terms.Kind != arkchannel.KindReceiveIntent {
		return nil, fmt.Errorf("daemon channel OOR must fund a " +
			"receive intent")
	}

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread waved/ark_channel_oor.go Resolved
Comment thread waved/server.go Resolved
Comment thread waved/rpc_ark_channel_recovery.go Resolved
Comment thread waved/rpc_ark_channel_oor.go Resolved
Comment thread waved/rpc_ark_channel_oor.go Resolved
Comment thread waved/rpc_ark_channel_oor.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 070cf3dfa4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread waved/ark_channel_process.go Resolved
Comment thread waved/ark_channel_oor.go Resolved
Comment thread waved/native_ark_channel_controller.go Resolved
Comment thread waved/native_ark_channel_controller.go Resolved
Comment thread waved/rpc_oor_receive.go Resolved
@litbot-9000

litbot-9000 commented Aug 24, 2026 •

Copy link
Copy Markdown
Collaborator

Doc gardening: scoped drift advisory

This PR's Go changes leave the per-package docs for waved, waverpc,
cmd/wavecli/waveclicommands, and harness behind the code — the
native Ark channel runtime and its startup/shutdown ordering, the six new
DaemonService channel-funding RPCs plus identity_key receive scripts, the
new channel macaroon entity and hidden channel CLI subtree, and the
announced-channel harness change are all undocumented today. Proposed
reconciliation below (each CLAUDE.md plus its byte-identical AGENTS.md
mirror).

cmd/wavecli/waveclicommands/devrpc and rpc/restclient were also in scope
but need no change: both docs describe their surfaces generically, and the new
methods land inside descriptions that are still accurate.

Proposed diff — 354 insertions, 24 deletions across 8 files
diff --git a/cmd/wavecli/waveclicommands/AGENTS.md b/cmd/wavecli/waveclicommands/AGENTS.md
index fa9b16a5..6435fd27 100644
--- a/cmd/wavecli/waveclicommands/AGENTS.md
+++ b/cmd/wavecli/waveclicommands/AGENTS.md
@@ -16,15 +16,16 @@ default `--help` face:
    wavewalletrpc-backed.
 2. **Daemon introspection (group "Introspection")** — getinfo, schema, mcp
    (the built-in `help` command is grouped here too).
-3. **Advanced subtrees (`ark`, `dev`, `recovery`)** — raw
-   waverpc/devrpc commands for power users and operator runbooks.
+3. **Advanced subtrees (`ark`, `channel`, `dev`, `recovery`)** — raw
+   waverpc/arkchannelrpc/devrpc commands for power users and operator
+   runbooks.
    Hidden from the default `--help` via cobra `Hidden` (not a build tag),
    so they stay compiled and fully runnable in the shipped binary;
    `WAVELENGTH_DEV=1` reveals them under an "Advanced" group. The env var only
    changes visibility — it never gates execution. `ark.*` stays on the
    `schema`/MCP surfaces; `dev` is reachable only as the generated (hidden)
-   CLI subtree — it is not registered in `schema`/MCP — and `recovery` is
-   exposed on neither.
+   CLI subtree — it is not registered in `schema`/MCP — and `channel` and
+   `recovery` are exposed on neither.
 
 The `swap.*` verbs were retired: `send`/`recv --offchain` and `activity`
 cover them (the swapruntime daemon runtime that powers those verbs is
@@ -72,6 +73,22 @@ who want direct access.
 | `ark listtransactions` | `ListTransactions` | Raw paginated transaction history |
 | `ark send {inround,oor}` | `SendVTXO` / `SendOOR` | Raw in-round / OOR send; real transfers require interactive approval or `--yes` |
 
+### `channel.*` advanced commands
+
+Development control surface for native Ark-backed Lightning channels,
+served by `arkchannelrpc.ArkChannelService` on the same daemon listener.
+Every verb prints the raw proto JSON response.
+
+| Command | RPC | Description |
+|---------|-----|-------------|
+| `channel create <amount-sat>` | `PromoteVTXO` | Promote wallet value into a channel; capacity is the only input — the daemon owns OOR preparation, backing reserve, and activation |
+| `channel get <channel-id>` | `GetChannel` | One durable channel snapshot |
+| `channel send <channel-id> <amount-sat>` | `SendPayment` | Pay a hub invoice over one active channel |
+| `channel receive <channel-id> <amount-sat>` | `ReceivePayment` | Create and settle a client invoice over one active channel |
+| `channel pay <bolt11>` | `PayLightningInvoice` | Bridge a private HTLC into the operator's public Lightning payment; `--max-fee-sat` (default 100000) caps routing fees |
+| `channel close <channel-id>` | `RequestCooperativeClose` | Start or resume the client-owned cooperative close |
+| `channel force-close <channel-id>` | `MaterializeAndForceClose` | Publish the Ark ancestry, signed backing, and latest commitment |
+
 ### `recovery.*` advanced commands
 
 Manual control of daemon-owned vHTLC recovery rows; normal swap clients
@@ -136,6 +153,8 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/cmd/wave
   - `rpc/wavewalletrpc` (generated stubs for the top-level wallet verbs;
     `WalletService` / `WalletInspectionService` clients).
   - `waverpc` (generated stubs for `ark.*`, `recovery.*`, getinfo).
+  - `rpc/arkchannelrpc` (generated `ArkChannelService` stubs for
+    `channel.*`).
   - `cmd/wavecli/waveclicommands/devrpc` (the generated `dev`
     subtree; its registry references `swapclientrpc` service
     descriptors).
@@ -182,6 +201,18 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/cmd/wave
   which flag to drop and why, since stating the constraint alone invites
   dropping `--onchain-address` and silently getting the more dangerous
   unilateral exit (`swapwallet.forceUnroll` carries the same wording).
+- `channel.*` dials `ArkChannelService` through the same
+  `getDaemonConn` transport as every other verb, via the
+  `getArkChannelClient` seam that command-wiring tests replace.
+  `parseChannelID` accepts a channel ID as either 32-byte hex or the
+  base64 form protobuf JSON prints, so an ID copied straight out of a
+  previous command's output round-trips; anything that does not decode to
+  exactly 32 bytes is rejected. Amounts must parse as strictly positive
+  int64.
+- `channel.*` verbs are NOT confirmation-gated and are NOT two-phase —
+  `create`, `send`, `pay`, `close`, and `force-close` all move funds in a
+  single call. They stay off the `schema`/MCP surfaces for that reason;
+  the gate is that the subtree is development-only.
 - `recovery escalate` refuses to run on non-interactive stdin unless
   `--yes` is passed — it never blocks on a y/N prompt an agent can't
   answer.
diff --git a/cmd/wavecli/waveclicommands/CLAUDE.md b/cmd/wavecli/waveclicommands/CLAUDE.md
index fa9b16a5..6435fd27 100644
--- a/cmd/wavecli/waveclicommands/CLAUDE.md
+++ b/cmd/wavecli/waveclicommands/CLAUDE.md
@@ -16,15 +16,16 @@ default `--help` face:
    wavewalletrpc-backed.
 2. **Daemon introspection (group "Introspection")** — getinfo, schema, mcp
    (the built-in `help` command is grouped here too).
-3. **Advanced subtrees (`ark`, `dev`, `recovery`)** — raw
-   waverpc/devrpc commands for power users and operator runbooks.
+3. **Advanced subtrees (`ark`, `channel`, `dev`, `recovery`)** — raw
+   waverpc/arkchannelrpc/devrpc commands for power users and operator
+   runbooks.
    Hidden from the default `--help` via cobra `Hidden` (not a build tag),
    so they stay compiled and fully runnable in the shipped binary;
    `WAVELENGTH_DEV=1` reveals them under an "Advanced" group. The env var only
    changes visibility — it never gates execution. `ark.*` stays on the
    `schema`/MCP surfaces; `dev` is reachable only as the generated (hidden)
-   CLI subtree — it is not registered in `schema`/MCP — and `recovery` is
-   exposed on neither.
+   CLI subtree — it is not registered in `schema`/MCP — and `channel` and
+   `recovery` are exposed on neither.
 
 The `swap.*` verbs were retired: `send`/`recv --offchain` and `activity`
 cover them (the swapruntime daemon runtime that powers those verbs is
@@ -72,6 +73,22 @@ who want direct access.
 | `ark listtransactions` | `ListTransactions` | Raw paginated transaction history |
 | `ark send {inround,oor}` | `SendVTXO` / `SendOOR` | Raw in-round / OOR send; real transfers require interactive approval or `--yes` |
 
+### `channel.*` advanced commands
+
+Development control surface for native Ark-backed Lightning channels,
+served by `arkchannelrpc.ArkChannelService` on the same daemon listener.
+Every verb prints the raw proto JSON response.
+
+| Command | RPC | Description |
+|---------|-----|-------------|
+| `channel create <amount-sat>` | `PromoteVTXO` | Promote wallet value into a channel; capacity is the only input — the daemon owns OOR preparation, backing reserve, and activation |
+| `channel get <channel-id>` | `GetChannel` | One durable channel snapshot |
+| `channel send <channel-id> <amount-sat>` | `SendPayment` | Pay a hub invoice over one active channel |
+| `channel receive <channel-id> <amount-sat>` | `ReceivePayment` | Create and settle a client invoice over one active channel |
+| `channel pay <bolt11>` | `PayLightningInvoice` | Bridge a private HTLC into the operator's public Lightning payment; `--max-fee-sat` (default 100000) caps routing fees |
+| `channel close <channel-id>` | `RequestCooperativeClose` | Start or resume the client-owned cooperative close |
+| `channel force-close <channel-id>` | `MaterializeAndForceClose` | Publish the Ark ancestry, signed backing, and latest commitment |
+
 ### `recovery.*` advanced commands
 
 Manual control of daemon-owned vHTLC recovery rows; normal swap clients
@@ -136,6 +153,8 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/cmd/wave
   - `rpc/wavewalletrpc` (generated stubs for the top-level wallet verbs;
     `WalletService` / `WalletInspectionService` clients).
   - `waverpc` (generated stubs for `ark.*`, `recovery.*`, getinfo).
+  - `rpc/arkchannelrpc` (generated `ArkChannelService` stubs for
+    `channel.*`).
   - `cmd/wavecli/waveclicommands/devrpc` (the generated `dev`
     subtree; its registry references `swapclientrpc` service
     descriptors).
@@ -182,6 +201,18 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/cmd/wave
   which flag to drop and why, since stating the constraint alone invites
   dropping `--onchain-address` and silently getting the more dangerous
   unilateral exit (`swapwallet.forceUnroll` carries the same wording).
+- `channel.*` dials `ArkChannelService` through the same
+  `getDaemonConn` transport as every other verb, via the
+  `getArkChannelClient` seam that command-wiring tests replace.
+  `parseChannelID` accepts a channel ID as either 32-byte hex or the
+  base64 form protobuf JSON prints, so an ID copied straight out of a
+  previous command's output round-trips; anything that does not decode to
+  exactly 32 bytes is rejected. Amounts must parse as strictly positive
+  int64.
+- `channel.*` verbs are NOT confirmation-gated and are NOT two-phase —
+  `create`, `send`, `pay`, `close`, and `force-close` all move funds in a
+  single call. They stay off the `schema`/MCP surfaces for that reason;
+  the gate is that the subtree is development-only.
 - `recovery escalate` refuses to run on non-interactive stdin unless
   `--yes` is passed — it never blocks on a y/N prompt an agent can't
   answer.
diff --git a/harness/AGENTS.md b/harness/AGENTS.md
index 2ac7ee2f..6be2bd71 100644
--- a/harness/AGENTS.md
+++ b/harness/AGENTS.md
@@ -48,6 +48,11 @@ helpers for end-to-end tests.
   primary LND node resyncs to the new tip.
 - `LNDRequireInterceptor` only applies to the primary LND node; additional
   nodes started via `StartAdditionalLND*` never set it.
+- `SetupChannelBetween` opens **announced** channels (`Private: false`,
+  set explicitly rather than left to the proto zero value). Tests that
+  route through a third node need the channel in the network graph, and
+  relying on the default would silently flip them to private if lnd ever
+  changed it.
 - Container teardown (`Stop`) is guarded by `sync.Once`; a signal handler
   also calls `Stop` as a safety net against orphaned containers.
 
diff --git a/harness/CLAUDE.md b/harness/CLAUDE.md
index 2ac7ee2f..6be2bd71 100644
--- a/harness/CLAUDE.md
+++ b/harness/CLAUDE.md
@@ -48,6 +48,11 @@ helpers for end-to-end tests.
   primary LND node resyncs to the new tip.
 - `LNDRequireInterceptor` only applies to the primary LND node; additional
   nodes started via `StartAdditionalLND*` never set it.
+- `SetupChannelBetween` opens **announced** channels (`Private: false`,
+  set explicitly rather than left to the proto zero value). Tests that
+  route through a third node need the channel in the network graph, and
+  relying on the default would silently flip them to private if lnd ever
+  changed it.
 - Container teardown (`Stop`) is guarded by `sync.Once`; a signal handler
   also calls `Stop` as a safety net against orphaned containers.
 
diff --git a/waved/AGENTS.md b/waved/AGENTS.md
index 8caf29d4..4cbaf9c3 100644
--- a/waved/AGENTS.md
+++ b/waved/AGENTS.md
@@ -14,7 +14,9 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/waved.<S
   server, and `ActorSystem`. Caches `localMailboxID` (pubkey-derived),
   `authSigHex` (Schnorr auth), `clientKeyDesc` (the stable daemon identity
   descriptor, behind `clientKeyDescMu`), `mailboxAuthSigs` (per-recipient
-  mailbox auth signature memo, behind `mailboxAuthSigsMu`), and a single
+  mailbox auth signature memo, behind `mailboxAuthSigsMu`), the Ark channel
+  process triple (`arkChannelController`, `arkChannelMailboxRuntime`,
+  `arkChannelPeerIngress`, all behind `arkChannelMu`), and a single
   `clk` (`clock.Clock`) shared by all sub-stores for deterministic time
   injection.
 - `RPCServer` — implements the gRPC `DaemonService`. Most write RPCs
@@ -22,7 +24,12 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/waved.<S
   validate input locally then `Ask` the relevant actor; `GetRound` and
   `ListVTXOs` merge live actor state with persisted SQL rows, while
   `GetFeeHistory` and `ListTransactions` are pure SQL reads
-  (`rpc_fees.go`).
+  (`rpc_fees.go`). The channel-funding RPCs (`PrepareArkChannelOOR`,
+  `LookupPreparedArkChannelOOR`, `ValidatePreparedArkChannelOOR`,
+  `CommitPreparedArkChannelOOR`, `AbortPreparedArkChannelOOR` in
+  `rpc_ark_channel_oor.go`) and `ExportOORRecoveryPackage`
+  (`rpc_ark_channel_recovery.go`) drive the `arkchannel/oorbridge` and
+  recovery-archive seams instead.
 - `Config` — daemon configuration: wallet backend selection, mailbox/chain
   backend wiring, `OORConfig`/`OORLimitsConfig` (receive safety caps),
   `UnrollConfig` (unilateral-exit fee-bump cadence and cap), and
@@ -33,6 +40,42 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/waved.<S
   post-unlock recovery hook.
 - `UnrollConfig` / `OORConfig` — subsystem tunables; see `Config.Validate()`
   for the invariants each enforces.
+- `ArkChannelController` — the local process boundary published behind
+  `arkchannelrpc.ArkChannelService`. It composes
+  `ArkChannelLifecycleController` (`PromoteVTXO`,
+  `MaterializeAndForceClose`, `RequestCooperativeClose`, `GetChannel`,
+  `PeerMessageHandler`, `Stop`) and `ArkChannelPaymentController`
+  (`SendPayment`, `ReceivePayment`, `PayLightningInvoice`, plus the
+  incoming-payment `Prepare`/`Register`/`Wait` triple the swap subserver
+  calls through `RPCServer.*ArkChannelIncomingPayment`).
+- `NativeArkChannelController` — the concrete implementation, owning one
+  `arkchannel` FSM and one modular lnd endpoint. Built either as a lazy
+  client endpoint (`NewClientArkChannelController`, which loads hub policy
+  on the first lifecycle request) or eagerly as the hub endpoint
+  (`NewHubArkChannelController` over `HubArkChannelControllerConfig`, whose
+  advertised policy comes from `NewHubFundingPeerInfo`).
+  `LightningPaymentResult` is what `PayLightningInvoice` returns.
+- `ArkChannelControllerConfig` — the process-owned dependency set supplied
+  after wallet, database, and authenticated swap-server transport startup:
+  channel store, peer transport, `lwwallet`, chain backend/notifier/fee
+  estimator, the OOR and unroll bridges, identity key, and the funding
+  seams below.
+- `ArkChannelOORPreparer` / `ArkChannelOORLookup` /
+  `ArkChannelReceiveCapitalReserver` — funding callbacks the controller
+  invokes; `Server.prepareArkChannelOOR` and `Server.lookupArkChannelOOR`
+  supply the first two, and only the hub supplies the third.
+- `ArkChannelRecoveryController` — the endpoint-local source archive, spend
+  watcher, and unroll-preparation boundary
+  (`lnruntime.ChannelRecoveryManager` +
+  `arkchannel.ChannelEventSinkBinder` + `unrollbridge.SourcePreparer`),
+  implemented by `arkChannelRecoveryArchive` over
+  `arkChannelSourceWatcher`.
+- `ArkChannelRecoveryRuntime` / `ArkChannelRecoveryRuntimeConfig` — the same
+  unroller, package archive, and channel materializer composed for a host
+  that owns its own database, chain backend, and wallet (swapd's hub
+  endpoint). `ArkChannelUnrollWallet` (built by
+  `NewLNDArkChannelUnrollWallet`) is the shared `txconfirm.Wallet` +
+  `unroll.SweepWallet` surface it needs.
 
 ## Relationships
 
@@ -40,7 +83,9 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/waved.<S
   `chainsource`, `lib/actormsg`, `db`, `ledger`, `round`, `txconfirm`,
   `unroll`, `vtxo`, `wallet`, `walletcore`, `oor`, `serverconn`, `indexer`,
   `arkrpc`, `lndbackend`, `fraud`, `gateway`, `rpc/restclient`,
-  `vhtlcrecovery`, `vhtlcrecovery/coordinator`, `vhtlcrecovery/unrollpolicy`.
+  `vhtlcrecovery`, `vhtlcrecovery/coordinator`, `vhtlcrecovery/unrollpolicy`,
+  `arkchannel`, `arkchannel/oorbridge`, `arkchannel/unrollbridge`,
+  `lnruntime`, `rpc/arkchannelrpc`, `chainfees`.
 - **Depended on by**: `cmd/waved`.
 
 ## Invariants
@@ -117,9 +162,68 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/waved.<S
   code must not call `clock.NewDefaultClock()` directly, use `s.clk`.
 - Actor startup order in `startWalletDependentActors`: VTXO manager, then
   round actor, then the unroll subsystem (`initUnrollSubsystem`), then the
-  OOR actor (`initOORActor`). The VTXO manager is constructed with a
+  OOR actor (`initOORActor`), then the Ark channel process
+  (`initArkChannelProcess`). The VTXO manager is constructed with a
   `vtxo.LazyChainResolver` placeholder that `initUnrollSubsystem` fills in
   later; anything needing that seam must run after `initUnrollSubsystem`.
+  The channel process is last because it needs the durable channel store,
+  the swap-server mailbox edge, and every wallet-owned native dependency.
+- The Ark channel runtime is **opt-in on transport, not on a user flag**:
+  `initArkChannelProcess` returns early unless `SwapConfig.ArkChannelMailbox`
+  is set, which `swapclientserver` publishes as process wiring
+  (`mapstructure:"-"`) and no config file can supply. When it is set the
+  daemon stands up a dedicated `serverconn.Runtime`
+  (`arkchannel-serverconn-<localMailboxID>`) over that authenticated edge,
+  an `lnruntime.PeerMessageIngress` actor for durable BOLT peer messages,
+  and the controller, then publishes all three together under
+  `arkChannelMu` via `setArkChannelProcess`.
+- Channel shutdown order is peer ingress → controller → mailbox runtime,
+  and it runs **before** the main `serverconn` runtime and
+  `actorSystem.Shutdown()`. The mailbox runtime's deferred stop in
+  `runInner` is registered *after* the swap registrar's cleanup defers so
+  it runs first: the channel transport borrows the registrar's edge and
+  must not outlive it.
+- `arkChannelRPCServer` serves `arkchannelrpc.ArkChannelService` on the same
+  authenticated gRPC listener as `DaemonService`. Every method returns
+  `codes.Unavailable` when `getArkChannelController()` is nil, so a caller
+  that dials before the wallet-dependent actors finish can retry instead of
+  reading a startup race as `Internal`. The swap subserver reaches the same
+  controller through `RPCServer.waitArkChannelController`, which polls every
+  `arkChannelControllerPollInterval` (25 ms) until the caller's context
+  ends, because subservers are constructed before the channel process is
+  published.
+- The `channel` macaroon entity (`rpc_auth.go`) gates both surfaces:
+  `channel:read` covers `LookupPreparedArkChannelOOR` and
+  `ArkChannelService.GetChannel`; `channel:write` covers the
+  prepare/validate/commit/abort quartet and every `ArkChannelService`
+  mutation. `ExportOORRecoveryPackage` is deliberately `oor:read` — it
+  exports OOR lineage, not channel state.
+- `NewReceiveScript` accepts `identity_key` to register the daemon's durable
+  `clientKeyDesc` instead of deriving a fresh receive key, for protocol
+  destinations that must survive an independent process restart. It cannot
+  be combined with `idempotency_key` (`InvalidArgument`): the two are
+  opposite retry models, one keyed on a caller string and one on the
+  daemon's own identity. `ensureConfiguredArkChannelCloseDelivery`
+  registers exactly that script for cooperative-close payouts from
+  `startWalletReadyServices` — after the main mailbox ingress is running,
+  since registration is an indexer RPC — bounded by
+  `operatorTermsRefreshTimeout`.
+- The unroll subsystem's `ExitSpendPolicyResolver` is an
+  `unroll.PolicyResolvers` chain: the vHTLC
+  `unrollpolicy.ExitSpendPolicyResolver` first, then `unrollbridge.Resolver`
+  over the Ark channel store. The channel-policy VTXO is recovery-only — it
+  never appears in wallet balance, coin selection, refresh, or ordinary VTXO
+  actor recovery, so its exit policy has to arrive through this resolver.
+- `startPrePONRReaper` runs one controller-lifetime loop over
+  `context.WithoutCancel`, expiring an abandoned pre-PONR channel
+  reservation after `defaultArkChannelPrePONRTimeout` (10 min, scanned every
+  30 s). Client controllers start it before lnd or the hub is reachable so a
+  locally reserved wallet VTXO is released even if the channel never
+  progresses.
+- `setupLoggers` also installs lnd's own subsystem loggers (`funding`,
+  `CHFD`, `LNWL`, `HSWC`, `INVC`, `routing`, `CNCT`, `BRAR`, `UTXN`, `SWPR`,
+  `CHDB`, `chainio`) into `SubLoggers`, so the embedded native channel stack
+  logs through waved's configuration rather than lnd's package defaults.
 - `initUnrollSubsystem` boot ordering is policy-preserving.
   `recoverySvc.RestoreNonTerminal` (in-flight vHTLC recovery jobs, each
   carrying its durable exit policy) runs **before** the chain resolver is
diff --git a/waved/CLAUDE.md b/waved/CLAUDE.md
index 8caf29d4..4cbaf9c3 100644
--- a/waved/CLAUDE.md
+++ b/waved/CLAUDE.md
@@ -14,7 +14,9 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/waved.<S
   server, and `ActorSystem`. Caches `localMailboxID` (pubkey-derived),
   `authSigHex` (Schnorr auth), `clientKeyDesc` (the stable daemon identity
   descriptor, behind `clientKeyDescMu`), `mailboxAuthSigs` (per-recipient
-  mailbox auth signature memo, behind `mailboxAuthSigsMu`), and a single
+  mailbox auth signature memo, behind `mailboxAuthSigsMu`), the Ark channel
+  process triple (`arkChannelController`, `arkChannelMailboxRuntime`,
+  `arkChannelPeerIngress`, all behind `arkChannelMu`), and a single
   `clk` (`clock.Clock`) shared by all sub-stores for deterministic time
   injection.
 - `RPCServer` — implements the gRPC `DaemonService`. Most write RPCs
@@ -22,7 +24,12 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/waved.<S
   validate input locally then `Ask` the relevant actor; `GetRound` and
   `ListVTXOs` merge live actor state with persisted SQL rows, while
   `GetFeeHistory` and `ListTransactions` are pure SQL reads
-  (`rpc_fees.go`).
+  (`rpc_fees.go`). The channel-funding RPCs (`PrepareArkChannelOOR`,
+  `LookupPreparedArkChannelOOR`, `ValidatePreparedArkChannelOOR`,
+  `CommitPreparedArkChannelOOR`, `AbortPreparedArkChannelOOR` in
+  `rpc_ark_channel_oor.go`) and `ExportOORRecoveryPackage`
+  (`rpc_ark_channel_recovery.go`) drive the `arkchannel/oorbridge` and
+  recovery-archive seams instead.
 - `Config` — daemon configuration: wallet backend selection, mailbox/chain
   backend wiring, `OORConfig`/`OORLimitsConfig` (receive safety caps),
   `UnrollConfig` (unilateral-exit fee-bump cadence and cap), and
@@ -33,6 +40,42 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/waved.<S
   post-unlock recovery hook.
 - `UnrollConfig` / `OORConfig` — subsystem tunables; see `Config.Validate()`
   for the invariants each enforces.
+- `ArkChannelController` — the local process boundary published behind
+  `arkchannelrpc.ArkChannelService`. It composes
+  `ArkChannelLifecycleController` (`PromoteVTXO`,
+  `MaterializeAndForceClose`, `RequestCooperativeClose`, `GetChannel`,
+  `PeerMessageHandler`, `Stop`) and `ArkChannelPaymentController`
+  (`SendPayment`, `ReceivePayment`, `PayLightningInvoice`, plus the
+  incoming-payment `Prepare`/`Register`/`Wait` triple the swap subserver
+  calls through `RPCServer.*ArkChannelIncomingPayment`).
+- `NativeArkChannelController` — the concrete implementation, owning one
+  `arkchannel` FSM and one modular lnd endpoint. Built either as a lazy
+  client endpoint (`NewClientArkChannelController`, which loads hub policy
+  on the first lifecycle request) or eagerly as the hub endpoint
+  (`NewHubArkChannelController` over `HubArkChannelControllerConfig`, whose
+  advertised policy comes from `NewHubFundingPeerInfo`).
+  `LightningPaymentResult` is what `PayLightningInvoice` returns.
+- `ArkChannelControllerConfig` — the process-owned dependency set supplied
+  after wallet, database, and authenticated swap-server transport startup:
+  channel store, peer transport, `lwwallet`, chain backend/notifier/fee
+  estimator, the OOR and unroll bridges, identity key, and the funding
+  seams below.
+- `ArkChannelOORPreparer` / `ArkChannelOORLookup` /
+  `ArkChannelReceiveCapitalReserver` — funding callbacks the controller
+  invokes; `Server.prepareArkChannelOOR` and `Server.lookupArkChannelOOR`
+  supply the first two, and only the hub supplies the third.
+- `ArkChannelRecoveryController` — the endpoint-local source archive, spend
+  watcher, and unroll-preparation boundary
+  (`lnruntime.ChannelRecoveryManager` +
+  `arkchannel.ChannelEventSinkBinder` + `unrollbridge.SourcePreparer`),
+  implemented by `arkChannelRecoveryArchive` over
+  `arkChannelSourceWatcher`.
+- `ArkChannelRecoveryRuntime` / `ArkChannelRecoveryRuntimeConfig` — the same
+  unroller, package archive, and channel materializer composed for a host
+  that owns its own database, chain backend, and wallet (swapd's hub
+  endpoint). `ArkChannelUnrollWallet` (built by
+  `NewLNDArkChannelUnrollWallet`) is the shared `txconfirm.Wallet` +
+  `unroll.SweepWallet` surface it needs.
 
 ## Relationships
 
@@ -40,7 +83,9 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/waved.<S
   `chainsource`, `lib/actormsg`, `db`, `ledger`, `round`, `txconfirm`,
   `unroll`, `vtxo`, `wallet`, `walletcore`, `oor`, `serverconn`, `indexer`,
   `arkrpc`, `lndbackend`, `fraud`, `gateway`, `rpc/restclient`,
-  `vhtlcrecovery`, `vhtlcrecovery/coordinator`, `vhtlcrecovery/unrollpolicy`.
+  `vhtlcrecovery`, `vhtlcrecovery/coordinator`, `vhtlcrecovery/unrollpolicy`,
+  `arkchannel`, `arkchannel/oorbridge`, `arkchannel/unrollbridge`,
+  `lnruntime`, `rpc/arkchannelrpc`, `chainfees`.
 - **Depended on by**: `cmd/waved`.
 
 ## Invariants
@@ -117,9 +162,68 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/waved.<S
   code must not call `clock.NewDefaultClock()` directly, use `s.clk`.
 - Actor startup order in `startWalletDependentActors`: VTXO manager, then
   round actor, then the unroll subsystem (`initUnrollSubsystem`), then the
-  OOR actor (`initOORActor`). The VTXO manager is constructed with a
+  OOR actor (`initOORActor`), then the Ark channel process
+  (`initArkChannelProcess`). The VTXO manager is constructed with a
   `vtxo.LazyChainResolver` placeholder that `initUnrollSubsystem` fills in
   later; anything needing that seam must run after `initUnrollSubsystem`.
+  The channel process is last because it needs the durable channel store,
+  the swap-server mailbox edge, and every wallet-owned native dependency.
+- The Ark channel runtime is **opt-in on transport, not on a user flag**:
+  `initArkChannelProcess` returns early unless `SwapConfig.ArkChannelMailbox`
+  is set, which `swapclientserver` publishes as process wiring
+  (`mapstructure:"-"`) and no config file can supply. When it is set the
+  daemon stands up a dedicated `serverconn.Runtime`
+  (`arkchannel-serverconn-<localMailboxID>`) over that authenticated edge,
+  an `lnruntime.PeerMessageIngress` actor for durable BOLT peer messages,
+  and the controller, then publishes all three together under
+  `arkChannelMu` via `setArkChannelProcess`.
+- Channel shutdown order is peer ingress → controller → mailbox runtime,
+  and it runs **before** the main `serverconn` runtime and
+  `actorSystem.Shutdown()`. The mailbox runtime's deferred stop in
+  `runInner` is registered *after* the swap registrar's cleanup defers so
+  it runs first: the channel transport borrows the registrar's edge and
+  must not outlive it.
+- `arkChannelRPCServer` serves `arkchannelrpc.ArkChannelService` on the same
+  authenticated gRPC listener as `DaemonService`. Every method returns
+  `codes.Unavailable` when `getArkChannelController()` is nil, so a caller
+  that dials before the wallet-dependent actors finish can retry instead of
+  reading a startup race as `Internal`. The swap subserver reaches the same
+  controller through `RPCServer.waitArkChannelController`, which polls every
+  `arkChannelControllerPollInterval` (25 ms) until the caller's context
+  ends, because subservers are constructed before the channel process is
+  published.
+- The `channel` macaroon entity (`rpc_auth.go`) gates both surfaces:
+  `channel:read` covers `LookupPreparedArkChannelOOR` and
+  `ArkChannelService.GetChannel`; `channel:write` covers the
+  prepare/validate/commit/abort quartet and every `ArkChannelService`
+  mutation. `ExportOORRecoveryPackage` is deliberately `oor:read` — it
+  exports OOR lineage, not channel state.
+- `NewReceiveScript` accepts `identity_key` to register the daemon's durable
+  `clientKeyDesc` instead of deriving a fresh receive key, for protocol
+  destinations that must survive an independent process restart. It cannot
+  be combined with `idempotency_key` (`InvalidArgument`): the two are
+  opposite retry models, one keyed on a caller string and one on the
+  daemon's own identity. `ensureConfiguredArkChannelCloseDelivery`
+  registers exactly that script for cooperative-close payouts from
+  `startWalletReadyServices` — after the main mailbox ingress is running,
+  since registration is an indexer RPC — bounded by
+  `operatorTermsRefreshTimeout`.
+- The unroll subsystem's `ExitSpendPolicyResolver` is an
+  `unroll.PolicyResolvers` chain: the vHTLC
+  `unrollpolicy.ExitSpendPolicyResolver` first, then `unrollbridge.Resolver`
+  over the Ark channel store. The channel-policy VTXO is recovery-only — it
+  never appears in wallet balance, coin selection, refresh, or ordinary VTXO
+  actor recovery, so its exit policy has to arrive through this resolver.
+- `startPrePONRReaper` runs one controller-lifetime loop over
+  `context.WithoutCancel`, expiring an abandoned pre-PONR channel
+  reservation after `defaultArkChannelPrePONRTimeout` (10 min, scanned every
+  30 s). Client controllers start it before lnd or the hub is reachable so a
+  locally reserved wallet VTXO is released even if the channel never
+  progresses.
+- `setupLoggers` also installs lnd's own subsystem loggers (`funding`,
+  `CHFD`, `LNWL`, `HSWC`, `INVC`, `routing`, `CNCT`, `BRAR`, `UTXN`, `SWPR`,
+  `CHDB`, `chainio`) into `SubLoggers`, so the embedded native channel stack
+  logs through waved's configuration rather than lnd's package defaults.
 - `initUnrollSubsystem` boot ordering is policy-preserving.
   `recoverySvc.RestoreNonTerminal` (in-flight vHTLC recovery jobs, each
   carrying its durable exit policy) runs **before** the chain resolver is
diff --git a/waverpc/AGENTS.md b/waverpc/AGENTS.md
index 9d2761a5..014626fd 100644
--- a/waverpc/AGENTS.md
+++ b/waverpc/AGENTS.md
@@ -2,9 +2,10 @@
 
 ## Purpose
 
-Daemon gRPC API definitions for wallet, boarding, round, OOR, unroll, and
-VHTLC-recovery operations, plus the `Sign*` family through which other
-subsystems borrow the daemon identity key (`SignReceiveAuthMessage[Compact]`,
+Daemon gRPC API definitions for wallet, boarding, round, OOR, unroll,
+VHTLC-recovery, and Ark-channel funding operations, plus the `Sign*` family
+through which other subsystems borrow the daemon identity key
+(`SignReceiveAuthMessage[Compact]`,
 `SignOORCustomInput`, `SignVTXOForfeit`, `SignOutSwapHtlcAck`,
 `SignCreditAccountAuthorization`). Proto source: `waverpc/daemon.proto`.
 Generated gRPC, REST-gateway, and mailbox-RPC stubs plus one hand-written
@@ -22,10 +23,16 @@ helper file (`errors.go`) for structured wallet-lifecycle errors.
 - `IsWalletNotReadyError(err)` / `WalletNotReadyState(err)` — Match and unpack
   the structured error produced above; callers should key off these instead of
   matching on message text.
+- `ArkChannelOORPreparationStatus` — enum returned by
+  `LookupPreparedArkChannelOOR`: `UNSPECIFIED`, `ABSENT`, `PENDING`,
+  `PREPARED`, `ACCEPTED`.
 
 ## Relationships
 
-- **Depends on**: `mailbox/rpc` (mailbox-RPC runtime types used by the
+- **Depends on**: `rpc/arkchannelrpc` (`daemon.proto` imports
+  `rpc/arkchannelrpc/ark_channel.proto` for `ChannelTerms`,
+  `ChannelVTXOBinding`, `OORRecoverySource`, and `ChannelRecoveryPackage`),
+  `mailbox/rpc` (mailbox-RPC runtime types used by the
   generated mailbox stubs), `google.golang.org/genproto/googleapis/rpc/errdetails`
   and `google.golang.org/grpc` (structured errors in `errors.go`),
   `grpc-gateway/runtime` (REST gateway in `daemon.pb.gw.go`).
@@ -48,3 +55,21 @@ helper file (`errors.go`) for structured wallet-lifecycle errors.
   identity or they will be handed each other's receive scripts. An empty key
   keeps the legacy allocate-a-fresh-script behavior; repeating a non-empty key
   with a *different* label is rejected rather than silently reallocated.
+- `NewReceiveScriptRequest.identity_key` registers the daemon's durable
+  identity key as the receive destination instead of deriving a fresh one.
+  It is reserved for restart-stable protocol destinations (today, Ark
+  channel cooperative-close payouts) and is **mutually exclusive with
+  `idempotency_key`** — one keys the allocation on a caller string, the
+  other on the daemon's own identity, and combining them is
+  `InvalidArgument`.
+- The Ark channel funding RPCs are a strict five-step protocol:
+  `PrepareArkChannelOOR` reserves daemon liquidity and builds the
+  channel-policy output *without releasing signatures*;
+  `LookupPreparedArkChannelOOR` reconciles the deterministic key without
+  selecting or locking new inputs; `ValidatePreparedArkChannelOOR` re-checks
+  a binding; and exactly one of `CommitPreparedArkChannelOOR` (only after
+  both lnd endpoints persisted the signed backing) or
+  `AbortPreparedArkChannelOOR` (pre-PONR release, `reason` required) ends
+  the reservation. `ExportOORRecoveryPackage` is the separate read-only
+  export of a finalized OOR package and its round ancestry for one exact
+  output.
diff --git a/waverpc/CLAUDE.md b/waverpc/CLAUDE.md
index 9d2761a5..014626fd 100644
--- a/waverpc/CLAUDE.md
+++ b/waverpc/CLAUDE.md
@@ -2,9 +2,10 @@
 
 ## Purpose
 
-Daemon gRPC API definitions for wallet, boarding, round, OOR, unroll, and
-VHTLC-recovery operations, plus the `Sign*` family through which other
-subsystems borrow the daemon identity key (`SignReceiveAuthMessage[Compact]`,
+Daemon gRPC API definitions for wallet, boarding, round, OOR, unroll,
+VHTLC-recovery, and Ark-channel funding operations, plus the `Sign*` family
+through which other subsystems borrow the daemon identity key
+(`SignReceiveAuthMessage[Compact]`,
 `SignOORCustomInput`, `SignVTXOForfeit`, `SignOutSwapHtlcAck`,
 `SignCreditAccountAuthorization`). Proto source: `waverpc/daemon.proto`.
 Generated gRPC, REST-gateway, and mailbox-RPC stubs plus one hand-written
@@ -22,10 +23,16 @@ helper file (`errors.go`) for structured wallet-lifecycle errors.
 - `IsWalletNotReadyError(err)` / `WalletNotReadyState(err)` — Match and unpack
   the structured error produced above; callers should key off these instead of
   matching on message text.
+- `ArkChannelOORPreparationStatus` — enum returned by
+  `LookupPreparedArkChannelOOR`: `UNSPECIFIED`, `ABSENT`, `PENDING`,
+  `PREPARED`, `ACCEPTED`.
 
 ## Relationships
 
-- **Depends on**: `mailbox/rpc` (mailbox-RPC runtime types used by the
+- **Depends on**: `rpc/arkchannelrpc` (`daemon.proto` imports
+  `rpc/arkchannelrpc/ark_channel.proto` for `ChannelTerms`,
+  `ChannelVTXOBinding`, `OORRecoverySource`, and `ChannelRecoveryPackage`),
+  `mailbox/rpc` (mailbox-RPC runtime types used by the
   generated mailbox stubs), `google.golang.org/genproto/googleapis/rpc/errdetails`
   and `google.golang.org/grpc` (structured errors in `errors.go`),
   `grpc-gateway/runtime` (REST gateway in `daemon.pb.gw.go`).
@@ -48,3 +55,21 @@ helper file (`errors.go`) for structured wallet-lifecycle errors.
   identity or they will be handed each other's receive scripts. An empty key
   keeps the legacy allocate-a-fresh-script behavior; repeating a non-empty key
   with a *different* label is rejected rather than silently reallocated.
+- `NewReceiveScriptRequest.identity_key` registers the daemon's durable
+  identity key as the receive destination instead of deriving a fresh one.
+  It is reserved for restart-stable protocol destinations (today, Ark
+  channel cooperative-close payouts) and is **mutually exclusive with
+  `idempotency_key`** — one keys the allocation on a caller string, the
+  other on the daemon's own identity, and combining them is
+  `InvalidArgument`.
+- The Ark channel funding RPCs are a strict five-step protocol:
+  `PrepareArkChannelOOR` reserves daemon liquidity and builds the
+  channel-policy output *without releasing signatures*;
+  `LookupPreparedArkChannelOOR` reconciles the deterministic key without
+  selecting or locking new inputs; `ValidatePreparedArkChannelOOR` re-checks
+  a binding; and exactly one of `CommitPreparedArkChannelOOR` (only after
+  both lnd endpoints persisted the signed backing) or
+  `AbortPreparedArkChannelOOR` (pre-PONR release, `reason` required) ends
+  the reservation. `ExportOORRecoveryPackage` is the separate read-only
+  export of a finalized OOR package and its round ancestry for one exact
+  output.

How to apply. Save the diff above and git apply it on this branch, or
run the gardening skill locally (/doc-gardening waved, waverpc,
cmd/wavecli/waveclicommands, harness) — the same pass the nightly sweep
runs — and let it regenerate the CLAUDE.md/AGENTS.md pairs.

This check is advisory only; it never fails the build.

View run

@sputn1ck
sputn1ck force-pushed the kon/ark-channel-daemon branch from 070cf3d to 98740b3 Compare August 24, 2026 15:28
@sputn1ck sputn1ck changed the title kon/ark channel daemon waved: Operate native Ark channels Aug 24, 2026
@sputn1ck
sputn1ck force-pushed the kon/ark-channel-daemon branch from 98740b3 to 1232f96 Compare August 24, 2026 15:35
@litbot-9000

litbot-9000 commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

This PR's Go changes leave the per-package docs for cmd/waved and swapclientserver stale — the new --swap.arkchannelreceiveenabled opt-in flag and the SwapConfig.ArkChannelMailbox publish/release handoff are undocumented (the other scoped packages — cmd/wavecli/waveclicommands, cmd/wavecli/waveclicommands/devrpc, harness, rpc/restclient, waved, waverpc — are already current).

Proposed doc changes (git diff -- '*.md')
diff --git a/cmd/waved/AGENTS.md b/cmd/waved/AGENTS.md
index e6eadd12..d0813b0d 100644
--- a/cmd/waved/AGENTS.md
+++ b/cmd/waved/AGENTS.md
@@ -27,6 +27,11 @@ hands off to `waved.Main` to run the daemon.
   `newRootCmd`. `registerMaxPaymentCLTVFlag` owns `--maxpaymentcltv`, the
   automatic-maintenance target for keeping enough VTXO lifetime available for
   Lightning payments.
+- `registerSwapRuntimeFlags(f, cfg)` — registers the whole `swap.*` surface
+  (swap server address/TLS, session database path, vHTLC-recovery escalation
+  policy) plus `--swap.arkchannelreceiveenabled`, the opt-in that lets a
+  Lightning receive settle over a direct Ark-backed channel instead of the
+  vHTLC rail alone.
 
 ## Relationships
 
@@ -55,6 +60,17 @@ hands off to `waved.Main` to run the daemon.
 - `EagerRoundJoin`'s flag default comes from `waved.DefaultConfig()`,
   which is itself build-tag aware (true under `wavewalletrpc`, false
   otherwise); `--eagerroundjoin` still overrides it either way.
+- `--swap.arkchannelreceiveenabled` defaults to **off**, so a Lightning
+  receive stays on the vHTLC rail until an operator opts in. The `swap.*`
+  flags are registered in every build (this file carries no build tag); they
+  only take effect once `configureSwapRuntime` has appended the `swapruntime`
+  subserver registrar.
+- The companion `SwapConfig.ArkChannelMailbox` deliberately has no flag and
+  no config key (`mapstructure:"-"`). `swapclientserver.Register` publishes
+  its authenticated swap-server mailbox into that field at runtime, and
+  `waved` starts its Ark channel process only when the field is populated —
+  so a build without the swap subserver exposes the receive flag but can
+  never run the channel process.
 - `--maxpaymentcltv`'s default is build-tag aware the same way: it reads
   `cfg.MaxPaymentCLTV`, which `waved.DefaultConfig()` seeds from
   `defaultMaxPaymentCLTV()` — 300 under `swapruntime`, zero otherwise. The
diff --git a/cmd/waved/CLAUDE.md b/cmd/waved/CLAUDE.md
index e6eadd12..d0813b0d 100644
--- a/cmd/waved/CLAUDE.md
+++ b/cmd/waved/CLAUDE.md
@@ -27,6 +27,11 @@ hands off to `waved.Main` to run the daemon.
   `newRootCmd`. `registerMaxPaymentCLTVFlag` owns `--maxpaymentcltv`, the
   automatic-maintenance target for keeping enough VTXO lifetime available for
   Lightning payments.
+- `registerSwapRuntimeFlags(f, cfg)` — registers the whole `swap.*` surface
+  (swap server address/TLS, session database path, vHTLC-recovery escalation
+  policy) plus `--swap.arkchannelreceiveenabled`, the opt-in that lets a
+  Lightning receive settle over a direct Ark-backed channel instead of the
+  vHTLC rail alone.
 
 ## Relationships
 
@@ -55,6 +60,17 @@ hands off to `waved.Main` to run the daemon.
 - `EagerRoundJoin`'s flag default comes from `waved.DefaultConfig()`,
   which is itself build-tag aware (true under `wavewalletrpc`, false
   otherwise); `--eagerroundjoin` still overrides it either way.
+- `--swap.arkchannelreceiveenabled` defaults to **off**, so a Lightning
+  receive stays on the vHTLC rail until an operator opts in. The `swap.*`
+  flags are registered in every build (this file carries no build tag); they
+  only take effect once `configureSwapRuntime` has appended the `swapruntime`
+  subserver registrar.
+- The companion `SwapConfig.ArkChannelMailbox` deliberately has no flag and
+  no config key (`mapstructure:"-"`). `swapclientserver.Register` publishes
+  its authenticated swap-server mailbox into that field at runtime, and
+  `waved` starts its Ark channel process only when the field is populated —
+  so a build without the swap subserver exposes the receive flag but can
+  never run the channel process.
 - `--maxpaymentcltv`'s default is build-tag aware the same way: it reads
   `cfg.MaxPaymentCLTV`, which `waved.DefaultConfig()` seeds from
   `defaultMaxPaymentCLTV()` — 300 under `swapruntime`, zero otherwise. The
diff --git a/swapclientserver/AGENTS.md b/swapclientserver/AGENTS.md
index 69571f77..a1f6ff7f 100644
--- a/swapclientserver/AGENTS.md
+++ b/swapclientserver/AGENTS.md
@@ -46,9 +46,15 @@ protocol behavior remain entirely inside `sdk/swaps` and `swapdk-server`.
   `MailboxOutSwapEventReceiver` (empty mailbox ID — receiver derives the
   per-swap mailbox from client identity + payment hash) on the
   `SwapClient` so out-swap HTLC events flow over the mailbox transport,
-  publishes `cfg.Swap.Backend`/`CreditServer`/`CreditDaemon` bridges,
-  registers the gRPC subserver, calls `resumePending` (unless
-  `cfg.Swap.SuppressResume`), and returns a cleanup function.
+  publishes `cfg.Swap.Backend`/`CreditServer`/`CreditDaemon` bridges and
+  `cfg.Swap.ArkChannelMailbox`, registers the gRPC subserver, calls
+  `resumePending` (unless `cfg.Swap.SuppressResume`), and returns a cleanup
+  function.
+- `bindArkChannelMailbox(cfg, client)` — publishes the authenticated
+  swap-server mailbox client on `cfg.Swap.ArkChannelMailbox` for the
+  daemon-owned Ark channel process and returns the matching release
+  function. This is the only way that field is ever set; it has no flag or
+  config key.
 
 ## RPC Methods
 
@@ -128,6 +134,13 @@ protocol behavior remain entirely inside `sdk/swaps` and `swapdk-server`.
   "no filesystem here". It mirrors `waved.ensureDataDir`; keep the two in
   step, since a Node host given an unwritable path should fail there rather
   than at the first database open.
+- `bindArkChannelMailbox` scopes `cfg.Swap.ArkChannelMailbox` to exactly this
+  subserver's lifetime: the release function runs early in `cleanup`, ahead of
+  `arkClient.Close()` and the swap-server transport teardown, so the field is
+  nil again before the connection it names goes away. `waved` reads that field
+  to decide whether to start its Ark channel process, so leaving a stale
+  non-nil client behind would let a later start attach the channel runtime to
+  a dead transport.
 - `SetOutSwapEventReceiver` must run before any receive worker is started:
   `SwapClient` captures the receiver into the per-swap worker at start time,
   so a late install would leave already-running workers using whatever
diff --git a/swapclientserver/CLAUDE.md b/swapclientserver/CLAUDE.md
index 69571f77..a1f6ff7f 100644
--- a/swapclientserver/CLAUDE.md
+++ b/swapclientserver/CLAUDE.md
@@ -46,9 +46,15 @@ protocol behavior remain entirely inside `sdk/swaps` and `swapdk-server`.
   `MailboxOutSwapEventReceiver` (empty mailbox ID — receiver derives the
   per-swap mailbox from client identity + payment hash) on the
   `SwapClient` so out-swap HTLC events flow over the mailbox transport,
-  publishes `cfg.Swap.Backend`/`CreditServer`/`CreditDaemon` bridges,
-  registers the gRPC subserver, calls `resumePending` (unless
-  `cfg.Swap.SuppressResume`), and returns a cleanup function.
+  publishes `cfg.Swap.Backend`/`CreditServer`/`CreditDaemon` bridges and
+  `cfg.Swap.ArkChannelMailbox`, registers the gRPC subserver, calls
+  `resumePending` (unless `cfg.Swap.SuppressResume`), and returns a cleanup
+  function.
+- `bindArkChannelMailbox(cfg, client)` — publishes the authenticated
+  swap-server mailbox client on `cfg.Swap.ArkChannelMailbox` for the
+  daemon-owned Ark channel process and returns the matching release
+  function. This is the only way that field is ever set; it has no flag or
+  config key.
 
 ## RPC Methods
 
@@ -128,6 +134,13 @@ protocol behavior remain entirely inside `sdk/swaps` and `swapdk-server`.
   "no filesystem here". It mirrors `waved.ensureDataDir`; keep the two in
   step, since a Node host given an unwritable path should fail there rather
   than at the first database open.
+- `bindArkChannelMailbox` scopes `cfg.Swap.ArkChannelMailbox` to exactly this
+  subserver's lifetime: the release function runs early in `cleanup`, ahead of
+  `arkClient.Close()` and the swap-server transport teardown, so the field is
+  nil again before the connection it names goes away. `waved` reads that field
+  to decide whether to start its Ark channel process, so leaving a stale
+  non-nil client behind would let a later start attach the channel runtime to
+  a dead transport.
 - `SetOutSwapEventReceiver` must run before any receive worker is started:
   `SwapClient` captures the receiver into the per-swap worker at start time,
   so a late install would leave already-running workers using whatever

How to apply: save the diff above and git apply it, or regenerate it
locally by running the doc-gardening skill scoped to the two packages:
/doc-gardening cmd/waved and /doc-gardening swapclientserver.


Advisory only — this check does not fail on doc drift.
Workflow run

@darioAnongba darioAnongba left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Composition is good where it's eager: controller last, ingress after controller, RPCs Unavailable-gated, dedicated mailbox runtime, exit-policy resolver registered eagerly so force materialization works even without the controller.

Two structural issues, both about when things run: the client endpoint starts lazily (idle restart = no breach watching), and one bad record in watch restore bricks every channel op. Plus force-close has no confirmation. Inline.

Channel funds are invisible: no ListChannels, GetChannel has no balance split (SelectActiveChannel already computes it), GetBalance untouched. After channel create 100000 the balance drops and nothing shows where it went. Same shape as #816, now on the main rail. I'd fold channel balances into GetBalance and add a list RPC before the CLI verbs land.

Stack ordering (+1 Codex): ArkChannelMailbox is declared here but only assigned in #1139, so this PR alone ships an inert RPC/CLI surface. Fine if #1139 follows immediately, but it breaks bisect and the description oversells it; either move the assignment or say so.

Bots I confirmed, +1 each: missing CancelOutgoingPayment on GetChannel/SCID mismatch and cancel with a dead ctx; VTXO unlock with the caller ctx (the neighbours already use WithoutCancel, so inconsistency rather than oversight); mailbox runtime double-stop; fmt.Errorf to codes.Unknown in the two RPC files; unsynchronized clientKeyDesc read vs the loadClientKeyDesc invariant in waved/CLAUDE.md.

Smaller: unlocked c.service reads race the start-failure cleanup, and WaitInvoiceAccepted/SettleHoldInvoice/CancelInvoice deref c.node without ensure; six hub-orchestration OOR RPCs on the public REST gateway with no consumer; stale CLAUDE.mds and the channel subtree escaping schema_parity_test.go. And no client-side metrics at all (phases, rail selection, manifestation latency, reaper); the hub got a ledger, the client got logs.

Long version: https://ark-channels.lightning.wiki/

Comment thread waved/native_ark_channel_controller.go Resolved
Comment thread waved/native_ark_channel_controller.go Resolved
Comment thread waved/ark_channel_source.go Resolved
Comment thread waved/native_ark_channel_controller.go Resolved
Comment thread waved/server.go Resolved
Comment thread waved/ark_channel_process.go Resolved
Comment thread waved/rpc_ark_channel_oor.go Resolved
sputn1ck added a commit that referenced this pull request Sep 8, 2026
Detach wallet and payment cleanup from canceled RPC contexts, isolate
recovery watch failures, serialize mailbox shutdown ownership, and
return typed mailbox errors.

Target-PR: #1192
sputn1ck added a commit that referenced this pull request Sep 8, 2026
Start client recovery after mailbox publication, share bounded startup
attempts across callers, retry persisted state, and make shutdown cancel
and join all controller-owned work.

Target-PR: #1192
sputn1ck added a commit that referenced this pull request Sep 8, 2026
Add deterministic creation keys, recoverable channel listing, and
optional live balance fields, then regenerate all Ark channel RPC
bindings.

Target-PR: #1192
sputn1ck added a commit that referenced this pull request Sep 8, 2026
Derive stable promotion identifiers from retry keys, expose durable
channel listing with best-effort balances, and require CLI confirmation
before channel fund movements.

Target-PR: #1192
@sputn1ck
sputn1ck force-pushed the kon/ark-channel-daemon branch from 1232f96 to d7d8947 Compare September 8, 2026 19:31
sputn1ck added a commit that referenced this pull request Sep 8, 2026
Detach wallet and payment cleanup from canceled RPC contexts, isolate
recovery watch failures, serialize mailbox shutdown ownership, and
return typed mailbox errors.

Target-PR: #1192
sputn1ck added a commit that referenced this pull request Sep 8, 2026
Start client recovery after mailbox publication, share bounded startup
attempts across callers, retry persisted state, and make shutdown cancel
and join all controller-owned work.

Target-PR: #1192
sputn1ck added a commit that referenced this pull request Sep 8, 2026
Add deterministic creation keys, recoverable channel listing, and
optional live balance fields, then regenerate all Ark channel RPC
bindings.

Target-PR: #1192
sputn1ck added a commit that referenced this pull request Sep 8, 2026
Derive stable promotion identifiers from retry keys, expose durable
channel listing with best-effort balances, and require CLI confirmation
before channel fund movements.

Target-PR: #1192
@sputn1ck
sputn1ck force-pushed the kon/ark-channel-daemon branch from 170ba62 to 41a6127 Compare September 8, 2026 20:50
@sputn1ck
sputn1ck force-pushed the kon/ark-channel-daemon branch from 77ff53f to f7d47ca Compare November 9, 2026 20:34
@sputn1ck
sputn1ck force-pushed the kon/ark-channel-daemon branch from f7d47ca to fe446a3 Compare November 9, 2026 20:46
@sputn1ck
sputn1ck force-pushed the kon/ark-channel-daemon branch from fe446a3 to 64d5613 Compare November 9, 2026 21:00
@litbot-9000

Copy link
Copy Markdown
Collaborator

@litbot-9000: review reminder
@sputn1ck, remember to re-request review from reviewers when ready

@sputn1ck
sputn1ck force-pushed the kon/ark-channel-daemon branch from 27017c0 to 1ab931b Compare November 16, 2026 15:15
@sputn1ck
sputn1ck force-pushed the kon/ark-channel-daemon branch from 1ab931b to 2a768f3 Compare November 17, 2026 21:46
@sputn1ck
sputn1ck force-pushed the kon/ark-channel-daemon branch from 2a768f3 to ff7b049 Compare November 17, 2026 21:58
@litbot-9000

Copy link
Copy Markdown
Collaborator

@litbot-9000: review reminder
@sputn1ck, remember to re-request review from reviewers when ready

@sputn1ck
sputn1ck force-pushed the kon/ark-channel-daemon branch from ff7b049 to ecf4fd4 Compare November 18, 2026 18:14
@sputn1ck sputn1ck closed this Nov 18, 2026
@sputn1ck sputn1ck reopened this Nov 18, 2026
@sputn1ck
sputn1ck force-pushed the kon/ark-channel-daemon branch from c41c57d to de7f2ab Compare November 19, 2026 16:04
@sputn1ck sputn1ck closed this Nov 19, 2026
Describe the daemon operations and signed payout artifacts without
exposing internal funding reservations as public RPCs.
Expose the channel controls over the existing transports and assign
macaroon permissions before enabling the handlers.
Install native logging once so multiple channel runtimes can share
the daemon without racing global logger replacement.
Authenticate the full source ancestry and recover materialization
from durable wallet state when notifications or restarts intervene.
Restore protection from durable local state before negotiation. Keep an
empty wallet dormant until an explicitly permitted open, and refuse to
disable recovery when the inventory is live or cannot be read.
Expose creation and payment only through the guarded daemon methods.
Keep ordinary wallet receives separate from explicit channel funding.
@litbot-9000

Copy link
Copy Markdown
Collaborator

@litbot-9000: review reminder
@sputn1ck, remember to re-request review from reviewers when ready

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.

4 participants