nostr_core_lib/nostr_core/nip001.h

37 lines
1.2 KiB
C

/*
* NOSTR Core Library - NIP-001: Basic Protocol Flow
*
* Event creation, signing, serialization and core protocol functions
*/
#ifndef NIP001_H
#define NIP001_H
#include <stdint.h>
#include <time.h>
#include "../cjson/cJSON.h"
// Error codes
#define NOSTR_SUCCESS 0
#define NOSTR_ERROR_INVALID_INPUT -1
#define NOSTR_ERROR_CRYPTO_FAILED -2
#define NOSTR_ERROR_MEMORY_FAILED -3
#define NOSTR_ERROR_IO_FAILED -4
#define NOSTR_ERROR_NETWORK_FAILED -5
#define NOSTR_ERROR_NIP04_INVALID_FORMAT -10
#define NOSTR_ERROR_NIP04_DECRYPT_FAILED -11
#define NOSTR_ERROR_NIP04_BUFFER_TOO_SMALL -12
#define NOSTR_ERROR_NIP05_INVALID_IDENTIFIER -20
#define NOSTR_ERROR_NIP05_HTTP_FAILED -21
#define NOSTR_ERROR_NIP05_JSON_PARSE_FAILED -22
#define NOSTR_ERROR_NIP05_NAME_NOT_FOUND -23
#define NOSTR_ERROR_NIP05_PUBKEY_MISMATCH -24
// Function declarations
int nostr_init(void);
void nostr_cleanup(void);
const char* nostr_strerror(int error_code);
cJSON* nostr_create_and_sign_event(int kind, const char* content, cJSON* tags, const unsigned char* private_key, time_t timestamp);
#endif // NIP001_H