Node Operations
This guide covers running a Shamwari node, configuring ports and security, and using the administrative APIs for node maintenance.
Prerequisites
- Java 21 JDK (minimum) — the
./jdkdirectory or a systemjavaonPATH - 2 GB RAM minimum recommended (4 GB for production)
- Network access on the API port (22025) and peer port (22022)
Shamwari does not use Maven or Gradle. Builds are driven by shell scripts that invoke javac directly.
Directory Layout
shamwariQKP/
├── run.sh # Starts the node (foreground or --daemon)
├── stop.sh # Stops a daemon-mode node
├── compile.sh # Compiles all Java: core, desktop, add-ons, tests
├── jar.sh # Builds shamwari.jar and shamwariservice.jar
├── package.sh # Full release package: compile, jar, javadoc, zip
├── generateAPICalls.sh # Generates typed API callers and response wrappers
├── tests/run-tests.sh # Runs non-live unit tests
├── conf/
│ ├── nxt-default.properties # Default configuration (do not edit)
│ └── nxt.properties # Your overrides (create this file)
├── lib/ # Runtime dependencies
├── classes/ # Compiled core classes (created by compile.sh)
├── addons/ # Add-on plugins (src/, classes/, lib/)
└── logs/ # Log output (created at runtime)
Data directory: ~/.shamwari/ — contains nxt.pid, logs/, and blockchain database files.
Build & Run
Compile
./compile.sh # Compile core + desktop + add-ons + tests
./compile.sh --skip-desktop # Skip JavaFX desktop UI compilation
This produces classes/ (core), addons/classes/ (add-ons), and test/classes/ (tests).
Build the JAR
./jar.sh
This creates two JAR files:
| File | Entry point | Use |
|---|---|---|
shamwari.jar | nxt.Nxt | Headless server node |
shamwariservice.jar | Windows service | Production Windows deployment |
Start the Node
./run.sh # Foreground (logs to console)
./run.sh --daemon # Background (writes PID to ~/.shamwari/nxt.pid)
./run.sh --desktop # Desktop mode with JavaFX wallet UI
./run.sh --authbind # Use authbind for privileged ports
The classpath is: classes:lib/*:conf:addons/classes:addons/lib/*:javafx-sdk/lib/*
Stop the Node
./stop.sh
This reads the PID from ~/.shamwari/nxt.pid and sends a kill signal, waiting for clean shutdown. The deprecated start.sh still works but prints a deprecation notice.
Run Tests
./tests/run-tests.sh
This runs non-live unit tests against production classes without starting a node:
nxt.crypto.CryptoTestnxt.crypto.ShamwariQkpTestnxt.account.AccountTestnxt.blockchain.BlockImplTestnxt.blockchain.TransactionImplTest
Tests use JUnit 5 via lib/junit-platform-console-standalone-1.5.2.jar.
Configuration
Configuration follows the Nxt convention:
conf/nxt-default.propertiescontains defaults (do not edit this file).- Create
conf/nxt.propertieswith only the values you want to override.
Key Settings
# --- Network & Ports ---
# API server: HTTP requests to /nxt?requestType=...
nxt.apiServerHost=0.0.0.0
nxt.apiServerPort=22025 # Mainnet API port
# Peer server: incoming peer-to-peer connections
nxt.peerServerHost=0.0.0.0
nxt.peerServerPort=22022
nxt.shareMyAddress=true # Announce your public IP to peers
# --- Security ---
# Restrict which IPs can call the API (semicolon-separated)
nxt.allowedBotHosts=127.0.0.1; localhost; 0.0.0.0
# Admin password required for debug/forging/node-management APIs
nxt.adminPassword=your_secure_admin_password
# --- Operational ---
nxt.isOffline=false # Set true for offline signing/transactions
# nxt.credentials.secretPhrase= # Required if nxt.isPermissioned=true
# --- Testnet override (create nxt-testnet.properties) ---
nxt.apiServerPort=22024
Default ports summary:
| Service | Default Port |
|---|---|
| API (mainnet) | 22025 |
| API (testnet) | 22024 |
| Peer server | 22022 |
API Endpoints
All HTTP APIs are served at a single endpoint:
http://host:22025/nxt?requestType=<apiName>
Each handler class in src/java/nxt/http/XXX.java registers a requestType string. The ApiSpec enum (auto-generated) validates parameters for each call.
Authentication
Two authentication mechanisms exist:
- Admin password (
adminPasswordparameter ornxt.adminPasswordin config) — required for allAPITag.DEBUGandAPITag.FORGINGendpoints. - ShamwariQKP key pair (
shamwariPrivateKey+shamwariPublicKey) — used for signing transactions and forging, replacing the NxtsecretPhrase/privateKeymodel.
Node Management APIs
requestType | Tag | Description |
|---|---|---|
getState | INFO | Node status, memory, peer counts, blockchain height, contract counts |
getBlockchainStatus | INFO | Chain status: current block, version, last block |
getConstants | INFO | Network constants, genesis, epoch, token definitions |
getConfiguration | INFO | Runtime configuration (sensitive values redacted) |
setConfiguration | DEBUG | Update runtime configuration (requires admin) |
getLog | DEBUG | Tail of the log file |
setLogging | DEBUG | Dynamically adjust logging level |
Example: Query Node State
curl -s "http://localhost:22025/nxt?requestType=getState&includeCounts=true" \
-H "adminPassword: your_admin_password"
Returns JSON with numberOfBlocks, numberOfPeers, numberOfTransactions, peerPort, isOffline, memory usage, and more.
Forging Management APIs
Shamwari uses hybrid post-quantum forging via ShamwariQKP (Kyber + Dilithium). Forging APIs accept shamwariPrivateKey and shamwariPublicKey rather than the legacy secretPhrase.
requestType | Tag | Description |
|---|---|---|
startForging | FORGING | Start forging with a ShamwariQKP key pair |
stopForging | FORGING | Stop forging for a specific key or all forgers (admin) |
getForging | FORGING | Get forging statistics for a key, or list all forgers (admin) |
Example: Start Forging
curl -s -X POST "http://localhost:22025/nxt" \
-d "requestType=startForging" \
-d "shamwariPrivateKey=YOUR_PRIV_KEY_HEX" \
-d "shamwariPublicKey=PUBLIC_KEY_HEX"
Returns JSON with hitTime, j LIS bonus, baseTarget, and other forging parameters.
Example: List All Active Forgers (admin)
curl -s "http://localhost:22025/nxt?requestType=getForging&adminPassword=admin"
Returns a generators array with each forger's address, weight, and hit time.
Blockchain Maintenance APIs
All under APITag.DEBUG — require admin password.
requestType | Description |
|---|---|
shutdown | Graceful shutdown (with ?scan=true triggers a full rescan) |
scan | Manual blockchain scan from a height or number of blocks |
popOff | Remove recent blocks from the chain (for testing/reorgs) |
clearUnconfirmedTransactions | Discard all unconfirmed transactions |
trimDerivedTables | Prune derived table data to save disk space |
rebroadcastUnconfirmedTransactions | Broadcast pending unconfirmed transactions |
Example: Rescan Last 100 Blocks
curl -s -X POST "http://localhost:22025/nxt" \
-d "requestType=scan" \
-d "numBlocks=100" \
-d "validate=true" \
-d "adminPassword=admin"
Example: Shutdown with Full Rescan
curl -s -X POST "http://localhost:22025/nxt" \
-d "requestType=shutdown" \
-d "scan=true" \
-d "adminPassword=admin"
Peer Management APIs
requestType | Tag | Description |
|---|---|---|
getPeers | NETWORK | List all known peer addresses |
getPeer | NETWORK | Get details about a specific peer |
addPeer | NETWORK | Add a new peer to the peer list |
blacklistPeer | DEBUG | Blacklist a misbehaving peer |
managePeersNetworking | DEBUG | Enable/disable inbound/outbound peer connections |
dumpPeers | DEBUG | Dump peer list in various formats |
Logging & Diagnostics
- Logs are written to
logs/shamwari.log(rolling file appender). - Log level can be adjusted at runtime via the
setLoggingAPI or inconf/logging.properties. - Use
getLogAPI to retrieve recent log entries. - Thread dumps available via the
getStackTracesAPI (APITag.DEBUG).
Wallet Files
- The desktop wallet uses
wallets/(created by desktop mode) for local wallet storage. - Headless nodes do not store wallet files; all signing must be done via API calls with a
shamwariPrivateKey.
Troubleshooting
| Symptom | Likely Cause |
|---|---|
errorCode: 1, errorDescription: Required admin password | Missing or incorrect adminPassword |
| Port 22025 already in use | Another process or node instance running |
| Node won't forge | nxt.isOffline=true or no valid ShamwariQKP keys |
classes/ directory missing | Run ./compile.sh before ./run.sh |
nxt.pid file stale after crash | Delete ~/.shamwari/nxt.pid and restart |