v0.4.7 - Implement NIP-70 Protected Events - Add protected event support with authentication checks, comprehensive testing, and relay metadata protection

This commit is contained in:
Your Name
2025-10-03 06:44:27 -04:00
parent 88b4aaa301
commit 36c9c84047
9 changed files with 322 additions and 89 deletions

View File

@@ -160,6 +160,8 @@ int update_cache_value(const char* key, const char* value) {
g_unified_cache.nip42_challenge_timeout = atoi(value);
} else if (strcmp(key, "nip42_time_tolerance") == 0) {
g_unified_cache.nip42_time_tolerance = atoi(value);
} else if (strcmp(key, "nip70_protected_events_enabled") == 0) {
g_unified_cache.nip70_protected_events_enabled = (strcmp(value, "true") == 0) ? 1 : 0;
} else {
// For NIP-11 relay info fields, update the cache buffers
if (strcmp(key, "relay_name") == 0) {
@@ -259,6 +261,10 @@ static int refresh_unified_cache_from_table(void) {
const char* time_tolerance = get_config_value_from_table("nip42_time_tolerance");
g_unified_cache.nip42_time_tolerance = time_tolerance ? atoi(time_tolerance) : 300;
// Load NIP-70 protected events config
const char* nip70_enabled = get_config_value_from_table("nip70_protected_events_enabled");
g_unified_cache.nip70_protected_events_enabled = (nip70_enabled && strcmp(nip70_enabled, "true") == 0) ? 1 : 0;
// Set cache expiration
int cache_timeout = get_cache_timeout();
g_unified_cache.cache_expires = time(NULL) + cache_timeout;