Skip to content

Commit

Permalink
remove unused lightning table
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Nov 27, 2023
1 parent 7fe4997 commit 015dd24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 112 deletions.
97 changes: 0 additions & 97 deletions cashu/mint/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
*,
Expand Down
19 changes: 4 additions & 15 deletions cashu/mint/migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')}")

0 comments on commit 015dd24

Please sign in to comment.