I finally got it work with security hole there.might need to dig into it. but might help someone else like to play around it.
I don't know how to implement the KGW (KimotoGravityWell)
for electrum:
https://github.com/9cat/templecoin/blob/templecoin/src/main.cpp#L1306So I simply avoid to check bit for now.
If anyone know how to implement the KGW part. I love to see if . and I will off TPC100 bounty for it
----------------------------------------------------------------
def verify_chain(self, chain):
first_header = chain[0]
prev_header = self.read_header(first_header.get('block_height') -1)
for header in chain:
height = header.get('block_height')
prev_hash = self.hash_header(prev_header)
bits, target = self.get_target(height/2016, chain)
_hash = self.pow_hash_header(header)
print_msg("prev_hash", prev_hash)
print_msg("prev_block_hash", header.get('prev_block_hash'))
print_msg("bits", bits)
print_msg("bits.header", header.get('bits'))
try:
assert prev_hash == header.get('prev_block_hash')
#assert bits == header.get('bits')
#assert int('0x'+_hash,16) < target
except Exception:
return False
prev_header = header
return True