This commit is contained in:
callebtc
2022-09-22 14:23:07 +03:00
parent de6a527d44
commit 8dfe2b8511
6 changed files with 34 additions and 11 deletions

View File

@@ -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).

2
poetry.lock generated
View File

@@ -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 = [

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "cashu"
version = "0.0.1"
version = "0.1.8"
description = "Ecash wallet and mint."
authors = ["calle <callebtc@protonmail.com>"]
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"]

View File

@@ -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