-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Labels
Description
Description
Protect buyers from unresponsive sellers by implementing a time-lock mechanism. If the deadline passes without confirmation or dispute, the buyer can reclaim their funds.
Requirements and Context
- Background: If a seller vanishes, the buyer's funds shouldn't be locked forever.
- Problem: Currently, funds rely on manual action. We need a fail-safe based on the ledger timestamp.
- Success Criteria:
- Use
env.ledger().timestamp()to compare againstescrow.deadline. - Implement
refund_expired(env, escrow_id). - Ensure logic handles "Disputed" state (disputes should pause expiration).
- Use
- Impact: Automates trustlessness; the contract enforces time limits without human intervention.
Suggested Execution
- Ensure
Escrowstruct has adeadline: u64field. - Implement
refund_expired:- Retrieve escrow.
- Check
current_timestamp > escrow.deadline. - Check status is
Funded(not Disputed/Completed). - Transfer funds back to Buyer.
- Update status to
Refunded.
Test and Commit
- Testing: Mock the ledger timestamp in tests to fast-forward time. Verify refund works after deadline but fails before.
- Commit Message:
feat(contract): implement expiration and auto-refund logic
Guidelines
- Handle time carefully (Stellar ledger timestamps are seconds since epoch).
- PR Requirement: Closes #issue
Reactions are currently unavailable