Allow to receive all pending tokens (#132)

This commit is contained in:
sihamon
2023-03-08 19:10:19 +01:00
committed by GitHub
parent cd1fddb524
commit 4d391382b1

View File

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