dogecoin / libdohj

Java library for adding altcoin support to bitcoinj
Apache License 2.0
109 stars 88 forks source link

Issue with parsing AUXPoW block #5

Closed patricklodder closed 8 years ago

patricklodder commented 9 years ago

I'm was trying to parse this block (not the only block this happens on and i suspect it happens on every block, but I get other errors as well): https://chain.so/block/DOGE/93a207e6d227f4d60ee64fad584b47255f654b0b6378d78e774123dd66f4fef9

and I got this error:

org.bitcoinj.core.VerificationException: Could not verify block 93a207e6d227f4d60ee64fad584b47255f654b0b6378d78e774123dd66f4fef9
v6422786 block: 
   previous block: a7f7608564c0dceef9b31727737deb0a993ea1c86b20b2b82df202ad29a54df2
   merkle root: b05f1fc14419b84487ffaed409f80d7d3cfac4278b8c79c116e38fa92ce1a068
   time: [1443439703] 2015-09-28T11:28:23Z
   difficulty target (nBits): 453187912
   nonce: 0
   with 7 transaction(s):
  7ed90038f8b4a63c9f5fec18775738a000552d5622e76b838b61ab8bc1c93edb: Unknown confidence level.
     == COINBASE TXN (scriptSig PUSHDATA(3)[8fa70d] PUSHDATA(15)[e4b883e5bda9e7a59ee4bb99e9b1bc] PUSHDATA(32)[5b323031352d30392d32385431313a32383a32342e3937303432363335325a5d])  (scriptPubKey PUSHDATA(33)[0214a5f15a73686b64cf27405e018e2f06e0501b52f4ff98282badd9d6948fb57d] CHECKSIG)
  [..]

    at org.bitcoinj.core.AbstractBlockChain.add(AbstractBlockChain.java:295)
    at org.bitcoinj.core.Peer.processBlock(Peer.java:841)
    at org.bitcoinj.core.Peer.processMessage(Peer.java:358)
    at org.bitcoinj.core.PeerSocketHandler.receiveBytes(PeerSocketHandler.java:182)
    [..]
Caused by: org.bitcoinj.core.VerificationException: Aux POW wrong index
    at org.bitcoinj.core.AuxPoW.checkProofOfWork(AuxPoW.java:370)
    at org.bitcoinj.core.AltcoinBlock.checkProofOfWork(AltcoinBlock.java:246)
    at org.bitcoinj.core.Block.verifyHeader(Block.java:638)
    at org.bitcoinj.core.AltcoinBlock.verifyHeader(AltcoinBlock.java:274)
    [..]

The cause is this check: AuxPoW.java#L363-L373 which seems to be the same implementation as auxpow.cpp#L84-L90 with the exception of the cpp implementation being an unsigned int as opposed to a (signed) Long.

Any ideas?

rnicoll commented 9 years ago

I'll have to break down the maths into steps, can't see anything obvious unfortunately. Will take a look in depth tomorrow.

rnicoll commented 9 years ago

Should be fixed in commit 8a96492c806c8e72339e49a2e06cd54cd3ef9725 - can you please check and confirm I can close this?