{-# LANGUAGE BangPatterns, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings #-} {-# OPTIONS_GHC -w #-} module Network.Haskoin.Store.ProtocolBuffers.Input (Input(..)) where import Prelude ((+), (/), (++), (.)) import qualified Prelude as Prelude' import qualified Data.Typeable as Prelude' import qualified GHC.Generics as Prelude' import qualified Data.Data as Prelude' import qualified Text.ProtocolBuffers.Header as P' import qualified Network.Haskoin.Store.ProtocolBuffers.TxId as ProtocolBuffers (TxId) data Input = Input{coinbase :: !(P'.Bool), txid :: !(ProtocolBuffers.TxId), output :: !(P'.Word32), sigscript :: !(P'.ByteString), sequence :: !(P'.Word32), witness :: !(P'.Seq P'.ByteString), value :: !(P'.Maybe P'.Word64), pkscript :: !(P'.Maybe P'.ByteString), address :: !(P'.Maybe P'.Utf8)} deriving (Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, Prelude'.Generic) instance P'.Mergeable Input where mergeAppend (Input x'1 x'2 x'3 x'4 x'5 x'6 x'7 x'8 x'9) (Input y'1 y'2 y'3 y'4 y'5 y'6 y'7 y'8 y'9) = Input (P'.mergeAppend x'1 y'1) (P'.mergeAppend x'2 y'2) (P'.mergeAppend x'3 y'3) (P'.mergeAppend x'4 y'4) (P'.mergeAppend x'5 y'5) (P'.mergeAppend x'6 y'6) (P'.mergeAppend x'7 y'7) (P'.mergeAppend x'8 y'8) (P'.mergeAppend x'9 y'9) instance P'.Default Input where defaultValue = Input P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue instance P'.Wire Input where wireSize ft' self'@(Input x'1 x'2 x'3 x'4 x'5 x'6 x'7 x'8 x'9) = case ft' of 10 -> calc'Size 11 -> P'.prependMessageSize calc'Size _ -> P'.wireSizeErr ft' self' where calc'Size = (P'.wireSizeReq 1 8 x'1 + P'.wireSizeReq 1 11 x'2 + P'.wireSizeReq 1 13 x'3 + P'.wireSizeReq 1 12 x'4 + P'.wireSizeReq 1 13 x'5 + P'.wireSizeRep 1 12 x'6 + P'.wireSizeOpt 1 4 x'7 + P'.wireSizeOpt 1 12 x'8 + P'.wireSizeOpt 1 9 x'9) wirePutWithSize ft' self'@(Input x'1 x'2 x'3 x'4 x'5 x'6 x'7 x'8 x'9) = case ft' of 10 -> put'Fields 11 -> put'FieldsSized _ -> P'.wirePutErr ft' self' where put'Fields = P'.sequencePutWithSize [P'.wirePutReqWithSize 0 8 x'1, P'.wirePutReqWithSize 10 11 x'2, P'.wirePutReqWithSize 16 13 x'3, P'.wirePutReqWithSize 26 12 x'4, P'.wirePutReqWithSize 32 13 x'5, P'.wirePutRepWithSize 42 12 x'6, P'.wirePutOptWithSize 48 4 x'7, P'.wirePutOptWithSize 58 12 x'8, P'.wirePutOptWithSize 66 9 x'9] put'FieldsSized = let size' = Prelude'.fst (P'.runPutM put'Fields) put'Size = do P'.putSize size' Prelude'.return (P'.size'WireSize size') in P'.sequencePutWithSize [put'Size, put'Fields] wireGet ft' = case ft' of 10 -> P'.getBareMessageWith (P'.catch'Unknown' P'.discardUnknown update'Self) 11 -> P'.getMessageWith (P'.catch'Unknown' P'.discardUnknown update'Self) _ -> P'.wireGetErr ft' where update'Self wire'Tag old'Self = case wire'Tag of 0 -> Prelude'.fmap (\ !new'Field -> old'Self{coinbase = new'Field}) (P'.wireGet 8) 10 -> Prelude'.fmap (\ !new'Field -> old'Self{txid = P'.mergeAppend (txid old'Self) (new'Field)}) (P'.wireGet 11) 16 -> Prelude'.fmap (\ !new'Field -> old'Self{output = new'Field}) (P'.wireGet 13) 26 -> Prelude'.fmap (\ !new'Field -> old'Self{sigscript = new'Field}) (P'.wireGet 12) 32 -> Prelude'.fmap (\ !new'Field -> old'Self{sequence = new'Field}) (P'.wireGet 13) 42 -> Prelude'.fmap (\ !new'Field -> old'Self{witness = P'.append (witness old'Self) new'Field}) (P'.wireGet 12) 48 -> Prelude'.fmap (\ !new'Field -> old'Self{value = Prelude'.Just new'Field}) (P'.wireGet 4) 58 -> Prelude'.fmap (\ !new'Field -> old'Self{pkscript = Prelude'.Just new'Field}) (P'.wireGet 12) 66 -> Prelude'.fmap (\ !new'Field -> old'Self{address = Prelude'.Just new'Field}) (P'.wireGet 9) _ -> let (field'Number, wire'Type) = P'.splitWireTag wire'Tag in P'.unknown field'Number wire'Type old'Self instance P'.MessageAPI msg' (msg' -> Input) Input where getVal m' f' = f' m' instance P'.GPB Input instance P'.ReflectDescriptor Input where getMessageInfo _ = P'.GetMessageInfo (P'.fromDistinctAscList [0, 10, 16, 26, 32]) (P'.fromDistinctAscList [0, 10, 16, 26, 32, 42, 48, 58, 66]) reflectDescriptorInfo _ = Prelude'.read "DescriptorInfo {descName = ProtoName {protobufName = FIName \".ProtocolBuffers.Input\", haskellPrefix = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule = [MName \"ProtocolBuffers\"], baseName = MName \"Input\"}, descFilePath = [\"Network\",\"Haskoin\",\"Store\",\"ProtocolBuffers\",\"Input.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".ProtocolBuffers.Input.coinbase\", haskellPrefix' = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule' = [MName \"ProtocolBuffers\",MName \"Input\"], baseName' = FName \"coinbase\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 0}, wireTag = WireTag {getWireTag = 0}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = True, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 8}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".ProtocolBuffers.Input.txid\", haskellPrefix' = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule' = [MName \"ProtocolBuffers\",MName \"Input\"], baseName' = FName \"txid\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 10}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = True, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 11}, typeName = Just (ProtoName {protobufName = FIName \".ProtocolBuffers.TxId\", haskellPrefix = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule = [MName \"ProtocolBuffers\"], baseName = MName \"TxId\"}), hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".ProtocolBuffers.Input.output\", haskellPrefix' = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule' = [MName \"ProtocolBuffers\",MName \"Input\"], baseName' = FName \"output\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 2}, wireTag = WireTag {getWireTag = 16}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = True, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 13}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".ProtocolBuffers.Input.sigscript\", haskellPrefix' = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule' = [MName \"ProtocolBuffers\",MName \"Input\"], baseName' = FName \"sigscript\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 3}, wireTag = WireTag {getWireTag = 26}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = True, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 12}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".ProtocolBuffers.Input.sequence\", haskellPrefix' = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule' = [MName \"ProtocolBuffers\",MName \"Input\"], baseName' = FName \"sequence\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 4}, wireTag = WireTag {getWireTag = 32}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = True, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 13}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".ProtocolBuffers.Input.witness\", haskellPrefix' = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule' = [MName \"ProtocolBuffers\",MName \"Input\"], baseName' = FName \"witness\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 5}, wireTag = WireTag {getWireTag = 42}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = True, mightPack = False, typeCode = FieldType {getFieldType = 12}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".ProtocolBuffers.Input.value\", haskellPrefix' = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule' = [MName \"ProtocolBuffers\",MName \"Input\"], baseName' = FName \"value\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 6}, wireTag = WireTag {getWireTag = 48}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 4}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".ProtocolBuffers.Input.pkscript\", haskellPrefix' = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule' = [MName \"ProtocolBuffers\",MName \"Input\"], baseName' = FName \"pkscript\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 7}, wireTag = WireTag {getWireTag = 58}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 12}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".ProtocolBuffers.Input.address\", haskellPrefix' = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule' = [MName \"ProtocolBuffers\",MName \"Input\"], baseName' = FName \"address\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 8}, wireTag = WireTag {getWireTag = 66}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = False, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing}], descOneofs = fromList [], keys = fromList [], extRanges = [], knownKeys = fromList [], storeUnknown = False, lazyFields = False, makeLenses = False, jsonInstances = False}" instance P'.TextType Input where tellT = P'.tellSubMessage getT = P'.getSubMessage instance P'.TextMsg Input where textPut msg = do P'.tellT "coinbase" (coinbase msg) P'.tellT "txid" (txid msg) P'.tellT "output" (output msg) P'.tellT "sigscript" (sigscript msg) P'.tellT "sequence" (sequence msg) P'.tellT "witness" (witness msg) P'.tellT "value" (value msg) P'.tellT "pkscript" (pkscript msg) P'.tellT "address" (address msg) textGet = do mods <- P'.sepEndBy (P'.choice [parse'coinbase, parse'txid, parse'output, parse'sigscript, parse'sequence, parse'witness, parse'value, parse'pkscript, parse'address]) P'.spaces Prelude'.return (Prelude'.foldl (\ v f -> f v) P'.defaultValue mods) where parse'coinbase = P'.try (do v <- P'.getT "coinbase" Prelude'.return (\ o -> o{coinbase = v})) parse'txid = P'.try (do v <- P'.getT "txid" Prelude'.return (\ o -> o{txid = v})) parse'output = P'.try (do v <- P'.getT "output" Prelude'.return (\ o -> o{output = v})) parse'sigscript = P'.try (do v <- P'.getT "sigscript" Prelude'.return (\ o -> o{sigscript = v})) parse'sequence = P'.try (do v <- P'.getT "sequence" Prelude'.return (\ o -> o{sequence = v})) parse'witness = P'.try (do v <- P'.getT "witness" Prelude'.return (\ o -> o{witness = P'.append (witness o) v})) parse'value = P'.try (do v <- P'.getT "value" Prelude'.return (\ o -> o{value = v})) parse'pkscript = P'.try (do v <- P'.getT "pkscript" Prelude'.return (\ o -> o{pkscript = v})) parse'address = P'.try (do v <- P'.getT "address" Prelude'.return (\ o -> o{address = v}))