Skip to main content

Developer Guide

This guide covers building, running, and extending the Shamwari Network node (shamwariQKP v2.2.6). The Shamwari codebase is a fork of the Nxt blockchain platform, written in Java and built with shell scripts (no Maven or Gradle). It uses a hybrid post-quantum cryptography scheme (Kyber + Dilithium).

Development Prerequisites​

ToolVersionNotes
Java JDK21 LTSRequired — compile.sh uses -source 21 -target 21
JavaFX SDK11+Needed only for the desktop wallet (javafx-sdk/lib/*)
Git2.40+Source control
Docker24+Containerized deployment

The project does not use Maven or Gradle. All compilation is done through shell scripts that invoke javac directly against the lib/ and classes/ directories.

Project Layout​

shamwariQKP/
├── compile.sh # Compile all Java sources
├── jar.sh # Generate JAR files (shamwari.jar, shamwariservice.jar)
├── package.sh # Build distributable ZIP
├── run.sh # Start the node (--desktop | --daemon | --authbind)
├── start.sh # [DEPRECATED] Use run.sh --daemon
├── stop.sh # Stop a running node (reads PID from ~/.shamwari/nxt.pid)
├── run-desktop.sh # [DEPRECATED] Use run.sh --desktop
├── compact.sh # Compact the H2 database (nxt.tools.CompactDatabase)
├── sign.sh # Sign transaction JSON (nxt.tools.SignTransactionJSON)
├── mint.sh # Run currency mint worker
├── generate-passphrase.sh # Generate passphrases (same flags as run.sh)
├── passphraseRecovery.sh # Search for a lost passphrase
├── contractManager.sh # Manage on-chain contracts (Java security manager + policy)
├── generateAPICalls.sh # Regenerate typed API callers/responses from source
├── constants-export.sh # Export blockchain constants to JS
├── javadoc.sh # Generate Javadoc
├── tests/run-tests.sh # Run non-live unit tests
├── src/java/nxt/ # Core source tree
│ ├── Nxt.java # Main entry point
│ ├── Constants.java # Blockchain constants
│ ├── http/ # REST API layer
│ │ ├── API.java # API server bootstrap (Jetty)
│ │ ├── APIServlet.java # HTTP servlet + APIRequestHandler base class
│ │ ├── APIEnum.java # All API endpoint registrations
│ │ ├── APITag.java # API category tags
│ │ ├── ParameterParser.java # Request parameter parsing
│ │ ├── JSONData.java # Response JSON builders
│ │ ├── JSONResponses.java # Error response constants
│ │ ├── APICall.java # Client-side API call builder
│ │ ├── callers/ # Auto-generated typed clients (ApiSpec, *Call)
│ │ ├── responses/ # Auto-generated typed response wrappers
│ │ ├── proxy/ # API proxy support
│ │ ├── [handler classes] # Individual requestType handlers
│ ├── account/ # Account model & ledger
│ ├── blockchain/ # Block & transaction processing, Generator, Binder
│ │ ├── contracts/ # On-chain Java contract framework
│ │ ├── chaincontrol/ # Permissioned chain controls
│ ├── crypto/ # Post-quantum cryptography
│ │ ├── ShamwariQKP.java # Hybrid Kyber-512 + Dilithium key pair
│ │ ├── ShamwariPrivateKey.java
│ │ ├── ShamwariPublicKey.java
│ │ ├── kyber/ # Kyber KEM
│ │ └── dilithium/ # Dilithium signatures
│ ├── ae/ # Asset Exchange (Totems)
│ ├── ms/ # Monetary System (currencies)
│ ├── peer/ # Peer-to-peer networking
│ ├── voting/ # Phasing & voting
│ ├── subscriptions/ # Subscription services
│ ├── apps/ # Application listings
│ ├── digitalcertificates/ # Digital certificates
│ ├── shuffling/ # Transaction shuffling (privacy)
│ ├── freeze/ # Freeze functionality
│ ├── addons/ # Add-on framework
│ ├── db/ # Database layer
│ ├── dbschema/ # Schema definitions
│ ├── configuration/ # Config parsing
│ ├── env/ # Runtime environment (daemon, dir provider)
│ ├── tools/ # CLI utilities
│ ├── util/ # Utilities (logging, crypto helpers)
│ └── migration/ # Data migration
├── src/java/shamwari/ # Shamwari-specific extensions (ShamwariIQ, agent gateway)
├── src/java/nxt/addons/ # Built-in add-ons (forging, binding, shuffling configs)
├── conf/
│ ├── nxt-default.properties # Default configuration (do not modify)
│ ├── nxt.properties # Local overrides (create this)
│ └── examples/ # Example configs (testnet, light client, desktop)
├── lib/ # JAR dependencies
├── html/ # Web UI + API developer console
├── logs/ # Log files (shamwari.log, rotated shamwari.*.log)
├── shamwari_db/ # Mainnet database (created at runtime)
├── shamwari_test_db/ # Testnet database
├── addons/ # Add-on classes & libs
└── docker/docker_start.sh # Docker entrypoint

Building​

# Compile core, desktop, add-ons, and tests
./compile.sh

# Compile without the JavaFX desktop wallet
./compile.sh --skip-desktop

# Package into distributable JARs (shamwari.jar, shamwariservice.jar)
./jar.sh

# Build the full distributable ZIP
./package.sh

# Generate Javadoc
./javadoc.sh

Regenerating the API Client Library​

The typed Java clients in callers/ and response wrappers in responses/ are auto-generated from the handler source files:

./generateAPICalls.sh

This reads src/java/nxt/http/*.java and emits src/java/nxt/http/callers/ and src/java/nxt/http/responses/ into the source tree.

Running the Node​

# Interactive mode (foreground)
./run.sh

# Background daemon (stores PID in ~/.shamwari/nxt.pid)
./run.sh --daemon

# Stop a daemon
./stop.sh

# Desktop wallet mode (requires JavaFX)
./run.sh --desktop

# Use authbind for privileged ports
./run.sh --authbind

Configuration lives in conf/nxt.properties (which overrides conf/nxt-default.properties). The default configuration runs on testnet (nxt.isTestnet=true).

Default Ports​

ProtocolTestnetMainnetPurpose
API (HTTP)2202422025REST API at /nxt
API (HTTPS)2202422025SSL API (nxt.apiSSL=true)
Peer2202222022P2P networking

API Architecture​

All REST endpoints are served from a single servlet mapped at /nxt. Each API is a handler class in nxt.http that extends APIServlet.APIRequestHandler. Endpoints are registered centrally in APIEnum.java and tagged with APITag categories.

Adding a New API Endpoint​

  1. Create a handler class extending APIServlet.APIRequestHandler in src/java/nxt/http/.
  2. Register it in APIEnum.java (add an enum constant at the end).
  3. Call ./generateAPICalls.sh to generate the typed client and response classes.
  4. Implement processRequest(HttpServletRequest).
public final class MyNewApi extends APIServlet.APIRequestHandler {
static final MyNewApi instance = new MyNewApi();

private MyNewApi() {
super(new APITag[] {APITag.ACCOUNTS}, "account", "param1");
}

@Override
protected JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
JSONObject response = new JSONObject();
// ... implementation ...
return response;
}
}

API Tags​

The APITag enum (APITag.java:22) defines endpoint categories:

TagDisplay name
ACCOUNTSAccounts
ACCOUNT_CONTROLAccount Ctrl
ADDONSAdd-ons
AEAsset Exchange
MSBanking
BETA_CHAIN_CONTROLChain Control
BIP32Bip32
BLOCKSBlocks
CERTIFICATECertificates
CONTRACTSContracts
DEBUGDebug
FORGINGForging
INFOServer Info
MESSAGESMessages
NETWORKNetworking
PAYMENTSPayments
PHASINGPhasing
SEARCHSearch
SHUFFLINGShuffling
SUBSCRIPTIONSSubscriptions
TOKENSTokens
TRANSACTIONSTransactions
UTILSUtils
VSVoting And Polling
AGENT_ATTESTATIONAgents

Authentication​

Two authentication mechanisms are used:

  • Secret Phrase / Private Key: For transaction-signing APIs, pass secretPhrase, or the hybrid key components shamwariPrivateKey and shamwariPublicKey (hex-encoded). Multi-sig variants use sharedPiece and sharedPieceAccount.
  • Admin Password: For administrative APIs, pass adminPassword when nxt.adminPassword is set and the API server listens on non-loopback addresses. Admin password is automatically disabled on localhost.

Smart Contracts​

Shamwari supports Java-based on-chain contracts. See Smart Contracts for full details.

Testing​

# Compile first
./compile.sh

# Run non-live unit tests (crypto, account, blockchain)
./tests/run-tests.sh

The test suite uses JUnit 5 via lib/junit-platform-console-standalone-1.5.2.jar. Tests do not start a node or connect to a database.

Add-ons​

Add-ons are custom extensions loaded via nxt.addOns in nxt-default.properties. Built-in add-ons include BindingEncryptedConfig, ForgingEncryptedConfig, FundingMonitorsEncryptedConfig, and StandbyShufflingEncryptedConfig. Custom add-ons can be placed in addons/classes/ or addons/lib/.

Resources​