mirror of
https://github.com/curly60e/pyblock.git
synced 2026-08-13 12:33:15 +02:00
89 lines
3.4 KiB
Python
89 lines
3.4 KiB
Python
# Symbolic-Hash-Satoshi.
|
|
# SHS by PyBLOCK Crew.
|
|
|
|
import socket
|
|
import json
|
|
import hashlib
|
|
import binascii
|
|
from pprint import pprint
|
|
import random
|
|
import secrets
|
|
import signal
|
|
import sys
|
|
signal.signal(signal.SIGINT, lambda x, y: sys.exit(0))
|
|
|
|
address = '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'
|
|
nonce = hex(secrets.randbelow(2**32))[2:].zfill(8)
|
|
host = 'pool110.pyblock.xyz'
|
|
port = 4445
|
|
|
|
def main():
|
|
print("\nSatoshi: {}\n\nNonce: {}\n".format(address,nonce))
|
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
try:
|
|
sock.connect((host,port))
|
|
|
|
sock.sendall(b'{"id": 1, "method": "mining.subscribe", "params": []}\n')
|
|
lines = sock.recv(1024).decode().split('\n')
|
|
response = json.loads(lines[0])
|
|
sub_details,extranonce1,extranonce2_size = response['result']
|
|
|
|
sock.sendall(b'{"params": ["'+address.encode()+b'", "password"], "id": 2, "method": "mining.authorize"}\n')
|
|
|
|
response = b''
|
|
while response.count(b'\n') < 4 and not(b'mining.notify' in response):
|
|
response += sock.recv(1024)
|
|
|
|
|
|
responses = [json.loads(res) for res in response.decode().split('\n') if len(res.strip())>0 and 'mining.notify' in res]
|
|
pprint(responses)
|
|
|
|
job_id,prevhash,coinb1,coinb2,merkle_branch,version,nbits,ntime,clean_jobs \
|
|
= responses[0]['params']
|
|
|
|
target = (nbits[2:]+'00'*(int(nbits[:2],16) - 3)).zfill(64)
|
|
print('\nNbits: {}\n\nTarget: {}\n'.format(nbits,target))
|
|
|
|
extranonce2 = hex(secrets.randbelow(2**32))[2:].zfill(2*extranonce2_size)
|
|
|
|
coinbase = coinb1 + extranonce1 + extranonce2 + coinb2
|
|
coinbase_hash_bin = hashlib.sha256(hashlib.sha256(binascii.unhexlify(coinbase)).digest()).digest()
|
|
|
|
print('Coinbase: {}\n\nCoinbase Hash: {}\n'.format(coinbase,binascii.hexlify(coinbase_hash_bin)))
|
|
merkle_root = coinbase_hash_bin
|
|
for h in merkle_branch:
|
|
merkle_root = hashlib.sha256(hashlib.sha256(merkle_root + binascii.unhexlify(h)).digest()).digest()
|
|
|
|
merkle_root = binascii.hexlify(merkle_root).decode()
|
|
|
|
merkle_root = ''.join([merkle_root[i]+merkle_root[i+1] for i in range(0,len(merkle_root),2)][::-1])
|
|
|
|
print('Merkle Root: {}\n'.format(merkle_root))
|
|
|
|
def noncework():
|
|
nonce = hex(secrets.randbelow(2**32))[2:].zfill(8)
|
|
blockheader = version + prevhash + merkle_root + nbits + ntime + nonce +\
|
|
'000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000'
|
|
|
|
hash = hashlib.sha256(hashlib.sha256(binascii.unhexlify(blockheader)).digest()).digest()
|
|
hash = binascii.hexlify(hash).decode()
|
|
if(hash[:5] == '00000'): print('Hash: {}'.format(hash))
|
|
if hash < target :
|
|
print('\nSuccess!!\n')
|
|
print('\nHash: {}\n'.format(hash))
|
|
payload = bytes('{"params": ["'+address+'", "'+job_id+'", "'+extranonce2 \
|
|
+'", "'+ntime+'", "'+nonce+'"], "id": 1, "method": "mining.submit"}\n', 'utf-8')
|
|
sock.sendall(payload)
|
|
print(sock.recv(1024))
|
|
input("\nPress Enter to continue...")
|
|
|
|
for k in range(33333333):
|
|
noncework()
|
|
print("\nSymbolic-Hash-Satoshi Finished with 33M Attempts.\n\nTrying Again...\n")
|
|
finally:
|
|
sock.close()
|
|
main()
|
|
|
|
if __name__ == '__main__':
|
|
main()
|