Author

Topic: Getmemorypool data proper response? (Read 1638 times)

sr. member
Activity: 444
Merit: 313
March 17, 2012, 05:28:02 PM
#7
Hmm, tried sending the fixed version to Bitcoin application in server mode, and got a false result. Tried the same with some other variation of the messages, and also got false-s.

This is the Getmemorypool data I received (ignoring all the transactions):

Code:
{'previousblockhash': '0000000020bcc87b08b88b6ccf1f79022bb2404b26e8fcec398fe323e93f2bc1', 'transactions': [], 'version': 1, 'coinbasevalue': 5005350000, 'time': 1332022461, 'bits': '1c2336a4'}

So, got this Getwork response:

Code:
00000001e93f2bc1398fe32326e8fcec2bb2404bcf1f790208b88b6c20bcc87b00000000b0bdf352aa835722693225753422bea517f9143755c2c705fad08617be75d1de4f65086e1c2336a462295f9f000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000

And tried calling the Bitcoin getmemorypool with the following parameters:


Code:
010000000000000020BCC87B08B88B6CCF1F79022BB2404B26E8FCEC398FE323E93F2BC1BE75D1DEFAD0861755C2C70517F914373422BEA569322575AA835722B0BDF3526E08654FA436231C9F5F29620101000000010000000000000000000000000000000000000000000000000000000000000000FFFFFFFF1D546865506961636875277E427B80F359164A5BC11171D7ED423A35EC7EFFFFFFFF0100F2052A01000000434104475876434DAB12C149E7DC68AA4AEF44B7DAD9BC9B90CB1C6751EAD47DE7BA3AC7AA10C6BCDEB6DC42C85BB7588BC114C6E47072E0264FB1C33B6FBD69E040F2AC00000000


Code:
01000000C12B3FE923E38F39ECFCE8264B40B22B02791FCF6C8BB8087BC8BC2000000000BE75D1DEFAD0861755C2C70517F914373422BEA569322575AA835722B0BDF3526E08654FA436231C9F5F29620101000000010000000000000000000000000000000000000000000000000000000000000000FFFFFFFF1D546865506961636875277E427B80F359164A5BC11171D7ED423A35EC7EFFFFFFFF0100F2052A01000000434104475876434DAB12C149E7DC68AA4AEF44B7DAD9BC9B90CB1C6751EAD47DE7BA3AC7AA10C6BCDEB6DC42C85BB7588BC114C6E47072E0264FB1C33B6FBD69E040F2AC00000000


Code:
010000000000000020BCC87B08B88B6CCF1F79022BB2404B26E8FCEC398FE323E93F2BC152F3BDB0225783AA75253269A5BE22343714F91705C7C2551786D0FADED175BE6E08654FA436231C9F5F29620101000000010000000000000000000000000000000000000000000000000000000000000000FFFFFFFF1D546865506961636875277E427B80F359164A5BC11171D7ED423A35EC7EFFFFFFFF0100F2052A01000000434104475876434DAB12C149E7DC68AA4AEF44B7DAD9BC9B90CB1C6751EAD47DE7BA3AC7AA10C6BCDEB6DC42C85BB7588BC114C6E47072E0264FB1C33B6FBD69E040F2AC00000000


Code:
01000000C12B3FE923E38F39ECFCE8264B40B22B02791FCF6C8BB8087BC8BC200000000052F3BDB0225783AA75253269A5BE22343714F91705C7C2551786D0FADED175BE6E08654FA436231C9F5F29620101000000010000000000000000000000000000000000000000000000000000000000000000FFFFFFFF1D546865506961636875277E427B80F359164A5BC11171D7ED423A35EC7EFFFFFFFF0100F2052A01000000434104475876434DAB12C149E7DC68AA4AEF44B7DAD9BC9B90CB1C6751EAD47DE7BA3AC7AA10C6BCDEB6DC42C85BB7588BC114C6E47072E0264FB1C33B6FBD69E040F2AC00000000

And all of them returned false.

From what I understand, the proper brakedown should be this:

Code:
01000000
C12B3FE923E38F39ECFCE8264B40B22B02791FCF6C8BB8087BC8BC2000000000
52F3BDB0225783AA75253269A5BE22343714F91705C7C2551786D0FADED175BE
6E08654F
A436231C
9F5F2962
01
01000000
01
0000000000000000000000000000000000000000000000000000000000000000FFFFFFFF
1D
546865506961636875277E427B80F359164A5BC11171D7ED423A35EC7E
FFFFFFFF
01
00F2052A01000000
43
4104475876434DAB12C149E7DC68AA4AEF44B7DAD9BC9B90CB1C6751EAD47DE7BA3AC7AA10C6BCDEB6DC42C85BB7588BC114C6E47072E0264FB1C33B6FBD69E040F2AC
00000000

So I've tried every variant of previous hash and merkle root endianness. What I'm guessing the problem can be is:
-The Bitcoin client does not like handling getmemorypool
-I've made some error calculating the merkle root
-The nonce setting is wrong
-There is something wrong with the coinbase transaction
legendary
Activity: 2576
Merit: 1186
March 05, 2012, 09:19:09 PM
#6
Code:
01000000 - version
0000000016375AF4A21B4CE2B2CE64B5A5B27B5EAB4C15E97DB66208C7938EF8 - previous hash
0C6B39F2051927306C8008A9DD29E9E33A8ABA9AB45A4D816C488B08E2368645 - merkle root
006B554F - timestamp
A436231C - bits
55FEC3C6 - nonce
01 - transaction number

01000000 - version
01 - inputs
0000000000000000000000000000000000000000000000000000000000000000FFFFFFFF - input
0A - script length
5468655069616368750B - script
FFFFFFFF - sequence
01 - outputs
00F2052A01000000 - value
43 - script length
4104475876434DAB12C149E7DC68AA4AEF44B7DAD9BC9B90CB1C6751EAD47DE7BA3AC7AA10C6BCDEB6DC42C85BB7588BC114C6E47072E0264FB1C33B6FBD69E040F2AC - script
00000000 - locktime

I still get "False" as a response to this. Where am I making an error?
Code:
01000000 - version
WRONG: 0000000016375AF4A21B4CE2B2CE64B5A5B27B5EAB4C15E97DB66208C7938EF8 - previous hash
FIXED: f88e93c70862b67de9154cab5e7bb2a5b564ceb2e24c1ba2f45a371600000000 - previous hash
WRONG: 0C6B39F2051927306C8008A9DD29E9E33A8ABA9AB45A4D816C488B08E2368645 - merkle root
FIXED: 458636e2088b486c814d5ab49aba8a3ae3e929dda908806c30271905f2396b0c - merkle root
006B554F - timestamp
A436231C - bits
55FEC3C6 - nonce
01 - transaction number

01000000 - version
01 - inputs
0000000000000000000000000000000000000000000000000000000000000000FFFFFFFF - input
0A - script length
5468655069616368750B - script
FFFFFFFF - sequence
01 - outputs
00F2052A01000000 - value
43 - script length
4104475876434DAB12C149E7DC68AA4AEF44B7DAD9BC9B90CB1C6751EAD47DE7BA3AC7AA10C6BCDEB6DC42C85BB7588BC114C6E47072E0264FB1C33B6FBD69E040F2AC - script
00000000 - locktime
sr. member
Activity: 444
Merit: 313
March 05, 2012, 08:53:54 PM
#5
So lets see, if I get this calling getmemorypool:
Code:
{'previousblockhash': '0000000016375af4a21b4ce2b2ce64b5a5b27b5eab4c15e97db66208c7938ef8', 'transactions': [], 'version': 1, 'coinbasevalue': 5000000000, 'time': 1330998016, 'bits': '1c2336a4'}
I can submit it to a miner, a proper response from a miner would be this:
Code:
"00000001c7938ef87db66208ab4c15e9a5b27b5eb2ce64b5a21b4ce216375af400000000e23686456c488b08b45a4d813a8aba9add29e9e36c8008a9051927300c6b39f24f556b001c2336a4c6c3fe55000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000"

And a proper call to bitcoind through getmemorypool would be this:
Code:
"010000000000000016375AF4A21B4CE2B2CE64B5A5B27B5EAB4C15E97DB66208C7938EF80C6B39F2051927306C8008A9DD29E9E33A8ABA9AB45A4D816C488B08E2368645006B554FA436231C55FEC3C60101000000010000000000000000000000000000000000000000000000000000000000000000FFFFFFFF0A5468655069616368750BFFFFFFFF0100F2052A01000000434104475876434DAB12C149E7DC68AA4AEF44B7DAD9BC9B90CB1C6751EAD47DE7BA3AC7AA10C6BCDEB6DC42C85BB7588BC114C6E47072E0264FB1C33B6FBD69E040F2AC00000000"

Or to brake it up:

Code:
01000000 - version
0000000016375AF4A21B4CE2B2CE64B5A5B27B5EAB4C15E97DB66208C7938EF8 - previous hash
0C6B39F2051927306C8008A9DD29E9E33A8ABA9AB45A4D816C488B08E2368645 - merkle root
006B554F - timestamp
A436231C - bits
55FEC3C6 - nonce
01 - transaction number

01000000 - version
01 - inputs
0000000000000000000000000000000000000000000000000000000000000000FFFFFFFF - input
0A - script length
5468655069616368750B - script
FFFFFFFF - sequence
01 - outputs
00F2052A01000000 - value
43 - script length
4104475876434DAB12C149E7DC68AA4AEF44B7DAD9BC9B90CB1C6751EAD47DE7BA3AC7AA10C6BCDEB6DC42C85BB7588BC114C6E47072E0264FB1C33B6FBD69E040F2AC - script
00000000 - locktime

I still get "False" as a response to this. Where am I making an error?
legendary
Activity: 2576
Merit: 1186
February 28, 2012, 10:48:04 PM
#4
It's a nice draft, but it doesn't really specify how to encode a block.
That's already part of the main Bitcoin protocol specification.

Even the endianness of "previousblockhash" in getmemorypool is different to the one we can see encoded in getwork "data", so it can be quite confusing.
That's because the getwork "data" is part of a SHA256 midstate, which interprets the little-endian data as big-endian... so effectively inverts every 32 bits.
sr. member
Activity: 444
Merit: 313
February 28, 2012, 10:26:56 PM
#3
It's a nice draft, but it doesn't really specify how to encode a block. Even the endianness of "previousblockhash" in getmemorypool is different to the one we can see encoded in getwork "data", so it can be quite confusing.
legendary
Activity: 2576
Merit: 1186
February 28, 2012, 09:04:54 PM
#2
https://en.bitcoin.it/wiki/BIP_DRAFT:_getmemorypool isn't quite done yet, and needs double-checking.
sr. member
Activity: 444
Merit: 313
February 25, 2012, 10:13:19 PM
#1
As there are a couple endiannesses used by Bitcoin, what is the proper way to encode the "data" response for a getmemorypool JSON API call?
Jump to: