fix: check invoice amount against blinded message amount
This commit is contained in:
parent
e842c3df52
commit
f27632eb8e
2 changed files with 12 additions and 5 deletions
|
|
@ -4,7 +4,7 @@ from typing import List, Union
|
|||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class CashuError(BaseModel):
|
||||
class CashuError(BaseException):
|
||||
code = "000"
|
||||
error = "CashuError"
|
||||
|
||||
|
|
|
|||
|
|
@ -284,6 +284,13 @@ async def mint_coins(
|
|||
detail="Tokens already issued for this invoice.",
|
||||
)
|
||||
|
||||
total_requested = sum([bm.amount for bm in data.blinded_messages])
|
||||
if total_requested > invoice.amount:
|
||||
# raise CashuError(error = f"Requested amount to high: {total_requested}. Invoice amount: {invoice.amount}")
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.PAYMENT_REQUIRED, detail=f"Requested amount to high: {total_requested}. Invoice amount: {invoice.amount}"
|
||||
)
|
||||
|
||||
status: PaymentStatus = await check_transaction_status(cashu.wallet, payment_hash)
|
||||
# todo: revert to: status.paid != True:
|
||||
if status.paid != True:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue