1

I know I have to somehow implement this spec but other than that I'm not sure.

Any help/resources is appreciated.

jtgrassie
  • 19,111
  • 4
  • 14
  • 51
PGBRULES
  • 23
  • 3

1 Answers1

1

You'd modify def pack_nonce to account for the Nicehash nonce byte. I.e. only pack 3 bytes.

E.g.

diff --git a/stratum-miner.py b/stratum-miner.py
index 486e877..ec3ae5f 100644
--- a/stratum-miner.py
+++ b/stratum-miner.py
@@ -99,8 +99,8 @@ def main():
 def pack_nonce(blob, nonce):
     b = binascii.unhexlify(blob)
     bin = struct.pack('39B', *bytearray(b[:39]))
-    bin += struct.pack('I', nonce)
-    bin += struct.pack('{}B'.format(len(b)-43), *bytearray(b[43:]))
+    bin += struct.pack('I', nonce & 0x00ffffff)[:3]
+    bin += struct.pack('{}B'.format(len(b)-42), *bytearray(b[42:]))
     return bin

@@ -146,6 +146,7 @@ def worker(q, s): elapsed = time.time() - started hr = int(hash_count / elapsed) print('{}Hashrate: {} H/s'.format(os.linesep, hr))

  •            nonce = struct.unpack('I', bin[39:43])[0]
               submit = {
                   'method':'submit',
                   'params': {
    

Or simply using the latest version with the --nicehash flag.

jtgrassie
  • 19,111
  • 4
  • 14
  • 51
  • Thank you so much for your answer. I knew it was something to do with pack_nonce, I'm just not sure how exactly to implement utilizing the given Nicehash nonce byte, regardless, thank you for your answer! – PGBRULES Feb 02 '22 at 21:36
  • @PGBRULES you would implement like: https://paste.debian.net/1229411/ – jtgrassie Feb 02 '22 at 23:04
  • did that code work for you when you tested with any xmrig-proxy pool in nicehash mode? For me, once I changed the nonce on line 158 to just send the raw nonce instead of what was there before, I only got low difficulty share errors. I'm mining on a 9900K. Line before: 'nonce': binascii.hexlify(struct.pack('<I', nonce)).decode(), Line after: 'nonce': nonce, – PGBRULES Feb 03 '22 at 00:19
  • Also had to change the nonce equals line to nonce = struct.unpack('I', bin[40:44])[0] – PGBRULES Feb 03 '22 at 00:21
  • Which is what I just showed you in https://paste.debian.net/1229411/ – jtgrassie Feb 03 '22 at 01:05
  • Not sure what you mean by that? In that paste you had bin[40,44] which produces a type error. As for my first comment: In the paste you didn't change the nonce when it was being submitted, you kept the hexify and decode part. I changed it submit the nonce as determined by struct.unpack. – PGBRULES Feb 03 '22 at 01:09
  • Not sure what you mean. You literally just commented with lines I wrote which you're saying you changed to?! And bin[40:44] is not a type error. – jtgrassie Feb 03 '22 at 01:19
  • + nonce = struct.unpack('I', bin[40,44])[0] is what you posted. I changed this to bin[40:44] as otherwise it produces a type error. In addition, I said in the submit field, you forgot to change it from the binascii.hexlify code to just passing the raw nonce. – PGBRULES Feb 03 '22 at 01:25
  • I didn't forget to change it, it shouldn't need changing. – jtgrassie Feb 03 '22 at 01:28
  • Of course it needs changing? 'nonce': binascii.hexlify(struct.pack('<I', nonce)).decode() wouldn't work when the nonce is an integer? nonce = struct.unpack('I', bin[40:44])[0] – PGBRULES Feb 03 '22 at 01:29
  • Of course it works. You are pack'ing and integer to binary then converting to a hex string. – jtgrassie Feb 03 '22 at 01:32
  • Well then it's something with that because when using the original nonce submission code('nonce': binascii.hexlify(struct.pack('<I', nonce)).decode()), I get an "Invalid nonce; is miner not compatible with NiceHash?" error which I don't get if I just send the nonce without hexifying it. – PGBRULES Feb 03 '22 at 01:35
  • The nonce is always a hex string, even with NiceHash. – jtgrassie Feb 03 '22 at 01:56
  • Well changing that line to just pass the struct.unpack('I', bin[40:44])[0] removes the nicehash compatibility error and instead just creates a new error of a low difficulty share error. – PGBRULES Feb 03 '22 at 02:07
  • change bin[40:44] to bin[39:43] I've just done, tested and validated as working: https://paste.debian.net/1229411/ – jtgrassie Feb 03 '22 at 02:15