aboutsummaryrefslogtreecommitdiff
path: root/include/nostr.hpp
diff options
context:
space:
mode:
authorLibravatar Michael Jurkoic <mjjurkoic@gmail.com>2024-03-12 09:51:04 -0500
committerLibravatar Michael Jurkoic <mjjurkoic@gmail.com>2024-03-12 09:51:04 -0500
commita59ade344b54d658ba780b3f9e8979376371d653 (patch)
tree134f1de4795e49116ddd29f21f31e398000184cf /include/nostr.hpp
parentc564313f7e97f2fd7db98c2acca187c809a40a8c (diff)
Generate a valid ID while serializing an event
Diffstat (limited to 'include/nostr.hpp')
-rw-r--r--include/nostr.hpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/nostr.hpp b/include/nostr.hpp
index ce25446..fa407ef 100644
--- a/include/nostr.hpp
+++ b/include/nostr.hpp
@@ -54,6 +54,15 @@ private:
* @remark The `createdAt` field defaults to the present if it is not already set.
*/
void validate();
+
+ /**
+ * @brief Generates an ID for the event.
+ * @param serializedData The serialized JSON string of all of the event data except the ID and
+ * the signature.
+ * @return A valid Nostr event ID.
+ * @remark The ID is a 32-bytes lowercase hex-encoded sha256 of the serialized event data.
+ */
+ std::string generateId(std::string serializedData) const;
};
/**