Skip to content

Commit 720663d

Browse files
authored
Update SoloMiner.pyw
1 parent 6e1cf23 commit 720663d

File tree

1 file changed

+12
-29
lines changed

1 file changed

+12
-29
lines changed

SoloMiner.pyw

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
#Setting
2-
# Mining Address **Change Me**
31
address = 'bc1qwp44lvxgrhh42de507kezjspcyh8cvw6tvuykp'
4-
# Mining Pool **Consider Before Change**
52
pool = "solo.ckpool.org"
63
port = 3333
7-
import requests,socket,threading,json,hashlib,binascii,random,time,traceback,psutil
4+
import requests,socket,threading,json,hashlib,binascii,random,time,traceback
85
import context as ctx
96
from signal import SIGINT, signal
10-
from colorama import Back, Fore, Style
11-
from tabulate import tabulate
127
sock = None
138
best_difficulty = 0
14-
best_hash = None
159
difficulty = 16
1610
best_share_difficulty = float('inf')
1711
best_share_hash = None
@@ -44,7 +38,7 @@ class ExitedThread(threading.Thread):
4438
try:
4539
self.thread_handler2(arg)
4640
except Exception as e:
47-
print("I am So Fucking Tired")
41+
Fuck=Fuck+1
4842
ctx.listfThreadRunning[n] = False
4943
time.sleep(2)
5044
def thread_handler2(self, arg):
@@ -57,11 +51,9 @@ class ExitedThread(threading.Thread):
5751
best_difficulty = 16
5852
def bitcoin_miner(t, restarted=False):
5953
global best_share_difficulty, best_share_hash
60-
start_time = time.time()
61-
total_hashes = 0
6254
share_difficulty = 0
6355
difficulty = 16
64-
best_difficulty = 0
56+
best_difficulty = 0
6557
target = (ctx.nbits[2:] + '00' * (int(ctx.nbits[:2], 16) - 3)).zfill(64)
6658
extranonce2 = hex(random.randint(0, 2**32 - 1))[2:].zfill(2 * ctx.extranonce2_size)
6759
coinbase = ctx.coinb1 + ctx.extranonce1 + extranonce2 + ctx.coinb2
@@ -77,13 +69,7 @@ def bitcoin_miner(t, restarted=False):
7769
def calculate_difficulty(target, hash_hex):
7870
hash_int = int(hash_hex, 16)
7971
target_int = int(target, 16)
80-
return target_int / max(hash_int, 1)
81-
def log_metrics(start_time, nonce, hashes_computed, best_difficulty, best_hash):
82-
elapsed_time = time.time() - start_time
83-
hash_rate = hashes_computed / max(elapsed_time, 1)
84-
prev_progress_percentage = None
85-
total_hashes = 0
86-
hash_rate = 0.0
72+
return target_int / max(hash_int, 1)
8773
while True:
8874
t.check_self_shutdown()
8975
if t.exit:
@@ -96,18 +82,19 @@ def bitcoin_miner(t, restarted=False):
9682
blockheader = ctx.version + ctx.prevhash + merkle_root + ctx.ntime + ctx.nbits + nonce + '000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000'
9783
hash = hashlib.sha256(hashlib.sha256(binascii.unhexlify(blockheader)).digest()).digest()
9884
hash = binascii.hexlify(hash).decode()
99-
ctx.total_hashes_computed += 1
100-
target_difficulty = '0000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'
85+
ctx.total_hashes_computed += 1
10186
this_hash = int(hash, 16)
10287
difficulty = _diff / this_hash
10388
if difficulty > best_difficulty:
10489
best_difficulty = difficulty
105-
best_hash = hash
10690
if ctx.nHeightDiff[work_on + 1] < difficulty:
10791
ctx.nHeightDiff[work_on + 1] = difficulty
108-
total_hashes += 1
109-
elapsed_time = time.time() - start_time
110-
hash_rate = total_hashes / elapsed_time
92+
if hash < target:
93+
payload = bytes('{"params": ["' + address + '", "' + ctx.job_id + '", "' + ctx.extranonce2 + '", "' + ctx.ntime + '", "' + nonce + '"], "id": 1, "method": "mining.submit"}\n', 'utf-8')
94+
sock.sendall(payload)
95+
ret = sock.recv(1024)
96+
time.sleep(1)
97+
return True
11198
if difficulty >= 16:
11299
share_payload = {
113100
"params": [address, ctx.job_id, ctx.extranonce2, ctx.ntime, nonce],
@@ -123,8 +110,6 @@ def bitcoin_miner(t, restarted=False):
123110
best_share_hash = hash
124111
if ctx.nHeightDiff[work_on + 1] < share_difficulty:
125112
ctx.nHeightDiff[work_on + 1] = share_difficulty
126-
elapsed_time = time.time() - start_time
127-
hash_rate = total_hashes / elapsed_time
128113
def block_listener(t) :
129114
sock = socket.socket(socket.AF_INET , socket.SOCK_STREAM)
130115
sock.connect((pool , port))
@@ -148,7 +133,6 @@ def block_listener(t) :
148133
while response.count(b'\n') < 4 and not (b'mining.notify' in response) : response += sock.recv(1024)
149134
responses = [json.loads(res) for res in response.decode().split('\n') if
150135
len(res.strip()) > 0 and 'mining.notify' in res]
151-
152136
if responses[0]['params'][1] != ctx.prevhash :
153137
ctx.job_id, ctx.prevhash, ctx.coinb1, ctx.coinb2, ctx.merkle_branch, ctx.version, ctx.nbits, ctx.ntime, ctx.clean_jobs = responses[0]['params']
154138
class CoinMinerThread(ExitedThread) :
@@ -185,9 +169,8 @@ def StartMining() :
185169
time.sleep(4)
186170
miner_t = CoinMinerThread(None)
187171
miner_t.start()
188-
time.sleep(1)
189172
if __name__ == '__main__':
190173
ctx.total_hashes_computed = 0
191174
ctx.mining_time_per_block = []
192175
signal(SIGINT, handler)
193-
StartMining()
176+
StartMining()

0 commit comments

Comments
 (0)