Skip to content

Feature: Publish Exchange Rates to Nostr (Censorship-Resistant Alternative to Yadio HTTP API) #684

@mostronatorcoder

Description

@mostronatorcoder

Problem

Currently, Mostro mobile clients rely on Yadio's HTTP API (https://api.yadio.io) for fetching Bitcoin/fiat exchange rates. This creates two issues:

  1. Censorship vulnerability — The API is blocked in Venezuela (and potentially other countries), preventing users from creating/taking orders.
  2. Scaling costs — HTTP APIs require infrastructure that scales with user count (more requests = higher costs for Yadio).

Proposed Solution

Publish exchange rates to Nostr relays using NIP-33 addressable events (kind 30078).

Benefits

  • Censorship-resistant — Governments cannot block decentralized Nostr relays
  • Zero scaling cost — Relays host events for free; Yadio (or Mostro) only publishes once every 5-10 minutes
  • Better UX in censored regions — Venezuela, Cuba, and other restricted countries can access rates
  • Backward compatible — HTTP API can remain as fallback

Technical Specification

Event Structure

Kind: 30078 (Application-specific data)
d tag: "mostro-rates"
Content: JSON object with all currency rates

Example Event

{
  "kind": 30078,
  "pubkey": "<yadio_or_mostro_pubkey>",
  "created_at": 1732546800,
  "tags": [
    ["d", "mostro-rates"],
    ["updated_at", "1732546800"],
    ["source", "yadio"]
  ],
  "content": "{\"USD\": {\"BTC\": 0.000024}, \"EUR\": {\"BTC\": 0.000022}, \"VES\": {\"BTC\": 0.0000000012}, ...}",
  "sig": "..."
}

Client Integration (Mostro Mobile)

// Subscribe to exchange rates from Nostr
final subscription = nostrPool.subscribe([
  Filter(
    kinds: [30078],
    authors: [yadioNostrPubkey],
    tags: {'#d': ['mostro-rates']},
  ),
]);

subscription.stream.listen((event) {
  final rates = jsonDecode(event.content);
  // Update UI with rates['USD']['BTC'], etc.
});

Fallback: If Nostr fetch fails, fall back to HTTP API.

Update Frequency

  • Recommended: Every 5-10 minutes (same as current HTTP API polling)
  • Publisher: Yadio (or Mostro daemon if Yadio doesn't adopt)

Recommended Relays

  • wss://relay.mostro.network (Mostro's relay, high availability)
  • wss://relay.damus.io (public, widely used)
  • wss://nos.lol (fast, good uptime)
  • wss://relay.nostr.band (archives everything, good fallback)

Implementation Plan

Phase 1: Proof of Concept (Mostro Daemon)

If Yadio doesn't adopt Nostr publishing, Mostro daemon can:

  1. Fetch rates from Yadio HTTP API every 5 minutes
  2. Publish to relay.mostro.network + public relays
  3. Sign events with Mostro's pubkey

Code location: src/exchange_rates.rs (new module)

Phase 2: Mobile Client Integration

  1. Update ExchangeService to support Nostr as primary source
  2. Add fallback to HTTP API if Nostr unavailable
  3. Cache rates locally (5-10 min TTL)

Related spec: EXCHANGE_SERVICE.md

References


Labels: enhancement, censorship-resistance, nostr, exchange-rates

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions