cgminer log shows stratum header constructed as below
20000000da780ff935f3917ed99a7b616cb98ebb3104b3fa000b7acd0000000000000000854e4bddb4eeb7c1841b651ceb26f4d12116bfcc2c41ed18220fd701571914ba5a6fdbfa176c214 600000000
Look at version, time, difficulty part. Shouldn't it be flipped as big endian ?
No, everything in Bitcoin is serialized as little endian. Actually, this is serialized as big endian, but in kind of a strange way. It seems like it is being printed out with each 4 byte chunk (32 bit integer length) in big endian, which also means that the merkle root and previous block hash fields are messed up. But this is not the actual block header it is hashing.
And at the calculation of midsate its flipping all 4 bytes.. meaning 00000020f90f78da7e91f335617b9ad9bb8eb96cfab30431cd7a0b000000000000000000dd4b4e8 5c1b7eeb41c651b84d1f426ebccbf162118ed412c01d70f22
This is the correct block header. Everything is in little endian as it should be. This is what the block header should look like.
When submitblock is called, what should be sent as block header ?
The second one.
Thanks, Below is the request received from pool, so if you check first header above which looks like big endian has previous hash as is.
So bloc header has previous hash flipped in 32 bit chunk ? But as per documentation it doesn't say so.
merkle 0: a3d18668bdf36123c62d4f514bf73ea4c7aa6fae2e84b5e5a05a9150167fa029
merkle 1: 56d152aca6c6dd57b6e76c57f6372c6c7bc17e3d2a4b60716129f3c14034cd04
merkle 2: 0e87a49ac8f40fcecf8d5401eccf41dbb1a83884d571119ac50e26f0a8e102ed
merkle 3: 3a017f03b73bf13542e19b8c72083ca666fb3ae8411c7f11043c4fd96ef79b8a
merkle 4: ba6a063a2d07b85a01d18e3cf66752a131a92b797e718d1d7643d9eb9e794afe
merkle 5: 3239626b7d311d43005f593a361c560da9ef9cda164a1fd78e5af9cbaa8006a5
merkle 6: b8e581d27c1830817fbc92df080d474ee0294c377a27d65b6fb38c6971297461
merkle 7: 01f51b074a5c7bf4b4848e4eee2933eca04b819c24973f598f667bf78c88ed11
Pool 0 coinbase 01000000010000000000000000000000000000000000000000000000000....
job_id: 59e1661b0002aa39
prev_hash:
da780ff935f3917ed99a7b616cb98ebb3104b3fa000b7acd0000000000000000coinbase1: 0100000001000000000000000000000000000000000000000000000000000000...
coinbase2: 0a636b706f6f6c112f736f6c6f2e636b706f6f6c2e6f72672fffffffff03d0b3...
bbversion: 20000000
nbit: 176c2146
ntime: 5a6fdbfa