@exodus/bitcoin-api

中文文档
5.0.14发布于 2026/11/11MITES Module近 30 天下载 2.3万

Bitcoin transaction and fee monitors, RPC with the blockchain node, other networking code.

原始使用文档
文档目录4 节
  1. Insight read recovery
  2. Mempool WebSocket-assisted confirmation checks
  3. Mempool Retry-After
  4. Mempool request scheduling

@exodus/bitcoin-api

Transaction monitors, fee monitors, RPC with the blockchain node, and other networking code for Bitcoin and Bitcoin-like assets (e.g. dogecoin, litecoin, zcash). See Asset Packages for more detail on this package's role.

Insight read recovery

Insight JSON reads retry malformed JSON, common transient network failures, and HTTP 500/502/503/504 responses at most twice. Retries wait one then two seconds with 0–20% positive jitter, respecting longer Retry-After seconds or HTTP dates. All attempts, response-body reads, and waits share a 30-second deadline, or a shorter caller timeout (ten seconds for block height). A retry that would exceed that deadline fails rather than waiting longer or retrying before the server permits it.

Cancellation and permanent HTTP errors, including 429, are not retried by this policy. Existing transaction-not-found behavior is preserved; malformed JSON is never treated as an empty balance or missing transaction. Address-history reads retain their separate configurable retry policy without nested retries. Broadcasts do not use the read-retry policy.

Mempool WebSocket-assisted confirmation checks

Confirmation-only scans reuse WebSocket transaction statuses and block heights for ten seconds, with at most 1,000 statuses per client. Missing or expired hints fall back to /api/tx/:txid/status instead of full transaction/outspend reads. New or replacement blocks, disconnect, stop, and backend changes invalidate the caches; standalone confirmations require a fresh tip lookup. Full history, UTXO, address-event, and reconnect reconciliation remain unchanged, as do Insight-backed monitors.

Confirmation checks recheck their inputs if a WebSocket update, disconnect, or backend change arrives during a lookup. They retry once, then fail rather than return obsolete confirmations if invalidated again.

Mempool Retry-After

Every HTTP 429 starts a process-local cooldown shared across clients and endpoints on the same origin. Valid Retry-After seconds or HTTP dates take precedence, using the server's Date header for clock skew when available, and are capped at five minutes. Missing or invalid values use a ten-second fallback; failed recovery doubles it with 0–20% positive jitter, also capped at five minutes. Concurrent responses from the original burst do not multiply backoff, but longer server deadlines are preserved. A 429 from a broadcast dispatched during cooldown or recovery renews the read cooldown, including the fallback for missing or invalid Retry-After; an older recovery response cannot release that renewed cooldown. Broadcasts do not increase the fallback as failed recovery reads do.

Reads receiving HTTP 429 rejoin the end of the queue instead of immediately failing the monitor scan. Each read permits at most two retries, sharing its original 30-second queue deadline; cancellation, overflow, or expiry still fail finally. Exhausted retries fail with code 429, finalError, bounded retryAt/retryAfterMs, and hint mempoolRateLimited; generic retries stop. Queued reads wait until one recovery read can run, with a ten-second timeout including its body. Success or an ordinary 404 releases the cooldown; other HTTP, transport, or body failures renew it. No recovery request is generated when the queue is empty.

Mempool request scheduling

At most two REST requests run concurrently, including body consumption, with at least 200 ms between starts. Reads queue FIFO, bounded to 100 entries and a 30-second wait including cooldown. Abort signals remove queued requests; expired or cancelled entries never dispatch later. Normal requests have a 30-second dispatch-time timeout including the body, respecting shorter caller timeouts. History scans submit two address batches at a time while retaining full address coverage; Insight concurrency is unchanged.

Broadcasts jump ahead of queued reads only when request capacity is available. Active requests and broadcasts waiting for pacing reserve the two request slots; when both slots are occupied or reserved, a new broadcast fails immediately with MEMPOOL_REQUEST_BUSY and finalError, without automatic retry or later dispatch. The read queue limit does not consume broadcast capacity. Accepted broadcasts preserve FIFO order and 200 ms pacing, with the original one-second queue deadline; expired broadcasts fail finally with MEMPOOL_REQUEST_QUEUE_TIMEOUT. Active requests remain uninterrupted. New and queued broadcasts bypass local cooldown and recovery waits. Broadcasts never become recovery probes, and their success does not release read cooldown. Dispatched broadcasts receiving 429 still establish read cooldown and fail without automatic replay.

Queue and request deadlines apply per attempt. The send wrapper can retry one non-final broadcast failure after ten seconds, so pacing waits and network timeouts across both attempts can total about 72 seconds, excluding transaction preparation and post-failure checks. The broadcast client does not currently accept a caller cancellation signal; consumers should await the send result rather than assume an earlier UI timeout cancels it.

Recovery resumes paced traffic rather than a burst. This client budget is not a vendor quota and cannot guarantee freedom from rate limits or bans. The five-minute cap may permit requests earlier than the server requested; queues and cooldowns are not persisted or coordinated across processes.

版本与发布记录

@exodus/bitcoin-api 共发布 207 个版本,首次发布于 2022/11/22;过去 12 个月发布了 55 个版本。

版本发布日期距今
5.0.14latest2026/11/113 天前
5.0.132026/11/0410 天前
5.0.122026/11/0410 天前
5.0.112026/10/2817 天前
5.0.102026/10/2817 天前
5.0.92026/10/2025 天前

其他发布通道:beta → 2.3.8-ordinals.1,alpha → 2.5.0-alpha.0。

关于 @exodus/bitcoin-api 的常见问题

@exodus/bitcoin-api 是什么?

Bitcoin transaction and fee monitors, RPC with the blockchain node, other networking code.

如何安装 @exodus/bitcoin-api?

在项目目录运行 npm install @exodus/bitcoin-api,或使用 pnpm add / yarn add / bun add。

@exodus/bitcoin-api 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/exodus__bitcoin-api 是否存在。

@exodus/bitcoin-api 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@exodus/bitcoin-api 可以商用吗?

@exodus/bitcoin-api 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@exodus/bitcoin-api 的下载量有多少?

根据 npm 官方下载统计,@exodus/bitcoin-api 在 2026/10/14 – 2026/11/12 这 30 天内被下载 23,058 次,日均约 769 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@exodus/bitcoin-api 还在维护吗?

最新版本 5.0.14 发布于 2026/11/11(3 天前);至今共发布 207 个版本,其中过去 12 个月发布了 55 个;首次发布于 2022/11/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。