From 6c50ab898cc7983693f8b4d0568edf545ef98df9 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 21 Mar 2026 07:00:46 -0400 Subject: [PATCH] v0.1.14 - Use wallet state for default mint resolution instead of config mint_count guards --- README.md | 4 ++-- src/cashu_wallet.c | 16 ++++++++++++++++ src/cashu_wallet.h | 1 + src/main.h | 4 ++-- src/tools/tool_cashu_wallet.c | 16 ++++++++-------- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 76fa026..f71a5b7 100644 --- a/README.md +++ b/README.md @@ -55,11 +55,11 @@ Skills compose by adoption-list order (`10123`) and trigger tags carry runtime e Didactyl will support local inference, which is very privacy preserving. Remote inference does however have it's advantages, and in those cases Didactyl supports using Bitcoin Lightning and eCash inference providers. -## Current Status — v0.1.13 +## Current Status — v0.1.14 **Active build — this project is barely working. Experiment at your own risk.** -> Last release update: v0.1.13 — Expose cashu_wallet_mints_get in tool schema so configured mints can be queried +> Last release update: v0.1.14 — Use wallet state for default mint resolution instead of config mint_count guards - Connects to configured relays with auto-reconnect and relay state transition logging - Publishes configured startup events per relay as each relay becomes connected diff --git a/src/cashu_wallet.c b/src/cashu_wallet.c index a132ced..737e586 100644 --- a/src/cashu_wallet.c +++ b/src/cashu_wallet.c @@ -465,6 +465,22 @@ static int ensure_wallet_ready(void) { return rc; } +int cashu_wallet_has_default_mint(void) { + if (!g_wallet.initialized || !g_wallet.cfg) return 0; + if (ensure_wallet_ready() != 0) return 0; + + int has_default = 0; + pthread_mutex_lock(&g_wallet.mutex); + has_default = (g_wallet.wallet_loaded && + g_wallet.wallet.mint_count > 0 && + g_wallet.wallet.mint_urls && + g_wallet.wallet.mint_urls[0] && + g_wallet.wallet.mint_urls[0][0] != '\0'); + pthread_mutex_unlock(&g_wallet.mutex); + + return has_default; +} + int cashu_wallet_create_new_from_config(void) { if (!g_wallet.initialized || !g_wallet.cfg) return -1; diff --git a/src/cashu_wallet.h b/src/cashu_wallet.h index e00bd06..8d0937d 100644 --- a/src/cashu_wallet.h +++ b/src/cashu_wallet.h @@ -11,6 +11,7 @@ void cashu_wallet_cleanup(void); int cashu_wallet_load_from_relays(void); int cashu_wallet_create_new_from_config(void); +int cashu_wallet_has_default_mint(void); int cashu_wallet_balance(cJSON** out_json); int cashu_wallet_info(const char* mint_url, cJSON** out_json); diff --git a/src/main.h b/src/main.h index 6ee8be6..834b0a5 100644 --- a/src/main.h +++ b/src/main.h @@ -12,8 +12,8 @@ // Using DIDACTYL_ prefix to avoid conflicts with nostr_core_lib VERSION macros #define DIDACTYL_VERSION_MAJOR 0 #define DIDACTYL_VERSION_MINOR 1 -#define DIDACTYL_VERSION_PATCH 13 -#define DIDACTYL_VERSION "v0.1.13" +#define DIDACTYL_VERSION_PATCH 14 +#define DIDACTYL_VERSION "v0.1.14" // Agent metadata #define DIDACTYL_NAME "Didactyl" diff --git a/src/tools/tool_cashu_wallet.c b/src/tools/tool_cashu_wallet.c index aae2ce9..7696269 100644 --- a/src/tools/tool_cashu_wallet.c +++ b/src/tools/tool_cashu_wallet.c @@ -73,7 +73,7 @@ char* execute_cashu_wallet_info(tools_context_t* ctx, const char* args_json) { cJSON* mint = cJSON_GetObjectItemCaseSensitive(args, "mint_url"); const char* mint_url = (mint && cJSON_IsString(mint) && mint->valuestring) ? mint->valuestring : NULL; - if ((!mint_url || mint_url[0] == '\0') && ctx->cfg->cashu_wallet.mint_count <= 0) { + if ((!mint_url || mint_url[0] == '\0') && !cashu_wallet_has_default_mint()) { cJSON_Delete(args); return json_error_local("cashu_wallet_info requires mint_url when no cashu_wallet.mint_urls are configured"); } @@ -100,7 +100,7 @@ char* execute_cashu_wallet_mint_quote(tools_context_t* ctx, const char* args_jso cJSON* unit = cJSON_GetObjectItemCaseSensitive(args, "unit"); const char* mint_url = (mint && cJSON_IsString(mint) && mint->valuestring) ? mint->valuestring : NULL; const char* unit_s = (unit && cJSON_IsString(unit) && unit->valuestring) ? unit->valuestring : NULL; - if ((!mint_url || mint_url[0] == '\0') && ctx->cfg->cashu_wallet.mint_count <= 0) { + if ((!mint_url || mint_url[0] == '\0') && !cashu_wallet_has_default_mint()) { cJSON_Delete(args); return json_error_local("cashu_wallet_mint_quote requires mint_url when no cashu_wallet.mint_urls are configured"); } @@ -125,7 +125,7 @@ char* execute_cashu_wallet_mint_check(tools_context_t* ctx, const char* args_jso cJSON* mint = cJSON_GetObjectItemCaseSensitive(args, "mint_url"); const char* mint_url = (mint && cJSON_IsString(mint) && mint->valuestring) ? mint->valuestring : NULL; - if ((!mint_url || mint_url[0] == '\0') && ctx->cfg->cashu_wallet.mint_count <= 0) { + if ((!mint_url || mint_url[0] == '\0') && !cashu_wallet_has_default_mint()) { cJSON_Delete(args); return json_error_local("cashu_wallet_mint_check requires mint_url when no cashu_wallet.mint_urls are configured"); } @@ -160,7 +160,7 @@ char* execute_cashu_wallet_mint_claim(tools_context_t* ctx, const char* args_jso cJSON* mint = cJSON_GetObjectItemCaseSensitive(args, "mint_url"); const char* mint_url = (mint && cJSON_IsString(mint) && mint->valuestring) ? mint->valuestring : NULL; - if ((!mint_url || mint_url[0] == '\0') && ctx->cfg->cashu_wallet.mint_count <= 0) { + if ((!mint_url || mint_url[0] == '\0') && !cashu_wallet_has_default_mint()) { cJSON_Delete(args); return json_error_local("cashu_wallet_mint_claim requires mint_url when no cashu_wallet.mint_urls are configured"); } @@ -187,7 +187,7 @@ char* execute_cashu_wallet_melt_quote(tools_context_t* ctx, const char* args_jso cJSON* unit = cJSON_GetObjectItemCaseSensitive(args, "unit"); const char* mint_url = (mint && cJSON_IsString(mint) && mint->valuestring) ? mint->valuestring : NULL; const char* unit_s = (unit && cJSON_IsString(unit) && unit->valuestring) ? unit->valuestring : NULL; - if ((!mint_url || mint_url[0] == '\0') && ctx->cfg->cashu_wallet.mint_count <= 0) { + if ((!mint_url || mint_url[0] == '\0') && !cashu_wallet_has_default_mint()) { cJSON_Delete(args); return json_error_local("cashu_wallet_melt_quote requires mint_url when no cashu_wallet.mint_urls are configured"); } @@ -212,7 +212,7 @@ char* execute_cashu_wallet_melt_pay(tools_context_t* ctx, const char* args_json) cJSON* mint = cJSON_GetObjectItemCaseSensitive(args, "mint_url"); const char* mint_url = (mint && cJSON_IsString(mint) && mint->valuestring) ? mint->valuestring : NULL; - if ((!mint_url || mint_url[0] == '\0') && ctx->cfg->cashu_wallet.mint_count <= 0) { + if ((!mint_url || mint_url[0] == '\0') && !cashu_wallet_has_default_mint()) { cJSON_Delete(args); return json_error_local("cashu_wallet_melt_pay requires mint_url when no cashu_wallet.mint_urls are configured"); } @@ -231,7 +231,7 @@ char* execute_cashu_wallet_check_proofs(tools_context_t* ctx, const char* args_j cJSON* mint = cJSON_GetObjectItemCaseSensitive(args, "mint_url"); const char* mint_url = (mint && cJSON_IsString(mint) && mint->valuestring) ? mint->valuestring : NULL; - if ((!mint_url || mint_url[0] == '\0') && ctx->cfg->cashu_wallet.mint_count <= 0) { + if ((!mint_url || mint_url[0] == '\0') && !cashu_wallet_has_default_mint()) { cJSON_Delete(args); return json_error_local("cashu_wallet_check_proofs requires mint_url when no cashu_wallet.mint_urls are configured"); } @@ -277,7 +277,7 @@ char* execute_cashu_wallet_send_token(tools_context_t* ctx, const char* args_jso cJSON* mint = cJSON_GetObjectItemCaseSensitive(args, "mint_url"); const char* mint_url = (mint && cJSON_IsString(mint) && mint->valuestring) ? mint->valuestring : NULL; - if ((!mint_url || mint_url[0] == '\0') && ctx->cfg->cashu_wallet.mint_count <= 0) { + if ((!mint_url || mint_url[0] == '\0') && !cashu_wallet_has_default_mint()) { cJSON_Delete(args); return json_error_local("cashu_wallet_send_token requires mint_url when no cashu_wallet.mint_urls are configured"); }