Bitcoin Forum
December 13, 2024, 10:47:07 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Getmemorypool data proper response?  (Read 1643 times)
ThePiachu (OP)
Sr. Member
****
Offline Offline

Activity: 444
Merit: 313



View Profile WWW
February 26, 2012, 03:13:19 AM
 #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?

1HWbVLhxj7bhewhyapMZpyhqWAeAhJd51E
My Bitcoin Calculator:
http://tpbitcalc.appspot.com/
Luke-Jr
Legendary
*
expert
Offline Offline

Activity: 2576
Merit: 1186



View Profile
February 29, 2012, 02:04:54 AM
 #2

https://en.bitcoin.it/wiki/BIP_DRAFT:_getmemorypool isn't quite done yet, and needs double-checking.

ThePiachu (OP)
Sr. Member
****
Offline Offline

Activity: 444
Merit: 313



View Profile WWW
February 29, 2012, 03:26:56 AM
 #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.

1HWbVLhxj7bhewhyapMZpyhqWAeAhJd51E
My Bitcoin Calculator:
http://tpbitcalc.appspot.com/
Luke-Jr
Legendary
*
expert
Offline Offline

Activity: 2576
Merit: 1186



View Profile
February 29, 2012, 03:48:04 AM
 #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.

ThePiachu (OP)
Sr. Member
****
Offline Offline

Activity: 444
Merit: 313



View Profile WWW
March 06, 2012, 01:53:54 AM
 #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?

1HWbVLhxj7bhewhyapMZpyhqWAeAhJd51E
My Bitcoin Calculator:
http://tpbitcalc.appspot.com/
Luke-Jr
Legendary
*
expert
Offline Offline

Activity: 2576
Merit: 1186



View Profile
March 06, 2012, 02:19:09 AM
 #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

ThePiachu (OP)
Sr. Member
****
Offline Offline

Activity: 444
Merit: 313



View Profile WWW
March 17, 2012, 10: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

1HWbVLhxj7bhewhyapMZpyhqWAeAhJd51E
My Bitcoin Calculator:
http://tpbitcalc.appspot.com/
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!