feat: add escrow dispute mechanism with optional arbitrator#20
Merged
Merged
Conversation
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
Contributor
|
Nice work @Marvy247 Thanks for contributing! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: AddedDisputeStatestruct (release_at,disputed,disputed_at) stored atescrow_state_key. Addedarbitrator: Option<Address>field to bothInvoiceandInvoiceOptions.New public functions
dispute_release— Creator raises a dispute during the escrow delay window. Blocksrelease_escrowuntil 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 currentDisputeStatefor an invoice.Modified functions
pay/`pool_pay** — Now storeDisputeStateinstead of a plainu64` release timestamp.release_escrow— Checks that no active dispute exists before releasing.create_invoice/`create_batch/\create_recurring** — Pass through the newarbitrator` field.New events
dispute_raised— emitted when a dispute is raiseddispute_resolved— emitted when a dispute is resolved (withrelease: bool)Tests
Added 4 tests covering: dispute-then-release, dispute-then-refund, arbitrator resolution, and blocking
release_escrowwhen disputed.Related issue
Closes #4