minor fix for cashu

This commit is contained in:
Believethehype 2023-11-28 18:25:59 +01:00
parent ab1524b478
commit 83ac35334d
2 changed files with 4 additions and 2 deletions

2
dvm.py
View File

@ -115,7 +115,9 @@ class DVM:
cashu_redeemed = False
if cashu != "":
print(cashu)
cashu_redeemed, cashu_message = redeem_cashu(cashu, int(amount), self.dvm_config, self.client)
print(cashu_message)
if cashu_message != "success":
send_job_status_reaction(nip90_event, "error", False, amount, self.client, cashu_message,
self.dvm_config)

View File

@ -281,7 +281,7 @@ def parse_cashu(cashu_token: str):
def redeem_cashu(cashu, required_amount, config, client) -> (bool, str):
proofs, mint, redeem_invoice_amount, total_amount = parse_cashu(cashu)
fees = total_amount - redeem_invoice_amount
if redeem_invoice_amount <= required_amount:
if redeem_invoice_amount < required_amount:
err = ("Token value (Payment: " + str(total_amount) + " Sats. Fees: " +
str(fees) + " Sats) below required amount of " + str(required_amount)
+ " Sats. Cashu token has not been claimed.")
@ -308,7 +308,7 @@ def redeem_cashu(cashu, required_amount, config, client) -> (bool, str):
is_paid = tree["paid"] if tree.get("paid") else False
print(is_paid)
if is_paid:
print("token redeemed")
print("cashu token redeemed")
return True, "success"
else:
msg = tree.get("detail").split('.')[0].strip() if tree.get("detail") else None