Dart · Bitcoin SV · SPV

An SPV wallet you can replay, audit and embed.

An actor-based Bitcoin SV SPV wallet library for Dart: event-sourced wallets, BEEF payments with merkle-proof validation, ARC broadcast, payment channels, BRC-100 key operations and pluggable token scripts.

dart pub add libspiffy

Runs where Dart runs

  • Flutter
  • iOS
  • Android
  • macOS · Windows · Linux
Event journal · bobexample
  1. #1wallet.createdbob
  2. #2invoice.created100000 sats
  3. #3wallet.utxo.receivedfrom a validated BEEF
  4. #4invoice.paidSEEN_ON_NETWORK
  5. #5wallet.transaction.confirmedproof matches header
→ projection: balance100,000 sats

What's in the box

Everything a wallet needs. Nothing it has to trust.

Event-sourced wallets

Every state change is an immutable event in the journal. State is rebuilt by replaying it, so any balance can be traced to the events behind it.

SPV with BEEF & BUMP

Payments arrive with their merkle proofs. libspiffy checks them against block headers it syncs itself, with no full node required.

Invoice payments

Multi-output invoices: P2PKH, P2MS multisig, OP_RETURN metadata and plugin-delegated outputs.

Payment channels

Off-chain micropayments between two peers, settled on chain and tracked as their own aggregate.

Script & token plugins

ScriptPlugin and TransactionBuilderPlugin add custom locking scripts and token protocols.

Isar or PostgreSQL

Embedded Isar storage for Flutter and desktop apps, PostgreSQL for server deployments.

One entry point

Ask the coordinator. Follow the events.

ask() sends a request and returns its own reply, or throws if it failed. on<E>() follows what happens without a request, from a new wallet to a confirmed payment.

final libspiffy = LibSpiffyActorSystem();
await libspiffy.initialize(
  isar: isar,
  secureStorage: secureStorage,
  networkType: 'regtest',
  peerAddresses: ['127.0.0.1:18444'], // localnet-teranode
  arcConfig: ArcServiceConfig(baseUrl: 'http://127.0.0.1:23011'),
);

final coordinator = libspiffy.coordinator;

Develop locally

A whole Teranode network on your laptop.

localnet-teranode runs a regtest Teranode in Docker, with Arcade for ARC-compatible broadcast, Merkle Service for proofs, an autominer and a faucet. Mine a block whenever you need one.

  • Point ArcServiceConfig at Arcade on :23011
  • Sync headers over the wire protocol on :18444
  • libspiffy's own integration tests run against the same stack
terminal
$ git clone https://github.com/twostack/localnet-teranode
$ cd localnet-teranode
$ ./scripts/start.sh
$ ./scripts/faucet.sh send <address> 1000000 --arcade
arcade RECEIVED
txid   <txid>
sent   1000000 sats to <address>
$ ./scripts/mine.sh 1

Where to next