NAC_Blockchain/services/nac-api-server
NAC Admin 1cdfd6c7cc refactor: 目录重组 - 明确中心化运维与去中心化业务边界
[目录重组]
- services/nac-admin → ops/nac-admin(运维后台归入 ops/)
- nac-monitor/nac-daemon/nac-deploy/nac-cee-integration → ops/(运维工具归组)
- nac-sdk/nac-cli/nac-serde → sdk/(开发者工具归组)
- nac-api-server/nac-explorer-api → services/(对外服务归组)
- 备份文件 → archive/(历史版本归档)

[nac-admin 职责拆分]
- 保留运维功能:Dashboard(节点监控)、AuditLog(审计)、RegulatoryMonitor(合规)
- 迁出业务功能:
  - KnowledgeBase → services/nac-knowledge-portal/
  - Crawlers → services/nac-data-crawler/
  - ApprovalCases + TagEngine → services/nac-rwa-portal/
  - ProtocolRegistry → services/nac-protocol-registry/

[修复]
- rpc.newassetchain.io nginx 配置修复(9547→9550,NAC_Lens 网关)

设计原则:ops/ 是合理的中心化运维入口,区块链协议和业务服务
完全独立,不归属任何 admin 目录,避免中心化联想。
2026-03-07 17:46:08 +08:00
..
src refactor: 目录重组 - 明确中心化运维与去中心化业务边界 2026-03-07 17:46:08 +08:00
tests refactor: 目录重组 - 明确中心化运维与去中心化业务边界 2026-03-07 17:46:08 +08:00
.gitignore refactor: 目录重组 - 明确中心化运维与去中心化业务边界 2026-03-07 17:46:08 +08:00
Cargo.lock refactor: 目录重组 - 明确中心化运维与去中心化业务边界 2026-03-07 17:46:08 +08:00
Cargo.toml refactor: 目录重组 - 明确中心化运维与去中心化业务边界 2026-03-07 17:46:08 +08:00
README.md refactor: 目录重组 - 明确中心化运维与去中心化业务边界 2026-03-07 17:46:08 +08:00
config.toml.example refactor: 目录重组 - 明确中心化运维与去中心化业务边界 2026-03-07 17:46:08 +08:00
issue_007_nac_lens_upgrade.md refactor: 目录重组 - 明确中心化运维与去中心化业务边界 2026-03-07 17:46:08 +08:00

README.md

NAC API服务器

NAC公链统一API服务器为钱包应用和RWA资产交易所提供后端API支持。

功能特性

核心功能

  • 钱包API - 余额查询、转账、交易历史
  • 交易所API - 资产列表、订单管理、市场数据、订单簿
  • 区块链集成 - 通过RPC连接真实NAC区块链节点
  • 安全机制 - JWT认证、速率限制、输入验证
  • 错误处理 - 统一错误格式、详细日志
  • 配置管理 - TOML配置文件支持

技术栈

  • Web框架: Axum 0.7
  • 异步运行时: Tokio
  • 序列化: Serde
  • HTTP客户端: Reqwest
  • 认证: JWT (jsonwebtoken)
  • 验证: Validator
  • 日志: Tracing

快速开始

1. 配置

复制配置文件示例:

cp config.toml.example config.toml

编辑config.toml修改区块链RPC地址和JWT密钥。

2. 编译

cargo build --release

3. 运行

cargo run --release

服务器将在http://0.0.0.0:8080启动。

4. 测试

# 运行所有测试
cargo test

# 健康检查
curl http://localhost:8080/health

API文档

钱包API

  • GET /api/wallet/balance/:address - 查询余额
  • POST /api/wallet/transfer - 发起转账
  • GET /api/wallet/transactions/:address - 查询交易历史
  • GET /api/wallet/transaction/:hash - 查询交易详情

交易所API

  • GET /api/exchange/assets - 获取资产列表
  • POST /api/exchange/orders - 创建订单
  • GET /api/exchange/orders/:order_id - 查询订单详情
  • GET /api/exchange/market/:asset - 获取市场数据
  • GET /api/exchange/orderbook/:asset - 获取订单簿
  • GET /api/exchange/trades - 获取最近交易

详细API文档请参考代码注释。

项目结构

nac-api-server/
├── src/
│   ├── main.rs              # 主入口
│   ├── blockchain/          # 区块链客户端
│   ├── auth/                # 认证模块
│   ├── middleware/          # 中间件
│   ├── error/               # 错误处理
│   ├── config/              # 配置管理
│   ├── models/              # 数据模型
│   ├── wallet.rs            # 钱包API
│   └── exchange.rs          # 交易所API
├── tests/                   # 集成测试
├── Cargo.toml               # 依赖配置
├── config.toml.example      # 配置示例
└── README.md                # 本文档

测试统计

  • 总测试数: 20个
  • 测试通过率: 100%
  • 代码覆盖: 核心模块全覆盖

许可证

Copyright © 2026 NAC Team. All rights reserved.


版本: 1.0.0
最后更新: 2026-02-18