Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Store = Store {
- storeManager :: !Manager
- storeChain :: !Chain
- storeBlock :: !BlockStore
- type BlockStore = Mailbox BlockMessage
- data StoreConfig = StoreConfig {
- storeConfMaxPeers :: !Int
- storeConfInitPeers :: ![HostPort]
- storeConfDiscover :: !Bool
- storeConfDB :: !DB
- storeConfNetwork :: !Network
- storeConfListen :: !(Listen StoreEvent)
- data StoreEvent
- data BlockData = BlockData {}
- data Transaction = Transaction {}
- data Input
- = Coinbase {
- inputPoint :: !OutPoint
- inputSequence :: !Word32
- inputSigScript :: !ByteString
- inputWitness :: !(Maybe WitnessStack)
- | Input {
- inputPoint :: !OutPoint
- inputSequence :: !Word32
- inputSigScript :: !ByteString
- inputPkScript :: !ByteString
- inputAmount :: !Word64
- inputWitness :: !(Maybe WitnessStack)
- = Coinbase {
- data Output = Output {
- outputAmount :: !Word64
- outputScript :: !ByteString
- outputSpender :: !(Maybe Spender)
- data Spender = Spender {
- spenderHash :: !TxHash
- spenderIndex :: !Word32
- data BlockRef
- data Unspent = Unspent {}
- data BlockTx = BlockTx {
- blockTxBlock :: !BlockRef
- blockTxHash :: !TxHash
- data XPubBal = XPubBal {
- xPubBalPath :: ![KeyIndex]
- xPubBal :: !Balance
- data XPubUnspent = XPubUnspent {
- xPubUnspentPath :: ![KeyIndex]
- xPubUnspent :: !Unspent
- data Balance = Balance {}
- data PeerInformation = PeerInformation {
- peerUserAgent :: !ByteString
- peerAddress :: !SockAddr
- peerVersion :: !Word32
- peerServices :: !Word64
- peerRelay :: !Bool
- newtype PreciseUnixTime = PreciseUnixTime Word64
- data HealthCheck = HealthCheck {
- healthHeaderBest :: !(Maybe BlockHash)
- healthHeaderHeight :: !(Maybe BlockHeight)
- healthBlockBest :: !(Maybe BlockHash)
- healthBlockHeight :: !(Maybe BlockHeight)
- healthPeers :: !(Maybe Int)
- healthNetwork :: !String
- healthOK :: !Bool
- healthSynced :: !Bool
- data PubExcept
- withStore :: (MonadLoggerIO m, MonadUnliftIO m) => StoreConfig -> (Store -> m a) -> m a
- store :: (MonadLoggerIO m, MonadUnliftIO m) => StoreConfig -> Inbox ManagerMessage -> Inbox ChainMessage -> Inbox BlockMessage -> m ()
- getBestBlock :: StoreRead r m => r -> m (Maybe BlockHash)
- getBlocksAtHeight :: StoreRead r m => r -> BlockHeight -> m [BlockHash]
- getBlock :: StoreRead r m => r -> BlockHash -> m (Maybe BlockData)
- getTransaction :: (Monad m, StoreRead r m) => r -> TxHash -> m (Maybe Transaction)
- getTxData :: StoreRead r m => r -> TxHash -> m (Maybe TxData)
- getSpenders :: StoreRead r m => r -> TxHash -> m (IntMap Spender)
- getSpender :: StoreRead r m => r -> OutPoint -> m (Maybe Spender)
- fromTransaction :: Transaction -> (TxData, IntMap Spender)
- toTransaction :: TxData -> IntMap Spender -> Transaction
- getBalance :: BalanceRead b m => b -> Address -> m (Maybe Balance)
- getMempool :: StoreStream r m => r -> Maybe PreciseUnixTime -> ConduitT () (PreciseUnixTime, TxHash) m ()
- getAddressUnspents :: StoreStream r m => r -> Address -> Maybe BlockRef -> ConduitT () Unspent m ()
- getAddressTxs :: StoreStream r m => r -> Address -> Maybe BlockRef -> ConduitT () BlockTx m ()
- getPeersInformation :: MonadIO m => Manager -> m [PeerInformation]
- xpubTxs :: (Monad m, BalanceRead i m, StoreStream i m) => i -> Maybe BlockRef -> XPubKey -> ConduitT () BlockTx m ()
- xpubBals :: (Monad m, BalanceRead i m) => i -> XPubKey -> m [XPubBal]
- xpubUnspent :: (Monad m, StoreStream i m, BalanceRead i m, StoreRead i m) => i -> Maybe BlockRef -> XPubKey -> ConduitT () XPubUnspent m ()
- publishTx :: (MonadUnliftIO m, MonadLoggerIO m) => Publisher StoreEvent -> Store -> DB -> Tx -> m (Either PubExcept ())
- transactionData :: Transaction -> Tx
- isCoinbase :: Input -> Bool
- confirmed :: BlockRef -> Bool
- blockDataToJSON :: Network -> BlockData -> Value
- blockDataToEncoding :: Network -> BlockData -> Encoding
- transactionToJSON :: Network -> Transaction -> Value
- transactionToEncoding :: Network -> Transaction -> Encoding
- outputToJSON :: Network -> Output -> Value
- outputToEncoding :: Network -> Output -> Encoding
- inputToJSON :: Network -> Input -> Value
- inputToEncoding :: Network -> Input -> Encoding
- unspentToJSON :: Network -> Unspent -> Value
- unspentToEncoding :: Network -> Unspent -> Encoding
- balanceToJSON :: Network -> Balance -> Value
- balanceToEncoding :: Network -> Balance -> Encoding
- xPubBalToJSON :: Network -> XPubBal -> Value
- xPubBalToEncoding :: Network -> XPubBal -> Encoding
- xPubUnspentToJSON :: Network -> XPubUnspent -> Value
- xPubUnspentToEncoding :: Network -> XPubUnspent -> Encoding
- cbAfterHeight :: (Monad m, StoreRead i m) => i -> Int -> BlockHeight -> TxHash -> m (Maybe Bool)
- healthCheck :: (MonadUnliftIO m, StoreRead r m) => Network -> r -> Manager -> Chain -> m HealthCheck
- mergeSourcesBy :: (Foldable f, Monad m) => (a -> a -> Ordering) -> f (ConduitT () a m ()) -> ConduitT i a m ()
Documentation
Store mailboxes.
Store | |
|
type BlockStore = Mailbox BlockMessage Source #
Mailbox for block store.
data StoreConfig Source #
Configuration for a Store
.
StoreConfig | |
|
data StoreEvent Source #
Events that the store can generate.
StoreBestBlock !BlockHash | new best block |
StoreMempoolNew !TxHash | new mempool transaction |
StorePeerConnected !Peer !SockAddr | new peer connected |
StorePeerDisconnected !Peer !SockAddr | peer has disconnected |
StorePeerPong !Peer !Word64 | peer responded |
StoreTxAvailable !Peer ![TxHash] | peer inv transactions |
StoreTxReject !Peer !TxHash !RejectCode !ByteString | peer rejected transaction |
Database value for a block entry.
BlockData | |
|
Instances
data Transaction Source #
Detailed transaction information.
Transaction | |
|
Instances
Input information.
Coinbase | coinbase details |
| |
Input | input details |
|
Instances
Output information.
Output | |
|
Instances
Eq Output Source # | |
Ord Output Source # | |
Read Output Source # | |
Show Output Source # | |
Generic Output Source # | |
Hashable Output Source # | |
Defined in Network.Haskoin.Store.Data | |
Serialize Output Source # | |
type Rep Output Source # | |
Defined in Network.Haskoin.Store.Data type Rep Output = D1 (MetaData "Output" "Network.Haskoin.Store.Data" "haskoin-store-0.11.0-D3Sd4YvENGlJLikz9mWamP" False) (C1 (MetaCons "Output" PrefixI True) (S1 (MetaSel (Just "outputAmount") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Word64) :*: (S1 (MetaSel (Just "outputScript") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 ByteString) :*: S1 (MetaSel (Just "outputSpender") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Spender))))) |
Information about input spending output.
Spender | |
|
Instances
Eq Spender Source # | |
Ord Spender Source # | |
Read Spender Source # | |
Show Spender Source # | |
Generic Spender Source # | |
Hashable Spender Source # | |
Defined in Network.Haskoin.Store.Data | |
ToJSON Spender Source # | |
Defined in Network.Haskoin.Store.Data | |
Serialize Spender Source # | |
type Rep Spender Source # | |
Defined in Network.Haskoin.Store.Data type Rep Spender = D1 (MetaData "Spender" "Network.Haskoin.Store.Data" "haskoin-store-0.11.0-D3Sd4YvENGlJLikz9mWamP" False) (C1 (MetaCons "Spender" PrefixI True) (S1 (MetaSel (Just "spenderHash") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 TxHash) :*: S1 (MetaSel (Just "spenderIndex") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Word32))) |
Reference to a block where a transaction is stored.
BlockRef | |
| |
MemRef | |
Instances
Eq BlockRef Source # | |
Ord BlockRef Source # | |
Defined in Network.Haskoin.Store.Data | |
Read BlockRef Source # | |
Show BlockRef Source # | |
Generic BlockRef Source # | |
Hashable BlockRef Source # | |
Defined in Network.Haskoin.Store.Data | |
ToJSON BlockRef Source # | |
Defined in Network.Haskoin.Store.Data | |
Serialize BlockRef Source # | Serialized entities will sort in reverse order. |
type Rep BlockRef Source # | |
Defined in Network.Haskoin.Store.Data type Rep BlockRef = D1 (MetaData "BlockRef" "Network.Haskoin.Store.Data" "haskoin-store-0.11.0-D3Sd4YvENGlJLikz9mWamP" False) (C1 (MetaCons "BlockRef" PrefixI True) (S1 (MetaSel (Just "blockRefHeight") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 BlockHeight) :*: S1 (MetaSel (Just "blockRefPos") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Word32)) :+: C1 (MetaCons "MemRef" PrefixI True) (S1 (MetaSel (Just "memRefTime") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 PreciseUnixTime))) |
Unspent output.
Unspent | |
|
Instances
Eq Unspent Source # | |
Ord Unspent Source # | |
Show Unspent Source # | |
Generic Unspent Source # | |
Hashable Unspent Source # | |
Defined in Network.Haskoin.Store.Data | |
Serialize Unspent Source # | |
type Rep Unspent Source # | |
Defined in Network.Haskoin.Store.Data type Rep Unspent = D1 (MetaData "Unspent" "Network.Haskoin.Store.Data" "haskoin-store-0.11.0-D3Sd4YvENGlJLikz9mWamP" False) (C1 (MetaCons "Unspent" PrefixI True) ((S1 (MetaSel (Just "unspentBlock") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 BlockRef) :*: S1 (MetaSel (Just "unspentPoint") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 OutPoint)) :*: (S1 (MetaSel (Just "unspentAmount") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Word64) :*: S1 (MetaSel (Just "unspentScript") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 ShortByteString)))) |
Transaction in relation to an address.
BlockTx | |
|
Instances
Eq BlockTx Source # | |
Ord BlockTx Source # | |
Show BlockTx Source # | |
Generic BlockTx Source # | |
Hashable BlockTx Source # | |
Defined in Network.Haskoin.Store.Data | |
ToJSON BlockTx Source # | |
Defined in Network.Haskoin.Store.Data | |
Serialize BlockTx Source # | |
type Rep BlockTx Source # | |
Defined in Network.Haskoin.Store.Data type Rep BlockTx = D1 (MetaData "BlockTx" "Network.Haskoin.Store.Data" "haskoin-store-0.11.0-D3Sd4YvENGlJLikz9mWamP" False) (C1 (MetaCons "BlockTx" PrefixI True) (S1 (MetaSel (Just "blockTxBlock") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 BlockRef) :*: S1 (MetaSel (Just "blockTxHash") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 TxHash))) |
Address balances for an extended public key.
XPubBal | |
|
Instances
Eq XPubBal Source # | |
Show XPubBal Source # | |
Generic XPubBal Source # | |
type Rep XPubBal Source # | |
Defined in Network.Haskoin.Store.Data type Rep XPubBal = D1 (MetaData "XPubBal" "Network.Haskoin.Store.Data" "haskoin-store-0.11.0-D3Sd4YvENGlJLikz9mWamP" False) (C1 (MetaCons "XPubBal" PrefixI True) (S1 (MetaSel (Just "xPubBalPath") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 [KeyIndex]) :*: S1 (MetaSel (Just "xPubBal") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Balance))) |
data XPubUnspent Source #
Unspent transaction for extended public key.
XPubUnspent | |
|
Instances
Eq XPubUnspent Source # | |
Defined in Network.Haskoin.Store.Data (==) :: XPubUnspent -> XPubUnspent -> Bool # (/=) :: XPubUnspent -> XPubUnspent -> Bool # | |
Show XPubUnspent Source # | |
Defined in Network.Haskoin.Store.Data showsPrec :: Int -> XPubUnspent -> ShowS # show :: XPubUnspent -> String # showList :: [XPubUnspent] -> ShowS # | |
Generic XPubUnspent Source # | |
Defined in Network.Haskoin.Store.Data type Rep XPubUnspent :: * -> * # from :: XPubUnspent -> Rep XPubUnspent x # to :: Rep XPubUnspent x -> XPubUnspent # | |
type Rep XPubUnspent Source # | |
Defined in Network.Haskoin.Store.Data type Rep XPubUnspent = D1 (MetaData "XPubUnspent" "Network.Haskoin.Store.Data" "haskoin-store-0.11.0-D3Sd4YvENGlJLikz9mWamP" False) (C1 (MetaCons "XPubUnspent" PrefixI True) (S1 (MetaSel (Just "xPubUnspentPath") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 [KeyIndex]) :*: S1 (MetaSel (Just "xPubUnspent") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Unspent))) |
Address balance information.
Balance | |
|
Instances
data PeerInformation Source #
Information about a connected peer.
PeerInformation | |
|
Instances
newtype PreciseUnixTime Source #
Unix time with nanosecond precision for mempool transactions.
Instances
data HealthCheck Source #
HealthCheck | |
|
Instances
Instances
Eq PubExcept Source # | |
Show PubExcept Source # | |
Exception PubExcept Source # | |
Defined in Haskoin.Store toException :: PubExcept -> SomeException # fromException :: SomeException -> Maybe PubExcept # displayException :: PubExcept -> String # |
withStore :: (MonadLoggerIO m, MonadUnliftIO m) => StoreConfig -> (Store -> m a) -> m a Source #
store :: (MonadLoggerIO m, MonadUnliftIO m) => StoreConfig -> Inbox ManagerMessage -> Inbox ChainMessage -> Inbox BlockMessage -> m () Source #
Run a Haskoin Store instance. It will launch a network node and a
BlockStore
, connect to the network and start synchronizing blocks and
transactions.
getBestBlock :: StoreRead r m => r -> m (Maybe BlockHash) Source #
getBlocksAtHeight :: StoreRead r m => r -> BlockHeight -> m [BlockHash] Source #
getTransaction :: (Monad m, StoreRead r m) => r -> TxHash -> m (Maybe Transaction) Source #
fromTransaction :: Transaction -> (TxData, IntMap Spender) Source #
toTransaction :: TxData -> IntMap Spender -> Transaction Source #
getMempool :: StoreStream r m => r -> Maybe PreciseUnixTime -> ConduitT () (PreciseUnixTime, TxHash) m () Source #
getAddressUnspents :: StoreStream r m => r -> Address -> Maybe BlockRef -> ConduitT () Unspent m () Source #
getAddressTxs :: StoreStream r m => r -> Address -> Maybe BlockRef -> ConduitT () BlockTx m () Source #
getPeersInformation :: MonadIO m => Manager -> m [PeerInformation] Source #
Obtain information about connected peers from peer manager process.
xpubTxs :: (Monad m, BalanceRead i m, StoreStream i m) => i -> Maybe BlockRef -> XPubKey -> ConduitT () BlockTx m () Source #
xpubUnspent :: (Monad m, StoreStream i m, BalanceRead i m, StoreRead i m) => i -> Maybe BlockRef -> XPubKey -> ConduitT () XPubUnspent m () Source #
publishTx :: (MonadUnliftIO m, MonadLoggerIO m) => Publisher StoreEvent -> Store -> DB -> Tx -> m (Either PubExcept ()) Source #
Publish a new transaction to the network.
transactionData :: Transaction -> Tx Source #
transactionToJSON :: Network -> Transaction -> Value Source #
transactionToEncoding :: Network -> Transaction -> Encoding Source #
xPubUnspentToJSON :: Network -> XPubUnspent -> Value Source #
xPubUnspentToEncoding :: Network -> XPubUnspent -> Encoding Source #
:: (Monad m, StoreRead i m) | |
=> i | |
-> Int | how many ancestors to test before giving up |
-> BlockHeight | |
-> TxHash | |
-> m (Maybe Bool) |
Check if any of the ancestors of this transaction is a coinbase after the
specified height. Returns Nothing
if answer cannot be computed before
hitting limits.
healthCheck :: (MonadUnliftIO m, StoreRead r m) => Network -> r -> Manager -> Chain -> m HealthCheck Source #