diff --git a/cashu/mint/crud.py b/cashu/mint/crud.py index f2ddf690..b4f80e7c 100644 --- a/cashu/mint/crud.py +++ b/cashu/mint/crud.py @@ -17,37 +17,47 @@ async def get_keyset(self, *args, **kwags): pass @abstractmethod - async def get_lightning_invoice(self, *args, **kwags): + async def get_lightning_invoice(self, *args, **kwags) -> Optional[Invoice]: pass - async def get_secrets_used(self, *args, **kwags): + @abstractmethod + async def get_secrets_used(self, *args, **kwags) -> List[str]: pass - async def invalidate_proof(self, *args, **kwags): + @abstractmethod + async def invalidate_proof(self, *args, **kwags) -> None: pass - async def get_proofs_pending(self, *args, **kwags): + @abstractmethod + async def get_proofs_pending(self, *args, **kwags) -> List[Proof]: pass - async def set_proof_pending(self, *args, **kwags): + @abstractmethod + async def set_proof_pending(self, *args, **kwags) -> None: pass - async def unset_proof_pending(self, *args, **kwags): + @abstractmethod + async def unset_proof_pending(self, *args, **kwags) -> None: pass - async def store_keyset(self, *args, **kwags): + @abstractmethod + async def store_keyset(self, *args, **kwags) -> None: pass - async def store_lightning_invoice(self, *args, **kwags): + @abstractmethod + async def store_lightning_invoice(self, *args, **kwags) -> None: pass - async def store_promise(self, *args, **kwags): + @abstractmethod + async def store_promise(self, *args, **kwags) -> None: pass - async def get_promise(self, *args, **kwags): + @abstractmethod + async def get_promise(self, *args, **kwags) -> Optional[BlindedSignature]: pass - async def update_lightning_invoice(self, *args, **kwags): + @abstractmethod + async def update_lightning_invoice(self, *args, **kwags) -> None: pass @@ -63,7 +73,7 @@ async def store_promise( e: str = "", s: str = "", conn: Optional[Connection] = None, - ): + ) -> None: await (conn or db).execute( f""" INSERT INTO {table_with_schema(db, 'promises')} diff --git a/cashu/mint/ledger.py b/cashu/mint/ledger.py index 4b0348bb..0f3b96a9 100644 --- a/cashu/mint/ledger.py +++ b/cashu/mint/ledger.py @@ -55,7 +55,7 @@ def __init__( self.derivation_path = derivation_path self.db = db - self.crud = crud + self.crud = crud() self.lightning = lightning self.pubkey = derive_pubkey(self.master_key) self.keysets = MintKeysets([]) @@ -385,14 +385,15 @@ async def request_mint(self, amount: int) -> Tuple[str, str]: async def mint( self, - B_s: List[BlindedMessage], + *, + outputs: List[BlindedMessage], id: Optional[str] = None, keyset: Optional[MintKeyset] = None, ) -> List[BlindedSignature]: - """Mints a promise for coins for B_. + """Mints new coins if payment `id` was successful. Ingest blind messages `outputs` and returns blind signatures `promises`. Args: - B_s (List[BlindedMessage]): Outputs (blinded messages) to sign. + outputs (List[BlindedMessage]): Outputs (blinded messages) to sign. id (Optional[str], optional): Id of (paid) Lightning invoice. Defaults to None. keyset (Optional[MintKeyset], optional): Keyset to use. If not provided, uses active keyset. Defaults to None. @@ -406,7 +407,7 @@ async def mint( List[BlindedSignature]: Signatures on the outputs. """ logger.trace("called mint") - amount_outputs = sum([b.amount for b in B_s]) + amount_outputs = sum([b.amount for b in outputs]) if settings.lightning: if not id: @@ -425,9 +426,9 @@ async def mint( ) del self.locks[id] - self._verify_outputs(B_s) + self._verify_outputs(outputs) - promises = await self._generate_promises(B_s, keyset) + promises = await self._generate_promises(outputs, keyset) logger.trace("generated promises") return promises diff --git a/cashu/mint/router.py b/cashu/mint/router.py index 0f8a94f3..9b0e5177 100644 --- a/cashu/mint/router.py +++ b/cashu/mint/router.py @@ -186,7 +186,7 @@ async def mint( """ logger.trace(f"> POST /mint: {payload}") - promises = await ledger.mint(payload.outputs, id=payload.id) + promises = await ledger.mint(outputs=payload.outputs, id=payload.id) blinded_signatures = PostMintResponse(promises=promises) logger.trace(f"< POST /mint: {blinded_signatures}") return blinded_signatures diff --git a/cashu/wallet/helpers.py b/cashu/wallet/helpers.py index 94cbc666..5b1f16f4 100644 --- a/cashu/wallet/helpers.py +++ b/cashu/wallet/helpers.py @@ -48,7 +48,7 @@ async def redeem_TokenV3_multimint(wallet: Wallet, token: TokenV3): t.mint, os.path.join(settings.cashu_dir, wallet.name) ) keysets = mint_wallet._get_proofs_keysets(t.proofs) - logger.debug(f"Keysets in tokens: {keysets}") + logger.trace(f"Keysets in tokens: {keysets}") # loop over all keysets for keyset in set(keysets): await mint_wallet.load_mint() diff --git a/cashu/wallet/secrets.py b/cashu/wallet/secrets.py index 57bf9349..9f38b0ce 100644 --- a/cashu/wallet/secrets.py +++ b/cashu/wallet/secrets.py @@ -74,8 +74,8 @@ async def _init_private_key(self, from_mnemonic: Optional[str] = None) -> None: self.seed = mnemo.to_seed(mnemonic_str) self.mnemonic = mnemonic_str - logger.debug(f"Using seed: {self.seed.hex()}") - logger.debug(f"Using mnemonic: {mnemonic_str}") + # logger.debug(f"Using seed: {self.seed.hex()}") + # logger.debug(f"Using mnemonic: {mnemonic_str}") # if no mnemonic was in the database, store the new one if ret_db is None: