Skip to content

fix(#694): reject min_funding_bps > 10 000 at invoice creation - #743

Merged
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
CodedBay:fix/issue-694-min-funding-bps-validation
Aug 31, 2026
Merged

fix(#694): reject min_funding_bps > 10 000 at invoice creation#743
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
CodedBay:fix/issue-694-min-funding-bps-validation

Conversation

@CodedBay

Copy link
Copy Markdown
Contributor

Summary

min_funding_bps sets the minimum percentage of the invoice total that must be funded before release. Previously there was no bounds check; a value above 10 000 would require more than 100% funding, making the invoice permanently unreleasable.

This PR replaces the bare assert! macro with panic_with_error!(env, ContractError::InvalidAmount), firing before any storage is written when min_funding_bps > 10_000.

What was changed

contracts/split/src/lib.rs

Replaced the old assert! with a typed error guard in _create_invoice_inner:

// Before
assert!(min_funding_bps <= 10_000, "min_funding_bps must be ≤ 10000");

// After — Issue #694
if min_funding_bps > 10_000 {
    panic_with_error!(env, ContractError::InvalidAmount);
}

contracts/split/src/test.rs

Two new unit tests:

  • test_min_funding_bps_above_10000_rejectedmin_funding_bps=10_001 → panics (#[should_panic])
  • test_min_funding_bps_exactly_10000_acceptedmin_funding_bps=10_000 → invoice created successfully (boundary value)

Acceptance criteria (from issue)

  • create_invoice returns ContractError::InvalidAmount when min_funding_bps > 10_000
  • Validation is present before any storage writes
  • Unit test: min_funding_bps = 10_001 is rejected
  • Unit test: min_funding_bps = 10_000 is accepted

Closes #694

…eation

min_funding_bps sets the minimum percentage of the invoice total that
must be funded before release. There was no bounds check; a value
above 10 000 would require more than 100% funding, making the invoice
permanently unreleasable.

Replace the bare assert! with panic_with_error!(env,
ContractError::InvalidAmount) so the contract returns a typed,
on-chain error code when min_funding_bps > 10_000. The guard fires
before any storage is written.

Tests added:
- test_min_funding_bps_above_10000_rejected: min_funding_bps=10_001
  → panic (should_panic)
- test_min_funding_bps_exactly_10000_accepted: min_funding_bps=10_000
  → invoice created successfully (boundary value)

Closes Stellar-split#694
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@CodedBay 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 4efaae8 into Stellar-split:main Aug 31, 2026
1 of 4 checks passed
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.

Validate min_funding_bps is in range 0-10 000 at invoice creation

2 participants