dartsv 0.1.0-alpha2

  • Readme
  • Changelog
  • Installing
  • 35

Overview #

DartSV 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.

This library therefore lacks , and will not implement :

  • Segregated Witness (Segwit) Transaction support
  • Schnorr Signature support
  • Check Datasig (OP_CHECKDATASIG)

Current Supported features are :

  • P2PKH Transactions (building and spending from)
  • Data-only Transactions (untested)
  • HD Key Derivation (BIP32)
  • Original Bitcoin Address format
  • Transaction Signing

Pending Features :

  • Script Interpreter (high priority)
  • P2SH support (low priority since it will be deprecated in BitcoinSV)
  • Broader support for original OP_CODES as they become available on BitcoinSV mainnet

Note to Developers #

This is an Alpha-Release aimed at interested individuals and experienced developers for the purpose of getting feedback on library improvements as I build towards a stable 0.1.0 release. I am especially interested in hearing from Flutter developers.

Documentation is lacking. Your best source for seeing how the library works is the cli-example application on GitHub: DartSV CLI Example

Here is a small sample of the Transaction API (method taken from cli-example):

String createWalletTxn(Address address, List<TransactionInput> utxosToSpendFrom, BigInt amount ){

    var transaction = new Transaction()
        .spendTo(address, amount)
        .sendChangeTo(_receivingAddress) // spend change to myself
        .signWith(this._walletPrivKey, sighashType: SighashType.SIGHASH_ALL | SighashType.SIGHASH_FORKID);

    return transaction.serialize();

Installation #

This library was built using the latest version (2.3.1) of the Dart SDK https://dart.dev/tools/sdk, but should work with Dart SDK 2.1.x onwards.
Therefore, as a pre-requisite ensure that you have at least that version of the Dart SDK installed before proceeding.

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 shell script :

> ./runtests.sh

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 :

  • @beardpappa on Twitter
  • $beardpappa (to buy me a beer)
  • stephan@werkswinkel.com

0.1.0-alpha2 #

  • Added support for contributed Bip39 mnemonics
  • Added support for Bitcoin Signed Messages

0.1.0-alpha #

  • Initial Release

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  dartsv: ^0.1.0-alpha2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:dartsv/dartsv.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Dec 11, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21

Health suggestions

Fix lib/src/transaction/transaction.dart. (-14.82 points)

Analysis of lib/src/transaction/transaction.dart reported 32 hints, including:

line 6 col 8: Unused import: 'package:sprintf/sprintf.dart'.

line 36 col 13: Don't explicitly initialize variables to null.

line 39 col 12: Don't explicitly initialize variables to null.

line 91 col 13: DO use curly braces for all flow control structures.

line 122 col 11: DO use curly braces for all flow control structures.

Fix lib/src/publickey.dart. (-10.89 points)

Analysis of lib/src/publickey.dart reported 23 hints, including:

line 2 col 8: Unused import: 'dart:math'.

line 7 col 8: Unused import: 'dart:convert'.

line 11 col 25: Unnecessary new keyword.

line 12 col 15: Unnecessary new keyword.

line 16 col 15: The value of the field '_publicKey' isn't used.

Fix lib/src/signature.dart. (-10.89 points)

Analysis of lib/src/signature.dart reported 23 hints, including:

line 10 col 8: Unused import: 'package:pointycastle/digests/ripemd160.dart'.

line 14 col 8: Unused import: 'package:pointycastle/random/fortuna_random.dart'.

line 16 col 8: Unused import: 'dart:convert'.

line 22 col 46: Unnecessary new keyword.

line 24 col 36: Unnecessary new keyword.

Fix additional 21 files with analysis or formatting issues. (-55.25 points)

Additional issues in the following files:

  • lib/src/privatekey.dart (22 hints)
  • lib/src/encoding/utils.dart (11 hints)
  • lib/src/crypto/childnumber.dart (10 hints)
  • lib/src/crypto/hdutils.dart (10 hints)
  • lib/src/hdprivatekey.dart (9 hints)
  • lib/src/encoding/base58check.dart (8 hints)
  • lib/src/sighash.dart (7 hints)
  • lib/src/svscript.dart (7 hints)
  • lib/src/encoding/ckdserializer.dart (5 hints)
  • lib/src/hdpublickey.dart (5 hints)
  • lib/src/address.dart (4 hints)
  • lib/src/script/interpreter.dart (4 hints)
  • lib/src/networks.dart (3 hints)
  • lib/src/bip39/bip39.dart (2 hints)
  • lib/src/encoding/wifcodec.dart (2 hints)
  • lib/src/message.dart (2 hints)
  • lib/src/transaction/transaction_output.dart (2 hints)
  • lib/dartsv.dart (Run dartfmt to format lib/dartsv.dart.)
  • lib/src/exceptions.dart (Run dartfmt to format lib/src/exceptions.dart.)
  • lib/src/script/opcodes.dart (Run dartfmt to format lib/src/script/opcodes.dart.)
  • lib/src/transaction/transaction_input.dart (Run dartfmt to format lib/src/transaction/transaction_input.dart.)

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and dartsv.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

The package description is too short. (-7 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-release. (-5 points)

Pre-release versions should be used with caution; their API can change in breaking ways.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
asn1lib ^0.5.8 0.5.14
collection ^1.14.11 1.14.12
hex ^0.1.2 0.1.2
pointycastle ^1.0.1 1.0.2
resource ^2.1.5 2.1.6
sprintf ^4.0.2 4.0.2
unorm_dart ^0.1.1 0.1.2
Transitive dependencies
typed_data 1.1.6
Dev dependencies
bip39 ^1.0.3
mockito ^4.0.0
pedantic ^1.0.0
test ^1.0.0