README.md (1800B)
1 # ppad-bolt1 2 3 [](https://hackage.haskell.org/package/ppad-bolt1) 4  5 [](https://docs.ppad.tech/bolt1) 6 7 A Haskell implementation of the Lightning Network base protocol (BOLT 8 #1), providing message and TLV encoding/decoding with validation. 9 10 ## Usage 11 12 A sample GHCi session: 13 14 ``` 15 > :set -XOverloadedStrings 16 > 17 > import qualified Data.ByteString as BS 18 > import Lightning.Protocol.BOLT1 19 > 20 > let msg = MsgPingVal (Ping 10 "") 21 > let ext = TlvStream [TlvRecord 101 "ext"] 22 > 23 > Right enc = encodeEnvelope msg (Just ext) 24 > enc 25 "\NUL\DC2\NUL\n\NUL\NULe\ETXext" 26 > 27 > decodeEnvelope enc 28 Right (Just (MsgPingVal (Ping {pingNumPongBytes = 10, pingIgnored = ""})), 29 Just (TlvStream [TlvRecord {tlvType = 101, tlvValue = "ext"}])) 30 ``` 31 32 ## Documentation 33 34 Haddocks (API documentation, etc.) are hosted at 35 [docs.ppad.tech/bolt1](https://docs.ppad.tech/bolt1). 36 37 ## Performance 38 39 The aim is best-in-class performance for message encoding/decoding. 40 Benchmarks are available under `bench/` and can be run with: 41 42 ``` 43 $ cabal bench 44 ``` 45 46 ## Security 47 48 This is a pre-release library that, at present, claims no security 49 properties whatsoever. 50 51 ## Development 52 53 You'll require [Nix][nixos] with [flake][flake] support enabled. Enter a 54 development shell with: 55 56 ``` 57 $ nix develop 58 ``` 59 60 Then do e.g.: 61 62 ``` 63 $ cabal repl ppad-bolt1 64 ``` 65 66 to get a REPL for the main library. 67 68 ## Attribution 69 70 This library implements the Lightning Network BOLT #1 specification: 71 https://github.com/lightning/bolts/blob/master/01-messaging.md 72 73 [nixos]: https://nixos.org/ 74 [flake]: https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html