bolt5

On-chain transaction handling for Lightning (docs.ppad.tech/bolt5).
git clone git://git.ppad.tech/bolt5.git
Log | Files | Refs | README | LICENSE

Weight.hs (1959B)


      1 module Main where
      2 
      3 import Fixtures
      4 import Lightning.Protocol.BOLT3
      5 import qualified Lightning.Protocol.BOLT5 as B5
      6 import Weigh
      7 
      8 -- note that 'weigh' doesn't work properly in a repl
      9 main :: IO ()
     10 main = do
     11   fx <- fixtures
     12   let keys = fx_keys fx
     13       revpk = ck_revocation_pubkey keys
     14       delayed = ck_local_delayed keys
     15   mainWith $ do
     16     wgroup "detect" $ do
     17       func "identify_close"
     18         (B5.identify_close (fx_other fx) (fx_commit fx)) (fx_raw fx)
     19       func "classify_local_commit_outputs"
     20         (\c -> B5.classify_local_commit_outputs c keys (fx_delay fx)
     21            StaticRemotekey)
     22         (fx_commit fx)
     23       func "classify_remote_commit_outputs"
     24         (\c -> B5.classify_remote_commit_outputs c keys) (fx_commit fx)
     25       func "classify_revoked_commit_outputs"
     26         (\c -> B5.classify_revoked_commit_outputs c revpk) (fx_commit fx)
     27       func "extract_preimage_offered"
     28         (B5.extract_preimage_offered (fx_hash fx)) (fx_claim fx)
     29       func "extract_preimage_htlc_success"
     30         (B5.extract_preimage_htlc_success (fx_hash fx)) (fx_success fx)
     31     wgroup "spend" $ do
     32       func "spend_to_local"
     33         (\v -> B5.spend_to_local (fx_outpoint fx) v revpk (fx_delay fx)
     34            delayed (fx_dest fx) (fx_feerate fx))
     35         (fx_value fx)
     36       func "spend_htlc_tx" (B5.spend_htlc_tx (fx_htlc_ctx fx)) keys
     37       func "spend_remote_htlc_timeout"
     38         (\v -> B5.spend_remote_htlc_timeout (fx_outpoint fx) v
     39            (fx_received fx) keys StaticRemotekey (fx_dest fx)
     40            (fx_feerate fx))
     41         (fx_value fx)
     42       func "spend_revoked_htlc"
     43         (\v -> B5.spend_revoked_htlc (fx_outpoint fx) v
     44            (B5.HTLCReceivedOutput (CltvExpiry 501)) revpk keys
     45            StaticRemotekey (fx_hash fx) (fx_dest fx) (fx_feerate fx))
     46         (fx_value fx)
     47       func "spend_anchor_owner"
     48         (\v -> B5.spend_anchor_owner (fx_outpoint fx) v
     49            (ck_local_funding keys) (fx_dest fx))
     50         (fx_anchor fx)