Skip to main content
Glama

SatRank

闪电支付的路由可靠性。专为代理经济构建。

SatRank 对闪电网络端点的可靠性进行评分。在每次支付前,代理会向 SatRank 查询以获取“通过/拒绝”(GO/NO-GO)决策——一次请求,一个答案,1 sat。

入门指南

npm install
npm run dev     # Start development server on :3000

架构

routes → controllers → services → repositories → SQLite

层级:

  • Routes — Express 端点定义

  • Controllers — 输入验证 (zod),响应格式化

  • Services — 业务逻辑与编排

  • Repositories — SQLite 数据访问 (better-sqlite3)

src/app.ts 中进行手动依赖注入,以提高可测试性。

评分算法

综合评分 0-100,由 5 个加权因子计算得出:

因子

权重

描述

交易量 (Volume)

25%

已验证交易,对数归一化

声誉 (Reputation)

30%

图中心度 + 对等信任 (BTC/通道)。LN+ 评级作为奖励(最高 +8)

资历 (Seniority)

15%

自首次出现以来的天数,边际效应递减

规律性 (Regularity)

15%

交易间隔变异系数的倒数

多样性 (Diversity)

15%

唯一交易对手,对数归一化

防作弊机制:

  • 相互证明循环检测 (A↔B),惩罚 95%

  • 循环集群检测 (A→B→C→A),惩罚 90%

  • 通过 BFS 进行扩展循环检测 (A→B→C→D→A,最多 4 跳),惩罚 90%

  • 证明者至少需要 7 天资历

  • 证明者分数加权(类似 PageRank 的递归)

  • 证明来源集中度惩罚

API

决策 API (代理的主要接口)

# GO / NO-GO decision with success probability
curl -X POST http://localhost:3000/api/decide \
  -H "Content-Type: application/json" \
  -d '{"target": "<hash>", "caller": "<your-hash>"}'

# Report transaction outcome (free — no L402)
curl -X POST http://localhost:3000/api/report \
  -H "Content-Type: application/json" \
  -H "X-API-Key: <key>" \
  -d '{"target": "<hash>", "reporter": "<your-hash>", "outcome": "success"}'

# Agent profile with reports, uptime, rank
curl http://localhost:3000/api/profile/<hash>

评分与判定 API

curl http://localhost:3000/api/agent/<hash>/verdict
# Returns: SAFE / RISKY / UNKNOWN with confidence, flags, risk profile

批量判定

curl -X POST http://localhost:3000/api/verdicts \
  -H "Content-Type: application/json" \
  -d '{"hashes": ["abc123...", "def456..."]}'

代理评分

curl http://localhost:3000/api/agent/<hash>
# Returns: score, components, evidence, delta, alerts

评分历史

curl http://localhost:3000/api/agent/<hash>/history?limit=10

已收到的证明

curl http://localhost:3000/api/agent/<hash>/attestations?limit=20

排行榜

curl http://localhost:3000/api/agents/top?limit=20&sort_by=score

涨幅榜

curl http://localhost:3000/api/agents/movers

按别名搜索

curl http://localhost:3000/api/agents/search?alias=atlas

提交证明 (免费 — 无需 L402)

curl -X POST http://localhost:3000/api/attestations \
  -H "Content-Type: application/json" \
  -H "X-API-Key: <your-key>" \
  -d '{"txId": "...", "attesterHash": "...", "subjectHash": "...", "score": 85, "category": "successful_transaction"}'

健康状况与统计

curl http://localhost:3000/api/health
curl http://localhost:3000/api/stats

MCP 服务器

SatRank 提供一个 MCP (模型上下文协议) 服务器,用于通过 stdio 进行代理原生访问。包含 11 个工具,涵盖信任决策、评分、搜索和报告。

在 Claude Code 中安装

claude mcp add satrank -- npx tsx src/mcp/server.ts

或使用环境变量:

claude mcp add satrank -e DB_PATH=./data/satrank.db -e SATRANK_API_KEY=<key> -- npx tsx src/mcp/server.ts

在 Cursor / VS Code 中安装

添加到 .cursor/mcp.json.vscode/mcp.json

{
  "mcpServers": {
    "satrank": {
      "command": "npx",
      "args": ["tsx", "src/mcp/server.ts"],
      "cwd": "/path/to/satrank",
      "env": {
        "DB_PATH": "./data/satrank.db",
        "SATRANK_API_KEY": "your-api-key"
      }
    }
  }
}

可用工具 (11)

工具

描述

decide

带有成功概率的 GO/NO-GO 决策 — 交易前的主要工具

report

报告结果 (成功/失败/超时) — 需要 API 密钥

get_profile

包含报告、正常运行时间、排名、证据的完整代理资料

get_agent_score

包含组成部分和证据的详细信任评分

get_verdict

带有风险概况和路径规划的 SAFE/RISKY/UNKNOWN 判定

get_batch_verdicts

最多 100 个代理的批量判定

get_top_agents

按分数排名的排行榜

search_agents

按别名搜索 (部分匹配)

get_network_stats

全局网络统计信息

get_top_movers

7 天内分数变化最大的代理

submit_attestation

提交信任证明 — 需要 API 密钥

手动运行

npm run mcp        # Development
npm run mcp:prod   # Production

SDK

npm install @satrank/sdk
import { SatRankClient } from '@satrank/sdk';

const client = new SatRankClient('http://localhost:3000');

// Full cycle in one line: decide → pay → report
const result = await client.transact('<target-hash>', '<your-hash>', async () => {
  const payment = await myWallet.pay(invoice);
  return { success: payment.ok, preimage: payment.preimage, paymentHash: payment.hash };
});
// result.paid, result.decision.go, result.report.weight

// Or step by step
const decision = await client.decide({ target: '<hash>', caller: '<your-hash>' });
const profile = await client.getProfile('<hash>');
const verdict = await client.getVerdict('<hash>');

Nostr 集成

SatRank 将闪电节点的信任评分发布为 NIP-85 信任断言 (kind 30382)。

发布内容: 综合评分 (0-100)、判定 (SAFE/RISKY/UNKNOWN)、可达性、生存预测,以及约 3,900 个分数 >= 30 的节点的 5 个评分组件。

频率: 每 6 小时一次。

事件格式:

{
  "kind": 30382,
  "tags": [
    ["d", "<lightning_pubkey>"],
    ["n", "lightning"],
    ["alias", "Kraken"],
    ["score", "94"],
    ["verdict", "SAFE"],
    ["reachable", "true"],
    ["survival", "stable"],
    ["volume", "100"],
    ["reputation", "79"],
    ["seniority", "87"],
    ["regularity", "100"],
    ["diversity", "100"]
  ],
  "content": ""
}

从任何 Nostr 客户端查询断言:

["REQ", "satrank", {"kinds": [30382], "authors": ["<SATRANK_NOSTR_PUBKEY>"]}]

为什么免费? 全局评分只是预告片。个性化的 /api/decide(从您的位置出发的路径规划、生存率、P_empirical)才是正片 — 通过 L402 收取 1 sat。

技术栈

  • TypeScript 严格模式

  • Express — REST API

  • better-sqlite3 — 嵌入式数据库,WAL 模式

  • zod — 输入验证

  • pino — 结构化日志

  • helmet — 安全标头

  • express-rate-limit — 防滥用保护

脚本

脚本

描述

npm run dev

带热重载的开发环境 (tsx watch)

npm run build

TypeScript 编译

npm start

生产环境

npm test

测试 (vitest)

npm run lint

TypeScript 检查

npm run crawl

Observer Protocol 爬虫

npm run crawl:cron

定时任务模式的爬虫

npm run mcp

MCP 服务器 (开发)

npm run mcp:prod

MCP 服务器 (生产)

npm run purge

清除过期数据

npm run backup

数据库备份

npm run rollback

数据库回滚

npm run calibrate

评分校准报告

npm run demo

证明演示脚本

npm run sdk:build

构建 TypeScript SDK

路线图

  • [x] 决策 API — 带有成功概率的 GO/NO-GO,结果报告,代理资料

  • [x] 个性化路径规划 — 通过 LND QueryRoutes 从调用者到目标的实时路由

  • [x] Aperture 集成 (L402 反向代理) — 以 sats 货币化查询

  • [x] Observer Protocol 爬虫 — 自动链上数据摄取

  • [x] 闪电网络图爬虫 — 通过 LND 节点获取通道拓扑和容量

  • [x] 路由探测爬虫 — 索引节点的可达性测试

  • [x] 代理 TypeScript SDK (@satrank/sdk)

  • [x] 判定 API — SAFE/RISKY/UNKNOWN 二元决策

  • [x] MCP 服务器 — 通过 stdio 进行代理原生访问

  • [x] 自动索引 — 按需索引未知公钥

  • [ ] 4tress 连接器 — 已验证的证明

  • [ ] 信任网络可视化仪表板

愿景

SatRank 是每次闪电支付前的可靠性检查。网络中 66% 的节点是幽灵节点 — 我们告诉您哪些端点是活跃的。

-
security - not tested
F
license - not found
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/proofoftrust21/satrank'

If you have feedback or need assistance with the MCP directory API, please join our Discord server