improve module import

This commit is contained in:
poka 2020-11-17 04:15:24 +01:00
parent 9f5ae2fb61
commit 4cedf50a8e
2 changed files with 5 additions and 9 deletions

View File

@ -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)

9
pay.py
View File

@ -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: