
# Usage

For installation, see [Install](install.md) or [build from source](build.md).

For configuration, see [configuration](configuration.md) and [how to connect with full node](bitcoind.md).

For connecting to rostrum with wallet or a programming library, see [connecting article](connecting.md).

For public server, or websocket support, you'll want to add [SSL/TLS Support](ssl-setup-guide.md).

Rostrum serves loads of metrics for monitoring, see [monitoring](monitoring.md).

## Nexa Integration

**Nexa on Linux includes Rostrum by default and runs it automatically alongside the node.** This means you don't need to install or configure Rostrum separately when using Nexa on Linux.

**On other platforms (macOS, Windows), the Electrum server is not enabled by default and must be explicitly enabled.**

When the built-in Electrum server is enabled, Nexa automatically launches Rostrum as a separate process. This provides seamless integration but gives you less control over the Rostrum instance.

**For better control over Rostrum, you can disable the built-in Electrum server and run Rostrum separately:**

```bash
# Disable built-in Electrum server
nexad -electrum=0

# Then run Rostrum separately with full control over configuration
rostrum --db-dir ./rostrum-db --electrum-rpc-addr 127.0.0.1:20001
```

The Electrum server is enabled by default on Linux (equivalent to `-electrum=1`) and can be configured using various `-electrum.*` options:

- `-electrum` or `-electrum=1` - Enable the built-in Electrum server (default on Linux, must be specified on other platforms)
- `-electrum=0` - Disable the built-in Electrum server
- `-electrum.port` - Port for Electrum RPC (default: mainnet 20001, testnet 30001, regtest 30401)
- `-electrum.host` - Host for Electrum RPC (default: all interfaces)
- `-electrum.ws.port` - Port for Electrum WebSocket (default: mainnet 20003, testnet 30003, regtest 30403)
- `-electrum.ws.host` - Host for Electrum WebSocket (default: all interfaces)
- `-electrum.dir` - Data directory for Electrum database
- `-electrum.shutdownonerror` - Shutdown if the Electrum server exits unexpectedly
- `-electrum.blocknotify` - Instantly notify Electrum server of new blocks
- `-electrum.rawarg` - Raw argument to pass directly to underlying Electrum daemon (can be specified multiple times)

**Platform-specific usage:**

- **Linux**: Electrum server runs by default, use `-electrum=0` to disable
- **macOS/Windows**: Use `-electrum` or `-electrum=1` to enable the Electrum server

The `-electrum.rawarg` option is particularly powerful as it allows you to pass any Rostrum configuration option directly to the underlying daemon. For example:
```bash
# On Linux (enabled by default)
nexad -electrum.rawarg="--server-banner=\"Welcome to my server!\""

# On other platforms (must enable first)
nexad -electrum -electrum.rawarg="--server-banner=\"Welcome to my server!\""
```

**Custom Rostrum binary location:**

If your Rostrum executable is not in the same directory as `nexad`, you can specify the full path:

```bash
# Specify custom path to Rostrum binary
nexad -electrum.exec=/usr/local/bin/rostrum

# Or with full configuration
nexad -electrum -electrum.exec=/usr/local/bin/rostrum -electrum.host=127.0.0.1
```

## Private Server Configuration

To make your Electrum server private and only accessible from the local machine, bind it to localhost (127.0.0.1):

```bash
# On Linux (enabled by default)
nexad -electrum.host=127.0.0.1 -electrum.ws.host=127.0.0.1

# On other platforms (must enable first)
nexad -electrum -electrum.host=127.0.0.1 -electrum.ws.host=127.0.0.1
```

This configuration ensures that:
- The Electrum RPC server only listens on localhost (port 20001 by default)
- The Electrum WebSocket server only listens on localhost (port 20003 by default)
- External connections are blocked, making it a private server
- Only applications running on the same machine can connect

For more configuration options, run `nexad --help` and look for the "Electrum server options" section.
