Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockchainScanner ¶
type BlockchainScanner interface {
// Start starts the service.
Start()
// Stop stops the service.
Stop()
// WatchForAccount instructs the scanner to start notifying about txs/utxos
// related to the given list of addresses belonging to the given HD account.
WatchForAccount(
accountName string, startingBlockHeight uint32,
addresses []domain.AddressInfo,
)
// WatchForUtxos instructs the scanner to notify when the given utxos are
// either spent or confirmed.
WatchForUtxos(
accountName string, utxos []domain.UtxoInfo,
)
// RestoreAccount makes the scanner discover and retuen all the used
// addresses for a certain account represented by its account index, xpub
// and master blinding key.
RestoreAccount(
accountIndex uint32, accountName, xpub string, masterBlindingKey []byte,
startingBlockHeight, addressesThreshold uint32,
) ([]domain.AddressInfo, []domain.AddressInfo, error)
// StopWatchForAccount instructs the scanner to stop notifying about
// txs/utxos related to any address belonging to the given HD account.
StopWatchForAccount(accountName string)
// GetUtxoChannel returns the channel where notification about utxos realated
// to the given HD account are sent.
GetUtxoChannel(accountName string) chan []*domain.Utxo
// GetTxChannel returns the channel where notification about txs realated to
// the given HD account are sent.
GetTxChannel(accountName string) chan *domain.Transaction
// GetLatestBlock returns the header of the latest block of the blockchain.
GetLatestBlock() ([]byte, uint32, error)
// GetBlockHash returns the hash of the block identified by its height.
GetBlockHash(height uint32) ([]byte, error)
// GetUtxos is a sync function to get info about the utxos represented by
// given outpoints (UtxoKeys).
GetUtxos(utxos []domain.Utxo) ([]domain.Utxo, error)
// GetUtxos is a sync function to get all utxos for the given list of addresses.
GetUtxosForAddresses(addresses []domain.AddressInfo) ([]*domain.Utxo, error)
// BroadcastTransaction sends the given raw tx (in hex string) over the
// network in order to be included in a later block of the Liquid blockchain.
BroadcastTransaction(txHex string) (string, error)
// GetTransactions returns info about the given txids.
GetTransactions(txids []string) ([]domain.Transaction, error)
}
BlockchainScanner is the abstraction for any kind of service representing an Elements node. It gives info about txs and utxos related to one or more HD accounts in a aync way (via channels), and lets broadcast transactions over the Liquid network.
type CoinSelector ¶
type CoinSelector interface {
// SelectUtxos implements a certain coin selection strategy.
SelectUtxos(
utxos []*domain.Utxo, targetAmount uint64, targetAsset string,
) (selectedUtxos []*domain.Utxo, change uint64, err error)
}
CoinSelector is the abstraction for any kind of service intended to return a subset of the given utxos with target asset hash, covering the target amount based on a specific strategy.
type RepoManager ¶
type RepoManager interface {
// WalletRepository returns the wallet repository.
WalletRepository() domain.WalletRepository
// UtxoRepository returns the utxo repository.
UtxoRepository() domain.UtxoRepository
// TransactionRepository returns the tx repository.
TransactionRepository() domain.TransactionRepository
// ExternalScriptRepository returns the external scripts repository.
ExternalScriptRepository() domain.ExternalScriptRepository
// RegisterHandlerForWalletEvent registers an handler function, executed
// whenever the given event type occurs.
RegisterHandlerForWalletEvent(
eventType domain.WalletEventType, handler WalletEventHandler,
)
// RegisterHandlerForUtxoEvent registers an handler function, executed
// whenever the given event type occurs.
RegisterHandlerForUtxoEvent(
eventType domain.UtxoEventType, handler UtxoEventHandler,
)
// RegisterHandlerForTxEvent registers an handler function, executed
// whenever the given event type occurs.
RegisterHandlerForTxEvent(
eventType domain.TransactionEventType, handler TxEventHandler,
)
// RegisterHandlerForExternalScriptEvent registers an handler function,
// executed whenever the given event type occurs.
RegisterHandlerForExternalScriptEvent(
eventType domain.ExternalScriptEventType, handler ScriptEventHandler,
)
// Reset brings all the repos to their initial state by deleting any persisted data.
Reset()
// Close closes the connection with all concrete repositories
// implementations.
Close()
}
RepoManager is the abstraction for any kind of service intended to manage domain repositories implementations of the same concrete type.
type ScriptEventHandler ¶ added in v0.2.0
type ScriptEventHandler func(event domain.ExternalScriptEvent)
type TxEventHandler ¶
type TxEventHandler func(event domain.TransactionEvent)
type UtxoEventHandler ¶
type WalletEventHandler ¶
type WalletEventHandler func(event domain.WalletEvent)
Click to show internal directories.
Click to hide internal directories.