mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-22 03:24:18 +01:00
Allow to receive all pending tokens (#132)
This commit is contained in:
@@ -396,6 +396,7 @@ async def receive(ctx: Context, token: str, lock: str):
|
|||||||
@click.option(
|
@click.option(
|
||||||
"--nostr", "-n", default=False, is_flag=True, help="Receive tokens via nostr."
|
"--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(
|
@click.option(
|
||||||
"--verbose",
|
"--verbose",
|
||||||
"-v",
|
"-v",
|
||||||
@@ -406,15 +407,22 @@ async def receive(ctx: Context, token: str, lock: str):
|
|||||||
)
|
)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
@coro
|
@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: Wallet = ctx.obj["WALLET"]
|
||||||
wallet.status()
|
wallet.status()
|
||||||
if token:
|
if token:
|
||||||
await receive(ctx, token, lock)
|
await receive(ctx, token, lock)
|
||||||
elif nostr:
|
elif nostr:
|
||||||
await receive_nostr(ctx, verbose)
|
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:
|
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.")
|
@cli.command("burn", help="Burn spent tokens.")
|
||||||
|
|||||||
Reference in New Issue
Block a user