update to cashu 0.6.0

This commit is contained in:
callebtc 2022-12-15 00:33:24 +01:00
parent e78bf8e323
commit cef4244bfc
4 changed files with 39 additions and 36 deletions

View File

@ -221,7 +221,7 @@ async def mint_coins(
status: PaymentStatus = await check_transaction_status(cashu.wallet, payment_hash) status: PaymentStatus = await check_transaction_status(cashu.wallet, payment_hash)
if status.paid != True: if LIGHTNING and status.paid != True:
raise HTTPException( raise HTTPException(
status_code=HTTPStatus.PAYMENT_REQUIRED, detail="Invoice not paid." status_code=HTTPStatus.PAYMENT_REQUIRED, detail="Invoice not paid."
) )
@ -265,10 +265,11 @@ async def melt_coins(
detail="Error: Tokens are from another mint.", detail="Error: Tokens are from another mint.",
) )
assert all([ledger._verify_proof(p) for p in proofs]), HTTPException( # set proofs as pending
status_code=HTTPStatus.BAD_REQUEST, await ledger._set_proofs_pending(proofs)
detail="Could not verify proofs.",
) try:
ledger._verify_proofs(proofs)
total_provided = sum([p["amount"] for p in proofs]) total_provided = sum([p["amount"] for p in proofs])
invoice_obj = bolt11.decode(invoice) invoice_obj = bolt11.decode(invoice)
@ -291,21 +292,23 @@ async def melt_coins(
extra={"tag": "cashu", "cashu_name": cashu.name}, extra={"tag": "cashu", "cashu_name": cashu.name},
) )
try:
logger.debug( logger.debug(
f"Cashu: Wallet {cashu.wallet} checking PaymentStatus of {invoice_obj.payment_hash}" f"Cashu: Wallet {cashu.wallet} checking PaymentStatus of {invoice_obj.payment_hash}"
) )
status: PaymentStatus = await check_transaction_status( status: PaymentStatus = await check_transaction_status(
cashu.wallet, invoice_obj.payment_hash cashu.wallet, invoice_obj.payment_hash
) )
logger.debug(f"Cashu: Got status.paid: {status.paid}")
if status.paid == True: if status.paid == True:
logger.debug("Cashu: Payment successful, invalidating proofs") logger.debug("Cashu: Payment successful, invalidating proofs")
await ledger._invalidate_proofs(proofs) await ledger._invalidate_proofs(proofs)
except Exception as e: except Exception as e:
logger.error(e) raise HTTPException(
logger.error("Cashu: Error in payment status check, invalidating proofs") status_code=HTTPStatus.BAD_REQUEST,
await ledger._invalidate_proofs(proofs) detail=f"Cashu: {str(e)}",
)
finally:
# delete proofs from pending list
await ledger._unset_proofs_pending(proofs)
return GetMeltResponse(paid=status.paid, preimage=status.preimage) return GetMeltResponse(paid=status.paid, preimage=status.preimage)

8
poetry.lock generated
View File

@ -123,7 +123,7 @@ uvloop = ["uvloop (>=0.15.2)"]
[[package]] [[package]]
name = "cashu" name = "cashu"
version = "0.5.5" version = "0.6.0"
description = "Ecash wallet and mint with Bitcoin Lightning support" description = "Ecash wallet and mint with Bitcoin Lightning support"
category = "main" category = "main"
optional = false optional = false
@ -1144,7 +1144,7 @@ testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools"
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = "^3.10 | ^3.9 | ^3.8 | ^3.7" python-versions = "^3.10 | ^3.9 | ^3.8 | ^3.7"
content-hash = "53a18d7695f02e9ad24dc7d0863b5ae815c18f2f390ef20d7166a54b202642ff" content-hash = "7f75ca0b067a11f19520dc2121f0789e16738b573a8da84ba3838ed8a466a6e1"
[metadata.files] [metadata.files]
aiofiles = [ aiofiles = [
@ -1208,8 +1208,8 @@ black = [
{file = "black-22.10.0.tar.gz", hash = "sha256:f513588da599943e0cde4e32cc9879e825d58720d6557062d1098c5ad80080e1"}, {file = "black-22.10.0.tar.gz", hash = "sha256:f513588da599943e0cde4e32cc9879e825d58720d6557062d1098c5ad80080e1"},
] ]
cashu = [ cashu = [
{file = "cashu-0.5.5-py3-none-any.whl", hash = "sha256:c1d707479b852e503acca5ed53aa341b1880cd6bd70369488ec002d647970c9b"}, {file = "cashu-0.6.0-py3-none-any.whl", hash = "sha256:54096af145643aab45943b235f95a3357b0ec697835c1411e66523049ffb81f6"},
{file = "cashu-0.5.5.tar.gz", hash = "sha256:cc0349d3b6d9a2428cb575fee6280b20074ca9c20a1e2e9c68729a73c01f5f9d"}, {file = "cashu-0.6.0.tar.gz", hash = "sha256:503a90c4ca8d25d0b2c3f78a11b163c32902a726ea5b58e5337dc00eca8e96ad"},
] ]
Cerberus = [ Cerberus = [
{file = "Cerberus-1.3.4.tar.gz", hash = "sha256:d1b21b3954b2498d9a79edf16b3170a3ac1021df88d197dc2ce5928ba519237c"}, {file = "Cerberus-1.3.4.tar.gz", hash = "sha256:d1b21b3954b2498d9a79edf16b3170a3ac1021df88d197dc2ce5928ba519237c"},

View File

@ -64,7 +64,7 @@ protobuf = "^4.21.6"
Cerberus = "^1.3.4" Cerberus = "^1.3.4"
async-timeout = "^4.0.2" async-timeout = "^4.0.2"
pyln-client = "0.11.1" pyln-client = "0.11.1"
cashu = "0.5.5" cashu = "^0.6.0"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]

View File

@ -7,7 +7,7 @@ attrs==22.1.0 ; python_version >= "3.7" and python_version < "4.0"
base58==2.1.1 ; python_version >= "3.7" and python_version < "4.0" base58==2.1.1 ; python_version >= "3.7" and python_version < "4.0"
bech32==1.2.0 ; python_version >= "3.7" and python_version < "4.0" bech32==1.2.0 ; python_version >= "3.7" and python_version < "4.0"
bitstring==3.1.9 ; python_version >= "3.7" and python_version < "4.0" bitstring==3.1.9 ; python_version >= "3.7" and python_version < "4.0"
cashu==0.5.5 ; python_version >= "3.7" and python_version < "4.0" cashu==0.6.0 ; python_version >= "3.7" and python_version < "4.0"
cerberus==1.3.4 ; python_version >= "3.7" and python_version < "4.0" cerberus==1.3.4 ; python_version >= "3.7" and python_version < "4.0"
certifi==2022.9.24 ; python_version >= "3.7" and python_version < "4.0" certifi==2022.9.24 ; python_version >= "3.7" and python_version < "4.0"
cffi==1.15.1 ; python_version >= "3.7" and python_version < "4.0" cffi==1.15.1 ; python_version >= "3.7" and python_version < "4.0"