decodeNprofileToMap method
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 decodedBech32 = decodeBech32(bech32);
final dataString = decodedBech32[0];
final data = HEX.decode(dataString);
final tlvList = tlv.decode(Uint8List.fromList(data));
final resultMap = _parseNprofileTlvList(tlvList);
if (resultMap['pubkey'].length != 64) {
throw Exception('Invalid pubkey length');
}
return resultMap;
}