Skip to content

Feature/914 915 916 917 escrow release controls - #983

Open
OZILSOLAR wants to merge 4 commits into
Stellar-split:mainfrom
OZILSOLAR:feature/914-915-916-917-escrow-release-controls
Open

OZILSOLAR wants to merge 4 commits into
Stellar-split:mainfrom
OZILSOLAR:feature/914-915-916-917-escrow-release-controls

Conversation

@OZILSOLAR

Copy link
Copy Markdown

Title:
feat(invoice-escrow): co-signer approvals, oracle guards, scheduled release & refund grace period

Description:

Summary

Adds four release/refund controls to the invoice-escrow contract. All of them are opt-in per invoice. They plug into one shared release check,
check_release_gates, which both release and the auto-release in deposit use. If a configured check isn't satisfied, a fully funded invoice stays
Active until release is called after it clears. Invoices that don't configure any of these behave exactly as before.

#914: Co-signer approval system

  • CosignerApproval record (signers, threshold, approvals, rejections, status Pending/Approved/Rejected)
  • set_cosigners (creator only; locked once voting starts), approve_release, reject_release, revoke_vote
  • Signers are checked with require_auth plus a membership check; duplicate votes are rejected, so concurrent or replayed votes can't inflate the count
  • UI views: get_approval, get_approval_status, has_approved, approvals_remaining
  • Events for configuration, each vote and status changes

#915: Oracle condition guards

  • New oracle.rs: PriceOracle interface (SEP-40-style lastprice)
  • OracleCondition: comparator (GreaterOrEqual/LessOrEqual), threshold, staleness window, optional fallback oracle; set by the creator while the
    invoice is Pending
  • Oracles are called with try_lastprice, so a failing oracle reports OracleUnavailable instead of aborting; stale, non-positive and future-dated
    prices are rejected
  • Falls back to the secondary oracle when the primary fails and emits an orc_fback event
  • Admin override clear_oracle_condition for oracles that are permanently down
  • Views: check_oracle_condition, get_oracle_condition, get_last_oracle_reading

#916: Scheduled release

  • ReleaseSchedule: release_at timestamp plus unlock_ledger (minimum ledger count), status Scheduled/Executed/Cancelled
  • schedule_release / cancel_release_schedule (creator only); release needs both the time and the ledger bound to have passed
  • Extends the schedule's and invoice's storage TTL past the unlock ledger so both are still stored when the release comes due
  • Views: get_release_schedule, is_release_due, seconds_until_release, ledgers_until_release

#917: Refund grace period

  • Admin default set_default_refund_grace, copied onto each new invoice (later changes never affect existing invoices)
  • Creator per-invoice override set_refund_grace (before any deposits)
  • Admin overrides: extend_refund_grace (max 30 days total) and waive_refund_grace
  • refund now returns RefundGraceActive while the grace timer is running
  • Status NoGrace/NotStarted/Active/Elapsed/Waived through get_refund_grace_status; countdown views refund_grace_remaining and
    refund_available_after

Other

  • New error variants 20–40, added after the existing ones (existing codes unchanged)
  • Test modules for each feature in src/test.rs, including mock oracle contracts (configurable and always-failing)

Not yet built or run locally. Please run cargo test -p invoice-escrow; CI checks need to pass before review.

Closes #914
Closes #915
Closes #916
Closes #917

Add optional N-of-M co-signer approval gating invoice release:
- CosignerApproval record with signers, threshold, approval/rejection
  tallies and a derived Pending/Approved/Rejected status
- set_cosigners (creator-only, locked once voting starts),
  approve_release, reject_release and revoke_vote with require_auth
  signature checks and duplicate-vote protection
- release and deposit auto-release now go through check_release_gates
- read-only hooks for UIs: get_approval, get_approval_status,
  has_approved, approvals_remaining
- events for configuration, votes and status transitions, plus tests
…t#915)

Add optional external price-feed validation before invoice release:
- PriceOracle interface (SEP-40 style lastprice) in oracle.rs
- OracleCondition with comparator, threshold, staleness window and an
  optional fallback oracle; set by the creator while Pending
- oracle calls go through try_lastprice so panicking/missing oracles map
  to OracleUnavailable; stale, non-positive and future-dated prices are
  rejected; fallback oracle consulted when the primary fails
- condition evaluated as a release gate (deposit auto-release and
  release), last reading stored for inspection
- admin clear_oracle_condition override for permanently failed oracles
- check_oracle_condition / get_oracle_condition / get_last_oracle_reading
  views, new error states and events, and integration tests with mock
  oracle contracts
…lit#916)

Support delayed release of invoice funds:
- ReleaseSchedule with release_at timestamp, unlock_ledger computed from
  a minimum ledger count, creation metadata and a
  Scheduled/Executed/Cancelled status
- schedule_release / cancel_release_schedule (creator-only, open
  invoices); release blocked until both time and ledger bounds pass
- schedule and invoice TTLs extended through the unlock ledger so the
  schedule persists until due
- schedule marked Executed on release; is_release_due,
  seconds_until_release and ledgers_until_release views
- new error states, events and edge-case tests
Add a configurable grace period after the deadline before refunds can be
processed:
- admin default (set_default_refund_grace) snapshotted onto each new
  invoice so later changes never alter existing terms
- creator per-invoice override (set_refund_grace) while Pending
- admin overrides: extend_refund_grace (bounded by 30 days total) and
  waive_refund_grace for immediate refunds after the deadline
- refund returns RefundGraceActive while the timer runs
- NoGrace/NotStarted/Active/Elapsed/Waived status via
  get_refund_grace_status, plus refund_available_after and
  refund_grace_remaining countdown views
- new error states, events and tests
@drips-wave

drips-wave Bot commented Oct 18, 2026

Copy link
Copy Markdown

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

@OZILSOLAR
OZILSOLAR force-pushed the feature/914-915-916-917-escrow-release-controls branch from 357a569 to b1e3f56 Compare October 18, 2026 01:54
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.

Implement refund grace period Add scheduled release functionality Implement oracle condition guards Add co-signer approval system

1 participant