I’ve been putting together a ‘stupid stratum server’ and playing on testnet as a way to learn more about how mining works.
I’m getting blocktemplates, sending work to the miner & getting solutions back - but zcashd rejects the assembled blocks with ‘invalid-solution’. I suspect I’m sending the miner garbage but cant confirm as there are too may other things I could be screwing up.
Any clues as to where I’m going wrong would be very useful
Here’s what I’m doing :-
Sending ‘nonce1’ to the miner as big-endian & the number of bytes for the miner to use (total nonce size is 256-bit)
Sending the ‘target’ to the miner as read from getblocktemplate
Sending work to the miner as :-
- work number
- version (from getblocktemplate, converted to 32-bit little-endian)
- previousblockhash (from getblocktemplate, reversed byte order)
- merkleroot (calculated, reversed byte order)
- finalsaplingroothash - (from getblocktemplate, reversed byte order)
- time (current epoch, converted to 32-bit, reversed byte order)
- bits (from getblocktemplate, reversed byte order)