Skip to content

fix(#615 #616 #617 #618): compact invoice validation, from_u8 panic, … - #653

Open
krypto-boi wants to merge 1 commit into
Stellar-split:mainfrom
krypto-boi:fix/615-618-compact-invoice-event-fixes
Open

fix(#615 #616 #617 #618): compact invoice validation, from_u8 panic, …#653
krypto-boi wants to merge 1 commit into
Stellar-split:mainfrom
krypto-boi:fix/615-618-compact-invoice-event-fixes

Conversation

@krypto-boi

Copy link
Copy Markdown

Title: fix: compact invoice validation, from_u8 panic, event data consistency (#615 #616 #617
#618)

─────────────────────────────────────────────────────────────────────────────────────────────

Description:

This PR fixes four issues in contracts/split/src/types.rs and contracts/split/src/events.rs.

─────────────────────────────────────────────────────────────────────────────────────────────

Changes

#615 — from_compact does not validate byte slice length

Added a length guard at the start of Invoice::from_compact. If compact.data contains fewer
than 25 bytes, the function now panics with "from_compact: data too short" instead of
unwrapping at an arbitrary offset.

#616 — InvoiceStatus::from_u8 silently maps unknown bytes to Pending

Replaced the _ => InvoiceStatus::Pending wildcard with _ => panic!("unknown InvoiceStatus
byte: {v}"). This surfaces data corruption from malformed migration or compact storage
encoding rather than masking it.

#617 — invoice_archived event omits invoice_id from data payload

Updated the data tuple from (event_seq,) to (invoice_id, event_seq), making it consistent
with other events like invoice_released and allowing data-only event decoders to identify the
invoice without parsing topics.

#618 — invoice_partially_released missing event_seq for ordering

Added a next_seq(env, invoice_id) call inside invoice_partially_released and changed the data
payload from recipients to (recipients, event_seq), enabling temporal ordering of
partial-release events.

─────────────────────────────────────────────────────────────────────────────────────────────

Tests

  • from_compact_too_short_panics_cleanly — passes a 1-byte CompactInvoice, asserts the
    descriptive panic fires
  • from_u8_unknown_byte_panics — uses std::panic::catch_unwind to verify byte 255 panics with
    the expected message

─────────────────────────────────────────────────────────────────────────────────────────────

Closes

Closes #615
Closes #616
Closes #617
Closes #618

…it#618): compact invoice validation, from_u8 panic, event data consistency

- Stellar-split#615: add from_compact data too short guard (panics if bytes < 25)
- Stellar-split#616: from_u8 wildcard now panics on unknown byte instead of silently mapping to Pending
- Stellar-split#617: invoice_archived data payload includes invoice_id alongside event_seq
- Stellar-split#618: invoice_partially_released now calls next_seq and includes event_seq in data

Tests added: from_compact_too_short_panics_cleanly, from_u8_unknown_byte_panics
@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@krypto-boi 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant