@blinkbitcoin/blink-client

中文文档
1.1.1发布于 2026/08/29MITTypeScriptCommonJS零依赖近 30 天下载 1929

JavaScript client library for the Blink stack. This is used in front-end applications like the web and mobile wallets.

原始使用文档
文档目录6 节
  1. Installation
  2. Usage
  3. parsePaymentDestination
  4. Test
  5. Build
  6. Local development

Blink Client

JavaScript client library for the Blink stack. This is used in front-end applications like the web and mobile wallets.

Installation

Install the package with:

pnpm add @blinkbitcoin/blink-client

Usage

parsePaymentDestination

import { parsePaymentDestination } from "@blinkbitcoin/blink-client"

const { valid, paymentType, amount } = parsePaymentDestination({
  destination: "username or invoice or bitcoin address",
  network: "mainnet", // or signet or regtest
  lnAddressDomains: ["blink.sv"],
})

Valid phone number inputs resolve as Lightning Addresses on pay.blink.sv for mainnet and pay.staging.blink.sv for signet or regtest. Set phoneNumberLnAddressDomain to override only that phone-number domain:

parsePaymentDestination({
  destination: "+50370123456",
  network: "mainnet",
  lnAddressDomains: ["blink.sv"],
  phoneNumberLnAddressDomain: "phone.example.com",
})
// lnurl: "[email protected]"

When a QR code or non-phone manual input matches one merchant payment integration, the result remains a valid PaymentType.Lnurl and includes isMerchant: true plus a merchant object. When the input matches multiple integrations that cannot be uniquely selected by displayCurrency, the result is:

{
  paymentType: PaymentType.Merchant,
  merchants: Merchant[],
}

Each merchant includes its ID, Lightning address, category, display metadata, and an optional display currency. category is metadata only; consumers make all selection, filtering, regional eligibility, and policy decisions.

PaymentType.Merchant requires consumer selection before payment and does not include a valid field. Branch on paymentType before relying on valid or initiating payment.

Test

Test with Jest framework:

pnpm test

Build

Build production (distribution) files in dist folder:

pnpm build

Local development

using pnpm

Run:

pnpm link --global

and in your test project run:

pnpm link --global @blinkbitcoin/blink-client

If you want to remove the link, run:

# in your test project
pnpm unlink @blinkbitcoin/blink-client

# in blinkbitcoin/client folder
pnpm unlink --global
using yalc

Run:

# in blinkbitcoin/blink-client folder
yalc publish

in your test project run:

yalc add @blinkbitcoin/blink-client

If you want to remove the symlink, run:

# in your test project
yalc remove @blinkbitcoin/blink-client

to update changes, you have to run yalc publish before run:

# in your test project
yalc update

版本与发布记录

@blinkbitcoin/blink-client 共发布 16 个版本,首次发布于 2025/03/31;过去 12 个月发布了 5 个版本。

版本发布日期距今
1.1.1latest2026/08/292 个月前
1.1.02026/07/253 个月前
1.0.02026/07/233 个月前
0.6.02026/06/254 个月前
0.5.32026/02/278 个月前
0.5.22025/10/281 年前

关于 @blinkbitcoin/blink-client 的常见问题

@blinkbitcoin/blink-client 是什么?

JavaScript client library for the Blink stack. This is used in front-end applications like the web and mobile wallets.

如何安装 @blinkbitcoin/blink-client?

在项目目录运行 npm install @blinkbitcoin/blink-client,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@bitcoinerlab/secp256k1(^1.1.1)、@noble/hashes(^1.8.0)、@scure/base(^1.1.9)、bitcoinjs-lib(^7.0.0)、bolt11(~1.4.1)、libphonenumber-js(^1.12.23)、lnurl-pay(^5.0.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@blinkbitcoin/blink-client 支持 TypeScript 吗?

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

@blinkbitcoin/blink-client 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@blinkbitcoin/blink-client 可以商用吗?

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

@blinkbitcoin/blink-client 的下载量有多少?

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

@blinkbitcoin/blink-client 还在维护吗?

最新版本 1.1.1 发布于 2026/08/29(2 个月前);至今共发布 16 个版本,其中过去 12 个月发布了 5 个;首次发布于 2025/03/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。