Skip to content

Commit

Permalink
Store preimage as well
Browse files Browse the repository at this point in the history
  • Loading branch information
sihamon committed Sep 8, 2023
1 parent c198abe commit 3c334d2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions cashu/mint/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,21 @@ async def get_keyset(
async def store_invoice_and_proofs(
db: Database,
invoice: bolt11_invoice,
preimage: str,
proof: Proof,
conn: Optional[Connection] = None,
):
await (conn or db).execute(
f"""
INSERT INTO {table_with_schema(db, 'payments')}
(invoice_amount, date, payment_hash, proof_amount, proof_C, proof_secret)
VALUES (?, ?, ?, ?, ?, ?)
(invoice_amount, date, payment_hash, preimage, proof_amount, proof_C, proof_secret)
VALUES (?, ?, ?, ?, ?, ?, ?)
""",
(
invoice.amount_msat / 1000,
invoice.date,
invoice.payment_hash,
preimage,
proof.amount,
proof.C,
proof.secret,
Expand Down
4 changes: 3 additions & 1 deletion cashu/mint/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,9 @@ async def melt(

if status:
for p in proofs:
await self.crud.store_invoice_and_proofs(self.db, invoice_obj, p)
await self.crud.store_invoice_and_proofs(
self.db, invoice_obj, preimage, p
)
logger.trace("invalidating proofs")
await self._invalidate_proofs(proofs)
logger.trace("invalidated proofs")
Expand Down
3 changes: 2 additions & 1 deletion cashu/mint/migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ async def m008_paid_invoices_and_proofs(db: Database):
invoice_amount {db.big_int} NOT NULL,
date TEXT NOT NULL,
payment_hash TEXT NOT NULL,
proof_amount TEXT NOT NULL,
preimage TEXT NOT NULL,
proof_amount {db.big_int} NOT NULL,
proof_C TEXT NOT NULL,
proof_secret TEXT NOT NULL,
Expand Down

0 comments on commit 3c334d2

Please sign in to comment.