-
Notifications
You must be signed in to change notification settings - Fork 3
/
getTransX.py
116 lines (79 loc) · 2.97 KB
/
getTransX.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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
from bloxplorer import bitcoin_explorer as explorer
from bitcash import PrivateKey
import bitsv
import json
import requests
from bs4 import BeautifulSoup
#https://github.com/sporestack/bitcash
#https://github.com/valinsky/bloxplorer
#https://github.com/AustEcon/bitsv
# good job people <3
def get_bal_from_BTG_page_content(tableStr):
cont = []
tempStr = ''
f = False
for char in tableStr:
if char == '<':
if tempStr!='':
cont.append(tempStr)
tempStr = ''
f = False
if f:
if char!=' ':
tempStr = tempStr + char
if char=='>':
f = True
tempStr = ''
f = False
for elem in cont:
if elem=='BTG':
f=False
if f:
tempStr = tempStr + elem
if elem=='Balance:':
f = True
return tempStr
def get_BTG_balance_bitinfo(address):
default_Parser = 'lxml'
tokenviewURL = 'https://bitinfocharts.com/bitcoin%20gold/address/' + address
#https://bitinfocharts.com/bitcoin%20gold/address/1ErMsR99tfkp8tBANRV5iyn1W3QdLsWaS6
raw_html = requests.get(tokenviewURL)
soup = BeautifulSoup(raw_html.content, default_Parser)
tables = soup.find_all('table')
if len(tables)==0:
return -1
else:
extrStr = str(tables[0])
return (get_bal_from_BTG_page_content(extrStr))
# if the page returns an empty html, return -1.
# not returning 0,
# as it can be confused with a 0 balance wallet.
# this is the case where the given wallet doesn't exist on the fork
def get_BTG_Balance(pub_key, sec_key):
return (get_BTG_balance_bitinfo(pub_key))
def get_BSV_Balance(pub_key, sec_key):
tK = bitsv.Key(sec_key)
return (tK.balance)
def get_BCH_Balance(pub_key, sec_key):
tK = PrivateKey(sec_key)
return (tK.balance)
def get_BTC_UTXO(pub_key, sec_key):
blx_api_response = explorer.addr.get_utxo(pub_key)
blx_response_dict = blx_api_response.data
return (len(blx_response_dict))
# utxo_list = [] // can have a method to return the utxo list. seems intriguing, gonna leave this here
def get_All_Bals(pub_key, sec_key):
output = []
output.append(get_BTC_UTXO(pub_key, sec_key))
output.append(get_BCH_Balance(pub_key, sec_key))
output.append(get_BSV_Balance(pub_key, sec_key))
output.append(get_BTG_Balance(pub_key, sec_key))
return output
jsonFile = open('privKeys.json',)
wallets = json.load(jsonFile)
jsonFile.close()
test_wallets = wallets
#public_kw_list = test_wallets.keys()
for iter_pub_key, iter_secret_key in test_wallets.items():
secret_key_sliced = iter_secret_key[6:]
print (get_All_Bals(iter_pub_key, secret_key_sliced) )