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