Skip to content

Commit

Permalink
Namecoin / AuxPoW: Use parent block's hash when comparing hash to tar…
Browse files Browse the repository at this point in the history
…get.
  • Loading branch information
JeremyRand committed Jun 30, 2018
1 parent eba586d commit d24daeb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions lib/auxpow.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,15 @@ def deserialize_merkle_branch(s):
index = vds.read_int32()
return hashes, index, s[vds.read_cursor:]

def hash_parent_header(header):
if not auxpow_active(header):
return electrum_nmc.blockchain.hash_header(header)

verify_auxpow(header)

return electrum_nmc.blockchain.hash_header(header['auxpow']['parent_header'])

# TODO: Implement this
def verify_auxpow(header):
pass

2 changes: 1 addition & 1 deletion lib/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def update_size(self):
self._size = os.path.getsize(p)//80 if os.path.exists(p) else 0

def verify_header(self, header, prev_hash, target):
_hash = hash_header(header)
_hash = auxpow.hash_parent_header(header)
if prev_hash != header.get('prev_block_hash'):
raise Exception("prev hash mismatch: %s vs %s" % (prev_hash, header.get('prev_block_hash')))
if constants.net.TESTNET:
Expand Down

0 comments on commit d24daeb

Please sign in to comment.