0

I am trying to run a simple python script to synchronise the Bitcoin block headers for an SPV client, using the python-bitcoinlib. This is the code that I am running, after doing the handshake:

msg = msg_getheaders()
locator = CBlockLocator()
hash_b = '000000000000000000003e2f9b46d6394450ee3e4bf4bc04ce77a9b3118d5933'
locator.vHave = [lx((hash_b))]
msg.locator = locator

print(msg.to_bytes())
s.sendall(msg.to_bytes())

while True:
response = s.recv(buffer_size)
f.write((response))
if not response:
break
print(binascii.hexlify(response))
f.close()


However, the response I get seems more like nonsense to me, as I receive a lot of data even when I have a locator containing the hash of a block having just 10 confirmations. For example, the response for the above:

b'f9beb4d973656e646865616465727300000000005df6e0e2'
b'f9beb4d973656e64636d70637400000009000000e92f5ef8'
b'f9beb4d9696e76000000000000000000f9010000483ae1a8'