Skip to content

feat: add escrow dispute mechanism with optional arbitrator#20

Merged
MarcusDavidG merged 1 commit into
stellar-sharpy:mainfrom
Marvy247:feat/escrow-dispute-4
Jun 21, 2026
Merged

feat: add escrow dispute mechanism with optional arbitrator#20
MarcusDavidG merged 1 commit into
stellar-sharpy:mainfrom
Marvy247:feat/escrow-dispute-4

Conversation

@Marvy247

Copy link
Copy Markdown
Contributor

Description

Currently escrow is purely time-based. This adds a dispute mechanism allowing the creator to contest release during the escrow delay window, with an optional third-party arbitrator to resolve.

Changes

Data model

  • types.rs: Added DisputeState struct (release_at, disputed, disputed_at) stored at escrow_state_key. Added arbitrator: Option<Address> field to both Invoice and InvoiceOptions.

New public functions

  • dispute_release — Creator raises a dispute during the escrow delay window. Blocks release_escrow until resolved.
  • resolve_dispute — Arbitrator (or creator if no arbitrator) resolves the dispute by either releasing funds to recipients or refunding all payers.
  • get_escrow_state — Returns the current DisputeState for an invoice.

Modified functions

  • **pay/`pool_pay** — Now store DisputeStateinstead of a plainu64` release timestamp.
  • release_escrow — Checks that no active dispute exists before releasing.
  • **create_invoice/`create_batch/\create_recurring** — Pass through the new arbitrator` field.

New events

  • dispute_raised — emitted when a dispute is raised
  • dispute_resolved — emitted when a dispute is resolved (with release: bool)

Tests

Added 4 tests covering: dispute-then-release, dispute-then-refund, arbitrator resolution, and blocking release_escrow when disputed.

Related issue

Closes #4

Allow invoice creators to raise a dispute during the escrow delay
window, blocking automatic release. Add resolve_dispute function for
arbitrators (or creator if no arbitrator) to either release or refund
the invoice. Add optional arbitrator field at invoice creation.

Also fixes pool_pay not setting escrow state when fully funding an
escrow-enabled invoice.

Closes stellar-sharpy#4
@MarcusDavidG
MarcusDavidG merged commit 8bb22e8 into stellar-sharpy:main Jun 21, 2026
@MarcusDavidG

Copy link
Copy Markdown
Contributor

Nice work @Marvy247 Thanks for contributing!

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.

Escrow dispute mechanism — allow creator to contest release

2 participants