| Crates.io | mostro |
| lib.rs | mostro |
| version | 0.16.0 |
| created_at | 2024-04-02 13:40:47.745996+00 |
| updated_at | 2026-01-16 20:04:01.510999+00 |
| description | Lightning Network peer-to-peer nostr platform |
| homepage | https://mostro.network |
| repository | https://github.com/MostroP2P/mostro |
| max_upload_size | |
| id | 1193539 |
| size | 852,112 |
A production-ready, censorship-resistant, non-custodial Lightning Network peer-to-peer exchange built on Nostr

Mostro is a production-ready Lightning Network peer-to-peer exchange that enables Bitcoin trading without custodial risk or KYC requirements. Built on the censorship-resistant Nostr protocol, Mostro provides a decentralized alternative to centralized exchanges and custodial platforms.
The need for KYC-free Bitcoin trading has never been greater. @lnp2pBot, a Telegram-based P2P exchange, has demonstrated strong global demandβparticularly in regions facing monetary instability like Latin America, Cuba, and Venezuela, where citizens resist tyranny by adopting Bitcoin over broken fiat currencies.
While @lnp2pBot works excellently, it relies on Telegramβa platform potentially vulnerable to government pressure. Nostr solves this: as a decentralized protocol with no single point of failure, it provides the censorship-resistant foundation needed for a truly unstoppable peer-to-peer exchange.
Mostro brings this vision to life. It's not just a proof of conceptβit's a fully operational daemon powering real trades today, with robust features including dispute resolution, reputation systems, development fee transparency, and admin tooling.
tracing, configurable log levelsMostro acts as a non-custodial escrow coordinator between buyers and sellers using the Lightning Network. The daemon handles three primary flows: order lifecycle, dispute resolution, and fee distribution.
sequenceDiagram
autonumber
participant S as Seller
participant M as Mostro
participant LN as Lightning Node
participant B as Buyer
Note over S,B: 1. ORDER CREATION
S->>M: Create sell order (100k sats @ market)
M->>M: Calculate fees (1% = 1k sats total)
M-->>S: Order published (pending)
Note over S,B: 2. ORDER ACCEPTANCE
B->>M: Take order
M->>M: Reserve order for buyer
M-->>S: Buyer found, prepare hold invoice
M-->>B: Order reserved, wait for seller
Note over S,B: 3. ESCROW SETUP
M->>LN: Create hold invoice (100,500 sats)
LN-->>M: Hold invoice + preimage
M->>S: Pay this hold invoice
S->>LN: Payment (holds funds)
LN-->>M: Payment received (held)
M-->>S: Escrowed! Wait for buyer invoice
M-->>B: Seller paid, send your invoice
Note over S,B: 4. BUYER INVOICE & FIAT TRANSFER
B->>M: Here's my invoice (99,500 sats)
M-->>S: Buyer ready, send fiat via [payment method]
S->>B: [Off-chain fiat transfer]
B->>M: Fiat sent
M-->>S: Buyer claims fiat sent
Note over S,B: 5. RELEASE
S->>M: Fiat received, release!
M->>LN: Settle hold invoice (preimage)
LN-->>M: Released (1,000 sats fee to Mostro)
M->>LN: Pay buyer invoice (99,500 sats)
LN-->>B: Payment received
M-->>S: Trade complete β
M-->>B: Trade complete β
Note over S,B: 6. POST-TRADE
M->>M: Update reputations
M->>M: Schedule dev fee payment (300 sats)
M->>LN: Pay dev fee to fund
M->>M: Publish audit event (kind 8383)
Key Points:
For more detailed protocol specifications, see the official protocol documentation.
When disputes occur, Mostro's arbiter system ensures fair resolution:
sequenceDiagram
autonumber
participant U as User (Buyer/Seller)
participant M as Mostro
participant A as Admin/Arbiter
participant LN as Lightning Node
U->>M: Open dispute (order stuck)
M->>M: Mark order as "Dispute"
M->>M: Record initiator (buyer/seller)
M-->>U: Dispute created, awaiting arbiter
M-->>A: New dispute notification
A->>M: Take dispute (via RPC or Nostr)
M->>M: Assign arbiter to case
M-->>U: Arbiter assigned
Note over U,A: Investigation & Communication
A->>U: Request evidence/information
U->>A: Provide proof of payment/issue
Note over A,LN: Resolution Decision
alt Settle to seller
A->>M: Settle order (seller wins)
M->>LN: Settle hold invoice
LN-->>M: Released to seller
M-->>U: Dispute resolved (seller)
else Cancel/Refund to buyer
A->>M: Cancel order (buyer wins)
M->>LN: Cancel hold invoice
LN-->>M: Refunded to buyer
M-->>U: Dispute resolved (buyer)
end
M->>M: Log resolution for audit
M-->>U: Case closed
Dispute Tracking (v0.15.6): Each dispute includes initiator identification (buyer or seller), arbiter assignment, resolution status, and audit trail in the database.
Mostro implements a transparent development sustainability model:
sequenceDiagram
autonumber
participant M as Mostro Daemon
participant DB as Database
participant LN as Lightning Node
participant Fund as Dev Fund (Lightning Address)
participant Nostr as Nostr Relays
Note over M,Nostr: After Successful Trade
M->>M: Order completed (status: settled-hold-invoice)
M->>M: Mostro collected 1,000 sats fee
M->>DB: Mark dev_fee=300, dev_fee_paid=0
Note over M,Nostr: Scheduler (every 60s)
M->>DB: Query unpaid dev fees
DB-->>M: Order #123: 300 sats unpaid
M->>LN: Resolve Lightning address (LNURL)
LN-->>M: Payment request
M->>LN: Send payment (300 sats)
LN-->>Fund: Payment delivered
LN-->>M: Payment hash: abc123...
M->>DB: UPDATE dev_fee_paid=1, hash=abc123...
M->>Nostr: Publish audit event (kind 8383)
Note over Nostr: Transparent, queryable by anyone
Nostr-->>M: Event published
Note over M,Nostr: Result
M->>M: Mostro keeps 700 sats (70%)
Fund->>Fund: Dev fund receives 300 sats (30%)
Transparency Features:
dev_fee_percentage (min 10%, max 100%, default 30%)Query all dev fee payments on Nostr:
# Requires nostreq and nostcat tools
nostreq --kinds 8383 --tag y=mostro --tag z=dev-fee-payment | nostcat --stream wss://relay.damus.io
Mostro is a Rust-based daemon with a modular architecture:
flowchart TB
subgraph "External Systems"
Nostr[Nostr Relays<br/>NIP-59 GiftWrap]
LND[LND Node<br/>Hold Invoices]
API[Price API<br/>Yadio]
end
subgraph "Mostro Daemon (mostrod)"
Main[main.rs<br/>Entry Point]
subgraph "Core Modules"
App[app.rs<br/>Event Router]
Lightning[lightning/*<br/>LND Client]
RPC[rpc/*<br/>gRPC Server]
Scheduler[scheduler.rs<br/>Background Jobs]
end
subgraph "Order Handlers (app/*)"
Order[order.rs]
TakeBuy[take_buy.rs]
TakeSell[take_sell.rs]
Release[release.rs]
Dispute[dispute.rs]
Admin[admin_*.rs]
end
DB[(SQLite<br/>mostro.db)]
Config[settings.toml]
end
Nostr <-->|GiftWrap Events| App
LND <-->|gRPC| Lightning
API -->|Price Feed| Order
Main --> Config
Main --> DB
Main --> App
Main --> Lightning
Main --> RPC
Main --> Scheduler
App --> Order
App --> TakeBuy
App --> TakeSell
App --> Release
App --> Dispute
App --> Admin
Order --> DB
Order --> Lightning
Release --> Lightning
Admin --> DB
Admin --> Lightning
Scheduler --> DB
Scheduler --> Lightning
RPC --> Admin
Key Components:
app.rs): Unwraps NIP-59 GiftWraps, validates PoW/signatures, routes to action handlersapp/*): 17 modules handling order lifecycle, disputes, admin operationslightning/*): Creates hold invoices, settles/cancels, manages paymentsrpc/*): gRPC interface for direct admin communication (optional)scheduler.rs): Background jobs for expiration, retries, dev fee paymentsdb.rs + SQLx): Order state, user reputation, trade indices, audit trailsTechnology Stack:
nostr-sdk v0.43 (NIP-59 GiftWrap, NIP-33 replaceable events)fedimint-tonic-lnd v0.3 (LND gRPC client)sqlx v0.6 with offline compile-time query verificationtonic + prost (Protocol Buffers)For detailed architecture documentation, see the docs/ directory:
Mostro supports three deployment methods. For production deployments, see INSTALL.md for complete step-by-step instructions.
All Methods:
Native Build Dependencies:
Ubuntu/Debian:
sudo apt update
sudo apt install -y cmake build-essential libsqlite3-dev pkg-config protobuf-compiler
macOS:
brew update
brew install cmake pkg-config sqlite3 protobuf
Best for: Production servers, VPS deployments, full control over the daemon
Quick Start:
# Clone repository
git clone https://github.com/MostroP2P/mostro.git
cd mostro
# Build release binary
cargo build --release
# Install to system
sudo install target/release/mostrod /usr/local/bin
# Setup configuration
mkdir -p ~/.mostro
cp settings.tpl.toml ~/.mostro/settings.toml
# Edit ~/.mostro/settings.toml (see Configuration section)
# Initialize database
cargo install sqlx-cli --version 0.6.2
./init_db.sh
# Run daemon
mostrod
Production Setup (systemd):
See INSTALL.md for complete Digital Ocean/VPS setup including:
/etc/systemd/system/mostro.service)Best for: Local testing, development environments, quick experiments
Quick Start:
# Clone repository
git clone https://github.com/MostroP2P/mostro.git
cd mostro
# Setup configuration
mkdir -p docker/config
cp docker/settings.docker.toml docker/config/settings.toml
cp docker/empty.mostro.db docker/config/mostro.db
# Edit docker/config/settings.toml
# Configure LND paths in docker/.env
echo "LND_CERT_FILE=~/.polar/networks/1/volumes/lnd/alice/tls.cert" >> docker/.env
echo "LND_MACAROON_FILE=~/.polar/networks/1/volumes/lnd/alice/data/chain/bitcoin/regtest/admin.macaroon" >> docker/.env
# Build and run
make docker-build
make docker-up
This starts:
Stop: make docker-down
For detailed Docker setup, see docker/README.md.
Best for: Start9 users, sovereign computing, non-technical users
Mostro is available as a StartOS package with enhanced features. Install directly from the Start9 marketplace or sideload:
# Build StartOS package
make docker-startos
Features in StartOS build:
For StartOS-specific documentation, see docker/README.md.
For complete local testing with mocked Lightning Network:
# Clone mostro-regtest (includes relay + LND + Mostro)
git clone https://github.com/MostroP2P/mostro-regtest.git
cd mostro-regtest
# Follow mostro-regtest README for setup
This provides a full Bitcoin regtest environment with pre-configured LND nodes and Nostr relay.
Mostro uses a TOML configuration file (settings.toml). Copy the template and customize:
cp settings.tpl.toml ~/.mostro/settings.toml
[lightning]
lnd_cert_file = '/path/to/lnd/tls.cert'
lnd_macaroon_file = '/path/to/lnd/admin.macaroon'
lnd_grpc_host = 'https://127.0.0.1:10009'
# Hold invoice expiration (5 minutes = 300 seconds)
hold_invoice_expiration_window = 300
# Payment retry configuration
payment_attempts = 3
payment_retries_interval = 60 # seconds between retries
Required: LND connection details. Mostro needs admin macaroon for hold invoice management.
[nostr]
# Your Mostro daemon's private key (nsec format)
nsec_privkey = 'nsec1...'
# Relays to connect to
relays = [
'wss://relay.damus.io',
'wss://relay.mostro.network',
'wss://nostr.wine'
]
Required: Generate a dedicated Nostr key for your Mostro instance:
# Using rana (https://github.com/grunch/rana)
rana --vanity mostro
Important: Never reuse keys between Mostro instances. Each daemon needs a unique identity.
[mostro]
# Trading fee (0.006 = 0.6%, charged to both parties)
fee = 0.006
# Maximum Lightning routing fee tolerance (0.001 = 0.1%)
max_routing_fee = 0.001
# Order limits (satoshis)
max_order_amount = 1000000 # 1M sats max per order
min_payment_amount = 100 # 100 sats minimum
# Order expiration
expiration_hours = 24 # Orders expire after 24 hours if not taken
expiration_seconds = 900 # 15 minutes for taker to complete payment
# Proof-of-Work requirement (0 = disabled)
pow = 0 # Set to 10-20 to prevent spam
# Development sustainability fee (0.30 = 30% of Mostro fee goes to dev fund)
dev_fee_percentage = 0.30 # Minimum: 0.10 (10%), Maximum: 1.0 (100%)
# Fiat currency whitelist (empty = accept all)
fiat_currencies_accepted = ['USD', 'EUR', 'ARS', 'BRL']
# Price feed API
bitcoin_price_api_url = "https://api.yadio.io"
Key Settings:
fee: Your Mostro's fee percentage (default 0.6% split between buyer/seller)dev_fee_percentage: Portion of your fee donated to Mostro development (default 30%)pow: Increase to 10-20 if experiencing spam (higher = slower client messages)fiat_currencies_accepted: Restrict supported currencies (empty array = accept all)[rpc]
enabled = false # Set to true to enable gRPC admin interface
listen_address = "127.0.0.1"
port = 50051
When enabled, exposes gRPC interface on 127.0.0.1:50051 for:
[database]
url = "sqlite://mostro.db" # Relative path or absolute: "sqlite:///home/mostro/.mostro/mostro.db"
Database Management:
# Initialize new database
cargo sqlx database create
cargo sqlx migrate run
# Backup database
cp ~/.mostro/mostro.db ~/.mostro/mostro.db.backup
# Inspect database
sqlite3 ~/.mostro/mostro.db
settings.toml - Contains private keys and credentialscargo sqlx migrate run after pulling updatesjournalctl -u mostro | grep "dev_fee"For complete settings reference, see settings.tpl.toml.
Native Binary:
# Foreground (see logs)
mostrod
# Background (systemd)
sudo systemctl start mostro
sudo systemctl status mostro
sudo journalctl -u mostro -f # Follow logs
Docker:
make docker-up # Start services
make docker-down # Stop services
docker compose logs -f mostro # View logs
Check active orders:
sqlite3 ~/.mostro/mostro.db "SELECT id, status, amount, fiat_amount FROM orders WHERE status = 'pending' ORDER BY created_at DESC LIMIT 10;"
Monitor dev fee payments:
sqlite3 ~/.mostro/mostro.db "SELECT id, dev_fee, dev_fee_paid, dev_fee_payment_hash FROM orders WHERE status = 'success' ORDER BY created_at DESC LIMIT 10;"
Query Nostr for Mostro info event:
# Install nostr tools: cargo install nostreq nostcat
# Fetch Mostro settings (kind 38383)
nostreq --kinds 38383 --limit 1 --authors YOUR_MOSTRO_PUBKEY | nostcat --stream wss://relay.damus.io | jq
Mostro requires a client to interact with the daemon. Available clients:
Example: Creating an order with mostro-cli:
# Install mostro-cli
git clone https://github.com/MostroP2P/mostro-cli.git
cd mostro-cli
cargo install --path .
# Create sell order (sell 100k sats for $50 USD via bank transfer)
mostro-cli order create --kind sell --amount 100000 --fiat-amount 50 --fiat-code USD --payment-method bank-transfer
# List available orders
mostro-cli order list
# Take an order
mostro-cli order take <order-id>
For client documentation, see the respective client repositories.
If RPC is enabled, use admin tools for dispute resolution:
# Cancel an order (admin override)
grpcurl -plaintext -d '{"order_id": "abc123"}' localhost:50051 mostro.admin.v1.AdminService/CancelOrder
# Settle disputed order
grpcurl -plaintext -d '{"order_id": "abc123"}' localhost:50051 mostro.admin.v1.AdminService/SettleOrder
# Add dispute solver
grpcurl -plaintext -d '{"solver_pubkey": "npub1..."}' localhost:50051 mostro.admin.v1.AdminService/AddSolver
Development fee payments are auditable via Nostr (kind 8383):
# Get all dev fee payments from your Mostro
nostreq --kinds 8383 --tag y=mostro --tag z=dev-fee-payment --authors YOUR_MOSTRO_PUBKEY | nostcat --stream wss://relay.damus.io | jq
# Calculate total dev fund contributions
nostreq --kinds 8383 --tag y=mostro --tag z=dev-fee-payment | jq '[.[] | .tags[] | select(.[0]=="amount") | .[1] | tonumber] | add'
This transparency allows third-party verification of development fund contributions.
Mostro is a backend daemon. Users interact with it through client applications that communicate via Nostr.
Repository: https://github.com/MostroP2P/mostro-cli Status: Production-ready Best For: Testing, automation, power users
Features:
Installation:
git clone https://github.com/MostroP2P/mostro-cli.git
cd mostro-cli
cargo install --path .
Repository: https://github.com/MostroP2P/mostro-web Status: In development Best For: General users, accessibility
Features (planned):
Mobile (iOS/Android) and desktop (Windows/Mac/Linux) clients are planned for future releases. Community contributions welcome!
Mostro clients communicate via Nostr using the mostro-core protocol library.
Quick Start:
// Add to Cargo.toml
[dependencies]
mostro-core = "0.6.57"
nostr-sdk = "0.43"
// Basic client structure
use mostro_core::{Message, Action, Order};
use nostr_sdk::Client;
// Connect to relays
let client = Client::new(&keys);
client.add_relay("wss://relay.mostro.network").await?;
// Create order message
let order = Order { /* ... */ };
let message = Message::new(Action::NewOrder, order);
// Send via NIP-59 GiftWrap to Mostro pubkey
// ...
Resources:
For detailed client development guide, see the protocol documentation.
Mostro is actively developed and welcomes contributions. Whether you're fixing bugs, adding features, or improving documentation, your help makes Mostro better for everyone.
git clone https://github.com/YOUR_USERNAME/mostro.git
cd mostro
# Rust toolchain (1.86+)
rustup update stable
# SQLx CLI (for database migrations)
cargo install sqlx-cli --version 0.6.2
# Development dependencies
sudo apt install protobuf-compiler cmake build-essential # Ubuntu
brew install protobuf cmake # macOS
# Copy template configuration
cp settings.tpl.toml settings.toml
# Edit settings.toml with your LND/Nostr config
# Initialize database
./init_db.sh
# With debug logging
RUST_LOG=debug cargo run
# Run tests
cargo test
# Check code formatting
cargo fmt --all -- --check
# Run linter
cargo clippy --all-targets --all-features -- -D warnings
mostro/
βββ src/
β βββ main.rs # Entry point, initialization
β βββ app.rs # Event router, message dispatcher
β βββ app/ # Order lifecycle handlers (17 modules)
β β βββ order.rs # Create orders
β β βββ take_buy.rs # Buyer takes sell order
β β βββ take_sell.rs # Seller takes buy order
β β βββ release.rs # Release escrow, payments
β β βββ dispute.rs # Dispute handling
β β βββ admin_*.rs # Admin operations (4 modules)
β βββ lightning/ # LND integration
β β βββ mod.rs # Client, hold invoice management
β β βββ invoice.rs # Invoice parsing, validation
β βββ rpc/ # gRPC server
β β βββ server.rs # Admin service implementation
β βββ config/ # Configuration management
β βββ db.rs # Database queries (SQLx)
β βββ scheduler.rs # Background jobs
β βββ util.rs # Shared utilities
βββ proto/ # Protocol Buffer definitions
β βββ admin.proto # RPC API specification
βββ migrations/ # SQLx database migrations
βββ docs/ # Architecture documentation
β βββ ARCHITECTURE.md # System overview
β βββ ORDERS_AND_ACTIONS.md
β βββ DEV_FEE.md # Development fee technical spec
β βββ RPC.md # RPC API reference
βββ docker/ # Docker configuration
βββ settings.tpl.toml # Configuration template
Before committing:
# Format code
cargo fmt
# Run linter
cargo clippy --all-targets --all-features -- -D warnings
# Run tests
cargo test
# Update SQLx offline data (after query/schema changes)
cargo sqlx prepare -- --bin mostrod
After schema changes:
# Create migration
sqlx migrate add my_feature_name
# Edit migrations/YYYYMMDDHHMMSS_my_feature_name.sql
# Apply migration
sqlx migrate run
# Update offline data
cargo sqlx prepare -- --bin mostrod
Unit Tests: Co-located in modules under mod tests
# Run all tests
cargo test
# Run specific test
cargo test test_get_dev_fee
# Run with output
cargo test -- --nocapture
Integration Testing: Use mostro-regtest for full stack testing
git clone https://github.com/MostroP2P/mostro-regtest.git
cd mostro-regtest
# Follow README for complete regtest environment
When adding features:
docs/ directory///) for public APIsFor extensive features, add a dedicated doc file (e.g., docs/MY_FEATURE.md).
For detailed contributing guidelines, see CONTRIBUTING.md.
Mostro's open-source design enables anyone to operate their own instance, ensuring no single entity controls the network. Multiple independent Mostro operators create a resilient, censorship-resistant ecosystem.
For the Network:
For You:
Technical Prerequisites:
Operational Commitment:
Financial Considerations:
Mostro implements a reputation system where users rate their experience with each Mostro operator. Poor reputation = fewer users = lower revenue. This creates economic incentives for operators to:
settings.tomlUsers can discover Mostro operators by:
Example Query:
# Find all Mostro instances on Nostr
nostreq --kinds 38383 | nostcat --stream wss://relay.damus.io | jq
Join the operator community:
cargo doc --open to generate and browse API documentationMostro is licensed under the MIT License.
Mostro is built by the community, for the community. Special thanks to:
Mostro offers bounties for contributions through our Rewards Board. We're grateful for the generous donations from contributors (many anonymous) and institutional grants that make this program possible.
While Mostro is not a company, the rewards program enables us to thank collaborators and accelerate development.
As of v0.15.6, Mostro includes a transparent development fee system where Mostro operators contribute a configurable percentage (default 30%, minimum 10%) of their fee income to the development fund. This ensures long-term sustainability while maintaining the project's open-source ethos.
All development fee payments are published to Nostr (kind 8383 events) for public verification. See docs/DEV_FEE.md for complete details.
For a complete list of contributors, see the contributors page.