Last active
August 15, 2018 02:45
-
-
Save yellowred/c93288db6897ae29745a4f19ec752a17 to your computer and use it in GitHub Desktop.
Check whether an account commenced a double baking lately
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Get double baking events from Tezos blockchain and check whether an offender was a certain baker. | |
me - your baker address, | |
tail - history length to check for double baking, | |
url - public api to use. | |
@source https://gist.github.com/yellowred/c93288db6897ae29745a4f19ec752a17 | |
""" | |
import urllib, json, sys | |
tail = '100' | |
me = 'tz1XQ7SRj4QQWjaeebNd8dFwuTrCot3GGDRF' | |
url = "http://api.tzscan.io/v1/operations?type=Double_baking_evidence&p=0&number=" + tail | |
response = urllib.urlopen(url) | |
data = json.loads(response.read()) | |
double_baked = False | |
for elem in data: | |
for ops in elem['type']['operations']: | |
if ops['offender']['tz'] == me: | |
print elem['hash'] | |
double_baked = True | |
if double_baked: | |
sys.exit(1) | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment