README.md (2287B)
1 # ppad-bolt7 2 3 [](https://hackage.haskell.org/package/ppad-bolt7) 4  5 [](https://docs.ppad.tech/bolt7) 6 7 A pure Haskell implementation of 8 [BOLT #7](https://github.com/lightning/bolts/blob/master/07-routing-gossip.md) 9 (Lightning Network routing gossip protocol). 10 11 ## Usage 12 13 A sample GHCi session: 14 15 ``` 16 > :set -XOverloadedStrings 17 > 18 > -- import qualified 19 > import qualified Lightning.Protocol.BOLT7 as B7 20 > 21 > -- decode a gossip_timestamp_filter from wire bytes (after msg type) 22 > -- wire contains: 32-byte chain_hash, 4-byte first_timestamp, 23 > -- 4-byte timestamp_range 24 > case B7.decodeGossipTimestampFilter wire of 25 > Left err -> print err 26 > Right (msg, rest) -> print (B7.gossipFilterFirstTimestamp msg) 27 1609459200 28 > 29 > -- construct and encode a gossip_timestamp_filter 30 > let msg = B7.GossipTimestampFilter B7.mainnetChainHash 1609459200 86400 31 > let encoded = B7.encodeGossipTimestampFilter msg 32 > 33 > -- validate a channel_announcement before processing 34 > case B7.validateChannelAnnouncement announcement of 35 > Left B7.ValidateNodeIdOrdering -> putStrLn "invalid node ordering" 36 > Right () -> putStrLn "valid" 37 > 38 > -- compute the hash for signature verification 39 > let sigHash = B7.channelAnnouncementHash encodedAnnouncement 40 > -- verify signatures with ppad-secp256k1 (separate library) 41 ``` 42 43 ## Overview 44 45 ppad-bolt7 provides types and codecs for BOLT #7 gossip messages: 46 47 * `channel_announcement` (256) 48 * `node_announcement` (257) 49 * `channel_update` (258) 50 * `announcement_signatures` (259) 51 * `query_short_channel_ids` (261) 52 * `reply_short_channel_ids_end` (262) 53 * `query_channel_range` (263) 54 * `reply_channel_range` (264) 55 * `gossip_timestamp_filter` (265) 56 57 ## Documentation 58 59 Haddock documentation is available at 60 [docs.ppad.tech/bolt7](https://docs.ppad.tech/bolt7). 61 62 ## Security 63 64 This is a pre-release version of the library and makes no claims about 65 security whatsoever. 66 67 ## Development 68 69 A Nix development shell is provided via flake. Enter it with: 70 71 ``` 72 $ nix develop 73 ``` 74 75 Then use `cabal` as usual: 76 77 ``` 78 $ cabal build 79 $ cabal test 80 $ cabal bench 81 ``` 82