Skip to content

Cooperative close: client-initiated fast refund (request waiver + submit on-chain) #971

Description

@alpergundogdu

Follow-up to #947 (closed). The provider half is merged — the node signs a CooperativeClose waiver on request (#957) and the on-chain PaymentChannel.cooperativeClose(...) binding exists in crates/incentive/src/payment_channel.rs. Nothing calls it yet, so a client still has no fast-refund path; it falls back to closeChannel → 48h → settleChannel.

Scope (client / initiator side)

Wire the end-to-end client flow:

  1. Send CooperativeCloseRequest { channel_id } over cdn/client/v1 and receive CooperativeCloseAuth { amount, nonce, bytes_delivered, signature } (variants already exist in protocol / client-pull).
  2. Pair the provider waiver with the client's own voucher sig over the same (channelId, amount, nonce, bytesDelivered) tuple.
  3. Submit cooperativeClose(...) on-chain via the payment_channel.rs binding (mirror the existing closeChannel/settleChannel send path in crates/node/src/payment_settlement.rs).
  4. Fall back to closeChannel if the node declines / is offline / returns no auth (nonce 0).

Surface it as a decdn CLI subcommand (no channel/reconcile subcommand exists today).

Out of scope

  • Automatic/periodic reconcile — that's the node-as-buyer follow-up (separate issue).

Refs: ADR 003 §Cooperative close, #948 (contract), #949 (wire+EIP-712), #957 (node side).

Activity

  1. added
    area:cli
    kind:feature
    prio:medium
    rust
    on Jun 22, 2026
  2. github-actions commented on Jun 22, 2026

    @github-actions

    🎯 Triage report

    Client-side implementation of the cooperative close flow for payment channels. The provider half is complete (#957 merged), wire types exist, and the on-chain binding is in place — this issue wires the call path that actually uses them, plus a new decdn CLI subcommand. No design uncertainty; this is pure plumbing across crates/incentive, crates/node, and crates/cli.

    📊 Assessment

    Dimension Value Reasoning
    Type Feature New client-initiated cooperative close flow; no existing code handles this path
    Labels enhancement, technical, rust, cli, medium Rust impl + new CLI subcommand; medium priority (eliminates 48h refund latency but client has working fallback via closeChannel)
    Coding agent Suitable Requirements are fully specified in 4 steps, implementation pattern is explicitly documented (mirror closeChannel/settleChannel in payment_settlement.rs), all prerequisites merged

    🔗 Similar issues

    💡 Notes and suggestions

    Key files to touch

    File Change
    crates/cli/src/... New channel close (or channel reconcile) subcommand
    crates/node/src/payment_settlement.rs Mirror the closeChannel send path for cooperativeClose
    crates/incentive/src/payment_channel.rs Existing cooperativeClose binding — call it here
    crates/protocol/src/... CooperativeCloseRequest / CooperativeCloseAuth variants already exist; verify they're exported

    Suggested implementation checklist

    • Step 1 — Request waiver: from the client, send CooperativeCloseRequest { channel_id } over cdn/client/v1; deserialize CooperativeCloseAuth { amount, nonce, bytes_delivered, signature } response
    • Step 2 — Dual-sig assembly: pair the received provider waiver with the client's own voucher sig over (channelId, amount, nonce, bytesDelivered) (EIP-712, COOPERATIVE_CLOSE_TYPEHASH per ADR 003 / feat(protocol,incentive): cooperative-close wire + EIP-712 foundation #949)
    • Step 3 — On-chain submission: call payment_channel.rs::cooperativeClose(...) with both sigs; await receipt
    • Step 4 — Fallback: if node declines (nonce 0), is offline, or the cooperative close tx reverts, fall through to the existing closeChannel path
    • Step 5 — CLI subcommand: surface as decdn channel close <channel-id> (no reconcile subcommand exists today); print tx hash + settlement amounts

    Watch points

    Generated by Agentic Triage for issue #971 · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:clikind:featureprio:mediumrust

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions