satoshi-payment-interface
v0.1.0
Published
Satoshi Payment Interface (SPI) V1 bilingual Go/TypeScript SDK with deterministic CBOR, HTTP authentication, and CollectOnce
Maintainers
Readme
Satoshi Payment Interface
SPI(Satoshi Payment Interface)V1 双语 Go/TypeScript SDK。npm 包名使用 npm 兼容的
satoshi-payment-interface,完整产品名仍为 Satoshi Payment Interface。它把余额查询/回收协议固定为严格的
deterministic CBOR;本包同时提供 HTTP AuthenticatedEnvelope 和 libp2p /spi/1.0.0
Stream 适配器。bitcoin-libp2p 只提供通用身份、Noise、Yamux 和 transport。
SPI payload 本身不携带公钥、签名、session_id 或过期时间。
Satoshi Payment Interface (SPI) V1 is a bilingual Go/TypeScript SDK. The TypeScript
package is published as satoshi-payment-interface; the matching Go module is
github.com/bsv8/SPI. Both SDKs use the same deterministic CBOR wire format,
HTTP authentication envelope, and libp2p /spi/1.0.0 adapter.
安装 / Install:
npm install [email protected]金额字段只能使用 TypeScript bigint;Go 侧对应 uint64。生产服务必须把
CollectOnce 的去重、全量校验、统一扣款和结果保存放进一次数据库事务。
import { newInformationRequest, parseResponse } from 'satoshi-payment-interface'
const request = newInformationRequest()
// 传输 request.wire 后,用传输层 pin 的服务公钥验证 HTTP 外壳,再解析响应:
// const response = parseResponse(payload, request.requestId)libp2p 使用由 bitcoin-libp2p 创建的 Noise 已认证 connection:
const server = await registerServer(node, backend)
const responseWire = await createClient().call(connection, request.wire)服务端从 authenticated connection 取得 remote_public_key,调用统一 handleRequest;
客户端每个 Stream 只发送一个请求并读取一个响应。
CDDL 说明协议结构;长度、数量和分配前安全边界由 Go/TypeScript SDK 常量及单元测试 执行。CDDL 不替代运行时输入校验。
HTTP 外壳只做签名认证和完整性保护,不提供内容保密;公网请使用 HTTPS。LocalSigner
仅用于测试和可信单进程示例,不要把测试私钥模式带入生产浏览器。
