-
Notifications
You must be signed in to change notification settings - Fork 1
/
puller.py
60 lines (58 loc) · 2.63 KB
/
puller.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
import hashlib
import secrets
import binascii
from binascii import unhexlify, hexlify
import csv
import random
################################
print("##########################################################")
################################
# Version + hashPrevBlock + hashMerkleRoot + Time + Bits + Nonce
# print("##########################################################")
################################
with open('list.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
for i in row:
def ensure_10_digits(i):
if len(i) >= 10:
i = i
print(i)
else:
additional_digits = ''.join(str(random.randint(0, 9)) for _ in range(10 - len(i)))
i = i + additional_digits
print(i)
#ensure_10_digits(i)
Nonce = str(i)
Version = "20000000"
hashPrevBlock = "0000000000000000000571509eac4819dae8ff2c320c487cfd612d36db7ffe1a"
hashMerkleRoot = "e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122b"
Time = "1672956895"
Bits = "1708417e"
# Variables
#Version = "01000000"
#hashPrevBlock = "0000000000000000000571509eac4819dae8ff2c320c487cfd612d36db7ffe1a"
#hashMerkleRoot = "e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122b"
#Time = "1672956895"
#Bits = "1708417e"
#Nonce = "42014695"
# Check
header_hex = (Version + hashPrevBlock + hashMerkleRoot + Time + Bits + Nonce)
def process_header(header_hex):
if len(header_hex) % 2 == 0:
header_bin = unhexlify(header_hex)
hash = hashlib.sha256(hashlib.sha256(header_bin).digest()).digest()
hexyh = hexlify(hash).decode("utf-8")
newBlockHash = hexlify(hash[::-1]).decode("utf-8")
print("preBlockHash", hashPrevBlock)
print("newBlockHash", newBlockHash)
else:
# add a leading zero to make the string an even length
header_hex = "0" + header_hex
header_bin = unhexlify(header_hex)
hash = hashlib.sha256(hashlib.sha256(header_bin).digest()).digest()
hexyh = hexlify(hash).decode("utf-8")
newBlockHash = hexlify(hash[::-1]).decode("utf-8")
print("preBlockHash", hashPrevBlock)
print("newBlockHash", newBlockHash)
process_header(header_hex)