Documentation ¶
Overview ¶
Package types is for types that are shared by multiple packages
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
// CurOfferVersion is the latest supported version of a serialised Offer struct
CurOfferVersion, _ = semver.NewVersion("1.0.0")
)
var EmptyHash = Hash{}
EmptyHash is an empty Hash
var EthAssetETH = EthAsset(ethcommon.Address{})
EthAssetETH describes regular ETH (rather than an ERC-20 token)
Functions ¶
func IsHashZero ¶
IsHashZero returns true if the hash is all zeros, otherwise false
Types ¶
type EthAsset ¶
EthAsset represents an Ethereum asset (ETH or a token address)
func (EthAsset) MarshalText ¶
MarshalText returns the hex representation of the EthAsset or, in some cases, a short string.
func (EthAsset) String ¶
String implements fmt.Stringer, returning the asset's address in hex prefixed by `ERC20@` if it's an ERC20 token, or ETH for ether.
func (*EthAsset) UnmarshalText ¶
UnmarshalText assigns the EthAsset from the input text
type Offer ¶
type Offer struct { Version semver.Version `json:"version"` ID Hash `json:"offerID" validate:"required"` Provides coins.ProvidesCoin `json:"provides" validate:"required"` MinAmount *apd.Decimal `json:"minAmount" validate:"required"` // Min XMR amount MaxAmount *apd.Decimal `json:"maxAmount" validate:"required"` // Max XMR amount ExchangeRate *coins.ExchangeRate `json:"exchangeRate" validate:"required"` EthAsset EthAsset `json:"ethAsset"` Nonce uint64 `json:"nonce" validate:"required"` }
Offer represents a swap offer
func NewOffer ¶
func NewOffer( coin coins.ProvidesCoin, minAmount *apd.Decimal, maxAmount *apd.Decimal, exRate *coins.ExchangeRate, ethAsset EthAsset, ) *Offer
NewOffer creates and returns an Offer with an initialised ID and Version fields
func UnmarshalOffer ¶
UnmarshalOffer deserializes a JSON offer, checking the version for compatibility before attempting to deserialize the whole blob.
func (*Offer) MarshalJSON ¶
MarshalJSON provides JSON marshalling for the Offer type
func (*Offer) UnmarshalJSON ¶
UnmarshalJSON provides JSON unmarshalling the Offer type
type OfferExtra ¶
type OfferExtra struct { // UseRelayer forces the XMR maker to claim using the relayer even when he // has enough funds to make the claim himself. Setting it to false will not // prevent the relayer from being used if there are insufficient ETH funds // to claim. UseRelayer bool `json:"useRelayer,omitempty"` }
OfferExtra represents extra data that is passed when an offer is made.
func NewOfferExtra ¶ added in v0.3.0
func NewOfferExtra(forceUseRelayer bool) *OfferExtra
NewOfferExtra creates an OfferExtra instance
type Pair ¶ added in v0.4.2
type Pair struct { ReportedLiquidityXMR *apd.Decimal `json:"reportedLiquidityXmr" validate:"required"` EthAsset EthAsset `json:"ethAsset" validate:"required"` Token coins.ERC20TokenInfo `json:"token" validate:"required"` Offers uint64 `json:"offers" validate:"required"` Verified bool `json:"verified" valdate:"required"` }
Pair represents a pair (Such as ETH / XMR)
type Status ¶
type Status byte
Status represents the stage that a swap is at.
const ( // UnknownStatus is a placeholder for unmatched status strings and // uninitialized variables UnknownStatus Status = iota // ExpectingKeys is the status of the taker between taking an offer and // receiving a response with swap keys from the maker. It is also the // maker's status after creating an offer up until receiving keys from a // taker accepting the offer. ExpectingKeys // KeysExchanged is the status of the maker after a taker accepts his offer. KeysExchanged // ETHLocked is the taker status after locking her ETH up until confirming // that the maker locked his XMR. ETHLocked // XMRLocked is the maker's state after locking the XMR up until he confirms // that the the taker has set the contract to ready. XMRLocked // ContractReady is the taker's state after verifying the locked XMR and // setting the contract to ready. ContractReady // SweepingXMR is the taker's state after claiming the XMR and sweeping it // back into their primary wallet. // It can also be the maker's state if the maker refunds and is sweeping // the XMR back into his primary wallet. // Note: if sweeping is disabled, this stage does not occur. // Also note that the swap protocol is technically "done" at this stage; // however, this stage is required so that the node is aware that a sweep // is occurring in case of a daemon restart. SweepingXMR // CompletedSuccess represents a successful swap. CompletedSuccess // CompletedRefund represents a swap that was refunded. CompletedRefund // CompletedAbort represents the case where the swap aborts before any funds // are locked. CompletedAbort )
Status values
func NewStatus ¶
NewStatus returns a Status from the given string. If there is no match, it returns UnknownStatus
func (Status) Description ¶
Description returns a description of the swap stage.
func (Status) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Status) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.