Use new balance command from GVA
This commit is contained in:
parent
c633fba6a2
commit
7961e589e1
|
@ -27,13 +27,8 @@ class Balance:
|
||||||
queryBuild = gql(
|
queryBuild = gql(
|
||||||
"""
|
"""
|
||||||
query ($pubkey: String!){
|
query ($pubkey: String!){
|
||||||
transactionsHistory(pubkey: $pubkey) {
|
balance(script: $pubkey) {
|
||||||
received {
|
amount
|
||||||
outputs
|
|
||||||
}
|
|
||||||
sent {
|
|
||||||
outputs
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
@ -44,34 +39,15 @@ class Balance:
|
||||||
|
|
||||||
# Send TX document
|
# Send TX document
|
||||||
try:
|
try:
|
||||||
self.historyDoc = self.client.execute(queryBuild, variable_values=paramsBuild)
|
balanceResult = self.client.execute(queryBuild, variable_values=paramsBuild)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
message = ast.literal_eval(str(e))["message"]
|
message = ast.literal_eval(str(e))["message"]
|
||||||
sys.stderr.write("Echec de récupération de l'historique:\n" + message + "\n")
|
sys.stderr.write("Echec de récupération du solde:\n" + message + "\n")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
res = self.historyDoc['transactionsHistory']['received']
|
balanceValue = balanceResult['balance']['amount']
|
||||||
amount=[]
|
print(balanceValue)
|
||||||
for i in res:
|
return balanceValue
|
||||||
for output in i['outputs']:
|
|
||||||
if re.search(self.pubkey, output):
|
|
||||||
amount.append(int(output.split(':')[0]))
|
|
||||||
receivedTotal = sum(amount)
|
|
||||||
|
|
||||||
res = self.historyDoc['transactionsHistory']['sent']
|
|
||||||
amount=[]
|
|
||||||
for i in res:
|
|
||||||
for output in i['outputs']:
|
|
||||||
if not re.search(self.pubkey, output):
|
|
||||||
amount.append(int(output.split(':')[0]))
|
|
||||||
sentTotal = sum(amount)
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: Get all UD from pubkey
|
|
||||||
|
|
||||||
|
|
||||||
total = (receivedTotal-sentTotal)/100
|
|
||||||
print(total)
|
|
||||||
|
|
||||||
def balance(self):
|
def balance(self):
|
||||||
self.sendDoc()
|
self.sendDoc()
|
||||||
|
|
Reference in New Issue