public string GetSolutionString(uint solution) { data[76] = (byte)(solution & 0xFF); data[77] = (byte)((solution & 0xFF00) >> 8); data[78] = (byte)((solution & 0xFF0000) >> 16); data[79] = (byte)((solution & 0xFF000000) >> 24); return(Utils.ByteArrayToHexString(data)); }
public void GenerateWork() { byte[] en2b = new byte[mExtraNonceSize]; for (int i = 0; i < mExtraNonceSize; i++) { ulong mask = (ulong)0xFF << (i * 8); ulong masked = (mExtraNonceB & mask) >> (i * 8); en2b[mExtraNonceSize - (1 + i)] = (byte)masked; } mExtraNonceB++; mExtraNonce2 = Utils.ByteArrayToHexString(en2b); string coinbase = mCoinBaseA + mExtraNonce + mExtraNonce2 + mCoinBaseB; byte[] cb = Utils.HexStringToByteArray(coinbase); byte[] cbHash = MinerLib_cs.Scrypt.SHA2562(cb); string merkleRoot = Utils.ByteArrayToHexString(cbHash); foreach (string merkle in mMerkleBranch) { byte[] hashData = Utils.HexStringToByteArray(merkleRoot + merkle); byte[] merkleHash = MinerLib_cs.Scrypt.SHA2562(hashData); merkleRoot = Utils.ByteArrayToHexString(merkleHash); } // byteswap the merkle root section byte[] merkleData = Utils.HexStringToByteArray(merkleRoot); Utils.ByteSwapIntegers(merkleData); merkleRoot = Utils.ByteArrayToHexString(merkleData); uint time = (uint)Utils.UnixTime() + 120; mTimeStr = Utils.UIntToHexString(time); strData = mVersion + mPrevHash + merkleRoot + mTimeStr + mDifficulty + "00000000" + "000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000"; data = Utils.HexStringToByteArray(strData); }