Completed refactoring to separate nip files, and updating build.sh
This commit is contained in:
@@ -5,57 +5,18 @@
|
||||
*/
|
||||
|
||||
#include "nip001.h"
|
||||
#include "nostr_crypto.h"
|
||||
#include "utils.h"
|
||||
#include "../cjson/cJSON.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "../nostr_core/nostr_common.h"
|
||||
|
||||
// Declare utility functions
|
||||
void nostr_bytes_to_hex(const unsigned char* bytes, size_t len, char* hex);
|
||||
int nostr_hex_to_bytes(const char* hex, unsigned char* bytes, size_t len);
|
||||
|
||||
/**
|
||||
* Initialize the NOSTR library
|
||||
*/
|
||||
int nostr_init(void) {
|
||||
if (nostr_crypto_init() != 0) {
|
||||
return NOSTR_ERROR_CRYPTO_FAILED;
|
||||
}
|
||||
return NOSTR_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup the NOSTR library
|
||||
*/
|
||||
void nostr_cleanup(void) {
|
||||
nostr_crypto_cleanup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert error code to human-readable string
|
||||
*/
|
||||
const char* nostr_strerror(int error_code) {
|
||||
switch (error_code) {
|
||||
case NOSTR_SUCCESS: return "Success";
|
||||
case NOSTR_ERROR_INVALID_INPUT: return "Invalid input";
|
||||
case NOSTR_ERROR_CRYPTO_FAILED: return "Cryptographic operation failed";
|
||||
case NOSTR_ERROR_MEMORY_FAILED: return "Memory allocation failed";
|
||||
case NOSTR_ERROR_IO_FAILED: return "I/O operation failed";
|
||||
case NOSTR_ERROR_NETWORK_FAILED: return "Network operation failed";
|
||||
case NOSTR_ERROR_NIP04_INVALID_FORMAT: return "NIP-04 invalid format";
|
||||
case NOSTR_ERROR_NIP04_DECRYPT_FAILED: return "NIP-04 decryption failed";
|
||||
case NOSTR_ERROR_NIP04_BUFFER_TOO_SMALL: return "NIP-04 buffer too small";
|
||||
case NOSTR_ERROR_NIP05_INVALID_IDENTIFIER: return "NIP-05: Invalid identifier format";
|
||||
case NOSTR_ERROR_NIP05_HTTP_FAILED: return "NIP-05: HTTP request failed";
|
||||
case NOSTR_ERROR_NIP05_JSON_PARSE_FAILED: return "NIP-05: JSON parsing failed";
|
||||
case NOSTR_ERROR_NIP05_NAME_NOT_FOUND: return "NIP-05: Name not found in .well-known";
|
||||
case NOSTR_ERROR_NIP05_PUBKEY_MISMATCH: return "NIP-05: Public key mismatch";
|
||||
default: return "Unknown error";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and sign a NOSTR event
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user