bitcoin_message_signer 1.0.0 copy "bitcoin_message_signer: ^1.0.0" to clipboard
bitcoin_message_signer: ^1.0.0 copied to clipboard

Sign messages like bitcoin core https://github.com/bitcoin/bitcoin

Bitcoin Message Signer #

A dart library to sign message like Bitcoin core.

How to use #

Add the dependency: dart pub add bitcoin_message_signer or flutter pub add bitcoin_message_signer

Use it to sign messages with a bech32 script (bc1... address):

import 'package:bitcoin_message_signer/bitcoin_message_signer.dart';

/// ...

final signer = BitcoinMessageSigner(
  privateKey: Uint8List.fromList(privateKey),
  scriptType: P2WPKH(),
);
final signature = signer.signMessage(message: 'Hello Bitcoin-World!');

Supported script types #

  • P2PKH uncompressed: 1... address from an uncompressed private key (5...)
  • P2PKH compressed: 1... address from a compressed private key (L... or K...)
  • P2SH: 3... addresses
  • P2WPKH: bc1... addresses

Checkout examples in the tests.

Where do I get the private key from? #

This depends on the bitcoin library you use. E.g. bdk_flutter returns the private key as List<int>, therefore you can simply transform it using Uint8List.fromList(privateKey). Most other libraries probably return the private key either as list too, as hex string or in WIF format. In either case you probably need another library to transform the private key into a Uint8List.

2
likes
0
points
33
downloads

Publisher

verified publishersatoshiengineering.com

Weekly Downloads

Sign messages like bitcoin core https://github.com/bitcoin/bitcoin

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

blockchain_utils, flutter, pointycastle

More

Packages that depend on bitcoin_message_signer