Add hangling errors
This commit is contained in:
parent
af39a60395
commit
94b007d3ea
|
@ -2,7 +2,7 @@
|
|||
|
||||
**Requierement**:
|
||||
```
|
||||
pip3 install --pre gql
|
||||
pip3 install -r requirements.txt
|
||||
chmod u+x pay.py
|
||||
```
|
||||
|
||||
|
|
25
pay.py
25
pay.py
|
@ -1,10 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys, os.path
|
||||
import sys, os.path, json
|
||||
from shutil import copyfile
|
||||
if not os.path.isfile("userEnv.py"):
|
||||
copyfile("userEnv.py.template", "userEnv.py")
|
||||
|
||||
from userEnv import issuer, dunikey, node
|
||||
from natools import fmt, sign, get_privkey
|
||||
from gql import gql, Client
|
||||
|
@ -23,7 +22,6 @@ amount = int(sys.argv[2])
|
|||
comment = sys.argv[3]
|
||||
|
||||
## GraphQL queries
|
||||
|
||||
# Build the TX Document
|
||||
queryBuild = gql(
|
||||
"""
|
||||
|
@ -44,14 +42,20 @@ paramsBuild = {
|
|||
}
|
||||
|
||||
# Send TX document
|
||||
try:
|
||||
txDoc = str(client.execute(queryBuild, variable_values=paramsBuild))[13:-3].replace('\\n','\n').encode()
|
||||
print("Document généré avec succès.")
|
||||
except Exception as e:
|
||||
print("Echec d'obtention du document de transaction:" + str(e))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
||||
# Sign TX document
|
||||
|
||||
signature = fmt["64"](sign(txDoc, get_privkey(dunikey, "pubsec"))[:-len(txDoc)])
|
||||
signedDoc = txDoc.decode() + signature.decode()
|
||||
|
||||
print(signedDoc)
|
||||
#print(signedDoc) # For debug
|
||||
|
||||
querySign = gql(
|
||||
"""
|
||||
|
@ -70,8 +74,13 @@ paramsSign = {
|
|||
}
|
||||
|
||||
# Send TX Signed document
|
||||
result = client.execute(querySign, variable_values=paramsSign)
|
||||
try:
|
||||
sentTX = client.execute(querySign, variable_values=paramsSign)
|
||||
print("Transaction effectué avec succès !")
|
||||
except Exception as e:
|
||||
print("Echec de la transaction:" + str(e))
|
||||
sys.exit(1)
|
||||
|
||||
#print(sentTX) #For debug
|
||||
|
||||
# print the result
|
||||
print(result)
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
gql
|
||||
duniterpy
|
Reference in New Issue