Skip to main content

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 ./jdk directory or a system java on PATH
  • 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:

FileEntry pointUse
shamwari.jarnxt.NxtHeadless server node
shamwariservice.jarWindows serviceProduction 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.CryptoTest
  • nxt.crypto.ShamwariQkpTest
  • nxt.account.AccountTest
  • nxt.blockchain.BlockImplTest
  • nxt.blockchain.TransactionImplTest

Tests use JUnit 5 via lib/junit-platform-console-standalone-1.5.2.jar.

Configuration​

Configuration follows the Nxt convention:

  1. conf/nxt-default.properties contains defaults (do not edit this file).
  2. Create conf/nxt.properties with 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:

ServiceDefault Port
API (mainnet)22025
API (testnet)22024
Peer server22022

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:

  1. Admin password (adminPassword parameter or nxt.adminPassword in config) — required for all APITag.DEBUG and APITag.FORGING endpoints.
  2. ShamwariQKP key pair (shamwariPrivateKey + shamwariPublicKey) — used for signing transactions and forging, replacing the Nxt secretPhrase/privateKey model.

Node Management APIs​

requestTypeTagDescription
getStateINFONode status, memory, peer counts, blockchain height, contract counts
getBlockchainStatusINFOChain status: current block, version, last block
getConstantsINFONetwork constants, genesis, epoch, token definitions
getConfigurationINFORuntime configuration (sensitive values redacted)
setConfigurationDEBUGUpdate runtime configuration (requires admin)
getLogDEBUGTail of the log file
setLoggingDEBUGDynamically 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.

requestTypeTagDescription
startForgingFORGINGStart forging with a ShamwariQKP key pair
stopForgingFORGINGStop forging for a specific key or all forgers (admin)
getForgingFORGINGGet 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.

requestTypeDescription
shutdownGraceful shutdown (with ?scan=true triggers a full rescan)
scanManual blockchain scan from a height or number of blocks
popOffRemove recent blocks from the chain (for testing/reorgs)
clearUnconfirmedTransactionsDiscard all unconfirmed transactions
trimDerivedTablesPrune derived table data to save disk space
rebroadcastUnconfirmedTransactionsBroadcast 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​

requestTypeTagDescription
getPeersNETWORKList all known peer addresses
getPeerNETWORKGet details about a specific peer
addPeerNETWORKAdd a new peer to the peer list
blacklistPeerDEBUGBlacklist a misbehaving peer
managePeersNetworkingDEBUGEnable/disable inbound/outbound peer connections
dumpPeersDEBUGDump 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 setLogging API or in conf/logging.properties.
  • Use getLog API to retrieve recent log entries.
  • Thread dumps available via the getStackTraces API (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​

SymptomLikely Cause
errorCode: 1, errorDescription: Required admin passwordMissing or incorrect adminPassword
Port 22025 already in useAnother process or node instance running
Node won't forgenxt.isOffline=true or no valid ShamwariQKP keys
classes/ directory missingRun ./compile.sh before ./run.sh
nxt.pid file stale after crashDelete ~/.shamwari/nxt.pid and restart