forked from ymgve/bitcoin_fork_claimer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsightlookup.py
22 lines (18 loc) · 834 Bytes
/
insightlookup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import argparse, json, urllib2
parser = argparse.ArgumentParser()
parser.add_argument("url", help="Insight block explorer base URL, like https://explorer.bitcoininterest.io")
parser.add_argument("address", help="Address to look up")
args = parser.parse_args()
url = args.url.rstrip("/")
pagenum = 0
while True:
res = urllib2.urlopen(url + "/api/txs?address=%s&pageNum=%d" % (args.address, pagenum))
addrinfo = json.loads(res.read())
for tx in addrinfo["txs"]:
for vout in tx["vout"]:
for addr in vout["scriptPubKey"]["addresses"]:
if addr == args.address:
print "Found transaction, txid %s txindex %d value %s" % (tx["txid"], vout["n"], vout["value"])
pagenum += 1
if "pagesTotal" not in addrinfo or int(addrinfo["pagesTotal"]) >= pagenum:
break