haskoin-store-0.2.2: 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 = Inbox BlockMessage Source #

Mailbox for block store.

data Output Source #

Output data.

Constructors

Output 

Fields

Instances
Eq Output Source # 
Instance details

Defined in Network.Haskoin.Store.Types

Methods

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

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

Ord Output Source # 
Instance details

Defined in Network.Haskoin.Store.Types

Show Output Source # 
Instance details

Defined in Network.Haskoin.Store.Types

Serialize Output Source # 
Instance details

Defined in Network.Haskoin.Store.Types

data Spender Source #

Information about input spending output.

Constructors

Spender 

Fields

data BlockRef Source #

Reference to a block where a transaction is stored.

Constructors

BlockRef 

Fields

data StoreConfig Source #

Configuration for a Store.

Constructors

StoreConfig 

Fields

data StoreEvent Source #

Event that the store can generate.

Constructors

BestBlock !BlockHash

new best block

MempoolNew !TxHash

new mempool transaction

TxException !TxHash !TxException

published tx could not be imported

PeerConnected !Peer

new peer connected

PeerDisconnected !Peer

peer has disconnected

PeerPong !Peer !Word64

peer responded Ping

data BlockValue Source #

Database value for a block entry.

Constructors

BlockValue 

Fields

data DetailedTx Source #

Detailed transaction information.

Constructors

DetailedTx 

Fields

data DetailedInput Source #

Input information.

Constructors

DetailedCoinbase

coinbase input details

Fields

DetailedInput

regular input details

Fields

data DetailedOutput Source #

Output information.

Constructors

DetailedOutput 

Fields

newtype NewTx Source #

Wrapper for an transaction that can be deserialized from a JSON object.

Constructors

NewTx 

Fields

Instances
Eq NewTx Source # 
Instance details

Defined in Network.Haskoin.Store.Types

Methods

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

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

Ord NewTx Source # 
Instance details

Defined in Network.Haskoin.Store.Types

Methods

compare :: NewTx -> NewTx -> Ordering #

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

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

(>) :: NewTx -> NewTx -> Bool #

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

max :: NewTx -> NewTx -> NewTx #

min :: NewTx -> NewTx -> NewTx #

Show NewTx Source # 
Instance details

Defined in Network.Haskoin.Store.Types

Methods

showsPrec :: Int -> NewTx -> ShowS #

show :: NewTx -> String #

showList :: [NewTx] -> ShowS #

FromJSON NewTx Source # 
Instance details

Defined in Network.Haskoin.Store.Types

data AddressBalance Source #

Address balance information.

Constructors

AddressBalance 

Fields

data TxException Source #

Reasons why a transaction may not get imported.

Constructors

DoubleSpend

outputs already spent by another transaction

OverSpend

outputs larger than inputs

OrphanTx

inputs unknown

NonStandard

non-standard transaction rejected by peer

LowFee

pony up

Dust

an output is too small

NoPeers

no peers to send the transaction to

InvalidTx

transaction is invalid in some other way

CouldNotImport

could not import for an unknown reason

PeerIsGone

the peer that got the transaction disconnected

AlreadyImported

the transaction is already in the database

PublishTimeout

some timeout was reached while publishing

PeerRejectOther

peer rejected transaction for unknown reason

NotAtHeight

this node is not yet synchronized

withStore :: (MonadLoggerIO m, MonadUnliftIO m) => StoreConfig -> (Store -> m a) -> m a Source #

Run a Haskoin Store instance. It will launch a network node, a BlockStore, connect to the network and start synchronizing blocks and transactions.

getBestBlock :: MonadIO m => DB -> Snapshot -> m BlockValue Source #

Get best block.

getBlockAtHeight :: MonadIO m => BlockHeight -> DB -> Snapshot -> m (Maybe BlockValue) Source #

Get one block at specified height.

getBlock :: MonadIO m => BlockHash -> DB -> Snapshot -> m (Maybe BlockValue) Source #

Get a block.

getBlocks :: MonadIO m => [BlockHash] -> DB -> Snapshot -> m [BlockValue] Source #

Get blocks for specific hashes.

getTx :: MonadUnliftIO m => Network -> TxHash -> DB -> Snapshot -> m (Maybe DetailedTx) Source #

Get single transaction.

getUnspent :: (MonadResource m, MonadUnliftIO m) => Address -> Maybe BlockHeight -> DB -> Snapshot -> ConduitT () AddrOutput m () Source #

Get unspent outputs for an address.

getBalance :: MonadIO m => Address -> DB -> Snapshot -> m AddressBalance Source #

Get balance for an address.

getMempool :: MonadUnliftIO m => DB -> Snapshot -> m [TxHash] Source #

Get list of transactions in mempool.

publishTx :: (MonadUnliftIO m, MonadLoggerIO m) => Network -> Store -> DB -> Tx -> m (Either TxException DetailedTx) Source #

Publish a new transaction to the network.