code: func (h *headerIndex) chainTip() (*chainhash.Hash, uint32, error) {
  	var (
  		tipHeight uint32
  		tipHash   *chainhash.Hash
  	)
  
  	err := walletdb.View(h.db, func(tx walletdb.ReadTx) error {
  		rootBucket := tx.ReadBucket(indexBucket)
  
  		var tipKey []byte
  
  		// Based on the specified index type of this instance of the
  		// index, we'll grab the particular key that tracks the chain
  		// tip.
  		switch h.indexType {
  		case Block:
  			tipKey = bitcoinTip
  		case RegularFilter:
  			tipKey = regFilterTip
  		default:
  			return fmt.Errorf("unknown chain tip index type: %v", h.indexType)
  		}
  
  		// Now that we have the particular tip key for this header
  		// type, we'll fetch the hash for this tip, then using that
  		// we'll fetch the height that corresponds to that hash.
  		tipHashBytes := rootBucket.Get(tipKey)
  		tipHeightBytes := rootBucket.Get(tipHashBytes)
  		if len(tipHeightBytes) != 4 {
  			return ErrHeightNotFound
  		}
  
  		// With the height fetched, we can now populate our return
  		// parameters.
  		h, err := chainhash.NewHash(tipHashBytes)
  		if err != nil {
  			return err
  		}
  		tipHash = h
  		tipHeight = binary.BigEndian.Uint32(tipHeightBytes)
  
  		return nil
  	})
  	if err != nil {
  		return nil, 0, err
  	}
  
  	return tipHash, tipHeight, nil
  }
docs: // chainTip returns the best hash and height that the index knows of.