Implement #163: dynamic recipient management (cap + replacement + quorum)#342
Open
jjb9707 wants to merge 1 commit into
Open
Implement #163: dynamic recipient management (cap + replacement + quorum)#342jjb9707 wants to merge 1 commit into
jjb9707 wants to merge 1 commit into
Conversation
…+ replacement + quorum) - Add optional max_recipients cap on InvoiceOptions, enforced at create_invoice time. - Add propose_recipient_replacement / approve_recipient_replacement (co-signer quorum) + private execute_recipient_replacement that inherits the recipient slot (keeps amounts/claimed aligned) and migrates the paid set. - Emit recipient_replacement_proposed / _executed events. - Add 4 tests covering quorum, claimed-amount preservation, released-invoice rejection, and the recipient cap.
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 GrantFox issue #163 — Dynamic recipient management for the split contract. Adds an optional recipient cap at creation time and a co-signer-gated recipient replacement flow, so a split invoice's payout targets can evolve without recreating the invoice.
Acceptance criteria
InvoiceOptions.max_recipients: Option<u32>is enforced increate_invoice: creating an invoice with more recipients than the cap panics with"exceeds max recipients".propose_recipient_replacementlets the creator or a co-creator propose swapping an existing recipient (old_recipient) for a new one (new_recipient). Only allowed while the invoice isPendingand not a streaming (drip) invoice.approve_recipient_replacementlets each authorized co-signer approve a pending proposal; oncerequired_signaturesdistinct co-signers have approved, the replacement is applied automatically. Whenrequired_signatures == 0, the proposal executes immediately on propose.execute_recipient_replacementoverwrites the same recipient slot (recipients.set(idx, new)), soamounts/claimedstay index-aligned, and migrates the paid set (the new recipient is marked paid if the old one already was). Emitsrecipient_replacement_proposed/recipient_replacement_executedevents.Tests added (
test.rs)test_recipient_replacement_requires_quorum— 2 co-signers +required_signatures = 2; first approval does not execute, second does.test_recipient_replacement_preserves_claimed_amounts— after a paid release, replacing a recipient keeps the claimed amount on the new slot and blocks a doublerelease_to_recipient.test_recipient_replacement_blocked_on_released_invoice— proposing on an already-released invoice panics (replacement requires pending invoice).test_recipient_cap_enforced_at_creation— 3 recipients withmax_recipients = 2panics at creation.Verification
cargo check -p split(lib) andcargo check --tests -p splitboth compile cleanly on the local GNU toolchain.cargo testsuite against the committed toolchain; the local environment could not link the test binary (no MSVC / incomplete GNU binutils) but type-checking of the new code and tests passes.This should be reviewed for on-chain storage compatibility of the
InvoiceOptionsstruct change before merge.