util.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import argparse
  2. async def arg_parser(client):
  3. parser = argparse.ArgumentParser(
  4. prog='drk',
  5. usage='%(prog)s [commands]',
  6. description="""DarkFi wallet command-line tool"""
  7. )
  8. parser.add_argument('-c', '--cashier', action='store_true', help='Create a cashier wallet')
  9. parser.add_argument('-w', '--wallet', action='store_true', help='Create a new wallet')
  10. parser.add_argument('-k', '--key', action='store_true', help='Test key')
  11. parser.add_argument('-i', '--info', action='store_true', help='Request info from daemon')
  12. parser.add_argument('-hi', '--hello', action='store_true', help='Test hello')
  13. parser.add_argument("-s", "--stop", action='store_true', help="Send a stop signal to the daemon")
  14. parser.add_argument("-t", "--test", action='store_true', help="Test writing to the wallet")
  15. try:
  16. args = parser.parse_args()
  17. if args.key:
  18. print("Attemping to generate a create key pair...")
  19. await client.key_gen(client.payload)
  20. if args.wallet:
  21. print("Attemping to create a wallet...")
  22. await client.create_wallet(client.payload)
  23. if args.info:
  24. print("Info was entered")
  25. await client.get_info(client.payload)
  26. print("Requesting daemon info...")
  27. if args.stop:
  28. print("Stop was entered")
  29. await client.stop(client.payload)
  30. print("Sending a stop signal...")
  31. if args.hello:
  32. print("Hello was entered")
  33. await client.say_hello(client.payload)
  34. if args.cashier:
  35. print("Attempting to generate a cashier wallet...")
  36. await client.create_cashier_wallet(client.payload)
  37. if args.test:
  38. print("Testing wallet write")
  39. await client.test_wallet(client.payload)
  40. except Exception:
  41. raise