haskoin-store-0.4.1: Storage and index for Bitcoin and Bitcoin Cash

Safe HaskellNone
LanguageHaskell2010

Haskoin.Store

Synopsis

Documentation

data Store Source #

Store mailboxes.

Constructors

Store 

Fields

type BlockStore = Mailbox BlockMessage Source #

Mailbox for block store.

data StoreConfig Source #

Configuration for a Store.

Constructors

StoreConfig 

Fields

data StoreEvent Source #

Events that the store can generate.

Constructors

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 Ping

data BlockData Source #

Database value for a block entry.

Constructors

BlockData 

Fields

Instances
Eq BlockData Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Ord BlockData Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Read BlockData Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Show BlockData Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Generic BlockData Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Associated Types

type Rep BlockData :: * -> * #

Hashable BlockData Source # 
Instance details

Defined in Network.Haskoin.Store.Data

ToJSON BlockData Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Serialize BlockData Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep BlockData Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep BlockData = D1 (MetaData "BlockData" "Network.Haskoin.Store.Data" "haskoin-store-0.4.1-74fOcYk0tGf4ofccsKcwcn" False) (C1 (MetaCons "BlockData" PrefixI True) ((S1 (MetaSel (Just "blockDataHeight") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 BlockHeight) :*: (S1 (MetaSel (Just "blockDataMainChain") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Bool) :*: S1 (MetaSel (Just "blockDataWork") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 BlockWork))) :*: (S1 (MetaSel (Just "blockDataHeader") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 BlockHeader) :*: (S1 (MetaSel (Just "blockDataSize") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Word32) :*: S1 (MetaSel (Just "blockDataTxs") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 [TxHash])))))

data Transaction Source #

Detailed transaction information.

Constructors

Transaction 

Fields

Instances
Eq Transaction Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Ord Transaction Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Show Transaction Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Generic Transaction Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Associated Types

type Rep Transaction :: * -> * #

Hashable Transaction Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Serialize Transaction Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep Transaction Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep Transaction = D1 (MetaData "Transaction" "Network.Haskoin.Store.Data" "haskoin-store-0.4.1-74fOcYk0tGf4ofccsKcwcn" False) (C1 (MetaCons "Transaction" PrefixI True) (((S1 (MetaSel (Just "transactionBlock") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 BlockRef) :*: S1 (MetaSel (Just "transactionVersion") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Word32)) :*: (S1 (MetaSel (Just "transactionLockTime") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Word32) :*: S1 (MetaSel (Just "transactionFee") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Word64))) :*: ((S1 (MetaSel (Just "transactionInputs") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 [Input]) :*: S1 (MetaSel (Just "transactionOutputs") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 [Output])) :*: (S1 (MetaSel (Just "transactionDeleted") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Bool) :*: S1 (MetaSel (Just "transactionRBF") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Bool)))))

data Input Source #

Input information.

Constructors

Coinbase

coinbase details

Fields

Input

input details

Fields

Instances
Eq Input Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Methods

(==) :: Input -> Input -> Bool #

(/=) :: Input -> Input -> Bool #

Ord Input Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Methods

compare :: Input -> Input -> Ordering #

(<) :: Input -> Input -> Bool #

(<=) :: Input -> Input -> Bool #

(>) :: Input -> Input -> Bool #

(>=) :: Input -> Input -> Bool #

max :: Input -> Input -> Input #

min :: Input -> Input -> Input #

Read Input Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Show Input Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Methods

showsPrec :: Int -> Input -> ShowS #

show :: Input -> String #

showList :: [Input] -> ShowS #

Generic Input Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Associated Types

type Rep Input :: * -> * #

Methods

from :: Input -> Rep Input x #

to :: Rep Input x -> Input #

Hashable Input Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Methods

hashWithSalt :: Int -> Input -> Int #

hash :: Input -> Int #

Serialize Input Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Methods

put :: Putter Input #

get :: Get Input #

type Rep Input Source # 
Instance details

Defined in Network.Haskoin.Store.Data

data Output Source #

Output information.

Constructors

Output 

Fields

Instances
Eq Output Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Methods

(==) :: Output -> Output -> Bool #

(/=) :: Output -> Output -> Bool #

Ord Output Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Read Output Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Show Output Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Generic Output Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Associated Types

type Rep Output :: * -> * #

Methods

from :: Output -> Rep Output x #

to :: Rep Output x -> Output #

Hashable Output Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Methods

hashWithSalt :: Int -> Output -> Int #

hash :: Output -> Int #

Serialize Output Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep Output Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep Output = D1 (MetaData "Output" "Network.Haskoin.Store.Data" "haskoin-store-0.4.1-74fOcYk0tGf4ofccsKcwcn" 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)))))

data Spender Source #

Information about input spending output.

Constructors

Spender 

Fields

Instances
Eq Spender Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Methods

(==) :: Spender -> Spender -> Bool #

(/=) :: Spender -> Spender -> Bool #

Ord Spender Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Read Spender Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Show Spender Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Generic Spender Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Associated Types

type Rep Spender :: * -> * #

Methods

from :: Spender -> Rep Spender x #

to :: Rep Spender x -> Spender #

Hashable Spender Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Methods

hashWithSalt :: Int -> Spender -> Int #

hash :: Spender -> Int #

ToJSON Spender Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Serialize Spender Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep Spender Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep Spender = D1 (MetaData "Spender" "Network.Haskoin.Store.Data" "haskoin-store-0.4.1-74fOcYk0tGf4ofccsKcwcn" False) (C1 (MetaCons "Spender" PrefixI True) (S1 (MetaSel (Just "spenderHash") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 TxHash) :*: S1 (MetaSel (Just "spenderIndex") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Word32)))

data BlockRef Source #

Reference to a block where a transaction is stored.

Constructors

BlockRef 

Fields

MemRef 

Fields

Instances
Eq BlockRef Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Ord BlockRef Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Read BlockRef Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Show BlockRef Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Generic BlockRef Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Associated Types

type Rep BlockRef :: * -> * #

Methods

from :: BlockRef -> Rep BlockRef x #

to :: Rep BlockRef x -> BlockRef #

Hashable BlockRef Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Methods

hashWithSalt :: Int -> BlockRef -> Int #

hash :: BlockRef -> Int #

ToJSON BlockRef Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Serialize BlockRef Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep BlockRef Source # 
Instance details

Defined in Network.Haskoin.Store.Data

data Unspent Source #

Unspent output.

Constructors

Unspent 

Fields

Instances
Eq Unspent Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Methods

(==) :: Unspent -> Unspent -> Bool #

(/=) :: Unspent -> Unspent -> Bool #

Ord Unspent Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Show Unspent Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Generic Unspent Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Associated Types

type Rep Unspent :: * -> * #

Methods

from :: Unspent -> Rep Unspent x #

to :: Rep Unspent x -> Unspent #

Hashable Unspent Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Methods

hashWithSalt :: Int -> Unspent -> Int #

hash :: Unspent -> Int #

Serialize Unspent Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep Unspent Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep Unspent = D1 (MetaData "Unspent" "Network.Haskoin.Store.Data" "haskoin-store-0.4.1-74fOcYk0tGf4ofccsKcwcn" False) (C1 (MetaCons "Unspent" PrefixI True) ((S1 (MetaSel (Just "unspentBlock") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 BlockRef) :*: S1 (MetaSel (Just "unspentAmount") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Word64)) :*: (S1 (MetaSel (Just "unspentScript") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 ByteString) :*: S1 (MetaSel (Just "unspentPoint") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 OutPoint))))

data AddressTx Source #

Transaction in relation to an address.

Constructors

AddressTx 

Fields

Instances
Eq AddressTx Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Ord AddressTx Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Show AddressTx Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Generic AddressTx Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Associated Types

type Rep AddressTx :: * -> * #

Hashable AddressTx Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Serialize AddressTx Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep AddressTx Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep AddressTx = D1 (MetaData "AddressTx" "Network.Haskoin.Store.Data" "haskoin-store-0.4.1-74fOcYk0tGf4ofccsKcwcn" False) (C1 (MetaCons "AddressTx" PrefixI True) (S1 (MetaSel (Just "addressTxAddress") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Address) :*: (S1 (MetaSel (Just "addressTxBlock") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 BlockRef) :*: S1 (MetaSel (Just "addressTxHash") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 TxHash))))

data XPubTx Source #

Address transaction from an extended public key.

Constructors

XPubTx 
Instances
Eq XPubTx Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Methods

(==) :: XPubTx -> XPubTx -> Bool #

(/=) :: XPubTx -> XPubTx -> Bool #

Show XPubTx Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Generic XPubTx Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Associated Types

type Rep XPubTx :: * -> * #

Methods

from :: XPubTx -> Rep XPubTx x #

to :: Rep XPubTx x -> XPubTx #

type Rep XPubTx Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep XPubTx = D1 (MetaData "XPubTx" "Network.Haskoin.Store.Data" "haskoin-store-0.4.1-74fOcYk0tGf4ofccsKcwcn" False) (C1 (MetaCons "XPubTx" PrefixI True) (S1 (MetaSel (Just "xPubTxKey") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 XPubKey) :*: (S1 (MetaSel (Just "xPubTxPath") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 SoftPath) :*: S1 (MetaSel (Just "xPubTx") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 AddressTx))))

data XPubBal Source #

Address balances for an extended public key.

Constructors

XPubBal 
Instances
Eq XPubBal Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Methods

(==) :: XPubBal -> XPubBal -> Bool #

(/=) :: XPubBal -> XPubBal -> Bool #

Show XPubBal Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Generic XPubBal Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Associated Types

type Rep XPubBal :: * -> * #

Methods

from :: XPubBal -> Rep XPubBal x #

to :: Rep XPubBal x -> XPubBal #

type Rep XPubBal Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep XPubBal = D1 (MetaData "XPubBal" "Network.Haskoin.Store.Data" "haskoin-store-0.4.1-74fOcYk0tGf4ofccsKcwcn" False) (C1 (MetaCons "XPubBal" PrefixI True) (S1 (MetaSel (Just "xPubBalKey") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 XPubKey) :*: (S1 (MetaSel (Just "xPubBalPath") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 SoftPath) :*: S1 (MetaSel (Just "xPubBal") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Balance))))

data XPubUnspent Source #

Unspent transaction for extended public key.

Instances
Eq XPubUnspent Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Show XPubUnspent Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Generic XPubUnspent Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Associated Types

type Rep XPubUnspent :: * -> * #

type Rep XPubUnspent Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep XPubUnspent = D1 (MetaData "XPubUnspent" "Network.Haskoin.Store.Data" "haskoin-store-0.4.1-74fOcYk0tGf4ofccsKcwcn" False) (C1 (MetaCons "XPubUnspent" PrefixI True) (S1 (MetaSel (Just "xPubUnspentKey") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 XPubKey) :*: (S1 (MetaSel (Just "xPubUnspentPath") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 SoftPath) :*: S1 (MetaSel (Just "xPubUnspent") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Unspent))))

data Balance Source #

Address balance information.

Constructors

Balance 

Fields

Instances
Eq Balance Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Methods

(==) :: Balance -> Balance -> Bool #

(/=) :: Balance -> Balance -> Bool #

Ord Balance Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Read Balance Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Show Balance Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Generic Balance Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Associated Types

type Rep Balance :: * -> * #

Methods

from :: Balance -> Rep Balance x #

to :: Rep Balance x -> Balance #

Hashable Balance Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Methods

hashWithSalt :: Int -> Balance -> Int #

hash :: Balance -> Int #

Serialize Balance Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep Balance Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep Balance = D1 (MetaData "Balance" "Network.Haskoin.Store.Data" "haskoin-store-0.4.1-74fOcYk0tGf4ofccsKcwcn" False) (C1 (MetaCons "Balance" PrefixI True) ((S1 (MetaSel (Just "balanceAddress") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Address) :*: S1 (MetaSel (Just "balanceAmount") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Word64)) :*: (S1 (MetaSel (Just "balanceZero") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int64) :*: S1 (MetaSel (Just "balanceCount") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Word64))))

data PeerInformation Source #

Information about a connected peer.

Constructors

PeerInformation 

Fields

Instances
Eq PeerInformation Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Ord PeerInformation Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Show PeerInformation Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Generic PeerInformation Source # 
Instance details

Defined in Network.Haskoin.Store.Data

Associated Types

type Rep PeerInformation :: * -> * #

ToJSON PeerInformation Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep PeerInformation Source # 
Instance details

Defined in Network.Haskoin.Store.Data

type Rep PeerInformation = D1 (MetaData "PeerInformation" "Network.Haskoin.Store.Data" "haskoin-store-0.4.1-74fOcYk0tGf4ofccsKcwcn" False) (C1 (MetaCons "PeerInformation" PrefixI True) ((S1 (MetaSel (Just "peerUserAgent") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 ByteString) :*: S1 (MetaSel (Just "peerAddress") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 SockAddr)) :*: (S1 (MetaSel (Just "peerVersion") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Word32) :*: (S1 (MetaSel (Just "peerServices") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Word64) :*: S1 (MetaSel (Just "peerRelay") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Bool)))))

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 #

getBlock :: StoreRead r m => r -> BlockHash -> m (Maybe BlockData) Source #

getTransaction :: StoreRead r m => r -> TxHash -> m (Maybe Transaction) Source #

getBalance :: StoreRead r m => r -> Address -> m Balance Source #

getMempool :: StoreStream r m => r -> ConduitT () (PreciseUnixTime, TxHash) m () Source #

getAddressUnspents :: StoreStream r m => r -> Address -> ConduitT () Unspent m () Source #

getAddressTxs :: StoreStream r m => r -> Address -> ConduitT () AddressTx m () Source #

getPeersInformation :: MonadIO m => Manager -> m [PeerInformation] Source #

Obtain information about connected peers from peer manager process.

xpubTxs :: (Monad m, StoreStream i m) => i -> XPubKey -> ConduitT () XPubTx m () Source #

xpubBals :: (Monad m, StoreStream i m, StoreRead i m) => i -> XPubKey -> m [XPubBal] Source #

xpubUnspent :: (Monad m, StoreStream i m, StoreRead i m) => i -> XPubKey -> ConduitT () XPubUnspent m () Source #

publishTx :: (MonadUnliftIO m, MonadLoggerIO m) => Manager -> Tx -> m Bool Source #

Publish a new transaction to the network.

isCoinbase :: Input -> Bool Source #

Is Input a Coinbase?

mergeSourcesBy :: (Foldable f, Monad m) => (a -> a -> Ordering) -> f (ConduitT () a m ()) -> ConduitT i a m () Source #