fix(#694): reject min_funding_bps > 10 000 at invoice creation - #743
Merged
Kingsman-99 merged 2 commits intoAug 31, 2026
Merged
Conversation
…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
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
min_funding_bpssets 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 withpanic_with_error!(env, ContractError::InvalidAmount), firing before any storage is written whenmin_funding_bps > 10_000.What was changed
contracts/split/src/lib.rsReplaced the old
assert!with a typed error guard in_create_invoice_inner:contracts/split/src/test.rsTwo new unit tests:
test_min_funding_bps_above_10000_rejected—min_funding_bps=10_001→ panics (#[should_panic])test_min_funding_bps_exactly_10000_accepted—min_funding_bps=10_000→ invoice created successfully (boundary value)Acceptance criteria (from issue)
create_invoicereturnsContractError::InvalidAmountwhenmin_funding_bps > 10_000min_funding_bps = 10_001is rejectedmin_funding_bps = 10_000is acceptedCloses #694