Skip to content

Instantly share code, notes, and snippets.

@yellowred
Last active August 15, 2018 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yellowred/c93288db6897ae29745a4f19ec752a17 to your computer and use it in GitHub Desktop.
Save yellowred/c93288db6897ae29745a4f19ec752a17 to your computer and use it in GitHub Desktop.
Check whether an account commenced a double baking lately
#!/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