-
-
Notifications
You must be signed in to change notification settings - Fork 177
Allow minting paid quotes after expiry #1122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Egge21M
wants to merge
1
commit into
cashubtc:main
Choose a base branch
from
Egge21M:fix/mint-paid-quotes-after-expiry
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -496,8 +496,7 @@ async def mint( | |
| Exception: Validation of outputs failed. | ||
| Exception: Quote not paid. | ||
| Exception: Quote already issued. | ||
| Exception: Quote expired. | ||
| Exception: Amount to mint does not match quote amount. | ||
| Exception: Amount to mint does not match quote amount. | ||
|
|
||
| Returns: | ||
| List[BlindedSignature]: Signatures on the outputs. | ||
|
|
@@ -512,19 +511,20 @@ async def mint( | |
| raise TransactionError("Mint quote already pending.") | ||
| if quote.issued: | ||
| raise QuoteAlreadyIssuedError() | ||
| if quote.state != MintQuoteState.paid: | ||
| raise QuoteNotPaidError() | ||
|
|
||
| previous_state = quote.state | ||
| if quote.state != MintQuoteState.paid: | ||
| raise QuoteNotPaidError() | ||
|
|
||
| # Quote expiry limits when the payment request can be paid. Once payment is | ||
| # confirmed, the quote remains mintable until its value has been issued. | ||
|
|
||
| previous_state = quote.state | ||
| await self.db_write._set_mint_quote_pending(quote_id=quote_id) | ||
| try: | ||
| if not quote.unit == output_unit.name: | ||
| raise TransactionError("quote unit does not match output unit") | ||
| if not quote.amount == sum_amount_outputs: | ||
| raise TransactionError("amount to mint does not match quote amount") | ||
| if quote.expiry and quote.expiry < int(time.time()): | ||
| raise TransactionError("quote expired") | ||
| if not self._verify_mint_quote_witness(quote, outputs, signature): | ||
| if not self._verify_mint_quote_witness(quote, outputs, signature): | ||
| raise QuoteSignatureInvalidError() | ||
| await self._store_blinded_messages(outputs, mint_id=quote_id) | ||
| promises = await self._sign_blinded_messages(outputs) | ||
|
|
@@ -592,15 +592,17 @@ async def mint_batch( | |
| if units.pop() != output_unit.name: | ||
| raise TransactionError("quote unit does not match output unit") | ||
|
|
||
| for quote in quotes: | ||
| if quote.pending: | ||
| raise TransactionError("mint quote already pending") | ||
| for quote in quotes: | ||
| if quote.pending: | ||
| raise TransactionError("mint quote already pending") | ||
| if quote.issued: | ||
| raise QuoteAlreadyIssuedError() | ||
| if quote.state != MintQuoteState.paid: | ||
| raise QuoteNotPaidError() | ||
|
|
||
| # Check amount balance | ||
| if quote.state != MintQuoteState.paid: | ||
| raise QuoteNotPaidError() | ||
|
|
||
| # Quote expiry limits payment, not issuance of already-paid value. | ||
|
|
||
| # Check amount balance | ||
|
Comment on lines
+600
to
+605
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this change isn't needed |
||
| if payload.quote_amounts: | ||
| if len(payload.quote_amounts) != len(quotes): | ||
| raise TransactionError("quote_amounts length must match quotes length") | ||
|
|
@@ -642,12 +644,8 @@ async def mint_batch( | |
| # Set all quotes to pending | ||
| quotes = await self.db_write._set_mint_quotes_pending(quote_ids=payload.quotes) | ||
|
|
||
| try: | ||
| for quote in quotes: | ||
| if quote.expiry and quote.expiry < int(time.time()): | ||
| raise TransactionError("quote expired") | ||
|
|
||
| # Store all blinded messages | ||
| try: | ||
| # Store all blinded messages | ||
| await self._store_blinded_messages( | ||
| payload.outputs, mint_id=payload.quotes[0] | ||
| ) | ||
|
|
||
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change isn't needed