mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-20 18:44:20 +01:00
isort
This commit is contained in:
51
mint/crud.py
51
mint/crud.py
@@ -1,5 +1,7 @@
|
||||
import secrets
|
||||
from typing import Optional
|
||||
|
||||
from core.base import Invoice
|
||||
from core.db import Connection, Database
|
||||
|
||||
|
||||
@@ -62,3 +64,52 @@ async def invalidate_proof(
|
||||
str(proof["secret"]),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
async def store_lightning_invoice(
|
||||
invoice: Invoice,
|
||||
db: Database,
|
||||
conn: Optional[Connection] = None,
|
||||
):
|
||||
|
||||
await (conn or db).execute(
|
||||
"""
|
||||
INSERT INTO invoices
|
||||
(amount, pr, hash, issued)
|
||||
VALUES (?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
invoice.amount,
|
||||
invoice.pr,
|
||||
invoice.hash,
|
||||
invoice.issued,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
async def get_lightning_invoice(
|
||||
hash: str,
|
||||
db: Database,
|
||||
conn: Optional[Connection] = None,
|
||||
):
|
||||
|
||||
row = await (conn or db).fetchone(
|
||||
"""
|
||||
SELECT * from invoices
|
||||
WHERE hash = ?
|
||||
""",
|
||||
hash,
|
||||
)
|
||||
return Invoice.from_row(row)
|
||||
|
||||
|
||||
async def update_lightning_invoice(
|
||||
hash: str,
|
||||
issued: bool,
|
||||
db: Database,
|
||||
conn: Optional[Connection] = None,
|
||||
):
|
||||
await (conn or db).execute(
|
||||
"UPDATE invoices SET issued = ? WHERE hash = ?",
|
||||
(issued, hash),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user