refactor receive

This commit is contained in:
callebtc
2022-12-26 16:46:45 +01:00
parent 96018cee45
commit 5a8dc1c898

View File

@@ -233,11 +233,6 @@ async def send(ctx, amount: int, lock: str):
wallet.status()
@cli.command("receive", help="Receive tokens.")
@click.argument("token", type=str)
@click.option("--lock", "-l", default=None, help="Unlock tokens.", type=str)
@click.pass_context
@coro
async def receive(ctx, token: str, lock: str):
wallet: Wallet = ctx.obj["WALLET"]
await wallet.load_mint()
@@ -260,6 +255,15 @@ async def receive(ctx, token: str, lock: str):
wallet.status()
@cli.command("receive", help="Receive tokens.")
@click.argument("token", type=str)
@click.option("--lock", "-l", default=None, help="Unlock tokens.", type=str)
@click.pass_context
@coro
async def receive_cli(ctx, token: str, lock: str):
await receive(ctx, token, lock)
@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.")
@@ -455,14 +459,15 @@ async def nostr(ctx):
client = NostrClient(privatekey_hex=NOSTR_PRIVATE_KEY)
await asyncio.sleep(2)
await receive(ctx, "asd", "")
def get_token_callback(event: Event, decrypted_content):
# print(
# f"From {event.public_key[:3]}..{event.public_key[-3:]}: {decrypted_content}"
# )
print(
f"From {event.public_key[:3]}..{event.public_key[-3:]}: {decrypted_content}"
)
try:
# call the receive method
asyncio.run(receive(ctx, decrypted_content))
asyncio.run(receive(ctx, decrypted_content, ""))
except Exception as e:
pass