Skip to content

fix: validate payment_open_at is before payment_close_at (#697) - #740

Merged
Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
deborahairtel887-dotcom:fix/issue-697-validate-payment-window
Aug 31, 2026
Merged

fix: validate payment_open_at is before payment_close_at (#697)#740
Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
deborahairtel887-dotcom:fix/issue-697-validate-payment-window

Conversation

@deborahairtel887-dotcom

Copy link
Copy Markdown
Contributor

Summary

Validates that payment_open_at < payment_close_at when both fields are configured on InvoiceOptions2 during create_invoice. If payment_open_at >= payment_close_at, create_invoice now returns ContractError::InvalidAmount.

Changes

  • In contracts/split/src/lib.rs, validate that payment_open_at < payment_close_at when both are Some(_), returning ContractError::InvalidAmount if payment_open_at >= payment_close_at.
  • Ensures no error is raised when only one of the fields is set or when both are None.
  • Added unit tests in contracts/split/src/test.rs:
    • test_create_invoice_payment_open_at_greater_than_close_at_rejected: verifies rejection with ContractError::InvalidAmount for open_at = 100, close_at = 99.
    • test_create_invoice_payment_open_at_equal_to_close_at_rejected: verifies rejection with ContractError::InvalidAmount for open_at = 100, close_at = 100.
    • test_create_invoice_payment_open_at_less_than_close_at_ok: verifies acceptance for open_at = 99, close_at = 100.
    • test_create_invoice_payment_window_only_one_or_none_ok: verifies invoice creation succeeds when only one field is set or both are None.

closes #697

@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@deborahairtel887-dotcom 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 81fd198 into Stellar-split:main Aug 31, 2026
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.

Validate payment_open_at is before payment_close_at when both are set

2 participants