Skip to content

fix(program): bind fund_escrow to the invoice mint; tolerate vault surplus - #3

Merged
kartsan03 merged 1 commit into
mainfrom
fix/escrow-mint-and-vault-surplus
Sep 27, 2026
Merged

kartsan03 merged 1 commit into
mainfrom
fix/escrow-mint-and-vault-surplus

Conversation

@kartsan03

Copy link
Copy Markdown
Owner

Two escrow bugs:

  • fund_escrow accepted any mint. usdc_mint was never checked against invoice.usdc_mint, and the vault constraint derives the ATA from whatever mint is passed. A client could fund with a self-minted token and flip the invoice to Funded, while settle could never pay because the real-mint vault is empty. Now address = invoice.usdc_mint (new InvalidMint error, appended so existing codes keep their numbers).
  • settle bricked by a 1-unit deposit. vault.amount == total failed forever once anyone sent tokens straight to the vault ATA. Now >=, still paying exactly total.

Two bankrun regression tests added. The devnet deployment still runs the old program until it is redeployed.

…rplus

fund_escrow never checked usdc_mint against invoice.usdc_mint. The vault
constraint derives the ATA from whichever mint is passed, so a client
could fund with a token they minted themselves and flip the invoice to
Funded. The freelancer sees a funded escrow, but settle can never pay:
its vault for the real mint is empty.

settle required vault.amount == total. Anyone can transfer into the
vault ATA, before or after funding, so a single base unit made settle
fail forever with no refund path. It now requires >= total and still
pays exactly total.

Adds InvalidMint at the end of the error enum so existing codes keep
their numbers, and two bankrun regression tests.
@vercel

vercel Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
stableinvoice Building Building Preview Sep 27, 2026 9:33pm UTC

@kartsan03
kartsan03 merged commit 9317df1 into main Sep 27, 2026
3 checks passed
@kartsan03
kartsan03 deleted the fix/escrow-mint-and-vault-surplus branch September 27, 2026 21:41

This branch was successfully deployed

1 active deployment
Preview — 3b68ee98 Deployed Sep 27, 2026 by vercel[bot]
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.

1 participant