Skip to content

feat(payments-engine): add closePaymentChannel for payment channels#218

Open
Creative-Titilayo wants to merge 1 commit into
MissBlue00:mainfrom
Creative-Titilayo:feat/issue-78-close-payment-channel
Open

feat(payments-engine): add closePaymentChannel for payment channels#218
Creative-Titilayo wants to merge 1 commit into
MissBlue00:mainfrom
Creative-Titilayo:feat/issue-78-close-payment-channel

Conversation

@Creative-Titilayo

Copy link
Copy Markdown

Overview

This PR adds a closePaymentChannel function to @stellar-pay/payments-engine to finalize an existing payment channel, distribute escrowed funds to channel parties, collect required multi-party signoffs, and return the final channel state with the settlement transaction hash.

Related Issue

Closes #78

Changes

⚙️ Payment Channel Close Flow

  • [ADD] packages/payments-engine/src/payment-channel.ts
  • Added closePaymentChannel(channel, server) to finalize and close payment channels.
  • Added buildChannelCloseTransaction() to construct settlement payment operations from escrow.
  • Validates channel state, distribution targets, and signer thresholds before submission.
  • Collects multi-party keypair signoffs and submits the close transaction via Horizon.
  • Returns ChannelCloseResult with final closed status and transaction hash.

📦 Public API Exports

  • [MODIFY] packages/payments-engine/src/index.ts
  • Exported PaymentChannel, PaymentChannelSigner, PaymentChannelDistribution, PaymentChannelAsset, PaymentChannelStatus, ChannelCloseResult, and Horizon.
  • Re-exported closePaymentChannel and buildChannelCloseTransaction.

Verification Results

pnpm --filter @stellar-pay/payments-engine build ✅ passed
runtime verification ✅ buildChannelCloseTransaction creates settlement ops and signatures
runtime verification ✅ closePaymentChannel returns closed status + transaction hash
runtime verification ✅ insufficient signoffs rejected with clear error
Acceptance Criteria Status
closePaymentChannel(channel, server) implemented
Finalizes channel and distributes funds
Handles multi-party signoffs
Returns final channel state and transaction hash
ChannelCloseResult interface added
pnpm --filter @stellar-pay/payments-engine build passes

Implements channel settlement with multi-party signoffs, fund distribution,
and ChannelCloseResult for issue MissBlue00#78.
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

@Creative-Titilayo is attempting to deploy a commit to the missblue00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 24, 2026

Copy link
Copy Markdown

@Creative-Titilayo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Add closePaymentChannel function

1 participant