Documentation ¶
Overview ¶
Package chainstate is the on-chain data service abstraction layer
Index ¶
- Constants
- Variables
- type AddFilterMessage
- type AgentClient
- func (a *AgentClient) AddFilter(regex, item string) (centrifuge.PublishResult, error)
- func (a *AgentClient) Connect() error
- func (a *AgentClient) Disconnect() error
- func (a *AgentClient) SetFilter(regex string, bloomFilter *BloomProcessorFilter) (centrifuge.PublishResult, error)
- func (a *AgentClient) SetToken(token string)
- type BlockInfo
- type BloomProcessor
- func (p *BloomProcessor) Add(regexString, item string) error
- func (p *BloomProcessor) Debug(debug bool)
- func (p *BloomProcessor) FilterTransaction(txHex string) (string, error)
- func (p *BloomProcessor) FilterTransactionPublishEvent(eData []byte) (string, error)
- func (p *BloomProcessor) GetFilters() map[string]*BloomProcessorFilter
- func (p *BloomProcessor) GetHash() string
- func (p *BloomProcessor) IsDebug() bool
- func (p *BloomProcessor) Logger() *zerolog.Logger
- func (p *BloomProcessor) Reload(regexString string, items []string) (err error)
- func (p *BloomProcessor) SetFilter(regex string, filter []byte) error
- func (p *BloomProcessor) SetLogger(logger *zerolog.Logger)
- func (p *BloomProcessor) Test(regexString, item string) bool
- type BloomProcessorFilter
- type ChainService
- type Client
- func (c *Client) Broadcast(ctx context.Context, id, txHex string, timeout time.Duration) (string, error)
- func (c *Client) BroadcastClient() broadcast.Client
- func (c *Client) BroadcastMiners() []*Miner
- func (c *Client) Close(ctx context.Context)
- func (c *Client) Debug(on bool)
- func (c *Client) DebugLog(text string)
- func (c *Client) DeleteUnreacheableMiners()
- func (c *Client) FeeUnit() *utils.FeeUnit
- func (c *Client) HTTPClient() HTTPInterface
- func (c *Client) IsDebug() bool
- func (c *Client) IsNewRelicEnabled() bool
- func (c *Client) Minercraft() minercraft.ClientInterface
- func (c *Client) Monitor() MonitorService
- func (c *Client) MonitorBlockHeaders(_ context.Context) error
- func (c *Client) Network() Network
- func (c *Client) QueryMiners() []*Miner
- func (c *Client) QueryTimeout() time.Duration
- func (c *Client) QueryTransaction(ctx context.Context, id string, requiredIn RequiredIn, timeout time.Duration) (*TransactionInfo, error)
- func (c *Client) QueryTransactionFastest(ctx context.Context, id string, requiredIn RequiredIn, timeout time.Duration) (*TransactionInfo, error)
- func (c *Client) SetLowestFees()
- func (c *Client) ValidateMiners(ctx context.Context)
- func (c *Client) VerifyMerkleRoots(ctx context.Context, merkleRoots []MerkleRootConfirmationRequestItem) error
- type ClientInterface
- type ClientOps
- func WithArc() ClientOps
- func WithBroadcastClient(client broadcast.Client) ClientOps
- func WithBroadcastClientAPIs(apis []broadcastClient.ArcClientConfig) ClientOps
- func WithBroadcastMiners(miners []*Miner) ClientOps
- func WithConnectionToPulse(url, authToken string) ClientOps
- func WithDebugging() ClientOps
- func WithExcludedProviders(providers []string) ClientOps
- func WithHTTPClient(client HTTPInterface) ClientOps
- func WithLogger(customLogger *zerolog.Logger) ClientOps
- func WithMAPI() ClientOps
- func WithMinercraft(client minercraft.ClientInterface) ClientOps
- func WithMinercraftAPIs(apis []*minercraft.MinerAPIs) ClientOps
- func WithMinercraftFeeQuotes() ClientOps
- func WithMonitoring(ctx context.Context, monitorOptions *MonitorOptions) ClientOps
- func WithMonitoringInterface(monitor MonitorService) ClientOps
- func WithNetwork(network Network) ClientOps
- func WithNewRelic() ClientOps
- func WithQueryMiners(miners []*Miner) ClientOps
- func WithQueryTimeout(timeout time.Duration) ClientOps
- func WithUserAgent(agent string) ClientOps
- type CoinbaseTxInfo
- type HTTPInterface
- type HeaderService
- type MerkleRootConfirmation
- type MerkleRootConfirmationRequestItem
- type MerkleRootConfirmationState
- type MerkleRootsConfirmationsResponse
- type Miner
- type MinerCraftBase
- func (m *MinerCraftBase) APIType() minercraft.APIType
- func (m *MinerCraftBase) AddMiner(miner minercraft.Miner, apis []minercraft.API) error
- func (m *MinerCraftBase) BestQuote(context.Context, string, string) (*minercraft.FeeQuoteResponse, error)
- func (m *MinerCraftBase) FastestQuote(context.Context, time.Duration) (*minercraft.FeeQuoteResponse, error)
- func (m *MinerCraftBase) FeeQuote(context.Context, *minercraft.Miner) (*minercraft.FeeQuoteResponse, error)
- func (m *MinerCraftBase) MinerAPIByMinerID(minerID string, apiType minercraft.APIType) (*minercraft.API, error)
- func (m *MinerCraftBase) MinerAPIsByMinerID(minerID string) *minercraft.MinerAPIs
- func (m *MinerCraftBase) MinerByID(minerID string) *minercraft.Miner
- func (m *MinerCraftBase) MinerByName(name string) *minercraft.Miner
- func (m *MinerCraftBase) MinerUpdateToken(name, token string, apiType minercraft.APIType)
- func (m *MinerCraftBase) Miners() []*minercraft.Miner
- func (m *MinerCraftBase) PolicyQuote(context.Context, *minercraft.Miner) (*minercraft.PolicyQuoteResponse, error)
- func (m *MinerCraftBase) QueryTransaction(context.Context, *minercraft.Miner, string, ...) (*minercraft.QueryTransactionResponse, error)
- func (m *MinerCraftBase) RemoveMiner(miner *minercraft.Miner) bool
- func (m *MinerCraftBase) SubmitTransaction(context.Context, *minercraft.Miner, *minercraft.Transaction) (*minercraft.SubmitTransactionResponse, error)
- func (m *MinerCraftBase) SubmitTransactions(context.Context, *minercraft.Miner, []minercraft.Transaction) (*minercraft.SubmitTransactionsResponse, error)
- func (m *MinerCraftBase) UserAgent() string
- type MinercraftServices
- type Monitor
- func (m *Monitor) Add(regexString, item string) error
- func (m *Monitor) AllowUnknownTransactions() bool
- func (m *Monitor) Connected()
- func (m *Monitor) Disconnected()
- func (m *Monitor) GetFalsePositiveRate() float64
- func (m *Monitor) GetLockID() string
- func (m *Monitor) GetMaxNumberOfDestinations() int
- func (m *Monitor) GetMonitorDays() int
- func (m *Monitor) IsConnected() bool
- func (m *Monitor) IsDebug() bool
- func (m *Monitor) LoadMonitoredDestinations() bool
- func (m *Monitor) Logger() *zerolog.Logger
- func (m *Monitor) Processor() MonitorProcessor
- func (m *Monitor) SaveDestinations() bool
- func (m *Monitor) SetChainstateOptions(options *clientOptions)
- func (m *Monitor) Start(_ context.Context, handler MonitorHandler, onStop func()) error
- func (m *Monitor) Stop(_ context.Context) error
- type MonitorClient
- type MonitorHandler
- type MonitorOptions
- type MonitorProcessor
- type MonitorService
- type Network
- type Page
- type ProviderServices
- type PulseClient
- type RegexProcessor
- func (p *RegexProcessor) Add(regex string, _ string) error
- func (p *RegexProcessor) Debug(debug bool)
- func (p *RegexProcessor) FilterTransaction(hex string) (string, error)
- func (p *RegexProcessor) FilterTransactionPublishEvent(eData []byte) (string, error)
- func (p *RegexProcessor) GetFilters() map[string]*BloomProcessorFilter
- func (p *RegexProcessor) GetHash() string
- func (p *RegexProcessor) IsDebug() bool
- func (p *RegexProcessor) Logger() *zerolog.Logger
- func (p *RegexProcessor) Reload(_ string, items []string) (err error)
- func (p *RegexProcessor) SetFilter(_ string, _ []byte) error
- func (p *RegexProcessor) SetLogger(logger *zerolog.Logger)
- func (p *RegexProcessor) Test(_ string, item string) bool
- type RequiredIn
- type ScriptPubKeyInfo
- type ScriptSigInfo
- type SetFilterMessage
- type SocketHandler
- type TransactionInfo
- type TransactionType
- type TxInfo
- type VinInfo
- type VoutInfo
Constants ¶
const ( // FilterBloom is for bloom filters FilterBloom = "bloom" // FilterRegex is for regex filters FilterRegex = "regex" )
const ( ProviderAll = "all" // All providers (used for errors etc) ProviderMAPI = "mapi" // Query & broadcast provider for mAPI (using given miners) ProviderWhatsOnChain = "whatsonchain" // Query & broadcast provider for WhatsOnChain ProviderBroadcastClient = "broadcastclient" // Query & broadcast provider for configured miners ProviderPulse = "pulse" // MerkleProof provider )
List of providers
Variables ¶
var DefaultFee = &utils.FeeUnit{
Satoshis: 1,
Bytes: 20,
}
DefaultFee is used when a fee has not been set by the user This default is currently accepted by all BitcoinSV miners (50/1000) (7.27.23) Actual TAAL FeeUnit - 1/1000, GorillaPool - 50/1000 (7.27.23)
var ErrInvalidRequirements = errors.New("requirements are invalid or missing")
ErrInvalidRequirements is when an invalid requirement was given
var ErrInvalidTransactionHex = errors.New("invalid transaction hex")
ErrInvalidTransactionHex is when the transaction hex is missing or invalid
var ErrInvalidTransactionID = errors.New("invalid transaction id")
ErrInvalidTransactionID is when the transaction id is missing or invalid
var ErrMissingBroadcastMiners = errors.New("missing: broadcasting miners")
ErrMissingBroadcastMiners is when broadcasting miners are missing
var ErrMissingQueryMiners = errors.New("missing: query miners")
ErrMissingQueryMiners is when query miners are missing
var ErrMonitorNotAvailable = errors.New("monitor processor not available")
ErrMonitorNotAvailable is when the monitor processor is not available
var ErrTransactionIDMismatch = errors.New("result tx id did not match provided tx id")
ErrTransactionIDMismatch is when the returned tx does not match the expected given tx id
var ErrTransactionNotFound = errors.New("transaction not found using all chain providers")
ErrTransactionNotFound is when a transaction was not found in any on-chain provider
Functions ¶
This section is empty.
Types ¶
type AddFilterMessage ¶ added in v0.2.14
type AddFilterMessage struct { Filter string `json:"filter"` Hash string `json:"hash"` Regex string `json:"regex"` Timestamp int64 `json:"timestamp"` }
AddFilterMessage defines a new filter to be published from the client todo Just rely on the agent for this data type
type AgentClient ¶ added in v0.2.14
type AgentClient struct { *centrifuge.Client Token string }
AgentClient implements MonitorClient with needed agent methods
func (*AgentClient) AddFilter ¶ added in v0.2.14
func (a *AgentClient) AddFilter(regex, item string) (centrifuge.PublishResult, error)
AddFilter adds a new filter to the agent
func (*AgentClient) Connect ¶ added in v0.2.14
func (a *AgentClient) Connect() error
Connect establishes connection to agent
func (*AgentClient) Disconnect ¶ added in v0.2.14
func (a *AgentClient) Disconnect() error
Disconnect closes connection to agent
func (*AgentClient) SetFilter ¶ added in v0.2.14
func (a *AgentClient) SetFilter(regex string, bloomFilter *BloomProcessorFilter) (centrifuge.PublishResult, error)
SetFilter (re)sets a filter to the agent
func (*AgentClient) SetToken ¶ added in v0.2.14
func (a *AgentClient) SetToken(token string)
SetToken set the client token
type BlockInfo ¶ added in v0.5.13
type BlockInfo struct { Bits string `json:"bits"` ChainWork string `json:"chainwork"` CoinbaseTx CoinbaseTxInfo `json:"coinbaseTx"` Confirmations int64 `json:"confirmations"` Difficulty float64 `json:"difficulty"` Hash string `json:"hash"` Height int64 `json:"height"` MedianTime int64 `json:"mediantime"` MerkleRoot string `json:"merkleroot"` Miner string `json:"Bmgpool"` NextBlockHash string `json:"nextblockhash"` Nonce int64 `json:"nonce"` Pages Page `json:"pages"` PreviousBlockHash string `json:"previousblockhash"` Size int64 `json:"size"` Time int64 `json:"time"` TotalFees float64 `json:"totalFees"` Tx []string `json:"tx"` TxCount int64 `json:"txcount"` Version int64 `json:"version"` VersionHex string `json:"versionHex"` }
BlockInfo is the response info about a returned block
type BloomProcessor ¶ added in v0.2.14
type BloomProcessor struct {
// contains filtered or unexported fields
}
BloomProcessor bloom filter processor
func NewBloomProcessor ¶ added in v0.2.14
func NewBloomProcessor(maxCells uint, falsePositiveRate float64) *BloomProcessor
NewBloomProcessor initialize a new bloom processor
func (*BloomProcessor) Add ¶ added in v0.2.14
func (p *BloomProcessor) Add(regexString, item string) error
Add a new item to the bloom filter
func (*BloomProcessor) Debug ¶ added in v0.2.14
func (p *BloomProcessor) Debug(debug bool)
Debug set debugging
func (*BloomProcessor) FilterTransaction ¶ added in v0.2.14
func (p *BloomProcessor) FilterTransaction(txHex string) (string, error)
FilterTransaction check whether a filter matches a tx event
func (*BloomProcessor) FilterTransactionPublishEvent ¶ added in v0.2.14
func (p *BloomProcessor) FilterTransactionPublishEvent(eData []byte) (string, error)
FilterTransactionPublishEvent check whether a filter matches a tx event
func (*BloomProcessor) GetFilters ¶ added in v0.2.14
func (p *BloomProcessor) GetFilters() map[string]*BloomProcessorFilter
GetFilters get all filters from the bloom processor
func (*BloomProcessor) GetHash ¶ added in v0.2.14
func (p *BloomProcessor) GetHash() string
GetHash get the hash of the current filter
func (*BloomProcessor) IsDebug ¶ added in v0.2.14
func (p *BloomProcessor) IsDebug() bool
IsDebug return whether debugging is on/off
func (*BloomProcessor) Logger ¶ added in v0.2.14
func (p *BloomProcessor) Logger() *zerolog.Logger
Logger return the logger
func (*BloomProcessor) Reload ¶ added in v0.2.14
func (p *BloomProcessor) Reload(regexString string, items []string) (err error)
Reload the bloom filter from the DB
func (*BloomProcessor) SetFilter ¶ added in v0.2.14
func (p *BloomProcessor) SetFilter(regex string, filter []byte) error
SetFilter replace and set a filter
func (*BloomProcessor) SetLogger ¶ added in v0.2.14
func (p *BloomProcessor) SetLogger(logger *zerolog.Logger)
SetLogger set the logger
func (*BloomProcessor) Test ¶ added in v0.2.14
func (p *BloomProcessor) Test(regexString, item string) bool
Test checks whether the item is in the bloom filter
type BloomProcessorFilter ¶ added in v0.2.14
type BloomProcessorFilter struct { Filter *boom.StableBloomFilter // contains filtered or unexported fields }
BloomProcessorFilter struct
type ChainService ¶
type ChainService interface { Broadcast(ctx context.Context, id, txHex string, timeout time.Duration) (string, error) QueryTransaction( ctx context.Context, id string, requiredIn RequiredIn, timeout time.Duration, ) (*TransactionInfo, error) QueryTransactionFastest( ctx context.Context, id string, requiredIn RequiredIn, timeout time.Duration, ) (*TransactionInfo, error) }
ChainService is the chain related methods
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the client (configuration)
func (*Client) Broadcast ¶
func (c *Client) Broadcast(ctx context.Context, id, txHex string, timeout time.Duration) (string, error)
Broadcast will attempt to broadcast a transaction using the given providers
func (*Client) BroadcastClient ¶ added in v0.5.12
BroadcastClient will return the BroadcastClient client
func (*Client) BroadcastMiners ¶
BroadcastMiners will return the broadcast miners
func (*Client) DeleteUnreacheableMiners ¶ added in v0.5.5
func (c *Client) DeleteUnreacheableMiners()
DeleteUnreacheableMiners deletes miners which can't be reacheable from config
func (*Client) HTTPClient ¶
func (c *Client) HTTPClient() HTTPInterface
HTTPClient will return the HTTP client
func (*Client) IsNewRelicEnabled ¶
IsNewRelicEnabled will return if new relic is enabled
func (*Client) Minercraft ¶
func (c *Client) Minercraft() minercraft.ClientInterface
Minercraft will return the Minercraft client
func (*Client) Monitor ¶ added in v0.2.14
func (c *Client) Monitor() MonitorService
Monitor will return the Monitor client
func (*Client) MonitorBlockHeaders ¶ added in v0.2.14
MonitorBlockHeaders will start up a block headers monitor
func (*Client) QueryMiners ¶
QueryMiners will return the query miners
func (*Client) QueryTimeout ¶
QueryTimeout will return the query timeout
func (*Client) QueryTransaction ¶
func (c *Client) QueryTransaction( ctx context.Context, id string, requiredIn RequiredIn, timeout time.Duration, ) (*TransactionInfo, error)
QueryTransaction will get the transaction info from all providers returning the "first" valid result
Note: this is slow, but follows a specific order: mAPI -> WhatsOnChain
func (*Client) QueryTransactionFastest ¶
func (c *Client) QueryTransactionFastest( ctx context.Context, id string, requiredIn RequiredIn, timeout time.Duration, ) (*TransactionInfo, error)
QueryTransactionFastest will get the transaction info from ALL provider(s) returning the "fastest" valid result
Note: this is fast but could abuse each provider based on how excessive this method is used
func (*Client) SetLowestFees ¶ added in v0.5.4
func (c *Client) SetLowestFees()
SetLowestFees takes the lowest fees among all miners and sets them as the feeUnit for future transactions
func (*Client) ValidateMiners ¶ added in v0.5.5
ValidateMiners will check if miner is reacheble by requesting its FeeQuote If there was on error on FeeQuote(), the miner will be deleted from miners list If usage of MapiFeeQuotes is enabled and miner is reacheble, miner's fee unit will be upadeted with MAPI fee quotes If FeeQuote returns some quote, but fee is not presented in it, it means that miner is valid but we can't use it's feequote
func (*Client) VerifyMerkleRoots ¶ added in v0.5.17
func (c *Client) VerifyMerkleRoots(ctx context.Context, merkleRoots []MerkleRootConfirmationRequestItem) error
VerifyMerkleRoots will try to verify merkle roots with all available providers
type ClientInterface ¶
type ClientInterface interface { ChainService ProviderServices MinercraftServices HeaderService Close(ctx context.Context) Debug(on bool) DebugLog(text string) HTTPClient() HTTPInterface IsDebug() bool IsNewRelicEnabled() bool Monitor() MonitorService Network() Network QueryTimeout() time.Duration }
ClientInterface is the chainstate client interface
type ClientOps ¶
type ClientOps func(c *clientOptions)
ClientOps allow functional options to be supplied that overwrite default client options.
func WithArc ¶ added in v0.5.8
func WithArc() ClientOps
WithArc will specify Arc as an API for minercraft client
func WithBroadcastClient ¶ added in v0.5.12
WithBroadcastClient will set broadcast client APIs
func WithBroadcastClientAPIs ¶ added in v0.5.12
func WithBroadcastClientAPIs(apis []broadcastClient.ArcClientConfig) ClientOps
WithBroadcastClientAPIs will set broadcast client APIs
func WithBroadcastMiners ¶
WithBroadcastMiners will set a list of miners for broadcasting
func WithConnectionToPulse ¶ added in v0.5.17
WithConnectionToPulse will set pulse API settings.
func WithExcludedProviders ¶ added in v0.2.21
WithExcludedProviders will set a list of excluded providers
func WithHTTPClient ¶
func WithHTTPClient(client HTTPInterface) ClientOps
WithHTTPClient will set a custom HTTP client
func WithLogger ¶
WithLogger will set a custom logger
func WithMAPI ¶ added in v0.5.8
func WithMAPI() ClientOps
WithMAPI will specify mAPI as an API for minercraft client
func WithMinercraft ¶
func WithMinercraft(client minercraft.ClientInterface) ClientOps
WithMinercraft will set a custom Minercraft client
func WithMinercraftAPIs ¶ added in v0.5.8
func WithMinercraftAPIs(apis []*minercraft.MinerAPIs) ClientOps
WithMinercraftAPIs will set miners APIs
func WithMinercraftFeeQuotes ¶ added in v0.5.8
func WithMinercraftFeeQuotes() ClientOps
WithMinercraftFeeQuotes will set minercraftFeeQuotes flag as true
func WithMonitoring ¶ added in v0.2.14
func WithMonitoring(ctx context.Context, monitorOptions *MonitorOptions) ClientOps
WithMonitoring will create a new monitorConfig interface with the given options
func WithMonitoringInterface ¶ added in v0.2.14
func WithMonitoringInterface(monitor MonitorService) ClientOps
WithMonitoringInterface will set the interface to use for monitoring the blockchain
func WithNetwork ¶
WithNetwork will set the network to use
func WithQueryMiners ¶
WithQueryMiners will set a list of miners for querying transactions
func WithQueryTimeout ¶
WithQueryTimeout will set a different timeout for transaction querying
func WithUserAgent ¶ added in v0.2.14
WithUserAgent will set the custom user agent
type CoinbaseTxInfo ¶ added in v0.5.13
type CoinbaseTxInfo struct { BlockHash string `json:"blockhash"` BlockTime int64 `json:"blocktime"` Confirmations int64 `json:"confirmations"` Hash string `json:"hash"` Hex string `json:"hex"` LockTime int64 `json:"locktime"` Size int64 `json:"size"` Time int64 `json:"time"` TxID string `json:"txid"` Version int64 `json:"version"` Vin []VinInfo `json:"vin"` Vout []VoutInfo `json:"vout"` }
CoinbaseTxInfo is the coinbase tx info inside the BlockInfo
type HTTPInterface ¶
HTTPInterface is the HTTP client interface
type HeaderService ¶ added in v0.5.17
type HeaderService interface {
VerifyMerkleRoots(ctx context.Context, merkleRoots []MerkleRootConfirmationRequestItem) error
}
HeaderService is header services interface
type MerkleRootConfirmation ¶ added in v0.5.17
type MerkleRootConfirmation struct { Hash string `json:"blockHash"` BlockHeight uint64 `json:"blockHeight"` MerkleRoot string `json:"merkleRoot"` Confirmation MerkleRootConfirmationState `json:"confirmation"` }
MerkleRootConfirmation is a confirmation of merkle roots inclusion in the longest chain.
type MerkleRootConfirmationRequestItem ¶ added in v0.6.0
type MerkleRootConfirmationRequestItem struct { MerkleRoot string `json:"merkleRoot"` BlockHeight uint64 `json:"blockHeight"` }
MerkleRootConfirmationRequestItem is a request type for verification of Merkle Roots inclusion in the longest chain.
type MerkleRootConfirmationState ¶ added in v0.6.0
type MerkleRootConfirmationState string
MerkleRootConfirmationState represents the state of each Merkle Root verification process and can be one of three values: Confirmed, Invalid and UnableToVerify.
const ( // Confirmed state occurs when Merkle Root is found in the longest chain. Confirmed MerkleRootConfirmationState = "CONFIRMED" // Invalid state occurs when Merkle Root is not found in the longest chain. Invalid MerkleRootConfirmationState = "INVALID" // UnableToVerify state occurs when Pulse is behind in synchronization with the longest chain. UnableToVerify MerkleRootConfirmationState = "UNABLE_TO_VERIFY" )
type MerkleRootsConfirmationsResponse ¶ added in v0.5.17
type MerkleRootsConfirmationsResponse struct { ConfirmationState MerkleRootConfirmationState `json:"confirmationState"` Confirmations []MerkleRootConfirmation `json:"confirmations"` }
MerkleRootsConfirmationsResponse is an API response for confirming merkle roots inclusion in the longest chain.
type Miner ¶ added in v0.2.14
type Miner struct { FeeLastChecked time.Time `json:"fee_last_checked"` // Last time the fee was checked via mAPI FeeUnit *utils.FeeUnit `json:"fee_unit"` // The fee unit returned from Policy request Miner *minercraft.Miner `json:"miner"` // The minercraft miner }
Miner is the internal chainstate miner (wraps Minercraft miner with more information)
type MinerCraftBase ¶ added in v0.5.5
type MinerCraftBase struct{}
MinerCraftBase is a mock implementation of the minercraft.MinerCraft interface.
func (*MinerCraftBase) APIType ¶ added in v0.5.8
func (m *MinerCraftBase) APIType() minercraft.APIType
APIType will return the API type
func (*MinerCraftBase) AddMiner ¶ added in v0.5.5
func (m *MinerCraftBase) AddMiner(miner minercraft.Miner, apis []minercraft.API) error
AddMiner adds a new miner to the list of miners.
func (*MinerCraftBase) BestQuote ¶ added in v0.5.5
func (m *MinerCraftBase) BestQuote(context.Context, string, string) (*minercraft.FeeQuoteResponse, error)
BestQuote returns the best quote for the given fee type and amount.
func (*MinerCraftBase) FastestQuote ¶ added in v0.5.5
func (m *MinerCraftBase) FastestQuote(context.Context, time.Duration) (*minercraft.FeeQuoteResponse, error)
FastestQuote returns the fastest quote for the given fee type and amount.
func (*MinerCraftBase) FeeQuote ¶ added in v0.5.5
func (m *MinerCraftBase) FeeQuote(context.Context, *minercraft.Miner) (*minercraft.FeeQuoteResponse, error)
FeeQuote returns a fee quote for the given miner.
func (*MinerCraftBase) MinerAPIByMinerID ¶ added in v0.5.8
func (m *MinerCraftBase) MinerAPIByMinerID(minerID string, apiType minercraft.APIType) (*minercraft.API, error)
MinerAPIByMinerID will return a miner's API given a miner id and API type
func (*MinerCraftBase) MinerAPIsByMinerID ¶ added in v0.5.8
func (m *MinerCraftBase) MinerAPIsByMinerID(minerID string) *minercraft.MinerAPIs
MinerAPIsByMinerID will return a miner's APIs given a miner id
func (*MinerCraftBase) MinerByID ¶ added in v0.5.5
func (m *MinerCraftBase) MinerByID(minerID string) *minercraft.Miner
MinerByID returns a miner by its ID.
func (*MinerCraftBase) MinerByName ¶ added in v0.5.5
func (m *MinerCraftBase) MinerByName(name string) *minercraft.Miner
MinerByName returns a miner by its name.
func (*MinerCraftBase) MinerUpdateToken ¶ added in v0.5.5
func (m *MinerCraftBase) MinerUpdateToken(name, token string, apiType minercraft.APIType)
MinerUpdateToken updates the token for the given miner.
func (*MinerCraftBase) Miners ¶ added in v0.5.5
func (m *MinerCraftBase) Miners() []*minercraft.Miner
Miners returns all miners.
func (*MinerCraftBase) PolicyQuote ¶ added in v0.5.5
func (m *MinerCraftBase) PolicyQuote(context.Context, *minercraft.Miner) (*minercraft.PolicyQuoteResponse, error)
PolicyQuote returns a policy quote for the given miner.
func (*MinerCraftBase) QueryTransaction ¶ added in v0.5.5
func (m *MinerCraftBase) QueryTransaction(context.Context, *minercraft.Miner, string, ...minercraft.QueryTransactionOptFunc) (*minercraft.QueryTransactionResponse, error)
QueryTransaction returns a transaction for the given miner.
func (*MinerCraftBase) RemoveMiner ¶ added in v0.5.5
func (m *MinerCraftBase) RemoveMiner(miner *minercraft.Miner) bool
RemoveMiner removes a miner from the list of miners.
func (*MinerCraftBase) SubmitTransaction ¶ added in v0.5.5
func (m *MinerCraftBase) SubmitTransaction(context.Context, *minercraft.Miner, *minercraft.Transaction) (*minercraft.SubmitTransactionResponse, error)
SubmitTransaction submits a transaction to the given miner.
func (*MinerCraftBase) SubmitTransactions ¶ added in v0.5.5
func (m *MinerCraftBase) SubmitTransactions(context.Context, *minercraft.Miner, []minercraft.Transaction) (*minercraft.SubmitTransactionsResponse, error)
SubmitTransactions submits transactions to the given miner.
func (*MinerCraftBase) UserAgent ¶ added in v0.5.5
func (m *MinerCraftBase) UserAgent() string
UserAgent returns the user agent.
type MinercraftServices ¶ added in v0.2.14
type MinercraftServices interface { BroadcastMiners() []*Miner QueryMiners() []*Miner ValidateMiners(ctx context.Context) FeeUnit() *utils.FeeUnit }
MinercraftServices is the minercraft services interface
type Monitor ¶ added in v0.2.14
type Monitor struct {
// contains filtered or unexported fields
}
Monitor starts a new monitorConfig to monitor and filter transactions from a source
Internal struct with all options being private
func NewMonitor ¶ added in v0.2.14
func NewMonitor(_ context.Context, options *MonitorOptions) (monitor *Monitor)
NewMonitor starts a new monitorConfig and loads all addresses that need to be monitored into the bloom filter
func (*Monitor) AllowUnknownTransactions ¶ added in v0.4.9
AllowUnknownTransactions gets whether we allow recording transactions with no relation to our xpubs
func (*Monitor) Connected ¶ added in v0.2.14
func (m *Monitor) Connected()
Connected sets the connected state to true
func (*Monitor) Disconnected ¶ added in v0.2.14
func (m *Monitor) Disconnected()
Disconnected sets the connected state to false
func (*Monitor) GetFalsePositiveRate ¶ added in v0.2.14
GetFalsePositiveRate gets the falsePositiveRate option
func (*Monitor) GetMaxNumberOfDestinations ¶ added in v0.2.14
GetMaxNumberOfDestinations gets the monitorDays option
func (*Monitor) GetMonitorDays ¶ added in v0.2.14
GetMonitorDays gets the monitorDays option
func (*Monitor) IsConnected ¶ added in v0.2.14
IsConnected returns whether we are connected to the socket
func (*Monitor) LoadMonitoredDestinations ¶ added in v0.2.14
LoadMonitoredDestinations gets where we want to add the monitored destinations from the database into the processor
func (*Monitor) Processor ¶ added in v0.2.14
func (m *Monitor) Processor() MonitorProcessor
Processor gets the monitor processor
func (*Monitor) SaveDestinations ¶ added in v0.2.14
SaveDestinations gets whether we should save destinations from transactions that pass monitor filter
func (*Monitor) SetChainstateOptions ¶ added in v0.2.14
func (m *Monitor) SetChainstateOptions(options *clientOptions)
SetChainstateOptions sets the chainstate options on the monitor to allow more syncing capabilities
type MonitorClient ¶ added in v0.2.14
type MonitorClient interface { AddFilter(regex, item string) (centrifuge.PublishResult, error) Connect() error Disconnect() error SetToken(token string) }
MonitorClient interface
type MonitorHandler ¶ added in v0.2.14
type MonitorHandler interface { SocketHandler RecordBlockHeader(ctx context.Context, bh bc.BlockHeader) error RecordTransaction(ctx context.Context, txHex string) error SetMonitor(monitor *Monitor) }
MonitorHandler interface
type MonitorOptions ¶ added in v0.2.14
type MonitorOptions struct { AuthToken string `json:"token"` BuxAgentURL string `json:"bux_agent_url"` Debug bool `json:"debug"` FalsePositiveRate float64 `json:"false_positive_rate"` LoadMonitoredDestinations bool `json:"load_monitored_destinations"` LockID string `json:"lock_id"` MaxNumberOfDestinations int `json:"max_number_of_destinations"` MonitorDays int `json:"monitor_days"` ProcessorType string `json:"processor_type"` SaveTransactionDestinations bool `json:"save_transaction_destinations"` AllowUnknownTransactions bool `json:"allow_unknown_transactions"` // whether to allow transactions that do not have an xpub_in_id or xpub_out_id }
MonitorOptions options for starting this monitorConfig
type MonitorProcessor ¶ added in v0.2.14
type MonitorProcessor interface { Add(regexString, item string) error Debug(bool) FilterTransaction(txHex string) (string, error) FilterTransactionPublishEvent(eData []byte) (string, error) GetFilters() map[string]*BloomProcessorFilter GetHash() string IsDebug() bool Logger() *zerolog.Logger Reload(regexString string, items []string) error SetFilter(regex string, filter []byte) error SetLogger(logger *zerolog.Logger) Test(regexString string, item string) bool }
MonitorProcessor struct that defines interface to all filter processors
type MonitorService ¶ added in v0.2.14
type MonitorService interface { Add(regexpString string, item string) error Connected() Disconnected() GetFalsePositiveRate() float64 GetLockID() string GetMaxNumberOfDestinations() int GetMonitorDays() int IsConnected() bool IsDebug() bool LoadMonitoredDestinations() bool AllowUnknownTransactions() bool Logger() *zerolog.Logger Processor() MonitorProcessor SaveDestinations() bool Start(ctx context.Context, handler MonitorHandler, onStop func()) error Stop(ctx context.Context) error }
MonitorService for the monitoring
type Network ¶
type Network string
Network is the supported Bitcoin networks
const ( MainNet Network = mainNet // Main public network StressTestNet Network = stn // Stress Test Network (https://bitcoinscaling.io/) TestNet Network = testNet // Test public network )
Supported networks
type ProviderServices ¶
type ProviderServices interface { Minercraft() minercraft.ClientInterface BroadcastClient() broadcast.Client }
ProviderServices is the chainstate providers interface
type PulseClient ¶ added in v0.5.17
type PulseClient struct {
// contains filtered or unexported fields
}
PulseClient is the internal chainstate pulse client
type RegexProcessor ¶ added in v0.2.14
type RegexProcessor struct {
// contains filtered or unexported fields
}
RegexProcessor simple regex processor This processor just uses regex checks to see if a raw hex string exists in a tx This is bound to have some false positives but is somewhat performant when filter set is small
func NewRegexProcessor ¶ added in v0.2.14
func NewRegexProcessor() *RegexProcessor
NewRegexProcessor initialize a new regex processor
func (*RegexProcessor) Add ¶ added in v0.2.14
func (p *RegexProcessor) Add(regex string, _ string) error
Add a new item to the processor
func (*RegexProcessor) Debug ¶ added in v0.2.14
func (p *RegexProcessor) Debug(debug bool)
Debug set debugging
func (*RegexProcessor) FilterTransaction ¶ added in v0.2.14
func (p *RegexProcessor) FilterTransaction(hex string) (string, error)
FilterTransaction filters transaction
func (*RegexProcessor) FilterTransactionPublishEvent ¶ added in v0.2.14
func (p *RegexProcessor) FilterTransactionPublishEvent(eData []byte) (string, error)
FilterTransactionPublishEvent check whether a filter matches a tx event
func (*RegexProcessor) GetFilters ¶ added in v0.2.14
func (p *RegexProcessor) GetFilters() map[string]*BloomProcessorFilter
GetFilters get all filters from the bloom processor
func (*RegexProcessor) GetHash ¶ added in v0.2.14
func (p *RegexProcessor) GetHash() string
GetHash get the hash of the filter
func (*RegexProcessor) IsDebug ¶ added in v0.2.14
func (p *RegexProcessor) IsDebug() bool
IsDebug return whether debugging is on/off
func (*RegexProcessor) Logger ¶ added in v0.2.14
func (p *RegexProcessor) Logger() *zerolog.Logger
Logger return the logger
func (*RegexProcessor) Reload ¶ added in v0.2.14
func (p *RegexProcessor) Reload(_ string, items []string) (err error)
Reload the items of the processor to match against
func (*RegexProcessor) SetFilter ¶ added in v0.2.14
func (p *RegexProcessor) SetFilter(_ string, _ []byte) error
SetFilter replace and set a filter
func (*RegexProcessor) SetLogger ¶ added in v0.2.14
func (p *RegexProcessor) SetLogger(logger *zerolog.Logger)
SetLogger set the logger
type RequiredIn ¶
type RequiredIn string
RequiredIn is the requirements for querying transaction information
const ( // RequiredInMempool is the transaction in mempool? (minimum requirement for a valid response) RequiredInMempool RequiredIn = requiredInMempool // RequiredOnChain is the transaction in on-chain? (minimum requirement for a valid response) RequiredOnChain RequiredIn = requiredOnChain )
type ScriptPubKeyInfo ¶ added in v0.5.13
type ScriptPubKeyInfo struct { Addresses []string `json:"addresses"` Asm string `json:"asm"` Hex string `json:"hex"` IsTruncated bool `json:"isTruncated"` OpReturn string `json:"-"` // todo: support this (can be an object of key/vals based on the op return data) ReqSigs int64 `json:"reqSigs"` Type string `json:"type"` }
ScriptPubKeyInfo is the scriptPubKey info inside the VoutInfo
type ScriptSigInfo ¶ added in v0.5.13
ScriptSigInfo is the scriptSig info inside the VinInfo
type SetFilterMessage ¶ added in v0.2.14
type SetFilterMessage struct { Filter []byte `json:"filter"` Hash string `json:"hash"` Regex string `json:"regex"` Timestamp int64 `json:"timestamp"` }
SetFilterMessage defines a new filter message with a list of filters
type SocketHandler ¶ added in v0.5.13
type SocketHandler interface { OnConnect(*centrifuge.Client, centrifuge.ConnectEvent) OnDisconnect(*centrifuge.Client, centrifuge.DisconnectEvent) OnError(*centrifuge.Client, centrifuge.ErrorEvent) OnJoin(*centrifuge.Subscription, centrifuge.JoinEvent) OnLeave(*centrifuge.Subscription, centrifuge.LeaveEvent) OnMessage(*centrifuge.Client, centrifuge.MessageEvent) OnPublish(*centrifuge.Subscription, centrifuge.PublishEvent) OnServerJoin(*centrifuge.Client, centrifuge.ServerJoinEvent) OnServerLeave(*centrifuge.Client, centrifuge.ServerLeaveEvent) OnServerPublish(*centrifuge.Client, centrifuge.ServerPublishEvent) OnServerSubscribe(*centrifuge.Client, centrifuge.ServerSubscribeEvent) OnServerUnsubscribe(*centrifuge.Client, centrifuge.ServerUnsubscribeEvent) OnSubscribeError(*centrifuge.Subscription, centrifuge.SubscribeErrorEvent) OnSubscribeSuccess(*centrifuge.Subscription, centrifuge.SubscribeSuccessEvent) OnUnsubscribe(*centrifuge.Subscription, centrifuge.UnsubscribeEvent) }
SocketHandler is composite interface of centrifuge handlers interfaces
type TransactionInfo ¶
type TransactionInfo struct { BlockHash string `json:"block_hash,omitempty"` // mAPI, WOC BlockHeight int64 `json:"block_height"` // mAPI, WOC Confirmations int64 `json:"confirmations,omitempty"` // mAPI, WOC ID string `json:"id"` // Transaction ID (Hex) MinerID string `json:"miner_id,omitempty"` // mAPI ONLY - miner_id found Provider string `json:"provider,omitempty"` // Provider is our internal source MerkleProof *bc.MerkleProof `json:"merkle_proof,omitempty"` // mAPI 1.5 ONLY. Should be also supported by Arc in future }
TransactionInfo is the universal information about the transaction found from a chain provider
func (*TransactionInfo) Valid ¶ added in v0.7.0
func (t *TransactionInfo) Valid() bool
Valid validates TransactionInfo by checking if it contains BlockHash and MerkleProof (from mAPI) or MerklePath (from Arc)
type TransactionType ¶ added in v0.2.14
type TransactionType string
TransactionType tx types
const Metanet TransactionType = "metanet"
Metanet type
const PlanariaB TransactionType = "planaria-b"
PlanariaB type
const PlanariaD TransactionType = "planaria-d"
PlanariaD type
const PubKeyHash TransactionType = "pubkeyhash"
PubKeyHash type
const RareCandyFrogCartel TransactionType = "rarecandy-frogcartel"
RareCandyFrogCartel type
type TxInfo ¶ added in v0.4.7
type TxInfo struct { BlockHash string `json:"blockhash"` BlockHeight int64 `json:"blockheight"` BlockTime int64 `json:"blocktime"` Confirmations int64 `json:"confirmations"` Hash string `json:"hash"` Hex string `json:"hex"` LockTime int64 `json:"locktime"` Size int64 `json:"size"` Time int64 `json:"time"` TxID string `json:"txid"` Version int64 `json:"version"` Vin []VinInfo `json:"vin"` Vout []VoutInfo `json:"vout"` Error string `json:"error"` }
TxInfo is the response info about a returned tx
type VinInfo ¶ added in v0.5.13
type VinInfo struct { Coinbase string `json:"coinbase"` ScriptSig ScriptSigInfo `json:"scriptSig"` Sequence int64 `json:"sequence"` TxID string `json:"txid"` Vout int64 `json:"vout"` }
VinInfo is the vin info inside the CoinbaseTxInfo
type VoutInfo ¶ added in v0.5.13
type VoutInfo struct { N int64 `json:"n"` ScriptPubKey ScriptPubKeyInfo `json:"scriptPubKey"` Value float64 `json:"value"` }
VoutInfo is the vout info inside the CoinbaseTxInfo
Source Files ¶
- broadcast.go
- broadcast_providers.go
- broadcast_utils.go
- chainstate.go
- client.go
- client_internal.go
- client_options.go
- definitions.go
- errors.go
- interface.go
- merkle_root.go
- merkle_root_provider.go
- mock_const.go
- mock_minercraft.go
- monitor.go
- monitor_client.go
- network.go
- processor.go
- requirements.go
- transaction.go
- transaction_info.go
- types.go