feat: add multi-stage invoice release#137
Merged
Kingsman-99 merged 1 commit intoMay 31, 2026
Merged
Conversation
- Add release_stages: Vec<u32> and released_stages: u32 to Invoice struct - Add release_stages field to InvoiceOptions - Add stage_release() function requiring creator auth - Each call distributes the next stage's proportion to recipients - Final stage sets invoice status to Released - Validate release_stages sum to 10000 basis points at creation - Block auto-release in _pay when release_stages is non-empty - Add 5 tests: 3-stage happy path, post-completion panic, non-creator panic, not-fully-funded panic, invalid sum panic - Fix pre-existing compilation errors from issues Stellar-split#87/Stellar-split#88/Stellar-split#89 closes Stellar-split#86
|
@Nuwe10 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
Implements creator-triggered staged fund distribution for large invoices (issue #86).
Changes
types.rs
release_stages: Vec<u32>toInvoicestruct — stores basis points per stage (must sum to 10 000 when non-empty)released_stages: u32toInvoicestruct — tracks how many stages have been distributedrelease_stages: Vec<u32>toInvoiceOptions— passed at invoice creationInvoice::from_legacyto include new fields with zero defaultslib.rs
create_invoice/_create_invoice_innerto accept and storerelease_stagesrelease_stagessums to 10 000 basis points when non-emptystage_release(env, invoice_id, creator)— requires creator auth, distributes the next stage's proportion proportionally to recipients, sets status toReleasedon the final stage_payauto-release guard to block whenrelease_stagesis non-empty_create_invoice_innercall sites (batch, subscription, rollover, template)test.rs
test_stage_release_3_stages— 3-stage (30%/40%/30%) happy path verifying correct amounts per calltest_stage_release_after_all_stages_panics— panics after all stages releasedtest_stage_release_non_creator_panics— non-creator cannot call stage_releasetest_stage_release_not_fully_funded_panics— panics if invoice not fully fundedtest_create_invoice_invalid_release_stages_panics— panics if stages don't sum to 10 000Test Results
cargo clippy: 0 warnings
closes #86