Skip to content

fix(wallet): atomically reserve on-chain withdrawal balance and add concurrency regression test#381

Open
kuse-design wants to merge 1 commit into
geevapp:mainfrom
kuse-design:fix/on-chain-withdrawal-reserve-balance
Open

fix(wallet): atomically reserve on-chain withdrawal balance and add concurrency regression test#381
kuse-design wants to merge 1 commit into
geevapp:mainfrom
kuse-design:fix/on-chain-withdrawal-reserve-balance

Conversation

@kuse-design

Copy link
Copy Markdown

Fixes on-chain withdrawal race condition in route.ts
Changes on-chain withdrawal flow to:
reserve balance atomically with updateMany({ walletBalance: { gte: amount } })
create pending withdrawal after successful reservation
refund reserved balance if submitStellarWithdrawal fails
Adds regression coverage in wallet-withdraw.test.ts
simulates two concurrent on-chain withdrawals that exceed available balance
verifies only one succeeds and wallet balance is not overdrawn
Verified with corepack pnpm --dir app exec vitest run tests/api/wallet-withdraw.test.ts

closes #349

@drips-wave

drips-wave Bot commented Jun 25, 2026

Copy link
Copy Markdown

@kuse-design 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

@3m1n3nc3

3m1n3nc3 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Please fix conflicts

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.

On-chain withdrawal checks balance before submit and decrements after — concurrent double-spend

2 participants