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 {
- transactionBlock :: !BlockRef
- transactionVersion :: !Word32
- transactionLockTime :: !Word32
- transactionInputs :: ![StoreInput]
- transactionOutputs :: ![StoreOutput]
- transactionDeleted :: !Bool
- transactionRBF :: !Bool
- transactionTime :: !Word64
- data Input = Input {
- nonWitnessUtxo :: Maybe Tx
- witnessUtxo :: Maybe TxOut
- partialSigs :: HashMap PubKeyI ByteString
- sigHashType :: Maybe SigHash
- inputRedeemScript :: Maybe Script
- inputWitnessScript :: Maybe Script
- inputHDKeypaths :: HashMap PubKeyI (Fingerprint, [KeyIndex])
- finalScriptSig :: Maybe Script
- finalScriptWitness :: Maybe WitnessStack
- inputUnknown :: UnknownMap
- data Output = Output {}
- 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
- data Event
- newtype TxAfterHeight = TxAfterHeight {}
- class JsonSerial a where
- class BinSerial a where
- data Except
- newtype TxId = TxId TxHash
- 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 m => m (Maybe BlockHash)
- getBlocksAtHeight :: StoreRead m => BlockHeight -> m [BlockHash]
- getBlock :: StoreRead m => BlockHash -> m (Maybe BlockData)
- getTransaction :: (Monad m, StoreRead m) => TxHash -> m (Maybe Transaction)
- getTxData :: StoreRead m => TxHash -> m (Maybe TxData)
- getSpenders :: StoreRead m => TxHash -> m (IntMap Spender)
- getSpender :: StoreRead m => OutPoint -> m (Maybe Spender)
- fromTransaction :: Transaction -> (TxData, IntMap Spender)
- toTransaction :: TxData -> IntMap Spender -> Transaction
- getBalance :: BalanceRead m => Address -> m (Maybe Balance)
- getMempool :: StoreStream m => Maybe PreciseUnixTime -> ConduitT () (PreciseUnixTime, TxHash) m ()
- getAddressUnspents :: StoreStream m => Address -> Maybe BlockRef -> ConduitT () Unspent m ()
- getAddressTxs :: StoreStream m => Address -> Maybe BlockRef -> ConduitT () BlockTx m ()
- getPeersInformation :: MonadIO m => Manager -> m [PeerInformation]
- xpubTxs :: (Monad m, BalanceRead m, StoreStream m) => Maybe BlockRef -> XPubKey -> ConduitT () BlockTx m ()
- xpubBals :: (Monad m, BalanceRead m) => XPubKey -> m [XPubBal]
- xpubUnspent :: (Monad m, StoreStream m, BalanceRead m, StoreRead m) => Maybe BlockRef -> XPubKey -> ConduitT () XPubUnspent m ()
- publishTx :: (MonadUnliftIO m, MonadLoggerIO m) => Publisher StoreEvent -> Store -> DB -> Tx -> m (Either PubExcept ())
- transactionData :: Transaction -> Tx
- isCoinbase :: StoreInput -> Bool
- confirmed :: BlockRef -> Bool
- cbAfterHeight :: (Monad m, StoreRead m) => Int -> BlockHeight -> TxHash -> m TxAfterHeight
- healthCheck :: (MonadUnliftIO m, StoreRead m) => Network -> Manager -> Chain -> m HealthCheck
- mergeSourcesBy :: (Foldable f, Monad m) => (a -> a -> Ordering) -> f (ConduitT () a m ()) -> ConduitT i a m ()
- withBlockDB :: ReadOptions -> DB -> ReaderT BlockDB m a -> m a
- withBlockSTM :: TVar HashMapDB -> ReaderT (TVar HashMapDB) STM a -> STM a
- withBalanceSTM :: TVar BalanceMap -> ReaderT (TVar BalanceMap) STM a -> STM a
- withUnspentSTM :: TVar UnspentMap -> ReaderT (TVar UnspentMap) STM a -> STM a
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
Inputs contain all of the data needed to sign a transaction and all of the resulting signature data after signing.
Outputs can contain information needed to spend the output at a later date.
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.14.0-GMHCIO7F5M1LmIz2U0HVB5" 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. |
BinSerial BlockRef Source # | |
type Rep BlockRef Source # | |
Defined in Network.Haskoin.Store.Data type Rep BlockRef = D1 (MetaData "BlockRef" "Network.Haskoin.Store.Data" "haskoin-store-0.14.0-GMHCIO7F5M1LmIz2U0HVB5" 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 # | |
BinSerial Unspent Source # | |
JsonSerial 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.14.0-GMHCIO7F5M1LmIz2U0HVB5" 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 # | |
BinSerial BlockTx Source # | |
JsonSerial 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.14.0-GMHCIO7F5M1LmIz2U0HVB5" 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 # | |
BinSerial XPubBal Source # | |
JsonSerial 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.14.0-GMHCIO7F5M1LmIz2U0HVB5" 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
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 # |
Instances
Eq Event Source # | |
Show Event Source # | |
Generic Event Source # | |
ToJSON Event Source # | |
Defined in Network.Haskoin.Store.Data | |
BinSerial Event Source # | |
JsonSerial Event Source # | |
type Rep Event Source # | |
Defined in Network.Haskoin.Store.Data type Rep Event = D1 (MetaData "Event" "Network.Haskoin.Store.Data" "haskoin-store-0.14.0-GMHCIO7F5M1LmIz2U0HVB5" False) (C1 (MetaCons "EventBlock" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 BlockHash)) :+: C1 (MetaCons "EventTx" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 TxHash))) |
newtype TxAfterHeight Source #
Instances
class JsonSerial a where Source #
Instances
JsonSerial TxHash Source # | |
JsonSerial TxId Source # | |
JsonSerial Except Source # | |
JsonSerial TxAfterHeight Source # | |
Defined in Network.Haskoin.Store.Data jsonSerial :: Network -> TxAfterHeight -> Encoding Source # | |
JsonSerial Event Source # | |
JsonSerial HealthCheck Source # | |
Defined in Network.Haskoin.Store.Data jsonSerial :: Network -> HealthCheck -> Encoding Source # | |
JsonSerial XPubUnspent Source # | |
Defined in Network.Haskoin.Store.Data jsonSerial :: Network -> XPubUnspent -> Encoding Source # | |
JsonSerial XPubBal Source # | |
JsonSerial PeerInformation Source # | |
Defined in Network.Haskoin.Store.Data jsonSerial :: Network -> PeerInformation -> Encoding Source # | |
JsonSerial Transaction Source # | |
Defined in Network.Haskoin.Store.Data jsonSerial :: Network -> Transaction -> Encoding Source # | |
JsonSerial BlockData Source # | |
JsonSerial Unspent Source # | |
JsonSerial Balance Source # | |
JsonSerial BlockTx Source # | |
JsonSerial a => JsonSerial [a] Source # | |
class BinSerial a where Source #
Instances
BinSerial TxHash Source # | |
BinSerial TxId Source # | |
BinSerial Except Source # | |
BinSerial TxAfterHeight Source # | |
Defined in Network.Haskoin.Store.Data | |
BinSerial Event Source # | |
BinSerial HealthCheck Source # | |
Defined in Network.Haskoin.Store.Data | |
BinSerial XPubUnspent Source # | |
Defined in Network.Haskoin.Store.Data | |
BinSerial XPubBal Source # | |
BinSerial PeerInformation Source # | |
Defined in Network.Haskoin.Store.Data | |
BinSerial Transaction Source # | |
Defined in Network.Haskoin.Store.Data | |
BinSerial BlockData Source # | |
BinSerial Unspent Source # | |
BinSerial Balance Source # | |
BinSerial BlockTx Source # | |
BinSerial BlockRef Source # | |
BinSerial a => BinSerial [a] Source # | |
Instances
Eq Except Source # | |
Show Except Source # | |
ToJSON Except Source # | |
Defined in Network.Haskoin.Store.Data | |
Exception Except Source # | |
Defined in Network.Haskoin.Store.Data toException :: Except -> SomeException # fromException :: SomeException -> Maybe Except # displayException :: Except -> String # | |
ScottyError Except Source # | |
Defined in Network.Haskoin.Store.Data | |
BinSerial Except Source # | |
JsonSerial Except Source # | |
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 m => m (Maybe BlockHash) Source #
getBlocksAtHeight :: StoreRead m => BlockHeight -> m [BlockHash] Source #
getTransaction :: (Monad m, StoreRead m) => TxHash -> m (Maybe Transaction) Source #
fromTransaction :: Transaction -> (TxData, IntMap Spender) Source #
toTransaction :: TxData -> IntMap Spender -> Transaction Source #
getMempool :: StoreStream m => Maybe PreciseUnixTime -> ConduitT () (PreciseUnixTime, TxHash) m () Source #
getAddressUnspents :: StoreStream m => Address -> Maybe BlockRef -> ConduitT () Unspent m () Source #
getPeersInformation :: MonadIO m => Manager -> m [PeerInformation] Source #
Obtain information about connected peers from peer manager process.
xpubTxs :: (Monad m, BalanceRead m, StoreStream m) => Maybe BlockRef -> XPubKey -> ConduitT () BlockTx m () Source #
xpubUnspent :: (Monad m, StoreStream m, BalanceRead m, StoreRead m) => 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 #
isCoinbase :: StoreInput -> Bool Source #
:: (Monad m, StoreRead m) | |
=> Int | how many ancestors to test before giving up |
-> BlockHeight | |
-> TxHash | |
-> m TxAfterHeight |
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 m) => Network -> Manager -> Chain -> m HealthCheck Source #
mergeSourcesBy :: (Foldable f, Monad m) => (a -> a -> Ordering) -> f (ConduitT () a m ()) -> ConduitT i a m () Source #
withBlockDB :: ReadOptions -> DB -> ReaderT BlockDB m a -> m a Source #