Internal.hs (1443B)
1 {-# OPTIONS_HADDOCK hide #-} 2 3 -- | 4 -- Module: Lightning.Protocol.BOLT1.Internal 5 -- Copyright: (c) 2025 Jared Tobin 6 -- License: MIT 7 -- Maintainer: Jared Tobin <jared@ppad.tech> 8 -- 9 -- Internal definitions for BOLT #1. 10 -- 11 -- This module exports unsafe constructors that bypass 12 -- validation. Use only in tests or trusted internal code. 13 14 module Lightning.Protocol.BOLT1.Internal ( 15 -- * Unsafe constructors 16 unsafeMsgUnknown 17 , unsafeEnvelope 18 , unsafeChainHash 19 , unsafeChannelId 20 ) where 21 22 import qualified Data.ByteString as BS 23 import Data.Word (Word16) 24 import Lightning.Protocol.BOLT1.Message 25 import Lightning.Protocol.BOLT1.Prim 26 import Lightning.Protocol.BOLT1.TLV 27 28 -- | Construct a 'MsgUnknown' without validation. 29 -- 30 -- This bypasses the check that prevents wrapping known 31 -- type codes. For test use only. 32 unsafeMsgUnknown :: Word16 -> MsgType 33 unsafeMsgUnknown = MsgUnknown 34 35 -- | Construct an 'Envelope' without validation. 36 -- 37 -- This bypasses the check that 'envType' matches the 38 -- message. For test use only. 39 unsafeEnvelope 40 :: MsgType 41 -> BS.ByteString 42 -> Maybe TlvStream 43 -> Envelope 44 unsafeEnvelope = Envelope 45 46 -- | Construct a 'ChainHash' without length validation. 47 -- 48 -- For test use only. 49 unsafeChainHash :: BS.ByteString -> ChainHash 50 unsafeChainHash = ChainHash 51 52 -- | Construct a 'ChannelId' without length validation. 53 -- 54 -- For test use only. 55 unsafeChannelId :: BS.ByteString -> ChannelId 56 unsafeChannelId = ChannelId