decodeNprofileToMap method

  1. @override
Map<String, dynamic> decodeNprofileToMap(
  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 nProfileDecodedMap = Nostr.instance.utilsService.decodeNprofileToMap(
 "nprofile1:..."
);

print(nProfileDecodedMap); // ...

Implementation

@override
Map<String, dynamic> decodeNprofileToMap(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 = _parseNprofileTlvList(tlvList);

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

  return resultMap;
}