搜索插件、代码仓与 APP 分类

插件详情v0.2.2

bech32

一个在 Flutter 中友好实现比特币 BIP173(Bech32 编码)规范的库。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
15万
喜欢数
6
Pub 分数
160

安装插件

flutter pub add bech32

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个与 Flutter 兼容的库,实现了比特币 BIP173 Bech32 编码标准,可安全高效地处理原生 segwit 地址。该库专为跨所有主要平台的无缝集成而设计,确保准确编码和解码现代比特币交易中使用的 Bech32 字符串。该包轻量且严格遵循官方规范,非常适合需要严格遵守 Bech32 格式的加密货币应用。

适合场景

  • 编码比特币 segwit 地址
  • 解码钱包中的Bech32字符串
  • 验证加密应用中的地址格式
  • 与基于比特币的服务集成
  • 跨平台地址处理

主要特点

  • 完全符合 BIP173
  • 支持 Android、iOS、Web、macOS、Windows、Linux
  • 用于编码和解码的简单 API
  • 轻便且快速
  • 强大的错误处理

适合对象

  • 比特币钱包开发者
  • 加密应用开发者
  • 区块链集成
  • 跨平台移动应用
  • 注重安全的应用程序

使用建议

  • 仅处理 Bech32 格式,不支持其他地址类型
  • 需要手动验证上下文相关的规则
  • 不适用于非比特币用例
  • 无原生支持 Bech32m (BIP350)
  • 限制为编码/解码操作

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Bech32

pub package CircleCI

An implementation of the BIP173 spec for Segwit Bech32 address format.

Examples

  Segwit address = segwit.decode("bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx");
  print(address.scriptPubKey);
  // => 5128751e76e8199196d454941c45d1b3a323f1433bd6751e76e8199196d454941c45d1b3a323f1433bd6
  print(address.version);
  // => 1

The lightning BOLT #11 spec can have longer inputs than the BIP173 spec allows. Use the positional maxLength parameter to override the validation.

  String paymentRequest = "lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d73gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ecky03ylcqca784w";
  Bech32Codec codec = Bech32Codec();
  Bech32 bech32 = codec.decode(
    paymentRequest,
    paymentRequest.length,
  );
  print("hrp: ${bech32.hrp}");
  // => hrp: lnbc

Exceptions

The specification defines a myriad of cases in which decoding and encoding should fail. Please make sure your code catches all the relevant exception defined in lib/exceptions.dart.

Installing

Add it to your pubspec.yaml:

dependencies:
  bech32: any

Licence overview

All files in this repository fall under the license specified in COPYING. The project is licensed as AGPL with a lesser clause. It may be used within a proprietary project, but the core library and any changes to it must be published online. Source code for this library must always remain free for everybody to access.

Thanks

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目