diff --git a/cashu/mint/crud.py b/cashu/mint/crud.py index cb21727f..923ae170 100644 --- a/cashu/mint/crud.py +++ b/cashu/mint/crud.py @@ -115,35 +115,6 @@ async def get_promise( conn: Optional[Connection] = None, ) -> Optional[BlindedSignature]: ... - # @abstractmethod - # async def store_lightning_invoice( - # self, - # *, - # db: Database, - # invoice: Invoice, - # conn: Optional[Connection] = None, - # ) -> None: ... - - # @abstractmethod - # async def update_lightning_invoice( - # self, - # *, - # db: Database, - # id: str, - # issued: bool, - # conn: Optional[Connection] = None, - # ) -> None: ... - - # @abstractmethod - # async def get_lightning_invoice( - # self, - # *, - # db: Database, - # id: Optional[str] = None, - # checking_id: Optional[str] = None, - # conn: Optional[Connection] = None, - # ) -> Optional[Invoice]: ... - @abstractmethod async def store_mint_quote( self, @@ -524,74 +495,6 @@ async def update_melt_quote( ), ) - # async def store_lightning_invoice( - # self, - # *, - # db: Database, - # invoice: Invoice, - # conn: Optional[Connection] = None, - # ) -> None: - # await (conn or db).execute( - # f""" - # INSERT INTO {table_with_schema(db, 'invoices')} - # (amount, bolt11, id, issued, payment_hash, out, created) - # VALUES (?, ?, ?, ?, ?, ?, ?) - # """, - # ( - # invoice.amount, - # invoice.bolt11, - # invoice.id, - # invoice.issued, - # invoice.payment_hash, - # invoice.out, - # int(time.time()), - # ), - # ) - - # async def get_lightning_invoice( - # self, - # *, - # db: Database, - # id: Optional[str] = None, - # checking_id: Optional[str] = None, - # conn: Optional[Connection] = None, - # ) -> Optional[Invoice]: - # clauses = [] - # values: List[Any] = [] - # if id: - # clauses.append("id = ?") - # values.append(id) - # if checking_id: - # clauses.append("payment_hash = ?") - # values.append(checking_id) - # where = "" - # if clauses: - # where = f"WHERE {' AND '.join(clauses)}" - # row = await (conn or db).fetchone( - # f""" - # SELECT * from {table_with_schema(db, 'invoices')} - # {where} - # """, - # tuple(values), - # ) - # return Invoice(**dict(row)) if row else None - - # async def update_lightning_invoice( - # self, - # *, - # db: Database, - # id: str, - # issued: bool, - # conn: Optional[Connection] = None, - # ) -> None: - # await (conn or db).execute( - # f"UPDATE {table_with_schema(db, 'invoices')} SET issued = ? WHERE id = ?", - # ( - # issued, - # id, - # ), - # ) - async def store_keyset( self, *, diff --git a/cashu/mint/migrations.py b/cashu/mint/migrations.py index 3a56c7ac..1544faf1 100644 --- a/cashu/mint/migrations.py +++ b/cashu/mint/migrations.py @@ -283,23 +283,12 @@ async def m011_add_quote_tables(db: Database): ); """) - -async def m012_migrate_invoices_table(db: Database): - async with db.connect() as conn: - # copy all entries of invoices table to mint_quotes table if out = False await conn.execute( f"INSERT INTO {table_with_schema(db, 'mint_quotes')} (quote, method," " request, checking_id, unit, amount, paid, issued, created_time," - " paid_time) SELECT bolt11, 'bolt11', bolt11, id, 'sat', amount, False," - f" issued, created, NULL FROM {table_with_schema(db, 'invoices')} WHERE" - " out = False" - ) - # copy all entries of invoices table to melt_quotes table if out = True - await conn.execute( - f"INSERT INTO {table_with_schema(db, 'melt_quotes')} (quote, method," - " request, checking_id, unit, amount, paid, created_time, paid_time)" - " SELECT bolt11, 'bolt11', bolt11, id, 'sat', amount, False, created," - f" NULL FROM {table_with_schema(db, 'invoices')} WHERE out = True" + " paid_time) SELECT id, 'bolt11', bolt11, payment_hash, 'sat', amount," + f" False, issued, created, NULL FROM {table_with_schema(db, 'invoices')} " ) + # drop table invoices - # await conn.execute(f"DROP TABLE {table_with_schema(db, 'invoices')}") + await conn.execute(f"DROP TABLE {table_with_schema(db, 'invoices')}")