Adding gettokenbalances API
This commit is contained in:
parent
98612dbd81
commit
d520da7c68
@ -108,6 +108,32 @@ def gettransactions():
|
|||||||
return jsonify(result='ok', transactions=rowarray_list)
|
return jsonify(result='ok', transactions=rowarray_list)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/v1.0/gettokenbalances', methods=['GET'])
|
||||||
|
def gettokenbalances():
|
||||||
|
token = request.args.get('token')
|
||||||
|
if token is None:
|
||||||
|
return jsonify(result='error')
|
||||||
|
|
||||||
|
dblocation = dbfolder + '/tokens/' + str(token) + '.db'
|
||||||
|
if os.path.exists(dblocation):
|
||||||
|
conn = sqlite3.connect(dblocation)
|
||||||
|
c = conn.cursor()
|
||||||
|
else:
|
||||||
|
return 'Token doesn\'t exist'
|
||||||
|
c.execute('SELECT address,SUM(transferBalance) FROM activeTable GROUP BY address')
|
||||||
|
addressBalances = c.fetchall()
|
||||||
|
|
||||||
|
returnList = []
|
||||||
|
|
||||||
|
for address in addressBalances:
|
||||||
|
tempdict = {}
|
||||||
|
tempdict['address'] = address[0]
|
||||||
|
tempdict['balance'] = address[1]
|
||||||
|
returnList.append(tempdict)
|
||||||
|
|
||||||
|
return jsonify(result='ok', balances=returnList)
|
||||||
|
|
||||||
|
|
||||||
# SMART CONTRACT APIs
|
# SMART CONTRACT APIs
|
||||||
|
|
||||||
@app.route('/api/v1.0/getsmartContractlist', methods=['GET'])
|
@app.route('/api/v1.0/getsmartContractlist', methods=['GET'])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user