diff --git a/README.md b/README.md index 0123304..d54dc7e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,9 @@ The easiest way to use Cashu is to install the package it via pip: pip install cashu ``` -To update Cashu, use `pip install cashu -U`. You can skip the entire next section about Poetry and jump right to [Using Cashu](#using-cashu). +To update Cashu, use `pip install cashu -U`. If you have problems running the command above on Ubuntu, run `sudo apt install -y pip pkg-config libpq-dev`. + +You can skip the entire next section about Poetry and jump right to [Using Cashu](#using-cashu). ### Hard install: Poetry These steps help you install Python via pyenv and Poetry. If you already have Poetry running on your computer, you can skip this step and jump right to [Install Cashu](#install-cashu). diff --git a/cashu/cashu/__init__.py b/cashu/cashu/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/cashu/tests/__init__.py b/cashu/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/poetry.lock b/poetry.lock index e7c7e05..4f84b80 100644 --- a/poetry.lock +++ b/poetry.lock @@ -709,7 +709,7 @@ testing = ["func-timeout", "jaraco.itertools", "pytest (>=6)", "pytest-black (>= [metadata] lock-version = "1.1" python-versions = "^3.7" -content-hash = "a4553430bb7df5a66a7006d638986509d065e931ee5009ded5244eaa017475b2" +content-hash = "d5ee88384ec1ec1774f9fab845d7e8ac6e8ab1859506bcce178f6783b98e535c" [metadata.files] anyio = [ diff --git a/pyproject.toml b/pyproject.toml index 22ab0e8..9bd3ea3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cashu" -version = "0.0.1" +version = "0.1.8" description = "Ecash wallet and mint." authors = ["calle "] license = "MIT" @@ -38,6 +38,8 @@ isort = "^5.10.1" [tool.poetry.group.dev.dependencies] mypy = "^0.971" +black = {version = "^22.8.0", allow-prereleases = true} +isort = "^5.10.1" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/wallet/cashu.py b/wallet/cashu.py index 165692f..94394a2 100755 --- a/wallet/cashu.py +++ b/wallet/cashu.py @@ -40,11 +40,7 @@ class NaturalOrderGroup(click.Group): @click.option("--host", "-h", default=MINT_URL, help="Mint address.") @click.option("--wallet", "-w", "walletname", default="wallet", help="Wallet to use.") @click.pass_context -def cli( - ctx, - host: str, - walletname: str, -): +def cli(ctx, host: str, walletname: str): ctx.ensure_object(dict) ctx.obj["HOST"] = host ctx.obj["WALLET_NAME"] = walletname @@ -127,17 +123,27 @@ async def receive(ctx, token: str): @cli.command("burn", help="Burn spent tokens.") @click.argument("token", required=False, type=str) @click.option("--all", "-a", default=False, is_flag=True, help="Burn all spent tokens.") +@click.option( + "--force", "-f", default=False, is_flag=True, help="Force check on all tokens." +) @click.pass_context @coro -async def burn(ctx, token: str, all: bool): +async def burn(ctx, token: str, all: bool, force: bool): wallet: Wallet = ctx.obj["WALLET"] await init_wallet(wallet) - if not (all or token) or (token and all): - print("Error: enter a token or use --all to burn all pending tokens.") + if not (all or token or force) or (token and all): + print( + "Error: enter a token or use --all to burn all pending tokens or --force to check all tokens." + ) return if all: + # check only those who are flagged as reserved proofs = await get_reserved_proofs(wallet.db) + if force: + # check all proofs in db + proofs = wallet.proofs else: + # check only the specified ones proofs = [ Proof.from_dict(p) for p in json.loads(base64.urlsafe_b64decode(token)) ] @@ -191,3 +197,16 @@ async def pay(ctx, invoice: str): _, send_proofs = await wallet.split_to_send(wallet.proofs, amount) await wallet.pay_lightning(send_proofs, amount, invoice) wallet.status() + + +@cli.command("info", help="Information about Cashu wallet.") +@click.pass_context +@coro +async def info(ctx): + wallet: Wallet = ctx.obj["WALLET"] + await init_wallet(wallet) + wallet.status() + print(f"Debug: {DEBUG}") + print(f"Cashu dir: {CASHU_DIR}") + print(f"Mint URL: {MINT_URL}") + return