bolt3

Lightning transaction and script formats, per BOLT #3 (docs.ppad.tech/bolt3).
git clone git://git.ppad.tech/bolt3.git
Log | Files | Refs | README | LICENSE

README.md (2325B)


      1 # ppad-bolt3
      2 
      3 [![](https://img.shields.io/hackage/v/ppad-bolt3?color=blue)](https://hackage.haskell.org/package/ppad-bolt3)
      4 ![](https://img.shields.io/badge/license-MIT-brightgreen)
      5 [![](https://img.shields.io/badge/haddock-bolt3-lightblue)](https://docs.ppad.tech/bolt3)
      6 
      7 A pure Haskell implementation of [BOLT #3][bolt3] (Lightning Network
      8 Bitcoin transaction and script formats), including commitment
      9 transactions, HTLC transactions, closing transactions, per-commitment
     10 key derivation, and secret storage.
     11 
     12 ## Usage
     13 
     14 A sample GHCi session:
     15 
     16 ```
     17   > :set -XOverloadedStrings
     18   >
     19   > import qualified Data.ByteString as BS
     20   > import qualified Data.ByteString.Base16 as B16
     21   > import Lightning.Protocol.BOLT3
     22   >
     23   > -- key derivation (BOLT #3 Appendix E test vector)
     24   > let basepoint = Point (B16.decodeLenient "036d6caac248af96f6afa7f904f550253a0f3ef3f5aa2fe6838a95b216691468e2")
     25   > let perCommitment = PerCommitmentPoint (Point (B16.decodeLenient "025f7117a78150fe2ef97db7cfc83bd57b2e2c0d0dd25eaf467a4a1c2a45ce1486"))
     26   > let Just (Pubkey derived) = derive_pubkey basepoint perCommitment
     27   > B16.encode derived
     28   "0235f2dbfaa89b57ec7b055afe29849ef7ddfeb1cefdb9ebdc43f5494984db29e5"
     29   >
     30   > -- secret generation (BOLT #3 Appendix D test vector)
     31   > let seed = BS.replicate 32 0xFF
     32   > B16.encode (generate_from_seed seed 281474976710655)
     33   "7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc"
     34   >
     35   > -- fee calculation
     36   > let feerate = FeeratePerKw 5000
     37   > let features = ChannelFeatures { cf_option_anchors = False }
     38   > commitment_fee feerate features 2
     39   Satoshi 5340
     40   >
     41   > -- HTLC trimming
     42   > let dust = DustLimit (Satoshi 546)
     43   > htlc_trim_threshold dust feerate features HTLCOffered
     44   Satoshi 3861
     45 ```
     46 
     47 ## Documentation
     48 
     49 Haddocks are hosted at [docs.ppad.tech/bolt3][hadoc].
     50 
     51 ## Security
     52 
     53 This is a pre-release version and makes no security guarantees whatsoever.
     54 
     55 ## Development
     56 
     57 You'll require [Nix][nixos] with [flake][flake] support enabled. Enter a
     58 development shell with:
     59 
     60 ```
     61 $ nix develop
     62 ```
     63 
     64 Then do e.g.:
     65 
     66 ```
     67 $ cabal build
     68 $ cabal test
     69 $ cabal bench
     70 ```
     71 
     72 [bolt3]: https://github.com/lightning/bolts/blob/master/03-transactions.md
     73 [nixos]: https://nixos.org/
     74 [flake]: https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html
     75 [hadoc]: https://docs.ppad.tech/bolt3