diff options
author | Michael Jurkoic <mjjurkoic@gmail.com> | 2024-03-12 09:51:04 -0500 |
---|---|---|
committer | Michael Jurkoic <mjjurkoic@gmail.com> | 2024-03-12 09:51:04 -0500 |
commit | a59ade344b54d658ba780b3f9e8979376371d653 (patch) | |
tree | 134f1de4795e49116ddd29f21f31e398000184cf /include/nostr.hpp | |
parent | c564313f7e97f2fd7db98c2acca187c809a40a8c (diff) |
Generate a valid ID while serializing an event
Diffstat (limited to 'include/nostr.hpp')
-rw-r--r-- | include/nostr.hpp | 9 |
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; }; /** |