diff --git a/libs/paylib.py b/libs/paylib.py index b3c7428..8f522b0 100644 --- a/libs/paylib.py +++ b/libs/paylib.py @@ -19,7 +19,7 @@ transport = AIOHTTPTransport(url=node) client = Client(transport=transport, fetch_schema_from_transport=True) issuer = get_privkey(dunikey, "pubsec").pubkey -def sendGenDoc(recipient, amount, comment): +def sendGenDoc(recipient, amount, comment=''): # TODO: Check args # Build TX generation document @@ -52,7 +52,7 @@ def sendGenDoc(recipient, amount, comment): # Check document -def checkTXDoc(txDoc, recipient, amount, comment): +def checkTXDoc(txDoc, recipient, amount, comment=''): docList = txDoc.splitlines() for i, line in enumerate(docList): if re.search("Issuers:", line): @@ -108,4 +108,3 @@ def sendTXDoc(signedDoc): sys.stderr.write("Echec de la transaction:\n" + message + "\n") sys.exit(1) - \ No newline at end of file diff --git a/pay.py b/pay.py index 449e12a..1acce79 100755 --- a/pay.py +++ b/pay.py @@ -1,8 +1,7 @@ #!/usr/bin/env python3 import sys -sys.path.insert(1, 'libs') -from paylib import * +from libs.paylib import sendGenDoc, checkTXDoc, signDoc, sendTXDoc # Get args try: @@ -10,16 +9,14 @@ try: amount = int(sys.argv[2]) if len(sys.argv) > 3: comment = sys.argv[3] - else: - comment = "" except Exception as e: print("Please enter the recipient's public and the amount\n" + str(e)) sys.exit(1) # Execute workflow ## Generate TX document from server and check it -returnGen = sendGenDoc(recipient, amount, comment) -docIsOK = checkTXDoc(returnGen, recipient, amount, comment) +returnGen = sendGenDoc(recipient, amount, comment='') +docIsOK = checkTXDoc(returnGen, recipient, amount, comment='') # Confirm TX document is ok, sign and send it if docIsOK: