Author

Topic: issues submitting block to litecoin using the submitblock rpc method (Read 159 times)

newbie
Activity: 55
Merit: 0
Ive been playing about with the idea of making a pool for an altcoin for research purposes.

I believe I currently have everything in place but think I maybe doing something wrong with the ordering of the bytes when trying to use the submitblock() method in the litecoin api. (Using Testnet)


Here is what I have.
After the miner subscribes and is authorized, my pool then sends them this below..

 < {"params":["f78eb698","e905cff1f70e8e1ed9c922382da02a0cf3ad1eae2b16dadff8c3e3b7fd676ba9","01000000010000000000000000000000000000000000000000000000000000000000000000fffff fff0a0132","ffffffff0100f2052a010000001976a914bebc4c636c3b53dff00d421346cac86ab03b760288ac0 0000000",[],"20000000","1e0fffff","5dbf3f3d",true],"id":null,"method":"mining.notify"}
 
 
 previous block hash = e905cff1f70e8e1ed9c922382da02a0cf3ad1eae2b16dadff8c3e3b7fd676ba9
 (Reversed by my pool before sending to the miner)
 
 coinb1 = 01000000010000000000000000000000000000000000000000000000000000000000000000fffff fff0a0132
 the 0a0132 that is at the end of coinb1 is 0a =ScriptSigSize in hex format,  01 = bytes being pushed in block, 32 = block height in hex (block 50 in decimal)
 
 
 coinb2 = ffffffff0100f2052a010000001976a914bebc4c636c3b53dff00d421346cac86ab03b760288ac0 0000000
 coinb2 contains outputcount, coinbase value, scryptpubkey and lock time
 version = 20000000
 network encoded difficulty = 1e0fffff as currently displayed in GTB call
 ntime = hex encoded time
 
 
 so presuming the above is correct the miner submits this
  > {"method": "mining.submit", "params": ["user.demo", "9d2b8a3d", "00000000", "5dbf3fb7", "360600c0"], "id":4}
 
    my pool then grabs the nonce
   5dbf3fb7 swaps the endianess so its now 4000d05f
   and puts it in the 80byte block header at the end like so
 
 
    02000000e905cff1f70e8e1ed9c922382da02a0cf3ad1eae2b16dadff8c3e3b7fd676ba9e87d96c ed06d962057735e472a76b6d143e45d4eaf62a
    644079e9a6d10ba63fd5dbf3fb7ffff0f1e4000d05f
 
   also append the coinb1 from earlier with extranonce1 that my pool gave to the miner apon subscribe and the extranonce2 that the miner submitted
   with the nonce , for some reaon the miner always submits with extranonce2 as (00000000) not sure if this matters or not then coinb2
 
   so its coinb1+extranonce1+extranonce2(from miner)+coinb2
 
 01000000010000000000000000000000000000000000000000000000000000000000000000fffff fff0a0132
 cd7ef2af = extranonce1
 00000000 = extranonce2
 ffffffff0100f2052a010000001976a914bebc4c636c3b53dff00d421346cac86ab03b760288ac0 0000000

 
  I then put the above nonce appended coinbase at the end of the block header like so
 
 
 02000000e905cff1f70e8e1ed9c922382da02a0cf3ad1eae2b16dadff8c3e3b7fd676ba9e87d96c ed06d962057735e472a76b6d143e45d4eaf62a6440
 79e9a6d10ba63fd5dbf3fb7ffff0f1e4000d05f -  Block header
 
 01 - I also added this for transaction count
 
  - raw coinbase transaction
  01000000010000000000000000000000000000000000000000000000000000000000000000fffff fff0a0132
   cd7ef2af = extranonce1
  00000000 = extranonce2
  ffffffff0100f2052a010000001976a914bebc4c636c3b53dff00d421346cac86ab03b760288ac0 0000000
 
 that gives me
 
  --SERIALIZED BLOCK HEADER
 02000000e905cff1f70e8e1ed9c922382da02a0cf3ad1eae2b16dadff8c3e3b7fd676ba9e87d96c ed06d962057735e472a76b6d143e45d4eaf62a644
 079e9a6d10ba63fd5dbf3fb7ffff0f1e4000d05f010000000100000000000000000000000000000 00000000000000000000000000000000000ffffffff
 0a0132cd7ef2af00000000ffffffff0100f2052a010000001976a914bebc4c636c3b53dff00d421 346cac86ab03b760288ac00000000

 I then use
 submitblock('02000000e905cff1f70e8e1ed9c922382da02a0cf3ad1eae2b16dadff8c3e3b7fd676ba9e87d96c ed06d962057735e472a76b6d143e45
 d4eaf62a644079e9a6d10ba63fd5dbf3fb7ffff0f1e4000d05f0100000001000000000000000000 0000000000000000000000000000000000000000
 000000ffffffff0a0132cd7ef2af00000000ffffffff0100f2052a010000001976a914bebc4c636 c3b53dff00d421346cac86ab03b760288ac00000000')

 code var version below
 submitblock($bheader.'01'.$_SESSION['coinb1'].$_SESSION['Extranonce1'].$extranonce2.$_SESSION['coinb2']);//submit new block

 but I keep getting invalid in the litecoin console.

 I can show my source code implementation if needed.

 I havent done any target checking yet on the pool side as I am using cpuminer and cpuminer obviously checks if the hash is lower then the target
 before even submitting it to the pool.

 for the merkle root in the header I just used the txid from the rawtransaction rpc call with the nonces appended in the coinbase, also reversed the
 txid before putting it in to the header.

 I think it could be something to do with the 80 byte header byte ordering or possibly coinb2 padding or scriptsig issues,
 any pointers would be great.
Jump to: