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

插件详情v3.1.3

dartsv

与比特币网络交互的Dart库。此库特别适合用于开发Flutter应用程序。

AndroidiOSmacOSWindowsLinux
近 30 天下载
1150
喜欢数
11
Pub 分数
120

安装插件

flutter pub add dartsv

插件介绍

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

DartSV 是一个专为与比特币网络交互而设计的 Dart 库,为开发者提供构建比特币应用的工具。它针对 Flutter 项目进行了优化,可无缝集成到 Android、iOS、macOS、Windows 和 Linux 平台。该库支持核心比特币操作,如地址生成、交易创建和加密功能,非常适合区块链应用开发。凭借其轻量级设计和对跨平台兼容性的关注,DartSV 简化了比特币集成,无需使用原生代码。其开源性质鼓励社区贡献并确保透明度。

适合场景

  • 构建比特币钱包
  • 创建区块链浏览器
  • 集成比特币支付
  • 开发去中心化应用
  • 处理比特币交易

主要特点

  • 比特币地址生成
  • 交易签名和序列化
  • 加密工具
  • 跨平台支持
  • 开源且持续维护

适合对象

  • Flutter 开发者
  • Web3 应用开发者
  • 专注于加密货币的移动应用
  • 区块链初学者
  • 比特币协议爱好者

使用建议

  • 需要理解比特币基础知识
  • 仅限比特币特定功能
  • 依赖外部比特币节点以实现完整功能
  • 不适用于高频交易
  • 最好与安全密钥管理实践一起使用

原始 README

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

Introduction

Dart CI

Overview

TwoStack WalletSDK is a Bitcoin library for the Dart Language ( dartlang.org ), loosely based on the Moneybutton/BSV Javascript library. This library has been built in line with the ideals espoused by BitcoinSV, i.e. massive on-chain scaling, protocol stability and original-bitcoin-protocol implementation. It is intended for use in building multi-platform applications using the Flutter framework, or server-side bitcoin applications using frameworks like Serverpod

A note about Version 2.x (August 2023)

Version 2.x of the library is a major refactor and breaks backwards compatibility with several previous library APIs.

  • A new TransactionBuilder class for composing Transactions
  • Removal of the old Builder interface which was directly attached to the Transaction class
  • A complete re-implementation of the Script Interpreter
  • The Sighash class now exposes the SigHash Pre-Image; useful when creating OP_PUSH_TX spending scripts.
  • A new ScriptBuilder class to make it easy to create custom locking/unlocking scripts.
  • Merged contributed code to have better Flutter Web support.

Generally Supported features are :

  • Custom-Script Builder Interface to support novel locking/spending conditions within Script
  • Pre-built library code to support "standard" locking/unlocking scripts
    • P2PKH Transactions
    • P2SH Transactions
    • P2MS Transactions (naked multisig)
    • P2PK Transactions
    • Data-only Transactions (locked with OP_FALSE OP_RETURN)
    • Spendable data-carrier Transactions (locked with PUSH_DATA [your_data] OP_DROP [P2PKH locking code])
  • HD Key Derivation (BIP32)
  • Original Bitcoin Address format
  • Bitcoin Signed Messages
  • Mnemonic Seed Support (BIP39)
  • A built-in Bitcoin Script Interpreter
  • ECIES Encryption / Decryption (Supports Electrum ECIES / BIE1 )
Sample of the Transaction API:
    var utxo = txWithUTXO.outputs[0]; 
    var outpoint = TransactionOutpoint(txWithUTXO.id, 0, utxo.satoshis, utxo.script);
    var signer = TransactionSigner(SighashType.SIGHASH_FORKID.value | SighashType.SIGHASH_ALL.value, privateKey);

    var unlocker = P2PKHUnlockBuilder(privateKey.publicKey);
    
    var transaction = TransactionBuilder()
        .spendFromOutpointWithSigner(signer, outpoint, TransactionInput.MAX_SEQ_NUMBER, unlocker)
        .spendToPKH(recipientAddress, BigInt.from(50000000)) //spend half of a bitcoin 
        .sendChangeToPKH(changeAddress) // spend change to a different address
        .withFeePerKb(50) //set a fee of 50 satoshis per kilobyte
        .build(false); //build the transaction, disabling checks

    //at this point you have a fully signed transaction ready to be broadcast

    try {
      transaction.verify(); //perform a pre-broadcast sanity check on the transaction
    } on VerificationException catch (ex){
      print("Transaction failed verification - ${ex.cause}");  
    }

Installation

This library was built using version 3.0.7 of the Dart SDK( https://dart.dev/tools/sdk ).
As of Version 1.0.0 this library supports Dart Null Safety. Current minimum Dart SDK version required is version 2.17.0.

Navigate to the root folder of this project, and pull the required supported Dart libraries using the pub package manager.

> pub get
Running the Tests

In the root folder of this project, run the command:

> pub run test

Acknowledgement

A debt of gratitude is owed to the developers acknowledged in the LICENSE file. Without the hard work of individuals working on earlier library and node implementations like Bitcoin Core, Bitcoin Cash, MoneyButton/BSV, BitcoinJ and many more, this library would likely not have come to fruition. Thank you.

Contact

You can reach the author at :

  • @twostack_org on Twitter
  • beardpappa@handcash.io (PayMail to buy me a beer)
  • stephan@twostack.org (drop me an email. GPG supported. )

所属分类

依赖

依赖清单 8 项

源码仓库

使用此插件的项目

暂无相关数据。