started adding mint stuff

This commit is contained in:
ben
2022-09-30 14:23:03 +01:00
parent a6ddc0b335
commit b09dbc4b85
4 changed files with 510 additions and 3 deletions
+59
View File
@@ -68,3 +68,62 @@ async def get_cashus(wallet_ids: Union[str, List[str]]) -> List[Cashu]:
async def delete_cashu(cashu_id: str) -> None:
await db.execute("DELETE FROM cashu.cashu WHERE id = ?", (cashu_id,))
###############MINT STUFF#################
async def store_promise(
amount: int,
B_: str,
C_: str,
db: Database,
conn: Optional[Connection] = None,
):
await (conn or db).execute(
"""
INSERT INTO promises
(amount, B_b, C_b)
VALUES (?, ?, ?)
""",
(
amount,
str(B_),
str(C_),
),
)
async def get_proofs_used(
db: Database,
conn: Optional[Connection] = None,
):
rows = await (conn or db).fetchall(
"""
SELECT secret from proofs_used
"""
)
return [row[0] for row in rows]
async def invalidate_proof(
proof: Proof,
db: Database,
conn: Optional[Connection] = None,
):
# we add the proof and secret to the used list
await (conn or db).execute(
"""
INSERT INTO proofs_used
(amount, C, secret)
VALUES (?, ?, ?)
""",
(
proof.amount,
str(proof.C),
str(proof.secret),
),
)