Skip to content

Tutorial: your first SPV payment

In this tutorial you build one Dart program, step by step. In it, Bob issues an invoice, Alice pays it, and Bob verifies the payment against block headers his own wallet synced. Everything runs on your machine against a local Teranode network, so no coins of any value are involved.

You will:

  1. Run a regtest Teranode network in Docker (localnet-teranode).
  2. Add libspiffy to a Dart console program and start its actor system.
  3. Create two HD wallets, Alice and Bob.
  4. Fund Alice from the network’s faucet, with a merkle proof her wallet checks.
  5. Have Bob create an invoice.
  6. Have Alice pay it, which gives you a BEEF to hand to Bob.
  7. Have Bob validate that BEEF, which also broadcasts it.
  8. Mine the payment and watch both wallets confirm it.

The program runs end to end in about a minute and a half once the network is up.

  • Docker with about 4 GB free (localnet-teranode uses about 2.5 GB at rest)
  • Go 1.27 or later, which builds the localnet faucet
  • The Dart SDK, 3.5.1 or later
  • macOS or Linux

The complete program is examples/first_payment in this site’s repository. It is built against libspiffy 5.0.0 and is run against localnet-teranode before each site release. Each page of the tutorial shows the part of it you’re adding.

Start with step 1 →