diff --git a/hubzilla/addon/cry01/config.json.template b/hubzilla/addon/cry01/config.json.template index dd79038..1327ef2 100644 --- a/hubzilla/addon/cry01/config.json.template +++ b/hubzilla/addon/cry01/config.json.template @@ -2,8 +2,6 @@ "_note": "Copy to config.json. Do not commit config.json — it contains installation-specific values.", "g1_rpc_endpoint": "REPLACE — Duniter node RPC over Wireguard, e.g. http://10.0.0.105:9944", "orchestrator_url": "REPLACE — orchestrator base URL, e.g. http://10.0.0.105:8700", - "operator_g1_pubkey": "REPLACE — operator Ğ1 public key (not private key — never store private keys)", - "operator_did": "REPLACE — operator did:web identifier, e.g. did:web:directory.diagnostics.kane-il.us", "cache_file": "REPLACE — absolute path to balance cache JSON on the host", "cache_max_age_seconds": 3600, "ots_calendar_url": "https://alice.btc.calendar.opentimestamps.org", diff --git a/hubzilla/addon/cry01/cry01_chain.php b/hubzilla/addon/cry01/cry01_chain.php index 34bf61b..a3c2f75 100644 --- a/hubzilla/addon/cry01/cry01_chain.php +++ b/hubzilla/addon/cry01/cry01_chain.php @@ -122,22 +122,21 @@ function cry01_cache_is_stale() { return (time() - filemtime($path)) > $max_age; } -function cry01_refresh_balance_cache() { - // Refreshes the balance cache by querying the Duniter node. - // Writes updated cache to disk. Called by the manage route. - $config = cry01_load_config(); - $pubkey = $config['operator_g1_pubkey'] ?? ''; - if (!$pubkey) { - logger('cry01_chain: operator_g1_pubkey not set in config'); +function cry01_refresh_balance_cache($g1_pubkey) { + // Refreshes the balance cache for the given public key. + // The public key comes from the wallet session via the manage POST form — never from config. + // Returns true on success, false on failure. + if (!$g1_pubkey) { + logger('cry01_chain: cry01_refresh_balance_cache called with empty pubkey'); return false; } - $balance = cry01_get_balance($pubkey); + $balance = cry01_get_balance($g1_pubkey); if ($balance === null) return false; $cache = cry01_read_cache(); - $cache['operator_balance'] = $balance; - $cache['operator_g1_pubkey'] = $pubkey; - $cache['refreshed_at'] = date('c'); + $cache['balance'] = $balance; + $cache['g1_pubkey'] = $g1_pubkey; + $cache['refreshed_at'] = date('c'); return cry01_write_cache($cache); } diff --git a/hubzilla/addon/cry01/cry01_renderer.php b/hubzilla/addon/cry01/cry01_renderer.php index eeca381..e1435c9 100644 --- a/hubzilla/addon/cry01/cry01_renderer.php +++ b/hubzilla/addon/cry01/cry01_renderer.php @@ -51,17 +51,18 @@ function cry01_render_landing($association_slug, $access) { // --------------------------------------------------------------------------- function cry01_render_balance_display() { - // Renders the operator Ğ1 balance from cache. Shows staleness if cache is old. - $cache = cry01_read_cache(); - $balance = $cache['operator_balance'] ?? null; - $pubkey = $cache['operator_g1_pubkey'] ?? ''; + // Renders the Ğ1 balance from cache. The cached key belongs to whoever last refreshed. + // Shows staleness if cache is old. + $cache = cry01_read_cache(); + $balance = $cache['balance'] ?? null; + $pubkey = $cache['g1_pubkey'] ?? ''; $refreshed = $cache['refreshed_at'] ?? null; $out = '
Balance not yet loaded. Operator: use Manage to refresh.
'; + $out .= 'Balance not yet loaded. Unlock your Ğ1 wallet and use Manage to refresh.
'; } else { $out .= '' . cry01_h($balance) . '
'; if ($pubkey) { @@ -88,7 +89,6 @@ function cry01_render_signal_board($association_slug, $access) { } // TODO: load signals from orchestrator spool for this association. - // Placeholder until orchestrator query is implemented. $out = 'No signals posted yet.
'; @@ -102,6 +102,7 @@ function cry01_render_signal_board($association_slug, $access) { function cry01_render_signal_form($association_slug, $access) { // Renders the capacity signal registration form. + // The g1_pubkey field is populated by the g1wallet session event when available. $config = cry01_load_config(); $categories = $config['signal_categories'] ?? []; $form_url = z_root() . '/cry01/' . cry01_h($association_slug) . '/signal'; @@ -110,14 +111,18 @@ function cry01_render_signal_form($association_slug, $access) { $out .= 'Describe what you are offering or seeking, denominated in Ğ1.
'; + // Wallet session note — replaced by g1wallet integration once built. + $out .= '