def status(): rev = raw_revision() #print rev try: q = rev['last_block'] except: rev = {'revision': rev} st = raw_stats() #print st try: q = st['properties_count'] except: st = {'stats': st} #coms=commits().get_data() #print coms #try: # coms=json.loads(coms) #except: # coms={'commits':coms} #print rev, st, coms #merged_response = {key: value for (key, value) in (rev.items() + st.items() + coms.items())} merged_response = { key: value for (key, value) in (rev.items() + st.items()) } return jsonify(merged_response)
def featureactivations(): rev = raw_revision() lb = rev['last_block'] ckey = "info:stats:featureactivations:" + str(lb) try: json_response = json.loads(lGet(ckey)) print_debug(("cache looked success", ckey), 7) except: print_debug(("cache looked failed", ckey), 7) ROWS = dbSelect( "select fa.featureid, fa.featurename, fa.activationblock, fa.minimumversion, fa.pending, tx.txhash " "from featureactivations fa, transactions tx where fa.lasttxdbserialnum = tx.txdbserialnum order by fa.featureid" ) response = [] for f in ROWS: response.append({ 'featureid': int(f[0]), 'featurename': f[1], 'activationblock': int(f[2]), 'minimumversion': int(f[3]), 'pending': f[4], 'txhash': f[5] }) json_response = {'activations': response} #cache 60 min lSet(ckey, json.dumps(json_response)) lExpire(ckey, 3600) return jsonify(json_response)
def ask_aspx(): print_debug(request.args,4) args=request.args if "api" not in args: return jsonify({"error":"invalid request"}) api=args['api'] #getbalance prop, address Requests the available balance for a given property ID and address if api=="getbalance": if 'prop' not in args or 'address' not in args: return jsonify({"error":"invalid request"}) prop=args['prop'] address=args['address'] #if is_valid_bitcoin_address(address): #jsonify encapsulates in a string, just return number return balance_propid(address,prop) #else: # return jsonify({"error":"invalid address"}) #getreservedbalance prop, address Requests the reserved balance for a given property ID and address #getpropertybalances prop Requests the balances of all addresses holding tokens of a given property ID elif api=="getpropertybalances": if 'prop' not in args: return jsonify({"error":"invalid request, missing prop"}) #weird formatting, to match legacy oe need to remove curly brackets return jsonify(getpropdistraw(args['prop'])) #gettx txid Requests the transaction details for a given transaction ID elif api=="gettx": if 'txid' not in args: return jsonify({"error":"invalid request, missing txid"}) #weird formatting, to match legacy oe need to remove curly brackets return json.dumps(gettxjson(args['txid']))[1:][:-1] #gettxvalidity txid Requests the validity of a given transaction ID elif api=="gettxvalidity": if 'txid' not in args: return jsonify({"error":"invalid request, missing txid"}) #weird formatting, to match legacy oe need to remove curly brackets return json.dumps(gettxjson(args['txid'])['valid'])[1:][:-1] #gettxblock txid Requests the block number for a given transaction ID elif api=="gettxblock": if 'txid' not in args: return jsonify({"error":"invalid request, missing txid"}) #weird formatting, to match legacy oe need to remove curly brackets return json.dumps(gettxjson(args['txid'])['block']) #gettxconfirmations txid Requests the number of confirmations for a given transaction ID elif api=="gettxconfirmations": if 'txid' not in args: return jsonify({"error":"invalid request, missing txid"}) #weird formatting, to match legacy oe need to remove curly brackets return json.dumps(gettxjson(args['txid'])['confirmations'])[1:][:-1] #getblocktx block Requests the transaction details for all Omni Layer transactions in a given block elif api=="getblocktx": if 'block' not in args: return jsonify({"error":"invalid request, missing block"}) return jsonify(getblocktxjson(args['block'])) #getlastblockprocessed - Requests the last block processed by OmniExplorer.info elif api=="getlastblockprocessed": return json.dumps(raw_revision()['last_block']) #gethistory address Requests the historical transactions for a given address elif api=="gethistory": if 'address' not in args: return jsonify({"error":"invalid request"}) address=args['address'] #if is_valid_bitcoin_address(address): return jsonify( getaddrhist(address,'both')) #else: # return jsonify({"error":"invalid address"}) #getsenderhistory address Requests the historical transactions sent from a given address elif api=="getsenderhistory": if 'address' not in args: return jsonify({"error":"invalid request"}) address=args['address'] #if is_valid_bitcoin_address(address): return jsonify( getaddrhist(address,'send')) #else: # return jsonify({"error":"invalid address"}) #getrecipienthistory address Requests the historical transactions received by a given address elif api=="getrecipienthistory": if 'address' not in args: return jsonify({"error":"invalid request"}) address=args['address'] #if is_valid_bitcoin_address(address): return jsonify( getaddrhist(address,'receive')) #else: # return jsonify({"error":"invalid address"}) #getpropertyname prop Requests the display name for a given property ID elif api=="getpropertyname": try: if 'prop' not in args: raise "missing arg" pid=args['prop'] raw=getpropertyraw(pid) return raw['name'] except Exception, e: print_debug("getpropertyname error: "+str(e),4) return jsonify({"error":"invalid request"})
def revision(): return jsonify(raw_revision())