Skip to content

ppad-tech/bolt1

Repository files navigation

ppad-bolt1

A Haskell implementation of the Lightning Network base protocol (BOLT #1), providing message and TLV encoding/decoding with validation.

Usage

A sample GHCi session:

  > :set -XOverloadedStrings
  >
  > import qualified Data.ByteString as BS
  > import Lightning.Protocol.BOLT1
  >
  > let msg = MsgPingVal (Ping 10 "")
  > let ext = TlvStream [TlvRecord 101 "ext"]
  >
  > Right enc = encodeEnvelope msg (Just ext)
  > enc
  "\NUL\DC2\NUL\n\NUL\NULe\ETXext"
  >
  > decodeEnvelope enc
  Right (Just (MsgPingVal (Ping {pingNumPongBytes = 10, pingIgnored = ""})),
         Just (TlvStream [TlvRecord {tlvType = 101, tlvValue = "ext"}]))

Documentation

Haddocks (API documentation, etc.) are hosted at docs.ppad.tech/bolt1.

Performance

The aim is best-in-class performance for message encoding/decoding. Benchmarks are available under bench/ and can be run with:

$ cabal bench

Security

This is a pre-release library that, at present, claims no security properties whatsoever.

Development

You'll require Nix with flake support enabled. Enter a development shell with:

$ nix develop

Then do e.g.:

$ cabal repl ppad-bolt1

to get a REPL for the main library.

Attribution

This library implements the Lightning Network BOLT #1 specification: https://github.com/lightning/bolts/blob/master/01-messaging.md

About

Base Lightning protocol, per BOLT #1.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors