URI: 
       tImplement blockchain.block.headers - obelisk - Electrum server using libbitcoin as its backend
  HTML git clone https://git.parazyd.org/obelisk
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit e51233f13b35509c929e35b4593e531bbb5464b6
   DIR parent e18c588c8f29e8395a2229d5b3e6d043a9377c05
  HTML Author: parazyd <parazyd@dyne.org>
       Date:   Wed,  7 Apr 2021 18:14:41 +0200
       
       Implement blockchain.block.headers
       
       Diffstat:
         M electrumobelisk/protocol.py         |      30 ++++++++++++++++++++++++++++++
       
       1 file changed, 30 insertions(+), 0 deletions(-)
       ---
   DIR diff --git a/electrumobelisk/protocol.py b/electrumobelisk/protocol.py
       t@@ -162,11 +162,41 @@ class ElectrumProtocol(asyncio.Protocol):  # pylint: disable=R0904
        
                _ec, data = await self.bx.block_header(index)
                if _ec and _ec != 0:
       +            self.log.debug("Got error: {_ec}")
                    return {"error": "request corrupted"}
                return {"result": safe_hexlify(data)}
        
            async def blockchain_block_headers(self, query):
                self.log.debug("query: %s", query)
       +        if "params" not in query or len(query["params"]) < 2:
       +            return {"error": "malformed query"}
       +        # Electrum doesn't allow max_chunk_size to be less than 2016
       +        # gopher://bitreich.org/9/memecache/convenience-store.mkv
       +        # TODO: cp_height
       +        max_chunk_size = 2016
       +        start_height = query["params"][0]
       +        count = query["params"][1]
       +
       +        if not is_non_negative_integer(start_height):
       +            return {"error": "invalid start_height"}
       +        if not is_non_negative_integer(count):
       +            return {"error": "invalid count"}
       +
       +        count = min(count, max_chunk_size)
       +        headers = bytearray()
       +        for i in range(count):
       +            _ec, data = await self.bx.block_header(i)
       +            if _ec and _ec != 0:
       +                self.log.debug("Got error: {_ec}")
       +                return {"error": "request corrupted"}
       +            headers.extend(data)
       +
       +        resp = {
       +            "hex": safe_hexlify(headers),
       +            "count": len(headers) // 80,
       +            "max": max_chunk_size,
       +        }
       +        return {"result": resp}
        
            async def blockchain_estimatefee(self, query):
                self.log.debug("query: %s", query)