iceland2k14 / solominer

Solo Mining in python for BTC Block Reward, Pure luck
MIT License
80 stars 31 forks source link

I want to add finded hash to txt file #4

Open Mert-Zengin opened 3 years ago

Mert-Zengin commented 3 years ago
   hash = hashlib.sha256(hashlib.sha256(binascii.unhexlify(blockheader)).digest()).digest()
    hash = binascii.hexlify(hash).decode()
#    print('hash: {}'.format(hash))
    if(hash[:5] == '00000'): print('hash: {}'.format(hash))
    if hash < target :
#    if(hash[:10] == '0000000000'):
    #file = open("buldu.txt", "a")
    #file.write('hash:{}'.format(hash)) <------- i added but didn't work 
    #file.close()
        print('success!!')
        print('hash: {}'.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))
#    else:
#        print('failed mine, hash is greater than target')

when i try to add getting error tab

iceland2k14 commented 3 years ago

This file code you added will be triggered only when you get the BTC Block. because it is inside the condition if hash < target If you want to look at all the hash generated during computation in a file then you can output it below the Line 80. https://github.com/iceland2k14/solominer/blob/6e2e1f6878c3c3808296a2e926abee862b885f8c/solo_miner.py#L80-L81 Put the code there you will see the hashes saved in your file.