Skip to content

Feature: Price Feed via Nostr (Relay Mode) for Blocked Regions #697

@mostronatorcoder

Description

@mostronatorcoder

Feature: Price Feed via Nostr (Relay Mode) for Blocked Regions

Problem

A Mostro node operator in Venezuela cannot fetch prices from the price API (api.yadio.io) because it's DNS-blocked by Venezuelan ISPs.

PR #685 solved this for mobile users — the daemon publishes kind 30078 price events to Nostr, and the app subscribes instead of hitting the blocked API.

But the node operator still needs to fetch prices. If the operator is in a region where the price API is blocked, they cannot publish prices.

Proposed Solution

Allow the node operator to subscribe to price events from trusted Mostro nodes via Nostr instead of fetching from the API directly.

Prices are always published to Nostr. This setting only controls the source.

Settings (settings.toml)

Add to [mostro] section:

# Price source configuration
# Options:
#   "api"        - fetch directly from price API (default)
#   "nostr"      - subscribe from trusted nodes via Nostr
#   "api_nostr"  - price API first, Nostr as fallback
price_source = "api"

# Trusted Mostro node pubkeys for price feed (hex, one per line)
# Only used when price_source = "nostr" or "api_nostr"
trusted_nodes = [
    "00000235a3e904cfe1213a8a54d6f1ec1bef7cc6bfaabd6193e82931ccf1366a",
    "82fa8cb978b43c79b2156585bac2c011176a21d2aead6d9f7c575c005be88390",
]

Relays are not reconfigured — the node uses existing relay configuration from [nostr] section.

Behavior

price_source Source Publish to Nostr
api Price API ✅ Always
nostr Nostr from trusted nodes ✅ Always
api_nostr API first, Nostr fallback ✅ Always

Technical Details

Kind 30078 (NIP-33)

The daemon already publishes kind 30078 events for price data:

{
  "kind": 30078,
  "tags": [
    ["d", "mostro-rates"],
    ["published_at", "1234567890"],
    ["source", "yadio"],
    ["expiration", "1234568190"]
  ],
  "content": "{\"BTC\":{\"USD\":50000.0,\"EUR\":45000.0}}"
}

The subscriber subscribes to kind 30078 from trusted_nodes pubkeys with d = "mostro-rates" tag.

Implementation

  1. Add price_source and trusted_nodes to MostroSettings config struct
  2. Create NostrPriceSubscriber that subscribes to kind 30078 from trusted nodes
  3. Cache prices from Nostr subscription
  4. Modify BitcoinPriceManager to use either API or Nostr based on price_source
  5. Relay configuration from [nostr] section is reused

Example: Venezuela Node Config

[mostro]
price_source = "nostr"
trusted_nodes = [
    # Negrunch's node (outside blocked regions)
    "82fa8cb978b43c79b2156585bac2c011176a21d2aead6d9f7c575c005be88390",
    # Mostro Cuba node
    "00000235a3e904cfe1213a8a54d6f1ec1bef7cc6bfaabd6193e82931ccf1366a",
]

[nostr]
relays = [
    "wss://relay.mostro.network",
]

Open Questions

  1. Staleness: If trusted nodes go offline, prices become stale. Should we log a warning?
  2. Cache TTL: Should we reject Nostr prices older than X minutes?
  3. Bootstrap: On first start with nostr, should we do one API fetch as bootstrap?
  4. Multi-node merge: If multiple trusted nodes publish different prices, which wins?

Reference

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions