From 4d391382b1e1c6d784e2fb82079ff26e223088c6 Mon Sep 17 00:00:00 2001 From: sihamon <126967444+sihamon@users.noreply.github.com> Date: Wed, 8 Mar 2023 19:10:19 +0100 Subject: [PATCH] Allow to receive all pending tokens (#132) --- cashu/wallet/cli/cli.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cashu/wallet/cli/cli.py b/cashu/wallet/cli/cli.py index 4b81dd8..f4e7322 100644 --- a/cashu/wallet/cli/cli.py +++ b/cashu/wallet/cli/cli.py @@ -396,6 +396,7 @@ async def receive(ctx: Context, token: str, lock: str): @click.option( "--nostr", "-n", default=False, is_flag=True, help="Receive tokens via nostr." ) +@click.option("--all", "-a", default=False, is_flag=True, help="Receive all pending tokens.") @click.option( "--verbose", "-v", @@ -406,15 +407,22 @@ async def receive(ctx: Context, token: str, lock: str): ) @click.pass_context @coro -async def receive_cli(ctx: Context, token: str, lock: str, nostr: bool, verbose: bool): +async def receive_cli(ctx: Context, token: str, lock: str, nostr: bool, all: bool, verbose: bool): wallet: Wallet = ctx.obj["WALLET"] wallet.status() if token: await receive(ctx, token, lock) elif nostr: await receive_nostr(ctx, verbose) + elif all: + reserved_proofs = await get_reserved_proofs(wallet.db) + if len(reserved_proofs): + for (key, value) in groupby(reserved_proofs, key=itemgetter("send_id")): + proofs = list(value) + token = await wallet.serialize_proofs(proofs) + await receive(ctx, token, lock) else: - print("Error: enter token or use the flag --nostr.") + print("Error: enter token or use either flag --nostr or --all.") @cli.command("burn", help="Burn spent tokens.")