chainmodels

package
v1.0.0-beta.37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ARCCallbackConfig

type ARCCallbackConfig struct {
	URL   string
	Token string
}

ARCCallbackConfig is the configuration for spv-wallet's endpoint for ARC to callback.

type ARCConfig

type ARCConfig struct {
	URL          string
	Token        string
	DeploymentID string
	Callback     *ARCCallbackConfig
	UseJunglebus bool
	TxsGetter    TransactionsGetter
}

ARCConfig is the configuration for the ARC API.

type ArcError

type ArcError struct {
	Type      string `json:"type"`
	Title     string `json:"title"`
	Status    int    `json:"status"`
	Detail    string `json:"detail"`
	Instance  string `json:"instance"`
	TxID      string `json:"txid"`
	ExtraInfo string `json:"extraInfo"`
}

ArcError represents an error returned by the ARC API when status code is 4xx.

func (*ArcError) Error

func (a *ArcError) Error() string

Error returns the error string it's the implementation of the error interface.

func (*ArcError) IsEmpty

func (a *ArcError) IsEmpty() bool

IsEmpty checks if the error is empty indicating that we could not parse the error response.

type BHSConfig

type BHSConfig struct {
	AuthToken string
	URL       string
}

BHSConfig consists of AuthToken and URL used to communicate with BlockHeadersService (BHS)

type MerkleRootConfirmationState

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 (
	// MRConfirmed state occurs when Merkle Root is found in the longest chain.
	MRConfirmed MerkleRootConfirmationState = "CONFIRMED"
	// MRInvalid state occurs when Merkle Root is not found in the longest chain.
	MRInvalid MerkleRootConfirmationState = "INVALID"
	// MRUnableToVerify state occurs when Block Headers Service is behind in synchronization with the longest chain.
	MRUnableToVerify MerkleRootConfirmationState = "UNABLE_TO_VERIFY"
)

type MerkleRootsConfirmations

type MerkleRootsConfirmations struct {
	ConfirmationState MerkleRootConfirmationState `json:"confirmationState"`
}

MerkleRootsConfirmations is an API response for confirming merkle roots inclusion in the longest chain.

type TXInfo

type TXInfo struct {
	BlockHash   string    `json:"blockHash,omitempty"`
	BlockHeight int64     `json:"blockHeight,omitempty"`
	ExtraInfo   string    `json:"extraInfo,omitempty"`
	MerklePath  string    `json:"merklePath,omitempty"`
	Timestamp   time.Time `json:"timestamp,omitempty"`
	TXStatus    TXStatus  `json:"txStatus,omitempty"`
	TxID        string    `json:"txid,omitempty"`
}

TXInfo is the struct that represents the transaction information from ARC

func (*TXInfo) Found

func (t *TXInfo) Found() bool

Found presents a convention to indicate that the transaction is known by ARC

type TXStatus

type TXStatus string

TXStatus is the status of the transaction

const (
	// Unknown status means that transaction has been sent to metamorph, but no processing has taken place. This should never be the case, unless something goes wrong.
	Unknown TXStatus = "UNKNOWN" // 0
	// Queued status means that transaction has been queued for processing.
	Queued TXStatus = "QUEUED" // 1
	// Received status means that transaction has been properly received by the metamorph processor.
	Received TXStatus = "RECEIVED" // 2
	// Stored status means that transaction has been stored in the metamorph store. This should ensure the transaction will be processed and retried if not picked up immediately by a mining node.
	Stored TXStatus = "STORED" // 3
	// AnnouncedToNetwork status means that transaction has been announced (INV message) to the Bitcoin network.
	AnnouncedToNetwork TXStatus = "ANNOUNCED_TO_NETWORK" // 4
	// RequestedByNetwork status means that transaction has been requested from metamorph by a Bitcoin node.
	RequestedByNetwork TXStatus = "REQUESTED_BY_NETWORK" // 5
	// SentToNetwork status means that transaction has been sent to at least 1 Bitcoin node.
	SentToNetwork TXStatus = "SENT_TO_NETWORK" // 6
	// AcceptedByNetwork status means that transaction has been accepted by a connected Bitcoin node on the ZMQ interface. If metamorph is not connected to ZQM, this status will never by set.
	AcceptedByNetwork TXStatus = "ACCEPTED_BY_NETWORK" // 7
	// SeenInOrphanMempool means that transaction has been sent to at least 1 Bitcoin node but parent transaction was not found.
	SeenInOrphanMempool TXStatus = "SEEN_IN_ORPHAN_MEMPOOL" // 10
	// SeenOnNetwork status means that transaction has been seen on the Bitcoin network and propagated to other nodes. This status is set when metamorph receives an INV message for the transaction from another node than it was sent to.
	SeenOnNetwork TXStatus = "SEEN_ON_NETWORK" // 8
	// DoubleSpendAttempted status means that transaction has been attempted to be double spent.
	DoubleSpendAttempted = "DOUBLE_SPEND_ATTEMPTED"
	// Rejected status means that transaction has been rejected by the Bitcoin network.
	Rejected TXStatus = "REJECTED" // 109
	// Mined status means that transaction has been mined into a block by a mining node.
	Mined TXStatus = "MINED" // 9
)

List of statuses available here: https://github.com/bitcoin-sv/arc

func (TXStatus) IsMined

func (t TXStatus) IsMined() bool

IsMined returns true if the transaction has been mined

func (TXStatus) IsProblematic

func (t TXStatus) IsProblematic() bool

IsProblematic returns true if the transaction is problematic (e.g rejected, double spend, unknown)

type TransactionsGetter

type TransactionsGetter interface {
	GetTransactions(ctx context.Context, ids iter.Seq[string]) ([]*sdk.Transaction, error)
}

TransactionsGetter is an interface for getting transactions by their IDs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL