@exodus/bip322-js

中文文档
3.2.5发布于 2026/11/04MITTypeScriptES Module近 30 天下载 1.9万

A Javascript library that provides utility functions related to the BIP-322 signature scheme

原始使用文档
文档目录4 节
  1. Limitations
  2. Documentation
  3. Supported Features
  4. Example

BIP322-JS

Unit Test Status Coverage Status

A Javascript library that provides utility functions related to the BIP-322 signature scheme. This is a fork of https://github.com/ACken2/bip322-js with dependencies change in order to reduce audit load. No breaking API changes present at the moment.

Limitations

Only P2PKH, P2SH-P2WPKH, P2WPKH, and single-key-spend P2TR are supported in this library.

Documentation

Available at https://acken2.github.io/bip322-js/

Supported Features

  1. Generate raw toSpend and toSign BIP-322 transactions
  2. Sign a BIP-322 signature using a private key
  3. Verify a simple BIP-322 signature

Example

// Import modules that are useful to you
const { BIP322, Signer, Verifier } = require('bip322-js')

// Signing a BIP-322 signature with a private key
const privateKey = 'L3VFeEujGtevx9w18HD1fhRbCH67Az2dpCymeRE1SoPK6XQtaN2k'
const address = 'bc1q9vza2e8x573nczrlzms0wvx3gsqjx7vavgkx0l'
const message = 'Hello World'
const signature = Signer.sign(privateKey, address, message)
console.log(signature)

// Verifying a simple BIP-322 signature
const validity = Verifier.verifySignature(address, message, signature)
console.log(validity) // True

// You can also get the raw unsigned BIP-322 toSpend and toSign transaction directly
const scriptPubKey = Buffer.from('00142b05d564e6a7a33c087f16e0f730d1440123799d', 'hex')
const toSpend = BIP322.buildToSpendTx(message, scriptPubKey) // bitcoin.Transaction
const toSpendTxId = toSpend.getId()
const toSign = BIP322.buildToSignTx(toSpendTxId, scriptPubKey) // bitcoin.Psbt
// Do whatever you want to do with the PSBT

More working examples can be found within the unit test for BIP322, Signer, and Verifier.

版本与发布记录

@exodus/bip322-js 共发布 24 个版本,首次发布于 2023/09/22;过去 12 个月发布了 6 个版本。

版本发布日期距今
3.2.5latest2026/11/0410 天前
3.2.42026/10/2817 天前
3.2.32026/10/101 个月前
3.2.22026/06/304 个月前
3.2.12026/04/226 个月前
3.2.02025/12/2710 个月前

关于 @exodus/bip322-js 的常见问题

@exodus/bip322-js 是什么?

A Javascript library that provides utility functions related to the BIP-322 signature scheme

如何安装 @exodus/bip322-js?

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

@exodus/bip322-js 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@exodus/bip322-js 支持 ESM 还是 CommonJS?

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

@exodus/bip322-js 可以商用吗?

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

@exodus/bip322-js 的下载量有多少?

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

@exodus/bip322-js 还在维护吗?

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