-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopCodes.py
More file actions
68 lines (50 loc) · 1.96 KB
/
opCodes.py
File metadata and controls
68 lines (50 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/python
# -*- coding: utf-8 -*-
import time
import base64
import json
import requests
api_token = '147GjmCAREtYv7FdfDivthzcmQLmdEhSYe'
def bitd(querry):
bitdbString64 = base64.b64encode(querry.encode()).decode("utf-8")
# print(bitdbString64)
url = "https://genesis.bitdb.network/q/1FnauZ9aUH2Bex6JzdcV4eNX7oLSSEbxtN/" + bitdbString64
headers = {'key': api_token}
response = requests.get(url, headers=headers)
response = response.json()
confirmedResponse = response['c']
return(confirmedResponse)
def getOutput(getOpTxs):
opoutput = dict()
opreturn = dict()
OP_DUP = dict()
OP_DUP["count"] = 0
OP_HASH160 = dict()
OP_HASH160["count"] = 0
OP_RETURN = dict()
OP_RETURN["count"] = 0
for tx in getOpTxs:
txID = tx["tx"]["h"]
for data in tx["out"]:
data = data["str"].split(" ")
if data[0] == "OP_DUP":
OP_DUP["count"] = OP_DUP["count"] + 1
OP_DUP["txExample"] = tx
elif data[0] == "OP_HASH160":
OP_HASH160["count"] = OP_HASH160["count"] + 1
OP_HASH160["txExample"] = tx
elif data[0] == "OP_RETURN":
OP_RETURN["count"] = OP_RETURN["count"] + 1
OP_RETURN["txExample"] = tx
else:
opoutput[data[0]] = 0
opoutput["OP_DUP"] = OP_DUP
opoutput["OP_HASH160"] = OP_HASH160
opoutput["OP_RETURN"] = OP_RETURN
print(json.dumps(opoutput, indent=4, sort_keys=True))
getLatestBlockQuerry = '{"v":3,"q":{"db":["c"],"find":{},"limit":1},"r":{"f":"[.[] | .blk | { current_blockheight: .i} ]"}}'
getLatestBlock = bitd(getLatestBlockQuerry)
current_blockheight = getLatestBlock[0]["current_blockheight"]
getOpTxs = '{"e":{"out.b1":"hex"},"q":{"find":{"blk.i":'+ str(current_blockheight) +'},"limit":1000,"project":{"blk.i":1,"out.str":1,"tx.h":1}},"v":3}'
getOpTxs = bitd(getOpTxs)
getOutput(getOpTxs)