Skip to content

feat: add balance verification to _release()#56

Merged
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
marvs8:feature/32-release-balance-verification
May 28, 2026
Merged

feat: add balance verification to _release()#56
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
marvs8:feature/32-release-balance-verification

Conversation

@marvs8

@marvs8 marvs8 commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a contract balance check to _release() before routing funds to recipients, as described in issue #32.

Changes

  • lib.rs: In _release(), call token_client.balance(&env.current_contract_address()) and assert it is >= invoice.funded before the transfer loop. Panics with "insufficient contract balance" if not.
  • test.rs: Added test_release_panics_on_low_balance — pays an invoice partially, drains the contract balance via TokenClient::transfer, then pays the remainder triggering auto-release, which panics as expected.

Acceptance Criteria

  • Balance check runs before any recipient transfer in _release()
  • Panics with "insufficient contract balance" if balance is too low
  • Normal release with correct balance is unaffected
  • Test mocks a low balance scenario and verifies panic
  • All existing cargo test pass (8/8)
  • cargo clippy passes with zero warnings

Closes #32

- Assert contract token balance >= invoice.funded before any transfer
- Panics with 'insufficient contract balance' on discrepancy
- Add test_release_panics_on_low_balance: drains contract mid-payment, verifies panic

All 8 tests pass, clippy clean.

Closes Stellar-split#32
@drips-wave

drips-wave Bot commented May 28, 2026

Copy link
Copy Markdown

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

@Kingsman-99 Kingsman-99 merged commit 1b65b4b into Stellar-split:main May 28, 2026
1 check failed
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.

Add release balance verification

2 participants