Этот скрипт был написан для litecoin. Я подготовил его в соответствии с протоколом слоя. У меня также есть разные коды для bitcoin etherum et c. Но я всегда получаю одну и ту же ошибку:
{"id":4,"result":null,"error":[23,"Low difficulty",null]}
для всех пулов майнинга и всей криптовалюты. Что мне теперь делать? Где моя ошибка?
import socket
import json
import hashlib
import binascii
import random
import scrypt
import codecs
host = 'eu-ltc.ss.btc.com'
port = 443
worker_name = 'nailcankara.007'
worker_password = '123'
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((host,port))
sock.sendall(b'{"id": 1, "method": "mining.subscribe", "params": []}\n')
lines = sock.recv(4096).decode().split('\n')
response = json.loads(lines[0])
sub_details,extranonce1,extranonce2_size = response['result']
sock.sendall(b'{"id": 2, "method": "mining.authorize", "params": ["'+worker_name.encode()+b'","'+worker_password.encode()+b'"]} \n')
authorize_lines = sock.recv(4096).decode().split('\n')
difficulty = json.loads(authorize_lines[1])['params'][0]
target = '{:x}'.format( int(0x0000FFFF00000000000000000000000000000000000000000000000000000000/difficulty))
target = target.zfill(64)
responses = json.loads(authorize_lines[2])
job_id,prevhash,coinb1,coinb2,merkle_branch,version,nbits,ntime,clean_jobs = responses['params']
prevhash = [endian(prevhash[i:i+8]) for i in range(0,len(prevhash),8)] #100%
prevhash = ''.join(prevhash)
version_block = endian(version)
nbits_block = endian(nbits)
ntime_block = endian(ntime)
nonce = hex(random.randint(0,2**32-1))[2:].zfill(8)
nonce_block = endian(nonce)
extranonce2 = hex(random.randint(0,2**(extranonce2_size*8)-1))[2:].zfill(16)
coinbase = coinb1 + extranonce1 + extranonce2 + coinb2
coinbasesha1 = hashlib.sha256(binascii.unhexlify(coinbase)).hexdigest()
coinbasesha2 = hashlib.sha256(binascii.unhexlify(coinbasesha1)).hexdigest()
merkle_root = coinbasesha2
for each in range (len(merkle_branch)):
merkle_root = merkle_root + merkle_branch[each]
merkle_root = hashlib.sha256(binascii.unhexlify(merkle_root)).hexdigest()
merkle_root = hashlib.sha256(binascii.unhexlify(merkle_root)).hexdigest()
merkle_root = endian(merkle_root)
blockheader = version_block + prevhash + merkle_root + ntime_block + nbits_block + nonce_block
blockheader_decoded = codecs.getdecoder("hex_codec")(blockheader)[0]
blockheader_scrypt = scrypt.hash(blockheader_decoded , blockheader_decoded , 1024, 1, 1, 32)
blockheader_hash = codecs.getencoder("hex_codec")(blockheader_scrypt)[0]
blockheader_hash = endian(codecs.getdecoder("utf-8")(blockheader_hash)[0])
sock.sendall(b'{"id": 4, "method": "mining.submit", "params": ["'+worker_name.encode()+b'", "'+job_id.encode()+b'", "'+extranonce2.encode()+b'", "'+ntime.encode()+b'", "'+nonce.encode()+b'"]} \n')
print(sock.recv(4096))
sock.close()