Skip to content

Commit 6727b84

Browse files
committed
Fix exchange rates other event
1 parent caea239 commit 6727b84

1 file changed

Lines changed: 4 additions & 55 deletions

File tree

src/other_events.md

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,9 @@ The operator of a Mostro instance decides which relays the events from that inst
224224

225225
The `r` label indicates the relays through which the Mostro instance is publishing its events.
226226

227-
## Exchange Rates (NIP-33 Kind 30078)
227+
## Exchange Rates
228228

229-
Each Mostro instance can optionally publish Bitcoin/fiat exchange rates to Nostr relays as [NIP-33](https://github.com/nostr-protocol/nips/blob/master/33.md) addressable events (kind 30078). This enables:
230-
231-
- **Censorship resistance**: Mobile clients in censored regions (Venezuela, Cuba, etc.) can fetch rates via Nostr relays
232-
- **Zero scaling cost**: Relays distribute events; no per-request infrastructure needed for the rate provider
233-
- **Backward compatibility**: HTTP API remains available as fallback for clients
234-
235-
The daemon fetches rates from a price API (e.g., Yadio) at a configurable interval and publishes the complete payload to Nostr. This is a **replaceable event** (NIP-33), meaning relays keep only the latest version identified by the `d` tag.
229+
Each Mostro instance publish Bitcoin/fiat exchange rates to Nostr relays as addressable events (kind 30078):
236230

237231
### Event Structure
238232

@@ -259,10 +253,10 @@ The daemon fetches rates from a price API (e.g., Yadio) at a configurable interv
259253

260254
### Tags
261255

262-
- **d**: `"mostro-rates"` — NIP-33 identifier that makes this event replaceable. Each new rate update replaces the previous one.
256+
- **d**: `"mostro-rates"` — NIP-01 identifier that makes this event replaceable. Each new rate update replaces the previous one.
263257
- **published_at**: Unix timestamp when the daemon published the event (daemon time, not source timestamp).
264258
- **source**: Rate source identifier (e.g., `"yadio"`).
265-
- **expiration**: Unix timestamp for event expiration ([NIP-40](https://github.com/nostr-protocol/nips/blob/master/40.md)). Prevents stale rates from being served. Calculated as `min(update_interval × 2, 3600)` to allow for delays while capping at 1 hour.
259+
- **expiration**: Unix timestamp for event expiration ([NIP-40](https://github.com/nostr-protocol/nips/blob/master/40.md)). Prevents stale rates from being served.
266260

267261
### Content Format
268262

@@ -284,51 +278,6 @@ The `content` field contains the full rate response in JSON format matching the
284278

285279
**Rate semantics**: Each value under `"BTC"` represents the price of 1 BTC in that currency.
286280

287-
**Example**: `"USD": 50000.0` means 1 BTC = 50,000 USD.
288-
289-
### Configuration
290-
291-
Exchange rate publishing is configured in `settings.toml`:
292-
293-
```toml
294-
[mostro]
295-
# Enable Nostr exchange rate publishing (default: true)
296-
publish_exchange_rates_to_nostr = true
297-
298-
# Update interval in seconds (default: 300, minimum: 60)
299-
exchange_rates_update_interval_seconds = 300
300-
```
301-
302-
If `publish_exchange_rates_to_nostr` is `false`, no exchange rate events are published.
303-
304-
### Client Usage
305-
306-
Clients should:
307-
308-
1. **Subscribe** to events with filter: `{"kinds": [30078], "#d": ["mostro-rates"], "authors": [<mostro_pubkey>]}`
309-
2. **Verify** the event signature and that `event.pubkey` matches the expected Mostro instance pubkey (prevents price manipulation)
310-
3. **Parse** the `content` field as JSON
311-
4. **Check** the `expiration` tag to ensure rates are not stale
312-
5. **Fall back** to HTTP API if Nostr fails or rates are expired
313-
314-
### Security Considerations
315-
316-
**⚠️ CRITICAL**: Clients MUST verify `event.pubkey == expected_mostro_pubkey` before using the rates. Without this check, a malicious actor could publish fake rates to manipulate prices.
317-
318-
**Signature verification**: Use standard Nostr signature verification (NIP-01) to ensure the event was signed by the Mostro instance's private key.
319-
320-
**Expiration**: Clients should reject events where `current_time > expiration` to avoid using stale rates.
321-
322-
### Why Nostr?
323-
324-
In countries with government censorship (Venezuela, Cuba, Iran, etc.), HTTP access to exchange rate APIs is often blocked. Nostr's decentralized relay network makes censorship impractical:
325-
326-
- **Geographic distribution**: Relays are hosted worldwide
327-
- **No single point of failure**: Blocking one relay doesn't affect others
328-
- **Standard Nostr infrastructure**: No special infrastructure needed; uses existing Nostr relay network
329-
330-
This aligns with Mostro's mission to provide censorship-resistant peer-to-peer Bitcoin trading.
331-
332281
# Development Fee
333282

334283
The development fee mechanism provides sustainable funding for Mostro development by automatically sending a configurable percentage of the Mostro fee to a lightning address on each successful order, this a regular event with kind 8383 which is expected to be stored by relays.

0 commit comments

Comments
 (0)