rachel-rose 5 лет назад
Родитель
Сommit
2744ddeeff
1 измененных файлов с 34 добавлено и 35 удалено
  1. 34 35
      scripts/drk

+ 34 - 35
scripts/drk

@@ -5,37 +5,43 @@ import requests
 import json
 import json
 
 
 def arg_parser(client):
 def arg_parser(client):
-    #choices = ['wallet', 'cashierwallet', 'keypair', 'pub']
     parser = argparse.ArgumentParser(prog='drk',
     parser = argparse.ArgumentParser(prog='drk',
                                           usage='%(prog)s [commands]',
                                           usage='%(prog)s [commands]',
                                           description="""DarkFi wallet
                                           description="""DarkFi wallet
                                           command-line tool""")
                                           command-line tool""")
-    parser.add_argument("-k", "--key", action='store_true', help="Generate a new keypair")
-    parser.add_argument("-i", "--info", action='store_true', help="Request info from daemon")
+    subparser = parser.add_subparsers(help='All available commands', title="Commands", dest='cmd')
+    subparser.metavar = 'subcommands';
+    #create = subparser.add_parser('create', help='create a new X')
+    login = subparser.add_parser('login', help='wallet login')
+    test = subparser.add_parser('test', help='test wallet functions')
+
+    #create.add_argument('-kp', '--keypair', dest='keypair', action='store_true', help='Create a new keypair')
+    #create.add_argument('-w', '--wallet', dest='wallet', action='store_true', help='Create a new wallet')
+    #create.add_argument('-c', '--cashier', dest='cashier',action='store_true', help='Create a cashier wallet')
+
+    login.add_argument('-u', '--username', type=str, required=True)
+    login.add_argument('-p', '--password', type=str, required=True)
+
+    test.add_argument('-k', '--key', dest='key', action='store_true', help='Test key')
+    test.add_argument('-p', '--path', dest='path', action='store_true', help='Test path')
+    test.add_argument('-pk', '--pkey', dest='pkey', action='store_true', help='Print test key')
+    test.add_argument('-ck', '--ckey', dest='ckey', action='store_true', help='Cashier test key')
+    test.add_argument('-i', '--info', dest='info', action='store_true', help='Request info from daemon')
+    test.add_argument('-hi', '--hello', dest='hello', action='store_true', help='Test hello')
+    test.add_argument('-w', '--wallet', dest='wallet', action='store_true', help='Create a new wallet')
+    test.add_argument('-c', '--cashier', dest='cashier',action='store_true', help='Create a cashier wallet')
+
     parser.add_argument("-s", "--stop", action='store_true', help="Send a stop signal to the daemon")
     parser.add_argument("-s", "--stop", action='store_true', help="Send a stop signal to the daemon")
-    parser.add_argument("-n", "--new", action='store_true', help="Generate a new wallet")
-    parser.add_argument("-o", "--hello", action='store_true', help="Say hello")
-    parser.add_argument("-c", "--cash", action='store_true', help="Create a new cashier wallet")
-    parser.add_argument("-q", "--ckeygen", action='store_true', help="Cash key gen")
-    parser.add_argument("-x", "--cashkey", action='store_true', help="Print cashierkey")
-    parser.add_argument("-t", "--test", action='store_true', help="Test path")
     args = parser.parse_args()
     args = parser.parse_args()
 
 
-    if args.test:
+    if args.path:
         try:
         try:
             print("Testing path...")
             print("Testing path...")
             client.test_path(client.payload)
             client.test_path(client.payload)
         except Exception:
         except Exception:
             raise
             raise
 
 
-    if args.ckeygen:
-        try:
-            print("Attempting to print cashier key...")
-            client.ckeygen(client.payload)
-        except Exception:
-            raise
-
-    if args.cashkey:
+    if args.pkey:
         try:
         try:
             print("Attempting to print cashier key...")
             print("Attempting to print cashier key...")
             client.cashkey(client.payload)
             client.cashkey(client.payload)
@@ -44,15 +50,15 @@ def arg_parser(client):
 
 
     if args.key:
     if args.key:
         try:
         try:
-            print("Attemping to generate a new key pair...")
+            print("Attemping to generate a create key pair...")
             client.key_gen(client.payload)
             client.key_gen(client.payload)
         except Exception:
         except Exception:
             raise
             raise
 
 
-    if args.new:
+    if args.wallet:
         try:
         try:
-            print("Attemping to generate a new wallet...")
-            client.new_wallet(client.payload)
+            print("Attemping to generate a create wallet...")
+            client.create_wallet(client.payload)
         except Exception:
         except Exception:
             raise
             raise
 
 
@@ -79,20 +85,13 @@ def arg_parser(client):
         except Exception:
         except Exception:
             raise
             raise
 
 
-    if args.cash:
+    if args.cashier:
         try:
         try:
             print("Cash was entered")
             print("Cash was entered")
-            client.new_cashier_wallet(client.payload)
+            client.create_cashier_wallet(client.payload)
         except Exception:
         except Exception:
             raise
             raise
 
 
-    #if args.wallet:
-    #    try:
-    #        print("This worked")
-    #    except Exception:
-    #        raise
-
-
 # TODO: refactor into async
 # TODO: refactor into async
 class DarkClient:
 class DarkClient:
     # TODO: generate random ID (4 byte unsigned int) (rand range 0 - max size
     # TODO: generate random ID (4 byte unsigned int) (rand range 0 - max size
@@ -155,15 +154,15 @@ class DarkClient:
         hello = self.__request(payload)
         hello = self.__request(payload)
         print(hello)
         print(hello)
     
     
-    def new_wallet(self, payload):
-        payload['method'] = "new_wallet"
+    def create_wallet(self, payload):
+        payload['method'] = "create_wallet"
         payload['jsonrpc'] = "2.0"
         payload['jsonrpc'] = "2.0"
         payload['id'] = "0"
         payload['id'] = "0"
         wallet = self.__request(payload)
         wallet = self.__request(payload)
         print(wallet)
         print(wallet)
 
 
-    def new_cashier_wallet(self, payload):
-        payload['method'] = "new_cashier_wallet"
+    def create_cashier_wallet(self, payload):
+        payload['method'] = "create_cashier_wallet"
         payload['jsonrpc'] = "2.0"
         payload['jsonrpc'] = "2.0"
         payload['id'] = "0"
         payload['id'] = "0"
         wallet = self.__request(payload)
         wallet = self.__request(payload)