跳转到主要内容

概述

钱包注册向 LaserSell API 证明你拥有某个 Solana 钱包。在连接钱包到退出智能流之前需要进行注册。流会验证 configure 消息中的每个钱包都已注册到你的账户。 注册使用 Ed25519 签名,因此无需链上交易。

POST /v1/wallets/register

通过 Ed25519 签名证明所有权来注册钱包。

请求

{
  "wallet_pubkey": "YourWalletPubkey...",
  "signature": "base58-encoded-ed25519-signature",
  "message": "lasersell-register:YourWalletPubkey...:1706000000",
  "label": "My Trading Wallet"
}
字段类型必需说明
wallet_pubkeystring要注册的 Solana 钱包公钥。
signaturestring消息的 Ed25519 签名,base58 编码。
messagestring结构化消息:lasersell-register:<pubkey>:<unix_timestamp>。时间戳必须在 5 分钟以内。
labelstring钱包的可选人类可读标签。

响应

{
  "wallet_pubkey": "YourWalletPubkey...",
  "registered": true
}

认证

需要带有有效 API 密钥的 x-api-key 头。

错误

状态代码说明
400Bad Request无效的公钥格式、格式错误的消息或过期的时间戳(>5 分钟)。
403Forbidden缺少或无效的 API 密钥,或签名验证失败。

DELETE /v1/wallets

取消注册钱包。

请求

{
  "wallet_pubkey": "YourWalletPubkey..."
}

响应

{
  "wallet_pubkey": "YourWalletPubkey...",
  "removed": true
}

SDK 用法

所有 4 种 SDK 都提供钱包注册的辅助方法。

proveOwnership / prove_ownership

使用你的密钥对在本地生成 WalletProof。这是纯加密操作,无网络调用。
import { proveOwnership } from "@lasersell/lasersell-sdk";

const proof = proveOwnership(keypair);
// proof = { walletPubkey, signature, message }

registerWallet / register_wallet

将证明发送到 API 以注册钱包。
const client = ExitApiClient.withApiKey(apiKey);
await client.registerWallet(proof, "My Wallet");

connectWithWallets / connect_with_wallets

便捷方法,一步完成注册钱包和连接流。
import { StreamClient, proveOwnership } from "@lasersell/lasersell-sdk";

const proof = proveOwnership(keypair);
const client = new StreamClient(apiKey);
const session = await client.connectWithWallets(
  [proof],
  { target_profit_pct: 50, stop_loss_pct: 10 },
  120, // deadline_timeout_sec
);