code: func handleGetHeaders(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
  	c := cmd.(*btcjson.GetHeadersCmd)
  
  	// Fetch the requested headers from chain while respecting the provided
  	// block locators and stop hash.
  	blockLocators := make([]*chainhash.Hash, len(c.BlockLocators))
  	for i := range c.BlockLocators {
  		blockLocator, err := chainhash.NewHashFromStr(c.BlockLocators[i])
  		if err != nil {
  			return nil, rpcDecodeHexError(c.BlockLocators[i])
  		}
  		blockLocators[i] = blockLocator
  	}
  	var hashStop chainhash.Hash
  	if c.HashStop != "" {
  		err := chainhash.Decode(&hashStop, c.HashStop)
  		if err != nil {
  			return nil, rpcDecodeHexError(c.HashStop)
  		}
  	}
  	headers := s.cfg.SyncMgr.LocateHeaders(blockLocators, &hashStop)
  
  	// Return the serialized block headers as hex-encoded strings.
  	hexBlockHeaders := make([]string, len(headers))
  	var buf bytes.Buffer
  	for i, h := range headers {
  		err := h.Serialize(&buf)
  		if err != nil {
  			return nil, internalRPCError(err.Error(),
  				"Failed to serialize block header")
  		}
  		hexBlockHeaders[i] = hex.EncodeToString(buf.Bytes())
  		buf.Reset()
  	}
  	return hexBlockHeaders, nil
  }
docs: // handleGetHeaders implements the getheaders command.
  //
  // NOTE: This is a btcsuite extension originally ported from
  // github.com/decred/dcrd.