decodeNeventToMap method

  1. @override
Map<String, dynamic> decodeNeventToMap(
  1. String bech32
)
override

Decodes the given bech32 nprofile id to a map with pubkey and relays. You can encode a map to a nprofile id with encodeNProfile.

Example:

final nEventDecodedMap = Nostr.instance.utilsService.decodeNeventToMap(
"nevent1:..."
);

print(nEventDecodedMap); // ...

Implementation

@override
Map<String, dynamic> decodeNeventToMap(String bech32) {
  final List<String> decodedBech32 = decodeBech32(bech32);

  final String dataString = decodedBech32[0];
  final List<int> data = HEX.decode(dataString);

  final List<TLV> tlvList = _tlvService.decode(Uint8List.fromList(data));
  final Map<String, dynamic> resultMap = _parseNeventTlvList(tlvList);

  if (resultMap["eventId"].length != 64) {
    throw Exception("Invalid pubkey length");
  }

  return resultMap;
}