Safe Haskell | None |
---|
- data Balance = Balance {
- balConfirmed :: Word64
- balUnconfirmed :: Word64
- data Coin = Coin {
- coinOutPoint :: OutPoint
- coinTxHeight :: TxHeight
- coinValue :: Word64
- data TxHeight = TxHeight {
- txHeightBlock :: Word
- txHeightId :: Hash256
- data StratumNotif = NotifAddress {}
- data StratumQuery
- = QueryVersion { }
- | QueryHistory { }
- | QueryBalance { }
- | QueryUnspent { }
- | QueryTx { }
- | QueryBroadcast { }
- | SubAddress { }
- data StratumResponse
- = ServerVersion {
- stratumServerVer :: String
- | AddressHistory {
- stratumAddrHist :: [TxHeight]
- | AddressBalance { }
- | AddressUnspent {
- stratumCoins :: [Coin]
- | Transaction { }
- | BroadcastId { }
- | AddrStatus { }
- = ServerVersion {
- type MessageStratum = Message StratumNotif StratumResponse Value String
- type NotifStratum = Request StratumNotif
- type RequestStratum = Request StratumQuery
- type ResponseStratum = Response StratumResponse Value String
- type ResultStratum = Result StratumResponse Value String
- type StratumSession = Session RequestStratum StratumResponse Value String StratumNotif
- toRequest :: StratumQuery -> Int -> RequestStratum
- parseResult :: StratumQuery -> ResultValue -> Parser ResultStratum
- parseNotif :: RequestValue -> Parser NotifStratum
- newStratumReq :: MonadIO m => StratumSession -> StratumQuery -> m Int
- data Session q r e v j
- initSession :: MonadIO m => Maybe (RequestParser j) -> m (Session q r e v j)
- newReq :: MonadIO m => Session q r e v j -> (Int -> q) -> ResponseParser r e v -> m Int
- newNotif :: MonadIO m => Session q r e v j -> q -> m ()
- reqSource :: (MonadIO m, ToJSON q) => Session q r e v j -> Source m ByteString
- resConduit :: MonadIO m => Session q r e v j -> Conduit ByteString m (Either String (Message j r e v))
- type Method = Text
- type ErrorValue = Error Value String
- type RequestValue = Request Value
- type ResponseValue = Response Value Value String
- type MessageValue = Message Value Value Value String
- type ResultValue = Result Value Value String
- data Id
- type Result r e v = Either (Error e v) r
- data Error e v
- data Request j = Request {}
- data Response r e v = Response {}
- data Message j r e v
- = MsgRequest (Request j)
- | MsgResponse (Response r e v)
- errParse :: ToJSON e => Maybe e -> Error e v
- errReq :: ToJSON e => Maybe e -> Error e v
- errMeth :: ToJSON e => Maybe e -> Error e v
- errParams :: ToJSON e => Maybe e -> Error e v
- errInternal :: ToJSON e => Maybe e -> Error e v
- errStr :: Error e Value -> String
- leftStr :: Either (Error e Value) r -> Either String r
- numericId :: Id -> Either String Int
Types
Bitcoin
Balance information.
Balance | |
|
Bitcoin outpoint information.
Coin | |
|
Transaction height and ID pair. Used in history responses.
TxHeight | |
|
Stratum data
data StratumNotif Source
Eq StratumNotif | |
Show StratumNotif | |
ToJSON StratumNotif |
data StratumQuery Source
Stratum Request data. To be placed inside JSON request.
QueryVersion | |
| |
QueryHistory | |
QueryBalance | |
QueryUnspent | |
QueryTx | |
QueryBroadcast | |
SubAddress | |
Eq StratumQuery | |
Show StratumQuery | |
ToJSON StratumQuery |
data StratumResponse Source
Stratum Response Result data.
ServerVersion | |
| |
AddressHistory | |
| |
AddressBalance | |
AddressUnspent | |
| |
Transaction | |
BroadcastId | |
AddrStatus | |
Eq StratumResponse | |
Show StratumResponse |
JSON-RPC data for Stratum
type MessageStratum = Message StratumNotif StratumResponse Value StringSource
Message from Stratum JSON-RPC server.
type NotifStratum = Request StratumNotifSource
JSON-RPC notification with Stratum payload.
type RequestStratum = Request StratumQuerySource
JSON-RPC request with Stratum payload.
type ResponseStratum = Response StratumResponse Value StringSource
JSON-RPC response with Stratum payload.
type ResultStratum = Result StratumResponse Value StringSource
Stratum result in JSON-RPC response.
Stratum Session for JSON-RPC Conduit
type StratumSession = Session RequestStratum StratumResponse Value String StratumNotifSource
Session type for JSON-RPC conduit.
Functions
:: StratumQuery | Stratum request data. |
-> Int | JSON-RPC request id. |
-> RequestStratum | Returns JSON-RPC request object. |
Create a JSON-RPC request from a Stratum request.
:: StratumQuery | StratumQuery used in corresponding request. |
-> ResultValue | Result from JSON-RPC response |
-> Parser ResultStratum | Returns Aeson parser. |
Parse result from JSON-RPC response into a Stratum response.
:: RequestValue | Request to parse. |
-> Parser NotifStratum | Parser to Stratum request format |
Parse notification from JSON-RPC request into Stratum format.
newStratumReq :: MonadIO m => StratumSession -> StratumQuery -> m IntSource
Helper function for Network.Haskoin.JSONRPC.Conduit
Generic JSON-RPC Conduit
Types
Functions
:: MonadIO m | |
=> Maybe (RequestParser j) | Parse incoming requests and notifications. Keep connection open. |
-> m (Session q r e v j) |
Create initial session.
:: MonadIO m | |
=> Session q r e v j | Session state. |
-> (Int -> q) | Request builder. |
-> ResponseParser r e v | Parser for response. |
-> m Int | Output ID of sent request. |
Send a new request. Goes to a channel that is read from reqSource.
:: MonadIO m | |
=> Session q r e v j | Session state. |
-> q | Request to send to the network. |
-> m () | No meaningful output. |
New notification, or request with no id tracking.
:: (MonadIO m, ToJSON q) | |
=> Session q r e v j | Session state. |
-> Source m ByteString | Source with serialized requests. |
Source of requests to send to the network.
:: MonadIO m | |
=> Session q r e v j | Session state. |
-> Conduit ByteString m (Either String (Message j r e v)) | Returns Conduit with parsed data or parsing errors. |
Conduit that parses messages from network.
Generic JSON-RPC Messages
Types
type ErrorValue = Error Value StringSource
JSON-RPC error object with default JSON values.
type RequestValue = Request ValueSource
JSON-RPC request with default JSON values.
type ResponseValue = Response Value Value StringSource
JSON-RPC response with default JSON values.
type MessageValue = Message Value Value Value StringSource
JSON-RPC request or response with default JSON values.
type ResultValue = Result Value Value StringSource
JSON-RPC result with default JSON values.
JSON-RPC id in text or integer form.
JSON-RPC error object in v1 or v2 format. Sent inside a JSONRes in case of error.
Messages
JSON-RPC request on notification.
JSON-RPC response or error.
JSON-RPC message, can contain request or response.
MsgRequest (Request j) | Request message container. |
MsgResponse (Response r e v) | response message container. |
Errors
errParse :: ToJSON e => Maybe e -> Error e vSource
Parse error in JSON-RPC v2 format. Provide optional error object.
errReq :: ToJSON e => Maybe e -> Error e vSource
Request error in JSON-RPC v2 format. Provide optional error object.
errMeth :: ToJSON e => Maybe e -> Error e vSource
Unknown method error in JSON-RPC v2 format. Provide optional error object.
errParams :: ToJSON e => Maybe e -> Error e vSource
Invalid parameters error in JSON-RPC v2 format. Provide optional error object.
errInternal :: ToJSON e => Maybe e -> Error e vSource
Internal error in JSON-RPC v2 format. Provide optional error object.