function normalizeToHexPubkey (key) {
  // If it's an npub, decode it
  if (typeof key === 'string' && key.startsWith('npub1')) {
    try {
      const { type, data } = nip19.decode(key)
      if (type === 'npub') {
        return data
      }
    } catch (e) {
      logger.error(`Error decoding npub ${key}: ${e.message}`)
    }
  }
  // Otherwise assume it's already in hex format
  return key
}
Convert a pubkey from npub to hex format if needed
@param {String} key - Pubkey in either npub or hex format
@returns {String} - Pubkey in hex format