-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblkchn_digger.py
executable file
·36 lines (26 loc) · 1.08 KB
/
blkchn_digger.py
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
#!/usr/bin/env python
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
import csv
rpc_user = "lusddm"
rpc_password = "2t2e8o"
rpc_connection = AuthServiceProxy("http://%s:%[email protected]:8332"%(rpc_user, rpc_password))
for j in range(399001, 450000, 1000):
print "starting range [" + str(j) + ", " + str(j+999) + "]... "
commands = [[ "getblockhash", height] for height in range(j,j+1000)]
block_hashes = rpc_connection.batch_(commands)
commands = [[ "getblock", block_hash] for block_hash in block_hashes]
block_infos = rpc_connection.batch_(commands)
n = len(block_hashes)
res = []
for i in range(len(block_hashes)):
txs = block_infos[i]['tx']
commands = [[ "getrawtransaction", tx, 1 ] for tx in txs]
tx_info = rpc_connection.batch_(commands)
for t in tx_info:
if(len(t['vin']) > 1):
res.append((t['txid'], len(t['vin'])))
filename = 'csv/test' + str(j) + '.csv'
csv_file = open(filename, "wb")
writer = csv.writer(csv_file)
for row in res:
writer.writerow(row)