Add expires_at field to invoices and reject payments on expired invoices#129
Open
AlonsoFi wants to merge 1 commit intoShadeProtocol:mainfrom
Open
Add expires_at field to invoices and reject payments on expired invoices#129AlonsoFi wants to merge 1 commit intoShadeProtocol:mainfrom
AlonsoFi wants to merge 1 commit intoShadeProtocol:mainfrom
Conversation
Collaborator
|
@AlonsoFi Fix the Ci and resolve the conflicts. |
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.
Closes: #114
Description
Add invoice expiry support via an optional expires_at: Option field on
invoices. When set, pay_invoice rejects payments after the expiry timestamp
with a new InvoiceExpired error. When None, invoices remain payable
indefinitely (backward-compatible).
Type of Change
not work as expected)
Related Issues
Fixes
Changes Made
shade.rs, and components/invoice.rs to accept the new parameter
env.ledger().timestamp() > expires_at
(build_message and verify_invoice_signature)
&None as expires_at
expires_at in signature construction
tests/mod.rs
Testing
New tests in test_invoice_expiry.rs:
ledger past it, asserts payment panics with InvoiceExpired (Create Comprehensive Tests for Merchant Public Key Management #21)
before it, asserts success
pays at a far-future timestamp, asserts success
Result: 150 tests pass (118 shade + 32 account), 0 failures.
Checklist
Additional Notes
The expires_at parameter is fully optional. Passing None preserves the
previous behavior — invoices without an expiry are payable at any time. The
expiry is also included in the signed message for create_invoice_signed,
ensuring it cannot be tampered with.