From dd26491619ae33e74f001675d2cffc1421910699 Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Mon, 2 Sep 2019 07:04:29 +0530 Subject: [PATCH] New api to check if given hash is blockhash, transactionhash or noise --- ranchimallflo_api.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ranchimallflo_api.py b/ranchimallflo_api.py index 09d5c95..734a9b8 100644 --- a/ranchimallflo_api.py +++ b/ranchimallflo_api.py @@ -570,6 +570,21 @@ async def getLatestBlockDetails(): return jsonify(result='ok', latestBlocks=tempdict) +@app.route('/api/v1.0/checkhash/') +async def checkhash(hash): + + # check if the hash is of a transaction + response = requests.get('{}transaction/{}'.format(apiUrl,hash)) + if response.status_code == 200: + return jsonify(type='transaction') + else: + response = requests.get('{}block/{}'.format(apiUrl,hash)) + if response.status_code == 200: + return jsonify(type='block') + else: + return jsonify(type='noise') + + @app.route('/test') async def test(): return render_template('test.html')