Skip to content

feat: add multi-stage invoice release#137

Merged
Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
Nuwe10:feature/issue-86-multi-stage-release
May 31, 2026
Merged

feat: add multi-stage invoice release#137
Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
Nuwe10:feature/issue-86-multi-stage-release

Conversation

@Nuwe10
Copy link
Copy Markdown
Contributor

@Nuwe10 Nuwe10 commented May 30, 2026

Summary

Implements creator-triggered staged fund distribution for large invoices (issue #86).

Changes

types.rs

  • Added release_stages: Vec<u32> to Invoice struct — stores basis points per stage (must sum to 10 000 when non-empty)
  • Added released_stages: u32 to Invoice struct — tracks how many stages have been distributed
  • Added release_stages: Vec<u32> to InvoiceOptions — passed at invoice creation
  • Updated Invoice::from_legacy to include new fields with zero defaults

lib.rs

  • Updated create_invoice / _create_invoice_inner to accept and store release_stages
  • Validates that release_stages sums to 10 000 basis points when non-empty
  • Added stage_release(env, invoice_id, creator) — requires creator auth, distributes the next stage's proportion proportionally to recipients, sets status to Released on the final stage
  • Updated _pay auto-release guard to block when release_stages is non-empty
  • Updated all _create_invoice_inner call sites (batch, subscription, rollover, template)

test.rs

  • test_stage_release_3_stages — 3-stage (30%/40%/30%) happy path verifying correct amounts per call
  • test_stage_release_after_all_stages_panics — panics after all stages released
  • test_stage_release_non_creator_panics — non-creator cannot call stage_release
  • test_stage_release_not_fully_funded_panics — panics if invoice not fully funded
  • test_create_invoice_invalid_release_stages_panics — panics if stages don't sum to 10 000

Test Results

cargo clippy: 0 warnings

closes #86

- 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
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

@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! 🚀

Learn more about application limits

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

Add multi-stage invoice release

2 participants