unsealRumor method

Future<Nip01Event> unsealRumor({
  1. required Nip01Event sealedEvent,
})

Implementation

Future<Nip01Event> unsealRumor({
  required Nip01Event sealedEvent,
}) async {
  final account = accounts.getLoggedAccount();
  if (account == null) {
    throw Exception("Cannot decrypt without account");
  }
  // Now decrypt the seal to get the rumor
  final decryptedRumorJson = await account.signer.decryptNip44(
    ciphertext: sealedEvent.content,
    senderPubKey: sealedEvent.pubKey,
  );

  if (decryptedRumorJson == null) {
    throw Exception("Failed to decrypt seal");
  }

  // Parse the rumor event
  final Map<String, dynamic> rumorJson = jsonDecode(decryptedRumorJson);
  final rumor = Nip01Event.fromJson(rumorJson);

  return rumor;
}