Skip to content

oor/unroll: Prepare channel-backed funding and recover its sources - #1189

Open
sputn1ck wants to merge 21 commits into
mainfrom
kon/ark-channel-oor-funding
Open

sputn1ck wants to merge 21 commits into
mainfrom
kon/ark-channel-oor-funding

Conversation

@sputn1ck

@sputn1ck sputn1ck commented Aug 24, 2026 •

Copy link
Copy Markdown
Member

Prepare and validate channel-backed OOR funding before commit. Preserve source lineage, prepared identity and reservation ownership across restart. Keep the foreign-asset regression with the pre-signed unroll path that introduced it.

Do not merge #1189 until the independently reviewed behavioral prerequisites land on main and this feature branch is rebased onto that main. GitHub anchors this native stack's bottom PR to main. Its Files changed view is cumulative while prerequisites are unmerged; a channel-only comparison is for review, not permission to merge the bundle. The corrected stack also depends on the independent wallet backend (#1642) and pending-swap retry (#1643).

Review the channel-only funding comparison. Its exact base is the aggregate of six independently reviewable main PRs: parser #1637, mailbox #1638, ordinary receive deadlines #1639, ordinary refund compatibility #1640, light-wallet backend #1642 and ordinary pending-swap retry #1643. Do not merge the aggregate as a bundle. The comparison excludes all six; the native PR Files changed view does not.

No native channel runtime, personal lnd replacement, generic worker retry or light-wallet backend change is introduced by the channel-only comparison. Package-level OOR, unroll, VTXO and database checks and changed-source lint passed locally. #1190 builds on this layer.

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

This PR adds infrastructure for Ark-backed Lightning channel flows by introducing application-owned “recovery-only” VTXOs, a two-phase (prepare/commit) OOR transfer mode, and non-standard unroll policy handling (including recognizing a peer-published pre-signed final spend as successful completion). It also adds DB and codec support so these new states and artifacts survive restarts and actor reaping.

Changes:

  • Add VTXOStatusRecoveryOnly plus store/manager logic to keep application-owned outputs out of wallet balance/selection/actors, while still allowing deterministic recovery and spend completion.
  • Extend unroll to support policy-kind dispatch and “pre-signed final spend” policies, treating the exact expected transaction as success even if published by the peer.
  • Add prepared OOR sessions (prepare → commit/abort), persist richer outgoing snapshots (recipients + pre-PONR failure marker), and allow registry state reads after terminal children are reaped.

Reviewed changes

Copilot reviewed 34 out of 36 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vtxo/manager.go Allows actorless completion for recovery-only spends and confirms recovery-only exits gated by non-standard policy kind.
vtxo/manager_admission_test.go Adds tests for actorless recovery-only completion and missing-actor rejection for normal VTXOs.
vtxo/interfaces.go Introduces VTXOStatusRecoveryOnly and string form.
vtxo/filter.go Excludes recovery-only from pending-balance accounting.
vtxo/filter_test.go Verifies pending-balance exclusion for recovery-only descriptors.
unroll/policy_resolvers.go Adds a composite resolver that dispatches exit spend policy by kind.
unroll/interfaces.go Adds PreSignedExitSpendPolicy interface for immutable final spends.
unroll/actor.go Recognizes the exact pre-signed final spend as a successful completion path.
unroll/actor_test.go Adds harness seam + test verifying peer-published pre-signed spend completes the actor.
oor/transitions.go Adds Prepared state handling, commit/abort events, and PrePONR tracking for failures.
oor/states.go Introduces Prepared state and extends Failed with PrePONR.
oor/session.go Adds APIs for prepared sessions and plumbs PrepareOnly through session creation.
oor/session_test.go Tests prepared commit behavior and abort releasing inputs (pre-PONR).
oor/session_actor_handlers.go Forwards PrepareOnly into session creation from actor handler.
oor/resume.go Ensures Prepared state has no implied outbox side effects on resume.
oor/registry.go Allows GetState to read persisted snapshots when a terminal child has been reaped.
oor/registry_test.go Tests GetState reads persisted snapshot without spawning a child.
oor/outgoing_snapshot.go Adds Prepared snapshot phase, recipient metadata persistence, and pre-PONR failure marker; adds recipient extraction helper.
oor/outgoing_snapshot_codec.go Adds TLV records for recipient metadata + pre-PONR failure flag; decodes them with limits.
oor/outgoing_snapshot_codec_test.go Extends TLV round-trip test coverage for new snapshot fields.
oor/events.go Adds prepare-only start flag and commit/abort prepared events.
oor/actor_messages.go Adds PrepareOnly to start-transfer request encode/decode.
oor/actor_durable_message.go Adds durable mailbox encoding for prepare-only + prepared commit/abort events; refactors incoming transfer decode helper.
oor/actor_durable_message_test.go Adds tests for prepare-only payload round-trip and prepared commit/abort durable round-trip.
lib/arkscript/channel_vtxo.go Adds compiled policy construction/validation helpers for Ark-backed channel VTXO scripts.
lib/arkscript/channel_vtxo_test.go Tests channel policy paths, reaction-window enforcement, and template validation.
db/vtxo_store.go Adds SaveRecoveryOnlyVTXO and SetRecoveryOnlyVTXORelativeExpiry plus descriptor replay validation.
db/vtxo_store_test.go Tests recovery-only descriptors are excluded from wallet sets and validates replay rules.
db/sqlc/vtxo.sql.go Adds generated SQL for setting recovery-only relative expiry.
db/sqlc/schemas/generated_schema.sql Documents new numeric status mapping for Expired/RecoveryOnly.
db/sqlc/queries/vtxo.sql Adds SetRecoveryOnlyVTXORelativeExpiry query.
db/sqlc/querier.go Exposes new query in the sqlc querier interface.
db/sqlc/migrations/000004_vtxos.up.sql Documents new numeric status mapping for Expired/RecoveryOnly.
db/round_store.go Plumbs the new query into the RoundStore interface.
db/oor_unroll_resolver.go Adds session-id-based package resolution path and shares traversal logic.
db/oor_unroll_resolver_test.go Tests resolving unroll packages by session ID before an outpoint binding exists.
Files not reviewed (2)
  • db/sqlc/querier.go: Generated file
  • db/sqlc/vtxo.sql.go: Generated file

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

Comment thread oor/actor_durable_message.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: 20dcd1c701

ℹ️ 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 oor/transitions.go Resolved
@sputn1ck sputn1ck changed the title kon/ark channel oor funding arkscript/oor: Prepare channel-backed OOR funding Aug 24, 2026
@sputn1ck

Copy link
Copy Markdown
Member Author

/gateway review

@lightninglabs-gateway lightninglabs-gateway 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.

Gateway review — 5 findings

🔴 0 Blocker · 🟠 3 Major · 🟡 2 Minor · 🔵 0 Nit

Summary

This is layer 1 of the Ark channels stack: a RecoveryOnly VTXO status that keeps application-owned outputs out of wallet balance/selection/actors, a prepare/commit two-phase OOR mode so a channel coordinator can use a deterministic outpoint before any signature is released, and unroll support for recognizing a peer-published pre-signed final spend as success. The layering is clean and the new states are threaded through the snapshot codec, the registry, and the DB consistently.

Three things need attention before merge. The prepare-only mode creates a durable session that carries an idempotency key but no dispatch-attempt row, and validateOutgoingDispatchIdentity treats exactly that shape as a keyless admission — so a keyed prepared transfer becomes unretriable after a restart. SaveRecoveryOnlyVTXO's replay validation treats expiry as immutable while SetRecoveryOnlyVTXORelativeExpiry, ten lines above it, exists to mutate that column. And ValidateChannelVTXOTemplate compares an untrusted template only by its set of compiled leaf scripts, never by the output script that template actually derives.

The new channel-policy delay arithmetic (validate) is carefully bounded and well tested; the recovery-only exclusion from ListLiveVTXOs / ListRecoverableVTXOs / selection candidates is covered end to end.

Bot commands
  • /gateway re-review — re-run after pushing changes (maintainers)
  • /gateway dismiss <id> — silence a finding (maintainers)
  • /gateway explain <id> — elaborate on a finding (anyone)

Comment thread oor/registry.go Resolved
Comment thread db/vtxo_store.go Resolved
Comment thread lib/arkscript/channel_vtxo.go Resolved
Comment thread unroll/policy_resolvers.go Resolved
Comment thread db/vtxo_store_test.go Resolved
@lightninglabs-gateway

Copy link
Copy Markdown

🤖 gateway audit metadata for this PR — auto-generated, please don't edit.

@litbot-9000

Copy link
Copy Markdown
Collaborator

@bhandras: review reminder
@darioAnongba: review reminder
@sputn1ck, remember to re-request review from reviewers when ready

@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.

Prepare/commit boundary is clean and abort-safe, and recovery-only never leaks into balance, selection, refresh or admission (checked all of them). Tests pass at this head. Two things I'd fix in this layer before the rest builds on it: the keyed Prepared lookup doesn't survive a restart, and ExitPolicyKind.Valid() never learned the channel kind, so the retirement path is dead at the tip. Inline.

Not anchorable (code this PR doesn't touch), oor/registry.go validateOutgoingDispatchIdentity / handleLookupTransfer, blocking: a keyed Prepared session has no dispatch-attempt row, pendingOutgoingKeys is same-boot only, and identity validation never compares record.IdempotencyKey. After a restart the lookup says "absent", we re-prepare, the wallet can't re-pick the still-reserved inputs, and the new commit collides with the unique key index. Open loops, inputs stranded until a manual abort. Compare the key in validateOutgoingDispatchIdentity and return the existing session, and fall back to a registry-row-by-key lookup in handleLookupTransfer. (Bots flagged this too; the restart consequence is the part I'd stress.)

Two design notes. Prepared has no TTL at the OOR layer, so if the coordinator record never gets created the reservations leak until someone aborts by session ID; AdmissionDeadlineUnixNanos is already plumbed, an auto-abort past it would make this self-healing. And ExitPolicyKind being two string types joined by a cast is what let the Valid() gap happen silently; a shared constant set with an exhaustiveness test would turn it into a test failure.

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

Comment thread vtxo/manager.go Resolved
Comment thread db/vtxo_store.go Resolved
Comment thread oor/transitions.go Resolved
Comment thread lib/arkscript/channel_vtxo.go Resolved
Comment thread unroll/actor.go Resolved
Comment thread oor/outgoing_snapshot.go Resolved
Comment thread unroll/policy_resolvers.go Resolved
Comment thread oor/actor_durable_message.go Resolved
@sputn1ck
sputn1ck force-pushed the kon/ark-channel-oor-funding branch from 20dcd1c to a3dcce4 Compare September 8, 2026 19:19
@sputn1ck
sputn1ck requested a review from Roasbeef as a code owner September 8, 2026 19:19
@sputn1ck
sputn1ck force-pushed the kon/ark-channel-oor-funding branch 2 times, most recently from 5a46e2c to beb5137 Compare September 8, 2026 21:10
@litbot-9000

Copy link
Copy Markdown
Collaborator

The Go changes on this branch left the per-package docs for db, lib/actormsg, lib/arkscript, oor, unroll, and vtxo stale — recovery-only VTXOs, the Ark channel VTXO policy, the pre-signed exit-spend path, and the prepared-OOR boundary are all undocumented (db/sqlc was in scope but needed no change, and oor/CLAUDE.md's snapshot-version bullet is amended rather than added).

Proposed CLAUDE.md / AGENTS.md updates
diff --git a/db/AGENTS.md b/db/AGENTS.md
index aee6255c..32606a75 100644
--- a/db/AGENTS.md
+++ b/db/AGENTS.md
@@ -38,6 +38,18 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/db.<Symb
   paginated listing (avoids deserializing full trees).
 - `VTXOPersistenceStore` — VTXO descriptor store
   (`InsertClientVTXO`, `FetchByOutpoint`). Persists `ChainDepth`.
+- `VTXOPersistenceStore.SaveRecoveryOnlyVTXO` — insert-and-transition in one
+  transaction for an application-owned descriptor (`vtxo.VTXOStatusRecoveryOnly`).
+  Unlike `SaveVTXO` it never leaves the row observable as live between the
+  insert and the status write, so concurrent wallet coin selection cannot
+  mistake a channel or contract output for spendable liquidity. A replay is
+  accepted only when `validateRecoveryOnlyVTXORow` finds the existing row still
+  `RecoveryOnly` or `Spent` **and** byte-identical on every immutable column;
+  relative expiry is excluded because channel recovery selects it afterwards.
+- `VTXOPersistenceStore.SetRecoveryOnlyVTXORelativeExpiry` — sets the exact
+  final-spend delay chosen by the Ark channel policy. The SQL is scoped to
+  `status = 9`, so an ordinary wallet VTXO can never be modified through it,
+  and a row count other than 1 is an error rather than a silent no-op.
 - `OORArtifactStore`, `OwnedReceiveScriptStore` — OOR session state
   and locally owned receive-script metadata.
 - `OwnedReceiveScriptRecord` — one owned receive-script row. Its
@@ -57,8 +69,14 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/db.<Symb
   different label fails with `ErrOwnedReceiveScriptReplayMismatch`.
 - `OORSessionRegistryStoreDB` / `OORSessionRegistryRecord` — control-plane
   registry of per-session durable OOR actors
-  (`UpsertSession`/`GetSession`/`ListSessions`/`ListNonTerminal`). One mutable
+  (`UpsertSession`/`GetSession`/`GetUnfailedSessionByIdempotencyKey`/
+  `ListSessions`/`ListNonTerminal`). One mutable
   row per session id is shared by both lifecycle directions.
+  `GetUnfailedSessionByIdempotencyKey` is the lookup for an outgoing identity
+  that is durable *before* its immutable `oor_dispatch_attempts` row exists
+  (an OOR session prepared but not yet committed). It filters out `status = 2`
+  (Failed), because a failed row deliberately releases its key, and returns
+  `ErrOORSessionNotFound` for an empty key.
 - `OORDispatchAttemptRecord` — immutable keyed outgoing identity, loaded by
   idempotency key or session id. It stores the canonical recipient record
   before the first transport enqueue and remains authoritative after the
@@ -112,6 +130,15 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/db.<Symb
   safety bounds enforced during `DeserializeTree`.
 - `resolveInputPackage` / `loadPackageBundleBySessionID` — two-stage
   OOR ancestry resolver (`oor_unroll_resolver.go`).
+- `OORArtifactPersistenceStore.ResolveUnrollPackages` /
+  `ResolveUnrollPackagesBySessionID` — the two entry points into that resolver,
+  sharing one `resolveUnrollPackages` traversal parameterized by how the target
+  package is loaded. The by-outpoint form is the ordinary path; the
+  by-session-id form resolves a chain *before* the local endpoint has installed
+  an outpoint binding, which is what an OOR sender needs while promoting a
+  recipient output into shared channel recovery state. The session variant fails
+  closed twice: the session id must equal `outpoint.Hash`, and the loaded
+  package must actually create the target outpoint.
 - `LatestMigrationVersion = 18` — current schema version.
 - `PendingIntentPersistenceStore` — implements `wallet.PendingIntentStore`,
   the persistence half of the generic restart-safe intent outbox (header
@@ -285,7 +312,11 @@ when adding one.
   `round_client_trees`, `client_tree_txids`.
 - `000004_vtxos` — `vtxos` plus the normalized `vtxo_ancestry_paths`
   side table. Routine queries skip the ancestry join; the unroller
-  loads ancestry only when resolving an exit.
+  loads ancestry only when resolving an exit. The `status` column's inline
+  comment enumerates the `vtxo.VTXOStatus` iota and is append-only alongside
+  it (`8 = Expired`, `9 = RecoveryOnly`); queries such as
+  `SetRecoveryOnlyVTXORelativeExpiry` hard-code those numbers, so a renumber
+  would silently retarget them.
 - `000005_oor` — OOR artifact store (packages, checkpoints, VTXO
   bindings), receiver-side polling state, and the
   `oor_session_registry` that owns per-session durable actors.
diff --git a/db/CLAUDE.md b/db/CLAUDE.md
index aee6255c..32606a75 100644
--- a/db/CLAUDE.md
+++ b/db/CLAUDE.md
@@ -38,6 +38,18 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/db.<Symb
   paginated listing (avoids deserializing full trees).
 - `VTXOPersistenceStore` — VTXO descriptor store
   (`InsertClientVTXO`, `FetchByOutpoint`). Persists `ChainDepth`.
+- `VTXOPersistenceStore.SaveRecoveryOnlyVTXO` — insert-and-transition in one
+  transaction for an application-owned descriptor (`vtxo.VTXOStatusRecoveryOnly`).
+  Unlike `SaveVTXO` it never leaves the row observable as live between the
+  insert and the status write, so concurrent wallet coin selection cannot
+  mistake a channel or contract output for spendable liquidity. A replay is
+  accepted only when `validateRecoveryOnlyVTXORow` finds the existing row still
+  `RecoveryOnly` or `Spent` **and** byte-identical on every immutable column;
+  relative expiry is excluded because channel recovery selects it afterwards.
+- `VTXOPersistenceStore.SetRecoveryOnlyVTXORelativeExpiry` — sets the exact
+  final-spend delay chosen by the Ark channel policy. The SQL is scoped to
+  `status = 9`, so an ordinary wallet VTXO can never be modified through it,
+  and a row count other than 1 is an error rather than a silent no-op.
 - `OORArtifactStore`, `OwnedReceiveScriptStore` — OOR session state
   and locally owned receive-script metadata.
 - `OwnedReceiveScriptRecord` — one owned receive-script row. Its
@@ -57,8 +69,14 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/db.<Symb
   different label fails with `ErrOwnedReceiveScriptReplayMismatch`.
 - `OORSessionRegistryStoreDB` / `OORSessionRegistryRecord` — control-plane
   registry of per-session durable OOR actors
-  (`UpsertSession`/`GetSession`/`ListSessions`/`ListNonTerminal`). One mutable
+  (`UpsertSession`/`GetSession`/`GetUnfailedSessionByIdempotencyKey`/
+  `ListSessions`/`ListNonTerminal`). One mutable
   row per session id is shared by both lifecycle directions.
+  `GetUnfailedSessionByIdempotencyKey` is the lookup for an outgoing identity
+  that is durable *before* its immutable `oor_dispatch_attempts` row exists
+  (an OOR session prepared but not yet committed). It filters out `status = 2`
+  (Failed), because a failed row deliberately releases its key, and returns
+  `ErrOORSessionNotFound` for an empty key.
 - `OORDispatchAttemptRecord` — immutable keyed outgoing identity, loaded by
   idempotency key or session id. It stores the canonical recipient record
   before the first transport enqueue and remains authoritative after the
@@ -112,6 +130,15 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/db.<Symb
   safety bounds enforced during `DeserializeTree`.
 - `resolveInputPackage` / `loadPackageBundleBySessionID` — two-stage
   OOR ancestry resolver (`oor_unroll_resolver.go`).
+- `OORArtifactPersistenceStore.ResolveUnrollPackages` /
+  `ResolveUnrollPackagesBySessionID` — the two entry points into that resolver,
+  sharing one `resolveUnrollPackages` traversal parameterized by how the target
+  package is loaded. The by-outpoint form is the ordinary path; the
+  by-session-id form resolves a chain *before* the local endpoint has installed
+  an outpoint binding, which is what an OOR sender needs while promoting a
+  recipient output into shared channel recovery state. The session variant fails
+  closed twice: the session id must equal `outpoint.Hash`, and the loaded
+  package must actually create the target outpoint.
 - `LatestMigrationVersion = 18` — current schema version.
 - `PendingIntentPersistenceStore` — implements `wallet.PendingIntentStore`,
   the persistence half of the generic restart-safe intent outbox (header
@@ -285,7 +312,11 @@ when adding one.
   `round_client_trees`, `client_tree_txids`.
 - `000004_vtxos` — `vtxos` plus the normalized `vtxo_ancestry_paths`
   side table. Routine queries skip the ancestry join; the unroller
-  loads ancestry only when resolving an exit.
+  loads ancestry only when resolving an exit. The `status` column's inline
+  comment enumerates the `vtxo.VTXOStatus` iota and is append-only alongside
+  it (`8 = Expired`, `9 = RecoveryOnly`); queries such as
+  `SetRecoveryOnlyVTXORelativeExpiry` hard-code those numbers, so a renumber
+  would silently retarget them.
 - `000005_oor` — OOR artifact store (packages, checkpoints, VTXO
   bindings), receiver-side polling state, and the
   `oor_session_registry` that owns per-session durable actors.
diff --git a/lib/actormsg/AGENTS.md b/lib/actormsg/AGENTS.md
index 7f163c7e..f95f41a1 100644
--- a/lib/actormsg/AGENTS.md
+++ b/lib/actormsg/AGENTS.md
@@ -18,7 +18,12 @@ package boundaries. Lives in `lib/` to break import cycles between `vtxo`,
 - `ReleaseSpendRequest` / `CompleteSpendRequest` — Spend lifecycle completion messages.
 - `ForceUnrollRequest` / `ForceUnrollResponse` — Ask-message that routes an operator or chain-resolver unroll trigger through the VTXO manager into the per-VTXO FSM. `ForceUnrollRequest.Trigger` (a `UnrollTrigger`) names *why* the coin is exiting, and `ForceUnrollRequest.ExitPolicy` (an `fn.Option[ExitPolicy]`) names *which* exit-spend policy the target unrolls under, so a single admission path carries manual, critical-expiry, fraud, and vHTLC-recovery intent through to the unroll registry. `ForceUnrollResponse.Accepted` is true when the request caused a state transition; when false, `Reason` distinguishes `"no such vtxo"` from `"already terminal"` so callers don't misread a silent self-loop as success.
 - `UnrollTrigger` — String-typed enum naming why a unilateral exit was started (`UnrollTriggerCriticalExpiry` is the empty-string zero value and preserves the historical critical-expiry admission, `UnrollTriggerManual`, `UnrollTriggerFraudSpend`). It mirrors the unroll package's `StartTrigger` so `vtxo` and `actormsg` can thread the trigger through `ForceUnroll` without importing `unroll` (which would form a cycle); the waved chain resolver bridge converts it back at the seam.
-- `ExitPolicyKind` / `ExitPolicyRef` / `ExitPolicy` — Durable exit-spend policy identity for a forced exit. `ExitPolicyKind` is a string-typed enum of the non-standard policies that ride `ForceUnroll` (`ExitPolicyVHTLCClaim`, `ExitPolicyVHTLCRefundWithoutReceiver`), with `Valid()` true only for those two vHTLC kinds; `ExitPolicyRef` is the policy-specific durable reference (e.g. a vHTLC recovery job id), kept a distinct type so `Kind` and `Ref` can't be transposed; `ExitPolicy` bundles the pair as one identity validated at the registry admission boundary. A `None` `ExitPolicy` selects the standard VTXO timeout policy.
+- `ExitPolicyKind` / `ExitPolicyRef` / `ExitPolicy` — Durable exit-spend policy identity for a forced exit. `ExitPolicyKind` is a string-typed enum of the non-standard policies that ride `ForceUnroll` (`ExitPolicyVHTLCClaim`, `ExitPolicyVHTLCRefundWithoutReceiver`, `ExitPolicyArkChannelBacking`), with `Valid()` true only for those kinds; `ExitPolicyRef` is the policy-specific durable reference (e.g. a vHTLC recovery job id), kept a distinct type so `Kind` and `Ref` can't be transposed; `ExitPolicy` bundles the pair as one identity validated at the registry admission boundary. A `None` `ExitPolicy` selects the standard VTXO timeout policy.
+- `ExitPolicyArkChannelBacking` — the pre-signed channel materialization spend
+  of a recovery-only channel-policy VTXO. Unlike the vHTLC kinds, the final
+  transaction is fixed before the unroll starts and either channel endpoint may
+  publish it, so `unroll` treats the exact pre-signed txid appearing on chain as
+  success rather than as an external conflict.
 - `RegisterIntentMsg` — Carries pre-composed cooperative intent package to
   round actor. The `TriggerRegistration bool` field controls whether the
   round FSM immediately fires `IntentRequested` after accepting the intent
diff --git a/lib/actormsg/CLAUDE.md b/lib/actormsg/CLAUDE.md
index 7f163c7e..f95f41a1 100644
--- a/lib/actormsg/CLAUDE.md
+++ b/lib/actormsg/CLAUDE.md
@@ -18,7 +18,12 @@ package boundaries. Lives in `lib/` to break import cycles between `vtxo`,
 - `ReleaseSpendRequest` / `CompleteSpendRequest` — Spend lifecycle completion messages.
 - `ForceUnrollRequest` / `ForceUnrollResponse` — Ask-message that routes an operator or chain-resolver unroll trigger through the VTXO manager into the per-VTXO FSM. `ForceUnrollRequest.Trigger` (a `UnrollTrigger`) names *why* the coin is exiting, and `ForceUnrollRequest.ExitPolicy` (an `fn.Option[ExitPolicy]`) names *which* exit-spend policy the target unrolls under, so a single admission path carries manual, critical-expiry, fraud, and vHTLC-recovery intent through to the unroll registry. `ForceUnrollResponse.Accepted` is true when the request caused a state transition; when false, `Reason` distinguishes `"no such vtxo"` from `"already terminal"` so callers don't misread a silent self-loop as success.
 - `UnrollTrigger` — String-typed enum naming why a unilateral exit was started (`UnrollTriggerCriticalExpiry` is the empty-string zero value and preserves the historical critical-expiry admission, `UnrollTriggerManual`, `UnrollTriggerFraudSpend`). It mirrors the unroll package's `StartTrigger` so `vtxo` and `actormsg` can thread the trigger through `ForceUnroll` without importing `unroll` (which would form a cycle); the waved chain resolver bridge converts it back at the seam.
-- `ExitPolicyKind` / `ExitPolicyRef` / `ExitPolicy` — Durable exit-spend policy identity for a forced exit. `ExitPolicyKind` is a string-typed enum of the non-standard policies that ride `ForceUnroll` (`ExitPolicyVHTLCClaim`, `ExitPolicyVHTLCRefundWithoutReceiver`), with `Valid()` true only for those two vHTLC kinds; `ExitPolicyRef` is the policy-specific durable reference (e.g. a vHTLC recovery job id), kept a distinct type so `Kind` and `Ref` can't be transposed; `ExitPolicy` bundles the pair as one identity validated at the registry admission boundary. A `None` `ExitPolicy` selects the standard VTXO timeout policy.
+- `ExitPolicyKind` / `ExitPolicyRef` / `ExitPolicy` — Durable exit-spend policy identity for a forced exit. `ExitPolicyKind` is a string-typed enum of the non-standard policies that ride `ForceUnroll` (`ExitPolicyVHTLCClaim`, `ExitPolicyVHTLCRefundWithoutReceiver`, `ExitPolicyArkChannelBacking`), with `Valid()` true only for those kinds; `ExitPolicyRef` is the policy-specific durable reference (e.g. a vHTLC recovery job id), kept a distinct type so `Kind` and `Ref` can't be transposed; `ExitPolicy` bundles the pair as one identity validated at the registry admission boundary. A `None` `ExitPolicy` selects the standard VTXO timeout policy.
+- `ExitPolicyArkChannelBacking` — the pre-signed channel materialization spend
+  of a recovery-only channel-policy VTXO. Unlike the vHTLC kinds, the final
+  transaction is fixed before the unroll starts and either channel endpoint may
+  publish it, so `unroll` treats the exact pre-signed txid appearing on chain as
+  success rather than as an external conflict.
 - `RegisterIntentMsg` — Carries pre-composed cooperative intent package to
   round actor. The `TriggerRegistration bool` field controls whether the
   round FSM immediately fires `IntentRequested` after accepting the intent
diff --git a/lib/arkscript/AGENTS.md b/lib/arkscript/AGENTS.md
index 0f1db272..c9884b47 100644
--- a/lib/arkscript/AGENTS.md
+++ b/lib/arkscript/AGENTS.md
@@ -44,6 +44,28 @@ validated invariants.
   one sender/receiver/operator key set, payment hash, and refund locktime;
   any other custom policy shape is rejected so vHTLC assumptions cannot be
   applied to it.
+- `ChannelVTXOPolicy` / `ChannelVTXOParams` / `NewChannelVTXOPolicy` — 3-leaf
+  policy for a VTXO backing an unpublished Lightning channel point
+  (`channel_vtxo.go`). The leaves are a 3-of-3 cooperative closure
+  (client Ark + hub Ark + Ark operator, no CSV), a `ChannelDelay`-gated 2-of-2
+  materialization closure (client channel + hub channel), and a longer
+  `FunderDelay`-gated single-key funder refund. Path accessors:
+  `CooperativeSpendPath()`, `ChannelSpendPath()`, `FunderSpendPath()`.
+- `DefaultChannelReactionWindow` (432 blocks, ≈3 days) — the minimum gap the
+  funder refund leaf must sit above the materialization leaf when
+  `ChannelVTXOParams.ReactionWindow` is left zero.
+- `EncodeChannelVTXOArtifacts(params)` — channel-VTXO counterpart to
+  `EncodeStandardVTXOArtifacts`; returns the encoded policy template bytes and
+  the canonical P2TR pkScript.
+- `ValidateChannelVTXOPolicy(template, operatorKey, minExitDelay)` — admission
+  check that recognizes the canonical three-leaf shape in an untrusted
+  template, recovers its key roles and delays, and re-derives the policy to
+  confirm the match. It deliberately does **not** label which of the two
+  symmetric endpoint keys is client and which is hub.
+- `ValidateChannelVTXOTemplate(template, params)` — stricter binding check for
+  a caller that already knows the exact intended roles and delays: rebuilds
+  the expected policy and requires both a leaf-script set match and an exact
+  pkScript match.
 - `CheckpointPolicy` — Parameters for OOR checkpoint taproot tree construction. `CheckpointTapScript` / `CheckpointPkScript` derive the checkpoint output.
 - `SpendInfo` — Witness script + control block needed to spend a specific leaf. Methods: `BuildSignDescriptor`, `CollabWitness`, `TimeoutWitness`.
 - `SpendPath` — Serializable spend path (leaf index + encoded leaf data) with `Witness` and `AttachTapLeafScript` helpers for PSBT integration.
@@ -116,6 +138,16 @@ validated invariants.
   (collaborative) and at least one non-operator leaf (exit/unilateral).
 - Exit delay must be >= `MinExitDelay` when `ValidateStandardVTXOPolicy` is
   used; `ValidatePolicy` with `MinExitDelay = 0` skips this check.
+- Channel VTXO construction enforces its own timing and key separation before
+  compiling: the three cooperative keys must be three distinct parties, the two
+  materialization keys must differ, `ChannelDelay >= MinExitDelay` (a zero
+  `MinExitDelay` is rejected, so the caller cannot opt out of the floor), both
+  delays must fit the BIP-68 block mode, and `FunderDelay >= ChannelDelay +
+  ReactionWindow`. The reaction window is what keeps the refund leaf from
+  opening while either endpoint can still materialize the channel, so it is a
+  construction-time invariant rather than an admission-time judgement. Key
+  comparison is by x-only tapscript encoding, so a parity flip cannot smuggle
+  the same party into two roles.
 - **Policy construction does not validate timing.** `NewVHTLCPolicy` compiles
   whatever timing tuple it is given; suitability depends on the lifecycle
   boundary and the current chain height, which the compiler does not know.
diff --git a/lib/arkscript/CLAUDE.md b/lib/arkscript/CLAUDE.md
index 0f1db272..c9884b47 100644
--- a/lib/arkscript/CLAUDE.md
+++ b/lib/arkscript/CLAUDE.md
@@ -44,6 +44,28 @@ validated invariants.
   one sender/receiver/operator key set, payment hash, and refund locktime;
   any other custom policy shape is rejected so vHTLC assumptions cannot be
   applied to it.
+- `ChannelVTXOPolicy` / `ChannelVTXOParams` / `NewChannelVTXOPolicy` — 3-leaf
+  policy for a VTXO backing an unpublished Lightning channel point
+  (`channel_vtxo.go`). The leaves are a 3-of-3 cooperative closure
+  (client Ark + hub Ark + Ark operator, no CSV), a `ChannelDelay`-gated 2-of-2
+  materialization closure (client channel + hub channel), and a longer
+  `FunderDelay`-gated single-key funder refund. Path accessors:
+  `CooperativeSpendPath()`, `ChannelSpendPath()`, `FunderSpendPath()`.
+- `DefaultChannelReactionWindow` (432 blocks, ≈3 days) — the minimum gap the
+  funder refund leaf must sit above the materialization leaf when
+  `ChannelVTXOParams.ReactionWindow` is left zero.
+- `EncodeChannelVTXOArtifacts(params)` — channel-VTXO counterpart to
+  `EncodeStandardVTXOArtifacts`; returns the encoded policy template bytes and
+  the canonical P2TR pkScript.
+- `ValidateChannelVTXOPolicy(template, operatorKey, minExitDelay)` — admission
+  check that recognizes the canonical three-leaf shape in an untrusted
+  template, recovers its key roles and delays, and re-derives the policy to
+  confirm the match. It deliberately does **not** label which of the two
+  symmetric endpoint keys is client and which is hub.
+- `ValidateChannelVTXOTemplate(template, params)` — stricter binding check for
+  a caller that already knows the exact intended roles and delays: rebuilds
+  the expected policy and requires both a leaf-script set match and an exact
+  pkScript match.
 - `CheckpointPolicy` — Parameters for OOR checkpoint taproot tree construction. `CheckpointTapScript` / `CheckpointPkScript` derive the checkpoint output.
 - `SpendInfo` — Witness script + control block needed to spend a specific leaf. Methods: `BuildSignDescriptor`, `CollabWitness`, `TimeoutWitness`.
 - `SpendPath` — Serializable spend path (leaf index + encoded leaf data) with `Witness` and `AttachTapLeafScript` helpers for PSBT integration.
@@ -116,6 +138,16 @@ validated invariants.
   (collaborative) and at least one non-operator leaf (exit/unilateral).
 - Exit delay must be >= `MinExitDelay` when `ValidateStandardVTXOPolicy` is
   used; `ValidatePolicy` with `MinExitDelay = 0` skips this check.
+- Channel VTXO construction enforces its own timing and key separation before
+  compiling: the three cooperative keys must be three distinct parties, the two
+  materialization keys must differ, `ChannelDelay >= MinExitDelay` (a zero
+  `MinExitDelay` is rejected, so the caller cannot opt out of the floor), both
+  delays must fit the BIP-68 block mode, and `FunderDelay >= ChannelDelay +
+  ReactionWindow`. The reaction window is what keeps the refund leaf from
+  opening while either endpoint can still materialize the channel, so it is a
+  construction-time invariant rather than an admission-time judgement. Key
+  comparison is by x-only tapscript encoding, so a parity flip cannot smuggle
+  the same party into two roles.
 - **Policy construction does not validate timing.** `NewVHTLCPolicy` compiles
   whatever timing tuple it is given; suitability depends on the lifecycle
   boundary and the current chain height, which the compiler does not know.
diff --git a/oor/AGENTS.md b/oor/AGENTS.md
index e34dde69..607ec31f 100644
--- a/oor/AGENTS.md
+++ b/oor/AGENTS.md
@@ -24,6 +24,29 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/oor.<Sym
 - `Session` / `ReceiveSession` — outgoing/incoming FSM state containers;
   `OutgoingSnapshot` / `IncomingSnapshot` are their durable, versioned
   serializations.
+- `Prepared` — outgoing state holding a deterministic OOR package (unsigned Ark
+  PSBT, checkpoint PSBTs, retained transfer inputs, recipient outputs, caller
+  key, dispatch proof) with **no** signature or transport released. Entered
+  from `Idle` when `StartTransferEvent.PrepareOnly` is set, and left only by an
+  explicit `CommitPreparedEvent` (→ `AwaitingArkSignatures`, emitting
+  `RequestArkSignatures`) or `AbortPreparedEvent` / `FailEvent` (→ `Failed`,
+  emitting `ReleaseInputsRequest`). The motivating caller is a channel
+  coordinator that needs the output outpoint to be stable while it negotiates
+  the lnd channel, before committing the transfer.
+- `NewPreparedSessionWithIdempotencyKey` — prepared-mode sibling of
+  `NewSessionWithIdempotencyKey`; both funnel into one unexported constructor
+  so the two admission modes cannot drift.
+- `StartTransferRequest.PrepareOnly` / `StartTransferEvent.PrepareOnly` — the
+  durable flag that selects prepared mode. Carried as an optional TLV record
+  (`startPayloadPrepareOnlyType`) so pre-feature mailbox messages decode as
+  `false`; a value other than 0 or 1 is rejected.
+- `OutgoingSnapshotRecipients(raw)` — extracts canonical Ark recipients from a
+  durable outgoing snapshot, re-attaching each output's `VTXOPolicyTemplate`
+  from the snapshot's `RecipientOutputs`. Lets an idempotent replay recover
+  response metadata without rebuilding the transfer or selecting new inputs.
+- `Failed.PrePONR` / `OutgoingSnapshot.PrePONRFailure` — records that a terminal
+  failure happened before the operator co-signed the checkpoints, so the source
+  VTXO reservation was provably safe to release.
 - `OutboxHandler` / `LocalPersistenceOutboxHandler` — handles the local
   persistence outbox events (mark-inputs-spent, incoming metadata query,
   VTXO materialization, ack); everything else is handled inline by the
@@ -77,9 +100,37 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/oor.<Sym
   messages and return as fresh events.
 - Snapshots are versioned per direction (`OutgoingSnapshot.Version = 7`,
   `IncomingSnapshot.Version = 1`); restore rejects zero and unknown future
-  versions. Outgoing v5 adds `FirstRejectUnixNanos`; v7 adds the pre-PONR
-  terminal-failure marker. Older snapshots decode absent optional records to
-  their conservative zero values.
+  versions. Outgoing v5 adds `FirstRejectUnixNanos`; v7 adds both the
+  `RecipientOutputs` record (semantic policy metadata a prepared or pre-submit
+  transfer needs after restart) and the pre-PONR terminal-failure marker — v6
+  was skipped, so no snapshot ever carries it. The current value lives in one
+  place, `outgoingSnapshotVersion`, and both the codec and
+  `OutgoingStateFromSnapshot` reject anything above it. Older snapshots decode
+  absent optional records to their conservative zero values.
+- **Preparation has no implied side effect.** `OutboxForState(*Prepared)`
+  returns no outbox events, so a restart that restores a prepared session
+  re-enters `Prepared` and waits; only an explicit `CommitPreparedEvent` may
+  release signatures. Aborting is the safe direction: `Prepared` has not
+  exposed a signature and has not crossed the operator co-sign boundary, so
+  `abortPreparedTransition` releases **every** input.
+- Pre-PONR-ness is derived from the protocol phase (`isPrePONRState`:
+  `Prepared`, `AwaitingArkSignatures`, `AwaitingSubmitAccepted`), not from
+  whether a corrupt or partially restored state happens to have retained its
+  input pointers. `failedState` stamps it on every `Failed` transition.
+- Outgoing idempotency-key admission consults
+  `GetUnfailedSessionByIdempotencyKey` before the in-memory
+  `pendingOutgoingKeys` map in both `handleStartTransfer` and
+  `handleLookupTransfer`. A prepared session is durable before its immutable
+  `oor_dispatch_attempts` row exists, so the mutable-row lookup is what makes
+  an exact replay find it; failed rows release the key, pending and completed
+  rows retain it. A key that resolves to a non-outgoing session is
+  `ErrIdempotencyKeyConflict`.
+- `GetStateRequest` is answered from the durable snapshot when the child is
+  gone. Terminal actors are deliberately short-lived and reaped, but a status
+  reader must not race that reap, so `routeAsk` falls back to
+  `persistedState`, which validates the record's flow version and decodes the
+  direction-appropriate snapshot. Every other message to an unknown session
+  still errors.
 - `StartTransferRequest.IdempotencyKey` dedup reads
   `oor_dispatch_attempts`, not the mutable session row. The table has one row
   per caller key and one caller key per deterministic session id. Once the
diff --git a/oor/CLAUDE.md b/oor/CLAUDE.md
index e34dde69..607ec31f 100644
--- a/oor/CLAUDE.md
+++ b/oor/CLAUDE.md
@@ -24,6 +24,29 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/oor.<Sym
 - `Session` / `ReceiveSession` — outgoing/incoming FSM state containers;
   `OutgoingSnapshot` / `IncomingSnapshot` are their durable, versioned
   serializations.
+- `Prepared` — outgoing state holding a deterministic OOR package (unsigned Ark
+  PSBT, checkpoint PSBTs, retained transfer inputs, recipient outputs, caller
+  key, dispatch proof) with **no** signature or transport released. Entered
+  from `Idle` when `StartTransferEvent.PrepareOnly` is set, and left only by an
+  explicit `CommitPreparedEvent` (→ `AwaitingArkSignatures`, emitting
+  `RequestArkSignatures`) or `AbortPreparedEvent` / `FailEvent` (→ `Failed`,
+  emitting `ReleaseInputsRequest`). The motivating caller is a channel
+  coordinator that needs the output outpoint to be stable while it negotiates
+  the lnd channel, before committing the transfer.
+- `NewPreparedSessionWithIdempotencyKey` — prepared-mode sibling of
+  `NewSessionWithIdempotencyKey`; both funnel into one unexported constructor
+  so the two admission modes cannot drift.
+- `StartTransferRequest.PrepareOnly` / `StartTransferEvent.PrepareOnly` — the
+  durable flag that selects prepared mode. Carried as an optional TLV record
+  (`startPayloadPrepareOnlyType`) so pre-feature mailbox messages decode as
+  `false`; a value other than 0 or 1 is rejected.
+- `OutgoingSnapshotRecipients(raw)` — extracts canonical Ark recipients from a
+  durable outgoing snapshot, re-attaching each output's `VTXOPolicyTemplate`
+  from the snapshot's `RecipientOutputs`. Lets an idempotent replay recover
+  response metadata without rebuilding the transfer or selecting new inputs.
+- `Failed.PrePONR` / `OutgoingSnapshot.PrePONRFailure` — records that a terminal
+  failure happened before the operator co-signed the checkpoints, so the source
+  VTXO reservation was provably safe to release.
 - `OutboxHandler` / `LocalPersistenceOutboxHandler` — handles the local
   persistence outbox events (mark-inputs-spent, incoming metadata query,
   VTXO materialization, ack); everything else is handled inline by the
@@ -77,9 +100,37 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/oor.<Sym
   messages and return as fresh events.
 - Snapshots are versioned per direction (`OutgoingSnapshot.Version = 7`,
   `IncomingSnapshot.Version = 1`); restore rejects zero and unknown future
-  versions. Outgoing v5 adds `FirstRejectUnixNanos`; v7 adds the pre-PONR
-  terminal-failure marker. Older snapshots decode absent optional records to
-  their conservative zero values.
+  versions. Outgoing v5 adds `FirstRejectUnixNanos`; v7 adds both the
+  `RecipientOutputs` record (semantic policy metadata a prepared or pre-submit
+  transfer needs after restart) and the pre-PONR terminal-failure marker — v6
+  was skipped, so no snapshot ever carries it. The current value lives in one
+  place, `outgoingSnapshotVersion`, and both the codec and
+  `OutgoingStateFromSnapshot` reject anything above it. Older snapshots decode
+  absent optional records to their conservative zero values.
+- **Preparation has no implied side effect.** `OutboxForState(*Prepared)`
+  returns no outbox events, so a restart that restores a prepared session
+  re-enters `Prepared` and waits; only an explicit `CommitPreparedEvent` may
+  release signatures. Aborting is the safe direction: `Prepared` has not
+  exposed a signature and has not crossed the operator co-sign boundary, so
+  `abortPreparedTransition` releases **every** input.
+- Pre-PONR-ness is derived from the protocol phase (`isPrePONRState`:
+  `Prepared`, `AwaitingArkSignatures`, `AwaitingSubmitAccepted`), not from
+  whether a corrupt or partially restored state happens to have retained its
+  input pointers. `failedState` stamps it on every `Failed` transition.
+- Outgoing idempotency-key admission consults
+  `GetUnfailedSessionByIdempotencyKey` before the in-memory
+  `pendingOutgoingKeys` map in both `handleStartTransfer` and
+  `handleLookupTransfer`. A prepared session is durable before its immutable
+  `oor_dispatch_attempts` row exists, so the mutable-row lookup is what makes
+  an exact replay find it; failed rows release the key, pending and completed
+  rows retain it. A key that resolves to a non-outgoing session is
+  `ErrIdempotencyKeyConflict`.
+- `GetStateRequest` is answered from the durable snapshot when the child is
+  gone. Terminal actors are deliberately short-lived and reaped, but a status
+  reader must not race that reap, so `routeAsk` falls back to
+  `persistedState`, which validates the record's flow version and decodes the
+  direction-appropriate snapshot. Every other message to an unknown session
+  still errors.
 - `StartTransferRequest.IdempotencyKey` dedup reads
   `oor_dispatch_attempts`, not the mutable session row. The table has one row
   per caller key and one caller key per deterministic session id. Once the
diff --git a/unroll/AGENTS.md b/unroll/AGENTS.md
index 125b61c1..9f11babb 100644
--- a/unroll/AGENTS.md
+++ b/unroll/AGENTS.md
@@ -117,6 +117,24 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/unroll.<
 - `ExitSpendPolicyResolver` — interface for looking up the final spend
   policy by `(ExitPolicyKind, ExitPolicyRef)`. Implemented by
   `vhtlcrecovery/unrollpolicy.ExitSpendPolicyResolver`.
+- `ResolverKindSupport` — optional interface a resolver implements to
+  advertise which `ExitPolicyKind`s it covers (`SupportsKind`). The registry
+  consults it at admission time so an unroutable kind fails closed before an
+  actor is spawned.
+- `PolicyResolvers` (`policy_resolvers.go`) — an `ExitSpendPolicyResolver`
+  that fans one `RegistryConfig.ExitSpendPolicyResolver` slot out over several
+  policy families, dispatching by kind. It is itself both an
+  `ExitSpendPolicyResolver` and a `ResolverKindSupport`, so it composes. A
+  child that does **not** implement `ResolverKindSupport` is treated as a
+  legacy resolver: `SupportsKind` admits any kind if such a child is present,
+  and resolution falls back to the first legacy child only after explicit
+  kind routing has found no match. That ordering is what preserves a
+  standalone pre-advertisement resolver's former behaviour when it is wrapped.
+- `PreSignedExitSpendPolicy` — `ExitSpendPolicy` extension for policies whose
+  final spend is fixed before the actor reaches CSV maturity.
+  `PreSignedSpendTx()` returns an isolated copy of the immutable, fully signed
+  transaction. Implemented by the Ark channel materialization policy
+  (`actormsg.ExitPolicyArkChannelBacking`).
 
 ### Feasibility & Funding
 
@@ -280,6 +298,27 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/unroll.<
   network fallback or a policy-owned emergency rate permits construction
   without a fresh estimate; vHTLC policies use the latter because another
   valid leaf can race either recovery action.
+- **A pre-signed final spend published by the peer is success, not a
+  conflict.** `handleSpendObserved` classifies a target-outpoint spend in five
+  cases; case 4 (`ackPreSignedExitSpend`) sits ahead of the catch-all
+  `FailEvent`. When the resolved exit policy implements
+  `PreSignedExitSpendPolicy` and its transaction's txid equals the observed
+  spending txid, the actor caches the full transaction as `b.sweepTx` (the txid
+  alone is not enough — checkpoint replay and exit-cost accounting both need the
+  exact bytes) and drives `TxConfirmedEvent` / `SweepBroadcastedEvent` /
+  `TxConfirmedEvent` idempotently, skipping any leg the planner state already
+  records. Either authorized party may publish the transaction after CSV
+  maturity, so the durable actor has to converge no matter who reached the chain
+  first. Two guards keep it from blessing the wrong spend: the transaction must
+  actually consume `cfg.TargetOutpoint` (otherwise a hard error, not a silent
+  fall-through), and a recorded sweep txid that differs from the observed one is
+  an error rather than an overwrite.
+- **A CSV-delayed spend dates its parent, not itself.** When the target's own
+  confirmation was never recorded, `ackPreSignedExitSpend` derives the parent
+  height as `SpendingHeight - policy.CSVDelay()` instead of using
+  `SpendingHeight` directly, which would make an already-confirmed spend look
+  immature to the planner. A negative result is a hard error: the observed spend
+  could not have satisfied its own CSV.
 - **Reissue fails hard on missing state.** The
   `ReissueInFlightTransactions` and `ReissueSweepConfirmation`
   outbox branches return errors on a missing proof node or nil
diff --git a/unroll/CLAUDE.md b/unroll/CLAUDE.md
index 125b61c1..9f11babb 100644
--- a/unroll/CLAUDE.md
+++ b/unroll/CLAUDE.md
@@ -117,6 +117,24 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/unroll.<
 - `ExitSpendPolicyResolver` — interface for looking up the final spend
   policy by `(ExitPolicyKind, ExitPolicyRef)`. Implemented by
   `vhtlcrecovery/unrollpolicy.ExitSpendPolicyResolver`.
+- `ResolverKindSupport` — optional interface a resolver implements to
+  advertise which `ExitPolicyKind`s it covers (`SupportsKind`). The registry
+  consults it at admission time so an unroutable kind fails closed before an
+  actor is spawned.
+- `PolicyResolvers` (`policy_resolvers.go`) — an `ExitSpendPolicyResolver`
+  that fans one `RegistryConfig.ExitSpendPolicyResolver` slot out over several
+  policy families, dispatching by kind. It is itself both an
+  `ExitSpendPolicyResolver` and a `ResolverKindSupport`, so it composes. A
+  child that does **not** implement `ResolverKindSupport` is treated as a
+  legacy resolver: `SupportsKind` admits any kind if such a child is present,
+  and resolution falls back to the first legacy child only after explicit
+  kind routing has found no match. That ordering is what preserves a
+  standalone pre-advertisement resolver's former behaviour when it is wrapped.
+- `PreSignedExitSpendPolicy` — `ExitSpendPolicy` extension for policies whose
+  final spend is fixed before the actor reaches CSV maturity.
+  `PreSignedSpendTx()` returns an isolated copy of the immutable, fully signed
+  transaction. Implemented by the Ark channel materialization policy
+  (`actormsg.ExitPolicyArkChannelBacking`).
 
 ### Feasibility & Funding
 
@@ -280,6 +298,27 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/unroll.<
   network fallback or a policy-owned emergency rate permits construction
   without a fresh estimate; vHTLC policies use the latter because another
   valid leaf can race either recovery action.
+- **A pre-signed final spend published by the peer is success, not a
+  conflict.** `handleSpendObserved` classifies a target-outpoint spend in five
+  cases; case 4 (`ackPreSignedExitSpend`) sits ahead of the catch-all
+  `FailEvent`. When the resolved exit policy implements
+  `PreSignedExitSpendPolicy` and its transaction's txid equals the observed
+  spending txid, the actor caches the full transaction as `b.sweepTx` (the txid
+  alone is not enough — checkpoint replay and exit-cost accounting both need the
+  exact bytes) and drives `TxConfirmedEvent` / `SweepBroadcastedEvent` /
+  `TxConfirmedEvent` idempotently, skipping any leg the planner state already
+  records. Either authorized party may publish the transaction after CSV
+  maturity, so the durable actor has to converge no matter who reached the chain
+  first. Two guards keep it from blessing the wrong spend: the transaction must
+  actually consume `cfg.TargetOutpoint` (otherwise a hard error, not a silent
+  fall-through), and a recorded sweep txid that differs from the observed one is
+  an error rather than an overwrite.
+- **A CSV-delayed spend dates its parent, not itself.** When the target's own
+  confirmation was never recorded, `ackPreSignedExitSpend` derives the parent
+  height as `SpendingHeight - policy.CSVDelay()` instead of using
+  `SpendingHeight` directly, which would make an already-confirmed spend look
+  immature to the planner. A negative result is a hard error: the observed spend
+  could not have satisfied its own CSV.
 - **Reissue fails hard on missing state.** The
   `ReissueInFlightTransactions` and `ReissueSweepConfirmation`
   outbox branches return errors on a missing proof node or nil
diff --git a/vtxo/AGENTS.md b/vtxo/AGENTS.md
index 4dfb2cdb..10efb15d 100644
--- a/vtxo/AGENTS.md
+++ b/vtxo/AGENTS.md
@@ -14,6 +14,15 @@ when the local wallet owns the receive script.
 ## Key Types
 
 - `VTXOState` — Sealed interface for all states (Live, Spending, Spent, PendingForfeit, Forfeiting, Forfeited, UnilateralExit, Expired, Failed).
+- `VTXOStatus` — persisted status enum, **append-only** so the numeric values
+  already written by SQL queries never shift. `VTXOStatusExpired` (8) and
+  `VTXOStatusRecoveryOnly` (9) are the two most recent additions.
+- `VTXOStatusRecoveryOnly` — an application-owned output whose descriptor exists
+  only so the common unroller can recover its on-chain ancestry (an Ark channel
+  backing VTXO is the motivating case). It is deliberately excluded from wallet
+  balance, coin selection, refresh, and VTXO actor recovery, and it has **no
+  VTXO actor**: the owning application FSM controls its lifecycle and admits the
+  exact final-spend policy to unroll.
 - `Descriptor` — Complete VTXO metadata: `Outpoint`, `Amount`, `PolicyTemplate`
   (the authoritative semantic policy for ownership/spend semantics),
   `PkScript`, `ClientKey` (keychain.KeyDescriptor), `OperatorKey`,
@@ -163,6 +172,23 @@ when the local wallet owns the receive script.
   `ListRecoverableVTXOs` includes them and is what `Manager.Start` recovers
   actors from. Coin selection is already `VTXOStatusLive`-scoped via
   `ListSelectionCandidatesByStatus`, so it excludes them by construction.
+- **Recovery-only descriptors are actorless by design, so the manager handles
+  them directly.** Three sites carry the exception, and each one is narrowed so
+  an ordinary wallet coin can never take the same path:
+  - `SumPendingBalance` and `exactSpendUnavailableError` group
+    `VTXOStatusRecoveryOnly` with the terminal/separately-accounted statuses, so
+    it contributes nothing to pending balance and an exact-spend request naming
+    it fails with `ErrInsufficientSpendableFunds`.
+  - `confirmExitedVTXO` accepts a recovery-only row **only** when
+    `req.ExitPolicyKind.Valid()`. The policy check is what stops an ordinary
+    timeout job from retiring an application-owned row; a plain
+    `VTXOStatusUnilateralExit` row still takes the pre-existing path.
+  - `completePersistedSpend` (formerly `isPersistedSpent`) recognizes exactly
+    two actorless completions: a terminal `Spent` row means a previous attempt
+    already finished, and a `RecoveryOnly` row is retired to `Spent` via
+    `UpdateVTXOStatusReleasingReservation`, which drops the durable spend
+    reservation in the same transaction. Every other status still requires its
+    normal VTXO actor, so the rename widened the contract but not the surface.
 - VTXO actor state is the single source of truth for availability.
 - Forfeit transaction is not broadcast until the connector output's round confirms (atomic replacement).
 - Refresh is auto-triggered at configurable height before expiry.
diff --git a/vtxo/CLAUDE.md b/vtxo/CLAUDE.md
index 4dfb2cdb..10efb15d 100644
--- a/vtxo/CLAUDE.md
+++ b/vtxo/CLAUDE.md
@@ -14,6 +14,15 @@ when the local wallet owns the receive script.
 ## Key Types
 
 - `VTXOState` — Sealed interface for all states (Live, Spending, Spent, PendingForfeit, Forfeiting, Forfeited, UnilateralExit, Expired, Failed).
+- `VTXOStatus` — persisted status enum, **append-only** so the numeric values
+  already written by SQL queries never shift. `VTXOStatusExpired` (8) and
+  `VTXOStatusRecoveryOnly` (9) are the two most recent additions.
+- `VTXOStatusRecoveryOnly` — an application-owned output whose descriptor exists
+  only so the common unroller can recover its on-chain ancestry (an Ark channel
+  backing VTXO is the motivating case). It is deliberately excluded from wallet
+  balance, coin selection, refresh, and VTXO actor recovery, and it has **no
+  VTXO actor**: the owning application FSM controls its lifecycle and admits the
+  exact final-spend policy to unroll.
 - `Descriptor` — Complete VTXO metadata: `Outpoint`, `Amount`, `PolicyTemplate`
   (the authoritative semantic policy for ownership/spend semantics),
   `PkScript`, `ClientKey` (keychain.KeyDescriptor), `OperatorKey`,
@@ -163,6 +172,23 @@ when the local wallet owns the receive script.
   `ListRecoverableVTXOs` includes them and is what `Manager.Start` recovers
   actors from. Coin selection is already `VTXOStatusLive`-scoped via
   `ListSelectionCandidatesByStatus`, so it excludes them by construction.
+- **Recovery-only descriptors are actorless by design, so the manager handles
+  them directly.** Three sites carry the exception, and each one is narrowed so
+  an ordinary wallet coin can never take the same path:
+  - `SumPendingBalance` and `exactSpendUnavailableError` group
+    `VTXOStatusRecoveryOnly` with the terminal/separately-accounted statuses, so
+    it contributes nothing to pending balance and an exact-spend request naming
+    it fails with `ErrInsufficientSpendableFunds`.
+  - `confirmExitedVTXO` accepts a recovery-only row **only** when
+    `req.ExitPolicyKind.Valid()`. The policy check is what stops an ordinary
+    timeout job from retiring an application-owned row; a plain
+    `VTXOStatusUnilateralExit` row still takes the pre-existing path.
+  - `completePersistedSpend` (formerly `isPersistedSpent`) recognizes exactly
+    two actorless completions: a terminal `Spent` row means a previous attempt
+    already finished, and a `RecoveryOnly` row is retired to `Spent` via
+    `UpdateVTXOStatusReleasingReservation`, which drops the durable spend
+    reservation in the same transaction. Every other status still requires its
+    normal VTXO actor, so the rename widened the contract but not the surface.
 - VTXO actor state is the single source of truth for availability.
 - Forfeit transaction is not broadcast until the connector output's round confirms (atomic replacement).
 - Refresh is auto-triggered at configurable height before expiry.

How to apply: save the diff above and git apply it on this branch, or run the nightly gardener locally with /doc-gardening scoped to the packages named above. Re-run make doc-check afterwards.

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

Workflow run

@sputn1ck
sputn1ck force-pushed the kon/ark-channel-oor-funding branch 2 times, most recently from 7d18ae7 to 9b96e03 Compare September 15, 2026 17:40
@litbot-9000

Copy link
Copy Markdown
Collaborator

@sputn1ck, remember to re-request review from reviewers when ready

@litbot-9000

Copy link
Copy Markdown
Collaborator

@bhandras: review reminder
@Roasbeef: review reminder
@sputn1ck, remember to re-request review from reviewers when ready

5 similar comments
@litbot-9000

Copy link
Copy Markdown
Collaborator

@bhandras: review reminder
@Roasbeef: review reminder
@sputn1ck, remember to re-request review from reviewers when ready

@litbot-9000

Copy link
Copy Markdown
Collaborator

@bhandras: review reminder
@Roasbeef: review reminder
@sputn1ck, remember to re-request review from reviewers when ready

@litbot-9000

Copy link
Copy Markdown
Collaborator

@bhandras: review reminder
@Roasbeef: review reminder
@sputn1ck, remember to re-request review from reviewers when ready

@litbot-9000

Copy link
Copy Markdown
Collaborator

@bhandras: review reminder
@Roasbeef: review reminder
@sputn1ck, remember to re-request review from reviewers when ready

@litbot-9000

Copy link
Copy Markdown
Collaborator

@bhandras: review reminder
@Roasbeef: review reminder
@sputn1ck, remember to re-request review from reviewers when ready

Comment thread lib/arkscript/channel_vtxo.go Outdated
// ChannelVTXOParams defines the key roles and relative delays of a VTXO that
// backs an unpublished Lightning channel point.
type ChannelVTXOParams struct {
ClientArkKey *btcec.PublicKey

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pls add godocs to these exported members, also generally everywhere.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added GoDocs for every exported member of ChannelVTXOParams and ChannelVTXOPolicy in 1d90beec, including signer roles and the immediate 3-of-3 in-Ark spend versus delayed 2-of-2 channel-funding and later funder-refund paths.

Comment thread oor/transitions.go
NextState: failedState(reason, state),
NewEvents: fn.Some(EmittedEvent{
Outbox: []OutboxEvent{
&ReleaseInputsRequest{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we pass ReserveEpochs here, and add Prepared to prePONRReserveEpochs?

The release runs before the OOR state commit. If the release goes through but the commit fails, the saved state stays in Prepared and the abort replays. If another transfer reserves the same coin in between, the replayed release has no epoch, so the manager releases unconditionally and drops the newer transfer's reservation. The coin goes back into selection while that transfer is still spending it.

Passing the original epoch makes the existing epoch guard catch this.

Can we also add a test for: abort → release ok → commit fails → coin re-reserved → abort replays?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Still a blocker after re-review. The abort still omits ReserveEpochs, and prePONRReserveEpochs still skips Prepared.

For example:

  1. Transfer A holds coin X at epoch 41.
  2. A aborts. Releasing X succeeds, but committing the OOR snapshot fails. The saved state is still Prepared.
  3. Transfer B reserves X at epoch 42.
  4. A's abort replays without an epoch. The manager treats zero as an unconditional release and drops B's reservation.

X can now be selected again while B is spending it. The existing stale-release guard would reject epoch 41 against epoch 42, but this path never supplies it.

Pls pass prePONRReserveEpochs(state) here, add Prepared to the helper, and cover that exact replay sequence. The channel input builder also needs to carry the selected reservation epochs into TransferInput; otherwise the release still gets zero. My local regression probe still fails on the latest head. I haven't demonstrated fund loss.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in bb2fe05f and daemon-layer commit 1ab931ba. Prepared abort/failure now forwards the original reservation epochs, and channel funding copies the wallet-selected epochs into its durable inputs. The regression uses the real wallet, reservation manager and SQL-backed VTXO store: release succeeds, snapshot commit fails, a new owner reserves the coin, then replay must preserve that newer reservation. The matching new epoch can still release it. Both abort and fail variants pass 20 repetitions with -race; the reordered two-input channel snapshot test also passes 20 repetitions.

Comment thread oor/registry.go
return fn.Err[ActorResp](err)
}
if child == nil {
if _, ok := msg.(*GetStateRequest); ok {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we reload the committed state before answering GetStateRequest when commitFailed is set? The early return is in oor/session_actor.go:391, outside this diff.

If an abort advances the in-memory FSM to Failed{PrePONR: true} but the commit fails, the saved state stays in Prepared. That early return still reports Failed.

The channel bridge re-reads state after a drive error and treats Failed.PrePONR as proof that the OOR aborted, allowing LND funding cleanup. So we can cancel the channel while the durable OOR is still prepared.

The reload in Receive already handles this for driving events. Can we move the state query after it, and add a test for: abort → commit fails → query before retry → must report Prepared?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Still a blocker after re-review. The new persisted-state fallback handles a reaped child, but this failure is in a resident child: oor/session_actor.go:391 still answers GetStateRequest before the commitFailed reload.

For example:

  1. The saved state is Prepared.
  2. Abort advances the in-memory FSM to Failed{PrePONR: true}.
  3. The snapshot commit fails, so the saved state remains Prepared.
  4. A status query arrives before another driving event. It returns the uncommitted Failed state.

The channel bridge re-reads status after a drive error and treats that result as proof of abort. That allows funding cleanup while the durable OOR is still prepared.

Pls run the existing reload before answering the query, and add the abort → failed commit → immediate query test. My local test still gets Failed where it must get Prepared. A later driving event repairs the in-memory state, but that is too late for this query.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 5f28d4ff. GetStateRequest now passes through the existing committed-state reload when commitFailed is set. Added TestPreparedAbortQueryReloadsCommittedState: abort advances in memory, persistence fails, an immediate query returns the durable Prepared state without replaying release side effects. It failed before the fix and passes afterward with -race.

Comment thread unroll/actor.go
// txid and record both its broadcast and confirmation so the durable
// actor converges regardless of which participant reached the chain
// first.
matched, err := b.ackPreSignedExitSpend(ctx, ax, msg)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This breaks external spend handling for asset VTXOs.

Case 4 now runs before the old Case 5 fail path. ackPreSignedExitSpend calls resolveExitSpendPolicy, which returns ErrAssetVTXORequiresTransition for any asset VTXO. We return that error, so the FailEvent is never reached. The actor errors on every redelivery instead of reaching PhaseFailed, and the VTXO manager never gets its exit outcome.

I have a test that fails here and passes with main's actor: asset VTXO, external spend of the target, expect PhaseFailed.

Can we return false, nil early when b.exitPolicyKind() == StandardVTXOTimeoutExitPolicyKind? Only non-standard kinds can be pre-signed. Pls also add the test.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Still reproducible on the latest head.

Example: an asset VTXO has an active unroll, then another transaction spends its target. This new check calls resolveExitSpendPolicy, which returns ErrAssetVTXORequiresTransition. We return the error before reaching the existing external-spend FailEvent path. Redelivery repeats the same error instead of reaching PhaseFailed.

Pls return false, nil from ackPreSignedExitSpend for StandardVTXOTimeoutExitPolicyKind, before resolving the policy. Standard timeout exits have no pre-signed final spend to match.

The regression test is: start an asset unroll → report a foreign spend of its target → expect PhaseFailed. It still fails here and passes with main's actor. The earlier small guard also makes it pass. The demonstrated regression is the missing terminal failure; I haven't demonstrated fund loss.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in b60f2be3. Standard timeout exits return (false, nil) before resolving a pre-signed final-spend policy. The real actor/registry regression covers both materializing and deferred asset exits, terminal persistence and recoverable manager feedback. Full unroll race coverage and the existing pre-signed channel completion regression pass.

Comment thread oor/registry.go
clientdb.OORSessionDirectionOutgoing &&
record.Status == clientdb.OORSessionStatusFailed:
record.Status == clientdb.OORSessionStatusFailed &&
(record.IdempotencyKey == "" || record.IdempotencyKey == key):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This changes behavior: a failed outgoing row can no longer be rebuilt under a different key. On main any failed row with the same session ID was replaceable. Now a new key gets ErrIdempotencyKeyConflict.

I think that's intended (it matches the oor/CLAUDE.md update), but can you confirm? There's no test for it. Can we add one: failed row with key A, retry with key B → conflict; retry with key A → rebuilds.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Confirmed: this identity constraint is intentional. Added TestOORRegistryFailedSessionRetainsKey in 30d11515: an attemptless failed outgoing row with key A rejects key B, while key A rebuilds the child. An already immutable dispatch attempt remains non-replaceable; the existing legacy/keyless exception is unchanged. No production behavior change was needed for this item.

Comment thread vtxo/interfaces.go
// in SQL queries are unchanged.
VTXOStatusExpired

// VTXOStatusRecoveryOnly identifies an application-owned output whose

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pls spell out that the owning FSM also owns the batch deadline. Excluding RecoveryOnly from refresh and actor recovery means nothing in the wallet will refresh or unroll it before BatchExpiry. If the owner doesn't act, the operator sweeps the batch and the materialize tx becomes worthless.

Something like: "The owning FSM must refresh or unroll the output before its BatchExpiry."

As far as I can tell nothing in the stack does this yet for idle channels. I'll raise the actual deadline handling on #1192.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Documented the owning FSM's absolute batch-expiry responsibility in 1d90beec. Neither CSV delay extends that deadline. Automatic idle-channel source-expiry protection is implemented and daemon-tested in a separate, still-unpublished local follow-up; I am not claiming this documentation patch closes the functional gap in the current published #1192. That remains a separate open requirement.

Comment thread lib/arkscript/channel_vtxo.go Outdated
)

const (
// DefaultChannelReactionWindow gives either channel endpoint roughly

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we say in the godoc what each delay protects?

  • ChannelDelay: operator's exit delay, so the operator can still claim with a forfeit / checkpoint before materialize matures.
  • FunderDelay = ChannelDelay + ReactionWindow: gives the non-funder time to materialize before the funder can refund.
  • Neither protects against BatchExpiry. Both only start counting once the channel VTXO is on chain.

Also where 432 comes from (3 days of blocks), and whether it should be configurable.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Clarified in 1d90beec: ChannelDelay preserves the Ark operator's checkpoint/forfeit recovery opportunity; the additional reaction window gives the non-funder time to materialize before refund eligibility. Both CSV clocks start from channel-policy VTXO confirmation, independently of absolute batch expiry. The default is 432 blocks (3 x 144), not a wall-clock guarantee. ReactionWindow is already a caller parameter; zero selects the default. Added a regression using a larger custom window.

@sputn1ck

Copy link
Copy Markdown
Member Author

Final validation of the focused review fixes is complete. The affected foundation race suites, full tagged channel/runtime/daemon/database race suites, native lint with actor-block checks, server runtime units and CLI harness units pass. One complete five-case real-daemon channel E2E run passed in 933.680 seconds, using GOWORK=off with published client ae1273a and server b81ed602. This covers send/receive, fresh receive-channel creation, vHTLC fallback/promotion, 3-of-3 in-Ark refresh, confirmed sweep resolution and offline-client hub recovery.

All five client branches and all five server branches have been restacked and pushed with explicit old-head leases. The seven inline threads have individual fix/test replies; they are left for reviewer re-review rather than self-resolved. The lifecycle layer retains its 24 behavior-ordered patches. Latest-trunk conflicts remain, and the older unpublished runtime/security and automatic source-expiry work is not included in this focused patch. No green CI or merge-readiness claim is made.

@sputn1ck
sputn1ck force-pushed the kon/ark-channel-oor-funding branch 4 times, most recently from 3c01fad to 44ec18b Compare November 19, 2026 16:25
@litbot-9000

Copy link
Copy Markdown
Collaborator

@sputn1ck, remember to re-request review from reviewers when ready

Let an operator recognize and bind a channel policy to the exact output
without importing the native channel runtime or pinning its lnd fork.
Keep retry identity stable without sharing transport correlations.
Scope durable ingress evidence to each reply mailbox so separate
connectors cannot acknowledge another delivery stream.
The invoice deadline bounds mailbox delivery, not acceptance of an event
that has already arrived. Persist accepted events with the caller
context so an exhausted polling grace window cannot expire a valid
receive. Keep parent cancellation effective for validation and storage.

Set the overdue receive regression poll window to zero to cover the
cached event path deterministically.
Keep the legacy checkpoint request intact. An explicit payout request
binds the owner and destination to both transactions and gets a distinct
signature for each spend.
Expose the additional proof and signature fields without changing any
legacy field numbers or service methods.
Preserve source owners when explicitly requested and carry their
independent payout signatures through durable preparation and signing.
Reconstruct the package before signing so the local signer attests to
the intended output, not just a checkpoint.
A capable client library is not evidence that its peer accepts a new
payout format. Select the legacy checkpoint for ordinary refunds and
require both signatures when the peer capability is explicitly known.
Never treat partial payout authorization as a completed refund.
@sputn1ck
sputn1ck force-pushed the kon/ark-channel-oor-funding branch from 44ec18b to 1b42430 Compare November 24, 2026 16:21
@sputn1ck sputn1ck changed the title arkscript/oor: Prepare channel-backed OOR funding oor/unroll: Prepare channel-backed funding and recover its sources Nov 24, 2026
Carry the independently reviewed wallet observations and pending swap
worker changes below the first channel feature. This comparison base is
for review and integration; land the standalone PRs against main.
Persist deterministic OOR packages before signatures or transport are
released so channel negotiation can commit or abort safely.
Keep application-owned channel VTXOs out of wallet balances while
retaining enough policy and expiry state to resume materialization.
A prepare-only transfer persists its caller key before any dispatch
attempt exists. Resolve retries through that durable registry row so a
restart cannot admit a duplicate transfer in the gap before commit.
Channel recovery chooses its final-spend delay after registering the
source VTXO. Treat that expiry as mutable so replaying source
preparation does not reject the already-owned output.
Classify the release boundary from the FSM state instead of populated
input pointers, and reject non-canonical boolean encodings at the
durable message boundary.
Name the current outgoing snapshot version and fail closed when durable
state was written by a newer schema. Continue accepting all older
additive versions.
Recognize Ark channel backing as a valid recovery-only policy and
preserve legacy resolver behavior when it is wrapped in the composite
dispatcher.
When the peer publishes the exact CSV-delayed materialization
transaction first, derive the latest possible parent confirmation
height. Recording the spend height itself would make valid observed
history appear immature.
A failed abort commit leaves the in-memory FSM ahead of its durable
gate. Reload before reads as well as driving events so a status probe
cannot authorize channel cleanup from a rolled-back abort.
An attemptless failed session may rebuild under its original caller key,
but a different key must conflict. Cover both branches so immutable
operation identity cannot regress during failed-session recovery.
Standard timeout exits have no pre-signed final spend. Skip custom exit
policy resolution before handling a foreign spend so asset sweep safety
does not prevent terminal persistence and manager feedback.
Document signer roles and the distinct operator recovery and funder
reaction delays. Both CSV clocks begin at VTXO confirmation; neither
extends batch expiry. Exercise the configurable reaction window.
Retain the original selection epoch when aborting a prepared transfer. A
release may succeed before snapshot persistence fails, so a replay must
not release another operation that subsequently reserved the same coin.
Exercise both abort and fail events through the real reservation
manager.
@sputn1ck
sputn1ck force-pushed the kon/ark-channel-oor-funding branch from 1b42430 to 1eae23a Compare November 24, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants