Skip to content

Nexlab-One/verus-t-rpc

Repository files navigation

Rust Verus RPC Server

A RPC server for Verus blockchain built in Rust. Acts as a secure proxy between clients and the Verus daemon with comprehensive validation and security controls.

πŸ“„ License

This project is dual-licensed:

  • MIT License for VerusCoin and non-commercial use
  • AGPL-3.0 License for commercial use

See LICENSE, LICENSE-VERUS, and LICENSE-EXCEPTION for details.

⚠️ Warning: This project is under active development.

Features, APIs, and configuration formats may change without notice.
Use in production environments is not recommended at this stage.
Please report issues and follow updates for breaking changes.

πŸ“‹ Prerequisites

  • Rust (1.70+)
  • Redis (optional, for caching)
  • Verus Daemon (verusd) running
  • Git

πŸš€ Quick Start

1. Installation

git clone https://github.com/Nexlab/verus-t-rpc.git
cd verus-t-rpc
cargo build --release

2. Configuration

Create config.toml:

[verus]
rpc_url = "http://127.0.0.1:27486"
rpc_user = "your_rpc_username"
rpc_password = "your_rpc_password"

[server]
bind_address = "127.0.0.1"
port = 8080

[security]
development_mode = false
enable_security_headers = true

[jwt]
secret_key = "your-32-character-secret-key-here"
expiration_seconds = 3600

[rate_limit]
enabled = true
requests_per_minute = 100

[cache]
enabled = true
redis_url = "redis://127.0.0.1:6379"

3. Running

# Development
cargo run

# Production
cargo run --release

4. Making Requests

# Basic RPC call
curl -X POST http://127.0.0.1:8080/ \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "getinfo",
    "params": [],
    "id": 1
  }'

# With authentication
curl -X POST http://127.0.0.1:8080/ \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{
    "jsonrpc": "2.0",
    "method": "getblock",
    "params": ["block_hash", true],
    "id": 1
  }'

πŸ“š Supported Methods

60+ Verus RPC methods with comprehensive validation:

  • Blockchain: getinfo, getblockchaininfo, getblock, getblockhash
  • Transactions: getrawtransaction, sendrawtransaction, createrawtransaction
  • Addresses: getaddressbalance, getaddressutxos, getaddressmempool
  • Identities: getidentity, registeridentity, updateidentity
  • Currencies: getcurrency, sendcurrency, listcurrencies

πŸ›‘οΈ Security Features

  • JWT Authentication: Token-based authentication with expiration
  • Rate Limiting: IP-based request throttling
  • Security Headers: CSP, XSS protection, clickjacking prevention
  • Method Validation: Only pre-approved methods allowed
  • Input Validation: Strict parameter type checking

πŸ“Š Monitoring

  • Health Check: /health (with circuit breaker monitoring)
  • Circuit Breaker Admin: /admin/circuit-breaker/status, /admin/circuit-breaker/reset
  • Metrics: /metrics (Prometheus format)
  • Structured Logging: JSON format with request/response tracking

πŸ§ͺ Testing

# Run all tests
cargo test

# Run with verbose output
cargo test --verbose

# Run in release mode
cargo test --release

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           HTTP Layer                β”‚
β”‚        (Warp Framework)             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚        Infrastructure Layer         β”‚
β”‚  (HTTP Server, Cache, Monitoring)   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚        Application Layer            β”‚
β”‚    (Use Cases, Services)            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚          Domain Layer               β”‚
β”‚    (Business Logic, Models)         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”§ Development

# Build
cargo build --release

# Format code
cargo fmt

# Lint code
cargo clippy

# Security audit
cargo audit

πŸš€ Production Deployment

Docker

FROM rust:1.70 as builder
WORKDIR /app
COPY . .
RUN cargo build --release

FROM debian:bullseye-slim
RUN apt-get update && apt-get install -y ca-certificates
COPY --from=builder /app/target/release/verus-rpc-server /usr/local/bin/
EXPOSE 8080
CMD ["verus-rpc-server"]

Environment Variables

export VERUS_RPC_URL="http://127.0.0.1:27486"
export VERUS_RPC_USER="your_username"
export VERUS_RPC_PASSWORD="your_password"
export SERVER_PORT="8080"
export JWT_SECRET_KEY="your-secret-key"

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

πŸ“„ License

MIT License - see LICENSE file for details.

πŸ“– Documentation

For comprehensive documentation, see the docs/ directory:

πŸ“ Project Structure

rust_verusd_rpc_server/
β”œβ”€β”€ docs/                    # Documentation
β”‚   β”œβ”€β”€ test_local_access.md
β”‚   └── ...
β”œβ”€β”€ examples/                # Example code and scripts
β”‚   β”œβ”€β”€ test_deployment.sh
β”‚   β”œβ”€β”€ test_project/        # Example Rust client
β”‚   └── dex_client_example.js
β”œβ”€β”€ src/                     # Source code
β”œβ”€β”€ Conf.toml               # Development configuration
β”œβ”€β”€ Conf.production.toml    # Production configuration
└── Conf.public-dex.toml    # Public DEX configuration

πŸ†˜ Support

Built with ❀️ by Nexlab-One

If you find this project valuable, please consider supporting:

Verus: zs10u0vvlchlv0yuew4a87cvpesrvdl2yc7dda0q9kjdg4lmezsx4nmj88nna2vcd0m4hmc2eg948c

Every contribution helps us keep building. Thank you!

⚠️ Liability Disclaimer

This software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders, contributors, or affiliated organizations be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.

You are solely responsible for deploying, configuring, and operating this software.
Use in production environments is at your own risk. Always review, audit, and test the code and configuration before use, especially in security-critical or financial contexts.

About

Rust Verus RPC Server

Topics

Resources

License

AGPL-3.0 and 2 other licenses found

Licenses found

AGPL-3.0
LICENSE
Unknown
LICENSE-EXCEPTION
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors