diff --git a/cashu/mint/ledger.py b/cashu/mint/ledger.py index 57079d0..4ec1eba 100644 --- a/cashu/mint/ledger.py +++ b/cashu/mint/ledger.py @@ -191,6 +191,7 @@ class Ledger: if not proof.id: private_key_amount = self.keyset.private_keys[proof.amount] else: + assert proof.id in self.keysets.keysets, f"keyset {proof.id} unknown" logger.trace( f"Validating proof with keyset {self.keysets.keysets[proof.id].id}." ) diff --git a/cashu/wallet/cli/cli.py b/cashu/wallet/cli/cli.py index cfb9070..768c69e 100644 --- a/cashu/wallet/cli/cli.py +++ b/cashu/wallet/cli/cli.py @@ -160,10 +160,10 @@ async def invoice(ctx: Context, amount: int, hash: str, split: int): assert amount >= split, "split must smaller or equal amount" n_splits = amount // split optional_split = [split] * n_splits - print(f"Requesting split with {n_splits}*{split} sat tokens.") + logger.debug(f"Requesting split with {n_splits} * {split} sat tokens.") if not settings.lightning: - r = await wallet.mint(amount) + r = await wallet.mint(amount, split=optional_split) # user requests an invoice elif amount and not hash: invoice = await wallet.request_mint(amount) diff --git a/cashu/wallet/wallet.py b/cashu/wallet/wallet.py index 97fe98a..8c29acc 100644 --- a/cashu/wallet/wallet.py +++ b/cashu/wallet/wallet.py @@ -253,7 +253,7 @@ class LedgerAPI: url + "/keys", ) resp.raise_for_status() - keys = resp.json() + keys: dict = resp.json() assert len(keys), Exception("did not receive any keys") keyset_keys = { int(amt): PublicKey(bytes.fromhex(val), raw=True) @@ -536,6 +536,7 @@ class Wallet(LedgerAPI): """ # specific split if split: + logger.trace(f"Mint with split: {split}") assert sum(split) == amount, "split must sum to amount" for a in split: if a not in [2**i for i in range(settings.max_order)]: diff --git a/tests/test_wallet_api.py b/tests/test_wallet_api.py index 7dbc39d..b5757fe 100644 --- a/tests/test_wallet_api.py +++ b/tests/test_wallet_api.py @@ -41,8 +41,7 @@ async def test_invoice_with_split(wallet: Wallet): assert response.json()["invoice"] else: assert response.json()["amount"] - # wallet = asyncio.run(init_wallet()) - # asyncio.run(wallet.load_proofs()) + # await wallet.load_proofs(reload=True) # assert wallet.proof_amounts.count(1) >= 10