Documentation
¶
Index ¶
- Constants
- Variables
- func AssetSeedAndPass(assetID uint32, appSeed []byte) ([]byte, []byte)
- func UnwrapErr(err error) error
- type Account
- type BalanceNote
- type BookFeed
- type BookUpdate
- type CandleUpdate
- type CandlesPayload
- type Coin
- type Config
- type Confirmations
- type ConnEventNote
- type Core
- func (c *Core) AccelerateOrder(pw []byte, oidB dex.Bytes, newFeeRate uint64) (string, error)
- func (c *Core) AccelerationEstimate(oidB dex.Bytes, newFeeRate uint64) (uint64, error)
- func (c *Core) AccountDisable(pw []byte, addr string) error
- func (c *Core) AccountExport(pw []byte, host string) (*Account, error)
- func (c *Core) AccountImport(pw []byte, acct Account) error
- func (c *Core) AckNotes(ids []dex.Bytes)
- func (c *Core) AssetBalance(assetID uint32) (*WalletBalance, error)
- func (c *Core) AutoWalletConfig(assetID uint32, walletType string) (map[string]string, error)
- func (c *Core) BackupDB(dst string, overwrite, compact bool) error
- func (c *Core) Book(dex string, base, quote uint32) (*OrderBook, error)
- func (c *Core) Cancel(pw []byte, oidB dex.Bytes) error
- func (c *Core) ChangeAppPass(appPW, newAppPW []byte) error
- func (c *Core) CloseWallet(assetID uint32) error
- func (c *Core) ConnectWallet(assetID uint32) error
- func (c *Core) CreateWallet(appPW, walletPW []byte, form *WalletForm) error
- func (c *Core) DeleteArchivedRecords(olderThan *time.Time, matchesFile, ordersFile string) error
- func (c *Core) DiscoverAccount(dexAddr string, appPW []byte, certI interface{}) (*Exchange, bool, error)
- func (c *Core) EstimateRegistrationTxFee(host string, certI interface{}, assetID uint32) (uint64, error)
- func (c *Core) Exchange(host string) (*Exchange, error)
- func (c *Core) Exchanges() map[string]*Exchange
- func (c *Core) ExportSeed(pw []byte) ([]byte, error)
- func (c *Core) FiatRateSources() map[string]bool
- func (c *Core) GetDEXConfig(dexAddr string, certI interface{}) (*Exchange, error)
- func (c *Core) InitializeClient(pw, restorationSeed []byte) error
- func (c *Core) IsInitialized() bool
- func (c *Core) Login(pw []byte) (*LoginResult, error)
- func (c *Core) Logout() error
- func (c *Core) MaxBuy(host string, base, quote uint32, rate uint64) (*MaxOrderEstimate, error)
- func (c *Core) MaxSell(host string, base, quote uint32) (*MaxOrderEstimate, error)
- func (c *Core) Network() dex.Network
- func (c *Core) NewDepositAddress(assetID uint32) (string, error)
- func (c *Core) NotificationFeed() <-chan Notification
- func (c *Core) OpenWallet(assetID uint32, appPW []byte) error
- func (c *Core) Order(oidB dex.Bytes) (*Order, error)
- func (c *Core) Orders(filter *OrderFilter) ([]*Order, error)
- func (c *Core) PreAccelerateOrder(oidB dex.Bytes) (*PreAccelerate, error)
- func (c *Core) PreOrder(form *TradeForm) (*OrderEstimate, error)
- func (c *Core) Ready() <-chan struct{}
- func (c *Core) ReconfigureWallet(appPW, newWalletPW []byte, form *WalletForm) error
- func (c *Core) RecoverWallet(assetID uint32, appPW []byte, force bool) error
- func (c *Core) Register(form *RegisterForm) (*RegisterResult, error)
- func (c *Core) RescanWallet(assetID uint32, force bool) error
- func (c *Core) Run(ctx context.Context)
- func (c *Core) Send(pw []byte, assetID uint32, value uint64, address string, subtract bool) (asset.Coin, error)
- func (c *Core) SetWalletPassword(appPW []byte, assetID uint32, newPW []byte) error
- func (c *Core) SupportedAssets() map[uint32]*SupportedAsset
- func (c *Core) SyncBook(host string, base, quote uint32) (BookFeed, error)
- func (c *Core) ToggleRateSourceStatus(source string, disable bool) error
- func (c *Core) Trade(pw []byte, form *TradeForm) (*Order, error)
- func (c *Core) UpdateCert(host string, cert []byte) error
- func (c *Core) UpdateDEXHost(oldHost, newHost string, appPW []byte, certI interface{}) (*Exchange, error)
- func (c *Core) User() *User
- func (c *Core) WalletLogFilePath(assetID uint32) (string, error)
- func (c *Core) WalletRestorationInfo(pw []byte, assetID uint32) ([]*asset.WalletRestoration, error)
- func (c *Core) WalletSettings(assetID uint32) (map[string]string, error)
- func (c *Core) WalletState(assetID uint32) *WalletState
- func (c *Core) Wallets() []*WalletState
- func (c *Core) Withdraw(pw []byte, assetID uint32, value uint64, address string) (asset.Coin, error)
- type DEXAuthNote
- type DEXBrief
- type EpochNotification
- type Error
- type Exchange
- type ExpirationErr
- type FeeAsset
- type FeeBreakdown
- type FeePaymentNote
- type FiatRatesNote
- type LoginResult
- type Market
- type MarketOrderBook
- type Match
- type MatchNote
- type MaxOrderEstimate
- type MiniOrder
- type Notification
- type Order
- type OrderBook
- type OrderEstimate
- type OrderFilter
- type OrderNote
- type OrderReader
- func (ord *OrderReader) AskString() string
- func (ord *OrderReader) AverageRateString() string
- func (ord *OrderReader) BaseAssetFees() string
- func (ord *OrderReader) BaseQtyString() string
- func (ord *OrderReader) Cancelable() bool
- func (ord *OrderReader) FilledFrom() string
- func (ord *OrderReader) FilledPercent() string
- func (ord *OrderReader) FilledTo() string
- func (ord *OrderReader) FromID() uint32
- func (ord *OrderReader) FromSymbol() string
- func (ord *OrderReader) FundingCoinIDs() []string
- func (ord *OrderReader) IsMarketBuy() bool
- func (ord *OrderReader) IsMarketOrder() bool
- func (ord *OrderReader) MatchReaders() []*matchReader
- func (ord *OrderReader) OfferString() string
- func (ord *OrderReader) QuoteAssetFees() string
- func (ord *OrderReader) RateString() string
- func (ord *OrderReader) RedemptionFeesString() string
- func (ord *OrderReader) SettledFrom() string
- func (ord *OrderReader) SettledPercent() string
- func (ord *OrderReader) SettledTo() string
- func (ord *OrderReader) SideString() string
- func (ord *OrderReader) SimpleRateString() string
- func (ord *OrderReader) StatusString() string
- func (ord *OrderReader) SwapFeesString() string
- func (ord *OrderReader) ToID() uint32
- func (ord *OrderReader) ToSymbol() string
- func (ord *OrderReader) TypeString() string
- type PendingFeeState
- type PreAccelerate
- type RegisterForm
- type RegisterResult
- type RemainderUpdate
- type SecurityNote
- type SendNote
- type ServerNotifyNote
- type SpotPriceNote
- type SupportedAsset
- type Topic
- type TradeForm
- type UpgradeNote
- type User
- type WalletBalance
- type WalletConfigNote
- type WalletForm
- type WalletState
- type WalletStateNote
Constants ¶
const ( NoteTypeFeePayment = "feepayment" NoteTypeSend = "send" NoteTypeOrder = "order" NoteTypeMatch = "match" NoteTypeEpoch = "epoch" NoteTypeConnEvent = "conn" NoteTypeBalance = "balance" NoteTypeSpots = "spots" NoteTypeWalletConfig = "walletconfig" NoteTypeWalletState = "walletstate" NoteTypeServerNotify = "notify" NoteTypeSecurity = "security" NoteTypeUpgrade = "upgrade" NoteTypeDEXAuth = "dex_auth" NoteTypeFiatRates = "fiatrateupdate" )
Notifications should use the following note type strings.
const ( FreshBookAction = "book" FreshCandlesAction = "candles" BookOrderAction = "book_order" EpochOrderAction = "epoch_order" UnbookOrderAction = "unbook_order" UpdateRemainingAction = "update_remaining" CandleUpdateAction = "candle_update" )
const (
// DefaultFiatCurrency is the currency for displaying assets fiat value.
DefaultFiatCurrency = "USD"
)
const (
DefaultResponseTimeout = comms.DefaultResponseTimeout
)
DefaultResponseTimeout is the default timeout for responses after a request is successfully sent.
Variables ¶
var ( // ActiveOrdersLogoutErr is returned from logout when there are active // orders. ActiveOrdersLogoutErr = errors.New("cannot log out with active orders") )
var CertStore = map[dex.Network]map[string][]byte{ dex.Mainnet: { "dex.decred.org:7232": dexDotDecredCert, }, dex.Testnet: { "dex-test.ssgen.io:7232": dexTestSSGenCert, }, dex.Simnet: { "127.0.0.1:17273": simnetHarnessCert, }, }
var HDKeyPurpose uint32 = hdkeychain.HardenedKeyStart + 0x646578 // ASCII "dex"
HDKeyPurpose is here because we're high-jacking the BIP-32 + BIP-43 HD key system to create child keys, so we must set a the purpose field to create an hdkeychain.ExtendedKey.
Functions ¶
func AssetSeedAndPass ¶ added in v0.4.0
AssetSeedAndPass derives the wallet seed and password that would be used to create a native wallet for a particular asset and application seed. Depending on external wallet software and their key derivation paths, this seed may be usable for accessing funds outside of DEX applications, e.g. btcwallet.
Types ¶
type Account ¶ added in v0.2.0
type Account struct { Host string `json:"host"` AccountID string `json:"accountID"` PrivKey string `json:"privKey"` DEXPubKey string `json:"DEXPubKey"` Cert string `json:"cert"` FeeCoin string `json:"feeCoin"` FeeProofSig string `json:"feeProofSig"` FeeProofStamp uint64 `json:"FeeProofStamp"` }
Account holds data returned from AccountExport.
type BalanceNote ¶
type BalanceNote struct { db.Notification AssetID uint32 `json:"assetID"` Balance *WalletBalance `json:"balance"` }
BalanceNote is an update to a wallet's balance.
type BookFeed ¶
type BookFeed interface { Next() <-chan *BookUpdate Close() Candles(dur string) error }
BookFeed manages a channel for receiving order book updates. It is imperative that the feeder (BookFeed).Close() when no longer using the feed.
type BookUpdate ¶
type BookUpdate struct { Action string `json:"action"` Host string `json:"host"` MarketID string `json:"marketID"` Payload interface{} `json:"payload"` }
BookUpdate is an order book update.
type CandleUpdate ¶ added in v0.4.0
type CandlesPayload ¶ added in v0.4.0
type Coin ¶ added in v0.2.0
type Coin struct { ID dex.Bytes `json:"id"` StringID string `json:"stringID"` AssetID uint32 `json:"assetID"` Symbol string `json:"symbol"` // Confs is populated only if this is a swap coin and we are waiting for // confirmations e.g. when this is the maker's swap and we're in // MakerSwapCast, or this is the takers swap, and we're in TakerSwapCast. Confs *Confirmations `json:"confs,omitempty"` }
Coin encodes both the coin ID and the asset-dependent string representation of the coin ID.
func (*Coin) SetConfirmations ¶ added in v0.2.0
SetConfirmations sets the Confs field of the Coin.
type Config ¶
type Config struct { // DBPath is a filepath to use for the client database. If the database does // not already exist, it will be created. DBPath string // Net is the current network. Net dex.Network // Logger is the Core's logger and is also used to create the sub-loggers // for the asset backends. Logger dex.Logger // Onion is the address (host:port) of a Tor proxy for use with DEX hosts // with a .onion address. To use Tor with regular DEX addresses as well, set // TorProxy. Onion string // TorProxy specifies the address of a Tor proxy server. TorProxy string // TorIsolation specifies whether to enable Tor circuit isolation. TorIsolation bool // Language. A BCP 47 language tag. Default is en-US. Language string }
Config is the configuration for the Core.
type Confirmations ¶ added in v0.2.0
Confirmations is the confirmation count and confirmation requirement of a Coin.
type ConnEventNote ¶
type ConnEventNote struct { db.Notification Host string `json:"host"` ConnectionStatus comms.ConnectionStatus `json:"connectionStatus"` }
ConnEventNote is a notification regarding individual DEX connection status.
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core is the core client application. Core manages DEX connections, wallets, database access, match negotiation and more.
func (*Core) AccelerateOrder ¶ added in v0.5.0
AccelerateOrder will use the Child-Pays-For-Parent technique to accelerate the swap transactions in an order.
func (*Core) AccelerationEstimate ¶ added in v0.5.0
AccelerationEstimate returns the amount of funds that would be needed to accelerate the swap transactions in an order to a desired fee rate.
func (*Core) AccountDisable ¶ added in v0.2.0
AccountDisable is used to disable an account by given host and application password.
func (*Core) AccountExport ¶ added in v0.2.0
AccountExport is used to retrieve account by host for export.
func (*Core) AccountImport ¶ added in v0.2.0
AccountImport is used import an existing account into the db.
func (*Core) AssetBalance ¶
func (c *Core) AssetBalance(assetID uint32) (*WalletBalance, error)
AssetBalance retrieves and updates the current wallet balance.
func (*Core) AutoWalletConfig ¶
AutoWalletConfig attempts to load setting from a wallet package's asset.WalletInfo.DefaultConfigPath. If settings are not found, an empty map is returned.
func (*Core) BackupDB ¶ added in v0.4.2
BackupDB makes a backup of the database at the specified location, optionally overwriting any existing file and compacting the database.
func (*Core) Book ¶
Book fetches the order book. If a subscription doesn't exist, one will be attempted and immediately closed.
func (*Core) ChangeAppPass ¶ added in v0.2.0
ChangeAppPass updates the application password to the provided new password after validating the current password.
func (*Core) CloseWallet ¶
CloseWallet closes the wallet for the specified asset. The wallet cannot be closed if there are active negotiations for the asset.
func (*Core) ConnectWallet ¶
ConnectWallet connects to the wallet without unlocking.
func (*Core) CreateWallet ¶
func (c *Core) CreateWallet(appPW, walletPW []byte, form *WalletForm) error
CreateWallet creates a new exchange wallet.
func (*Core) DeleteArchivedRecords ¶ added in v0.5.0
DeleteArchivedRecords deletes archived matches from the database. Optionally set a time to delete records after and file paths to save deleted records as comma separated values. If a nil *time.Time is provided, current time is used.
func (*Core) DiscoverAccount ¶ added in v0.4.0
func (c *Core) DiscoverAccount(dexAddr string, appPW []byte, certI interface{}) (*Exchange, bool, error)
DiscoverAccount fetches the DEX server's config, and if the server supports the new deterministic account derivation scheme by providing its public key in the config response, DiscoverAccount also checks if the account is already paid. If the returned paid value is true, the account is ready for immediate use. If paid is false, Register should be used to complete the registration. For an older server that does not provide its pubkey in the config response, paid will always be false and the user should proceed to use Register.
The purpose of DiscoverAccount is existing account discovery when the client has been restored from seed. As such, DiscoverAccount is not strictly necessary to register on a DEX, and Register may be called directly, although it requires the expected fee amount as an additional input and it will pay the fee if the account is not discovered and paid.
func (*Core) EstimateRegistrationTxFee ¶ added in v0.4.3
func (c *Core) EstimateRegistrationTxFee(host string, certI interface{}, assetID uint32) (uint64, error)
EstimateRegistrationTxFee provides an estimate for the tx fee needed to pay the registration fee for a certain asset. The dex host is required because the dex server is used as a fallback to determine the current fee rate in case the client wallet is unable to do it.
func (*Core) Exchange ¶ added in v0.5.0
Exchange returns an exchange with a certain host. It returns an error if no exchange exists at that host.
func (*Core) Exchanges ¶
Exchanges creates a map of *Exchange keyed by host, including markets and orders.
func (*Core) ExportSeed ¶ added in v0.4.0
ExportSeed exports the application seed.
func (*Core) FiatRateSources ¶ added in v0.5.0
FiatRateSources returns a list of fiat rate sources and their individual status.
func (*Core) GetDEXConfig ¶ added in v0.2.0
GetDEXConfig creates a temporary connection to the specified DEX Server and fetches the full exchange config. The connection is closed after the config is retrieved. An error is returned if user is already registered to the DEX since a DEX connection is already established and the config is accessible via the User or Exchanges methods. A TLS certificate, certI, can be provided as either a string filename, or []byte file contents.
func (*Core) InitializeClient ¶
InitializeClient sets the initial app-wide password and app seed for the client. The seed argument should be left nil unless restoring from seed.
func (*Core) IsInitialized ¶
IsInitialized checks if the app is already initialized.
func (*Core) Login ¶
func (c *Core) Login(pw []byte) (*LoginResult, error)
Login logs the user in, decrypting the account keys for all known DEXes.
func (*Core) MaxBuy ¶ added in v0.2.0
MaxBuy is the maximum-sized *OrderEstimate for a buy order on the specified market. An order rate must be provided, since the number of lots available for trading will vary based on the rate for a buy order (unlike a sell order).
func (*Core) MaxSell ¶ added in v0.2.0
func (c *Core) MaxSell(host string, base, quote uint32) (*MaxOrderEstimate, error)
MaxSell is the maximum-sized *OrderEstimate for a sell order on the specified market.
func (*Core) NewDepositAddress ¶
NewDepositAddress retrieves a new deposit address from the specified asset's wallet, saves it to the database, and emits a notification.
func (*Core) NotificationFeed ¶
func (c *Core) NotificationFeed() <-chan Notification
NotificationFeed returns a new receiving channel for notifications. The channel has capacity 1024, and should be monitored for the lifetime of the Core. Blocking channels are silently ignored.
func (*Core) OpenWallet ¶
OpenWallet opens (unlocks) the wallet for use.
func (*Core) Orders ¶
func (c *Core) Orders(filter *OrderFilter) ([]*Order, error)
Orders fetches a batch of user orders, filtered with the provided OrderFilter.
func (*Core) PreAccelerateOrder ¶ added in v0.5.0
func (c *Core) PreAccelerateOrder(oidB dex.Bytes) (*PreAccelerate, error)
PreAccelerateOrder returns information the user can use to decide how much to accelerate stuck swap transactions in an order.
func (*Core) PreOrder ¶ added in v0.2.0
func (c *Core) PreOrder(form *TradeForm) (*OrderEstimate, error)
func (*Core) Ready ¶
func (c *Core) Ready() <-chan struct{}
Ready returns a channel that is closed when Run completes its initialization tasks and Core becomes ready for use.
func (*Core) ReconfigureWallet ¶
func (c *Core) ReconfigureWallet(appPW, newWalletPW []byte, form *WalletForm) error
ReconfigureWallet updates the wallet configuration settings, it also updates the password if newWalletPW is non-nil. Do not make concurrent calls to ReconfigureWallet for the same asset.
func (*Core) RecoverWallet ¶ added in v0.5.0
RecoverWallet will retrieve some recovery information from the wallet, which may not be possible if the wallet is too corrupted, disconnect and destroy the old wallet, create a new one, and if the recovery information was retrieved from the old wallet, send this information to the new one. If force is false, this will check for active orders involving this asset before initiating a rescan. WARNING: It is ill-advised to initiate a wallet recovery with active orders unless the wallet db is definitely corrupted and even a rescan will not save it.
DO NOT MAKE CONCURRENT CALLS TO THIS FUNCTION WITH THE SAME ASSET.
func (*Core) Register ¶
func (c *Core) Register(form *RegisterForm) (*RegisterResult, error)
Register registers an account with a new DEX. If an error occurs while fetching the DEX configuration or creating the fee transaction, it will be returned immediately. A thread will be started to wait for the requisite confirmations and send the fee notification to the server. Any error returned from that thread is sent as a notification.
func (*Core) RescanWallet ¶ added in v0.4.1
RescanWallet will issue a Rescan command to the wallet if supported by the wallet implementation. It is up to the underlying wallet backend if and how to implement this functionality. It may be asynchronous. Core will emit wallet state notifications until the rescan is complete. If force is false, this will check for active orders involving this asset before initiating a rescan. WARNING: It is ill-advised to initiate a wallet rescan with active orders unless as a last ditch effort to get the wallet to recognize a transaction needed to complete a swap.
func (*Core) Send ¶ added in v0.5.0
func (c *Core) Send(pw []byte, assetID uint32, value uint64, address string, subtract bool) (asset.Coin, error)
Send initiates either send or withdraw from an exchange wallet. if subtract is true, fees are subtracted from the value else fees are taken from the exchange wallet. The client password must be provided as an additional verification.
func (*Core) SetWalletPassword ¶
SetWalletPassword updates the (encrypted) password for the wallet. Returns passwordErr if provided newPW is nil. The wallet will be connected if it is not already.
func (*Core) SupportedAssets ¶
func (c *Core) SupportedAssets() map[uint32]*SupportedAsset
SupportedAssets returns a map of asset information for supported assets.
func (*Core) SyncBook ¶
SyncBook subscribes to the order book and returns the book and a BookFeed to receive order book updates. The BookFeed must be Close()d when it is no longer in use.
func (*Core) ToggleRateSourceStatus ¶ added in v0.5.0
ToggleRateSourceStatus toggles a fiat rate source status. If disable is true, the fiat rate source is disabled, otherwise the rate source is enabled.
func (*Core) UpdateCert ¶ added in v0.5.0
UpdateCert attempts to connect to a server using a new TLS certificate. If the connection is successful, then the cert in the database is updated.
func (*Core) UpdateDEXHost ¶ added in v0.5.0
func (c *Core) UpdateDEXHost(oldHost, newHost string, appPW []byte, certI interface{}) (*Exchange, error)
UpdateDEXHost updates the host for a connection to a dex. The dex at oldHost and newHost must be the same dex, which means that the dex at both hosts use the same public key.
func (*Core) WalletLogFilePath ¶ added in v0.4.1
WalletLogFilePath returns the path to the wallet's log file.
func (*Core) WalletRestorationInfo ¶ added in v0.5.0
WalletRestorationInfo returns information about how to restore the currently loaded wallet for assetID in various external wallet software. This function will return an error if the currently loaded wallet for assetID does not implement the WalletRestorer interface.
func (*Core) WalletSettings ¶
WalletSettings fetches the current wallet configuration details from the database.
func (*Core) WalletState ¶
func (c *Core) WalletState(assetID uint32) *WalletState
WalletState returns the *WalletState for the asset ID.
func (*Core) Wallets ¶
func (c *Core) Wallets() []*WalletState
Wallets creates a slice of WalletState for all known wallets.
func (*Core) Withdraw ¶
func (c *Core) Withdraw(pw []byte, assetID uint32, value uint64, address string) (asset.Coin, error)
Withdraw initiates a withdraw from an exchange wallet. The client password must be provided as an additional verification. This method is DEPRECATED. Use Send with the subtract option instead.
type DEXAuthNote ¶
type DEXAuthNote struct { db.Notification Host string `json:"host"` Authenticated bool `json:"authenticated"` }
DEXAuthNote is a notification regarding individual DEX authentication status.
type DEXBrief ¶
type DEXBrief struct { Host string `json:"host"` AcctID string `json:"acctID"` Authed bool `json:"authed"` AuthErr string `json:"autherr,omitempty"` TradeIDs []string `json:"tradeIDs"` }
DEXBrief holds data returned from initializeDEXConnections.
type EpochNotification ¶
type EpochNotification struct { db.Notification Host string `json:"host"` MarketID string `json:"marketID"` Epoch uint64 `json:"epoch"` }
EpochNotification is a data notification that a new epoch has begun.
func (*EpochNotification) String ¶
func (on *EpochNotification) String() string
String supplements db.Notification's Stringer with the Epoch index.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is an error code and a wrapped error.
type Exchange ¶
type Exchange struct { Host string `json:"host"` AcctID string `json:"acctID"` Markets map[string]*Market `json:"markets"` Assets map[uint32]*dex.Asset `json:"assets"` ConnectionStatus comms.ConnectionStatus `json:"connectionStatus"` Fee *FeeAsset `json:"feeAsset"` // DEPRECATED. DCR. RegFees map[string]*FeeAsset `json:"regFees"` PendingFee *PendingFeeState `json:"pendingFee,omitempty"` CandleDurs []string `json:"candleDurs"` }
Exchange represents a single DEX with any number of markets.
type ExpirationErr ¶
type ExpirationErr string
ExpirationErr indicates that the wait.TickerQueue has expired a waiter, e.g. a reported coin was not found before the set expiration time.
func (ExpirationErr) Error ¶
func (err ExpirationErr) Error() string
Error satisfies the error interface for ExpirationErr.
type FeeAsset ¶ added in v0.2.0
type FeeAsset struct { ID uint32 `json:"id"` Confs uint32 `json:"confs"` Amt uint64 `json:"amount"` }
FeeAsset has an analogous msgjson type for server providing supported registration fee assets.
type FeeBreakdown ¶
FeeBreakdown is categorized fee information.
type FeePaymentNote ¶
type FeePaymentNote struct { db.Notification Asset *uint32 `json:"asset,omitempty"` Confirmations *uint32 `json:"confirmations,omitempty"` Dex string `json:"dex,omitempty"` }
FeePaymentNote is a notification regarding registration fee payment.
type FiatRatesNote ¶ added in v0.5.0
type FiatRatesNote struct { db.Notification FiatRates map[uint32]float64 `json:"fiatRates"` }
FiatRatesNote is an update of fiat rate data for assets.
type LoginResult ¶
type LoginResult struct { Notifications []*db.Notification `json:"notifications"` DEXes []*DEXBrief `json:"dexes"` }
LoginResult holds data returned from Login.
type Market ¶
type Market struct { Name string `json:"name"` BaseID uint32 `json:"baseid"` BaseSymbol string `json:"basesymbol"` QuoteID uint32 `json:"quoteid"` QuoteSymbol string `json:"quotesymbol"` LotSize uint64 `json:"lotsize"` RateStep uint64 `json:"ratestep"` EpochLen uint64 `json:"epochlen"` StartEpoch uint64 `json:"startepoch"` MarketBuyBuffer float64 `json:"buybuffer"` Orders []*Order `json:"orders"` SpotPrice *msgjson.Spot `json:"spot"` }
Market is market info.
func (*Market) BaseContractLocked ¶
BaseContractLocked is the amount of base asset locked in un-redeemed contracts.
func (*Market) BaseOrderLocked ¶
BaseOrderLocked is the amount of base asset locked in epoch or booked orders.
func (*Market) QuoteContractLocked ¶
QuoteContractLocked is the amount of quote asset locked in un-redeemed contracts.
func (*Market) QuoteOrderLocked ¶
QuoteOrderLocked is the amount of quote asset locked in epoch or booked orders.
type MarketOrderBook ¶
type MarketOrderBook struct { Base uint32 `json:"base"` Quote uint32 `json:"quote"` Book *OrderBook `json:"book"` }
MarketOrderBook is used as the BookUpdate's Payload with the FreshBookAction. The subscriber will likely need to translate into a JSON tagged type.
type Match ¶
type Match struct { MatchID dex.Bytes `json:"matchID"` Status order.MatchStatus `json:"status"` Active bool `json:"active"` Revoked bool `json:"revoked"` Rate uint64 `json:"rate"` Qty uint64 `json:"qty"` Side order.MatchSide `json:"side"` FeeRate uint64 `json:"feeRate"` Swap *Coin `json:"swap,omitempty"` CounterSwap *Coin `json:"counterSwap,omitempty"` Redeem *Coin `json:"redeem,omitempty"` CounterRedeem *Coin `json:"counterRedeem,omitempty"` Refund *Coin `json:"refund,omitempty"` Stamp uint64 `json:"stamp"` // Server's time stamp - we have no local time recorded IsCancel bool `json:"isCancel"` }
Match represents a match on an order. An order may have many matches.
type MatchNote ¶ added in v0.2.0
type MatchNote struct { db.Notification OrderID dex.Bytes `json:"orderID"` Match *Match `json:"match"` Host string `json:"host"` MarketID string `json:"marketID"` }
MatchNote is a notification about a match.
type MaxOrderEstimate ¶ added in v0.2.0
type MaxOrderEstimate struct { Swap *asset.SwapEstimate `json:"swap"` Redeem *asset.RedeemEstimate `json:"redeem"` }
MaxOrderEstimate is an estimate of the fees and locked amounts associated with an order.
type MiniOrder ¶
type MiniOrder struct { Qty float64 `json:"qty"` QtyAtomic uint64 `json:"qtyAtomic"` Rate float64 `json:"rate"` MsgRate uint64 `json:"msgRate"` Epoch uint64 `json:"epoch,omitempty"` Sell bool `json:"sell"` Token string `json:"token"` }
MiniOrder is minimal information about an order in a market's order book. Replaced MiniOrder, which had a float Qty in conventional units.
type Notification ¶
type Notification interface { // Type is a string ID unique to the concrete type. Type() string // Topic is a string ID unique to the message subject. Since subjects must // be translated, we cannot rely on the subject to programatically identify // the message. Topic() Topic // Subject is a short description of the notification contents. When displayed // to the user, the Subject will typically be given visual prominence. For // notifications with Severity < Poke (not meant for display), the Subject // field may be repurposed as a second-level category ID. Subject() string // Details should contain more detailed information. Details() string // Severity is the notification severity. Severity() db.Severity // Time is the notification timestamp. The timestamp is set in // db.NewNotification. Time is a UNIX timestamp, in milliseconds. Time() uint64 // Acked is true if the user has seen the notification. Acknowledgement is // recorded with (*Core).AckNotes. Acked() bool // ID should be unique, except in the case of identical copies of // db.Notification where the IDs should be the same. ID() dex.Bytes // Stamp sets the notification timestamp. If db.NewNotification is used to // construct the db.Notification, the timestamp will already be set. Stamp() // DBNote returns the underlying *db.Notification. DBNote() *db.Notification // String generates a compact human-readable representation of the // Notification that is suitable for logging. String() string }
Notification is an interface for a user notification. Notification is satisfied by db.Notification, so concrete types can embed the db type.
type Order ¶
type Order struct { Host string `json:"host"` BaseID uint32 `json:"baseID"` BaseSymbol string `json:"baseSymbol"` QuoteID uint32 `json:"quoteID"` QuoteSymbol string `json:"quoteSymbol"` MarketID string `json:"market"` Type order.OrderType `json:"type"` ID dex.Bytes `json:"id"` Stamp uint64 `json:"stamp"` // Server's time stamp SubmitTime uint64 `json:"submitTime"` Sig dex.Bytes `json:"sig"` Status order.OrderStatus `json:"status"` Epoch uint64 `json:"epoch"` Qty uint64 `json:"qty"` Sell bool `json:"sell"` Filled uint64 `json:"filled"` Matches []*Match `json:"matches"` Cancelling bool `json:"cancelling"` Canceled bool `json:"canceled"` FeesPaid *FeeBreakdown `json:"feesPaid"` FundingCoins []*Coin `json:"fundingCoins"` LockedAmt uint64 `json:"lockedamt"` AccelerationCoins []*Coin `json:"accelerationCoins"` Rate uint64 `json:"rate"` // limit only TimeInForce order.TimeInForce `json:"tif"` // limit only TargetOrderID dex.Bytes `json:"targetOrderID"` // cancel only }
Order is core's general type for an order. An order may be a market, limit, or cancel order. Some fields are only relevant to particular order types.
type OrderBook ¶
type OrderBook struct { Sells []*MiniOrder `json:"sells"` Buys []*MiniOrder `json:"buys"` Epoch []*MiniOrder `json:"epoch"` }
OrderBook represents an order book, which are sorted buys and sells, and unsorted epoch orders.
type OrderEstimate ¶ added in v0.2.0
type OrderEstimate struct { Swap *asset.PreSwap `json:"swap"` Redeem *asset.PreRedeem `json:"redeem"` }
OrderEstimate is a Core.PreOrder estimate.
type OrderFilter ¶
type OrderFilter struct { N int `json:"n"` Offset dex.Bytes `json:"offset"` Hosts []string `json:"hosts"` Assets []uint32 `json:"assets"` Statuses []order.OrderStatus `json:"statuses"` }
OrderFilter is almost the same as db.OrderFilter, except the Offset order ID is a dex.Bytes instead of a order.OrderID.
type OrderNote ¶
type OrderNote struct { db.Notification Order *Order `json:"order"` }
OrderNote is a notification about an order or a match.
type OrderReader ¶ added in v0.5.0
OrderReader wraps a Order and provides methods for info display. Whenever possible, add an OrderReader methods rather than a template func.
func (*OrderReader) AskString ¶ added in v0.5.0
func (ord *OrderReader) AskString() string
AskString will print the minimum received amount for the filled limit order. The actual settled amount may be more.
func (*OrderReader) AverageRateString ¶ added in v0.5.0
func (ord *OrderReader) AverageRateString() string
AverageRateString returns a formatting string containing the average rate of the matches that have been filled in an order.
func (*OrderReader) BaseAssetFees ¶ added in v0.5.0
func (ord *OrderReader) BaseAssetFees() string
BaseAssetFees is a formatted string of the fees paid in the base asset.
func (*OrderReader) BaseQtyString ¶ added in v0.5.0
func (ord *OrderReader) BaseQtyString() string
BaseQtyString formats the order quantity in units of the base asset.
func (*OrderReader) Cancelable ¶ added in v0.5.0
func (ord *OrderReader) Cancelable() bool
Cancelable will be true for standing limit orders in status epoch or booked.
func (*OrderReader) FilledFrom ¶ added in v0.5.0
func (ord *OrderReader) FilledFrom() string
FilledFrom is the sum filled in units of the outgoing asset. Excludes cancel matches.
func (*OrderReader) FilledPercent ¶ added in v0.5.0
func (ord *OrderReader) FilledPercent() string
FilledPercent is the percent of the order that has filled, without percent sign. Excludes cancel matches.
func (*OrderReader) FilledTo ¶ added in v0.5.0
func (ord *OrderReader) FilledTo() string
FilledTo is the sum filled in units of the incoming asset. Excludes cancel matches.
func (*OrderReader) FromID ¶ added in v0.5.0
func (ord *OrderReader) FromID() uint32
FromID is the asset ID of the asset which will be sent.
func (*OrderReader) FromSymbol ¶ added in v0.5.0
func (ord *OrderReader) FromSymbol() string
FromSymbol is the symbol of the asset which will be sent.
func (*OrderReader) FundingCoinIDs ¶ added in v0.5.0
func (ord *OrderReader) FundingCoinIDs() []string
func (*OrderReader) IsMarketBuy ¶ added in v0.5.0
func (ord *OrderReader) IsMarketBuy() bool
IsMarketBuy is true if this is a market buy order.
func (*OrderReader) IsMarketOrder ¶ added in v0.5.0
func (ord *OrderReader) IsMarketOrder() bool
IsMarketOrder is true if this is a market order.
func (*OrderReader) MatchReaders ¶ added in v0.5.0
func (ord *OrderReader) MatchReaders() []*matchReader
MatchReaders creates a slice of *matchReader for the order's matches.
func (*OrderReader) OfferString ¶ added in v0.5.0
func (ord *OrderReader) OfferString() string
OfferString formats the order quantity in units of the outgoing asset, performing a conversion if necessary.
func (*OrderReader) QuoteAssetFees ¶ added in v0.5.0
func (ord *OrderReader) QuoteAssetFees() string
QuoteAssetFees is a formatted string of the fees paid in the quote asset.
func (*OrderReader) RateString ¶ added in v0.5.0
func (ord *OrderReader) RateString() string
RateString is a formatted rate with units.
func (*OrderReader) RedemptionFeesString ¶ added in v0.5.0
func (ord *OrderReader) RedemptionFeesString() string
RedemptionFeesString is a formatted string of the paid redemption fees.
func (*OrderReader) SettledFrom ¶ added in v0.5.0
func (ord *OrderReader) SettledFrom() string
SettledFrom is the sum settled outgoing asset.
func (*OrderReader) SettledPercent ¶ added in v0.5.0
func (ord *OrderReader) SettledPercent() string
SettledPercent is the percent of the order which has completed settlement.
func (*OrderReader) SettledTo ¶ added in v0.5.0
func (ord *OrderReader) SettledTo() string
SettledTo is the sum settled of incoming asset.
func (*OrderReader) SideString ¶ added in v0.5.0
func (ord *OrderReader) SideString() string
SideString is "sell" for sell orders, "buy" for buy orders, and "" for cancels.
func (*OrderReader) SimpleRateString ¶ added in v0.5.0
func (ord *OrderReader) SimpleRateString() string
SimpleRateString is the formatted match rate.
func (*OrderReader) StatusString ¶ added in v0.5.0
func (ord *OrderReader) StatusString() string
StatusString is the order status.
func (*OrderReader) SwapFeesString ¶ added in v0.5.0
func (ord *OrderReader) SwapFeesString() string
SwapFeesString is a formatted string of the paid swap fees.
func (*OrderReader) ToID ¶ added in v0.5.0
func (ord *OrderReader) ToID() uint32
FromID is the asset ID of the asset which will be received.
func (*OrderReader) ToSymbol ¶ added in v0.5.0
func (ord *OrderReader) ToSymbol() string
FromSymbol is the symbol of the asset which will be received.
func (*OrderReader) TypeString ¶ added in v0.5.0
func (ord *OrderReader) TypeString() string
TypeString combines the order type and side into a single string.
type PendingFeeState ¶ added in v0.4.0
type PendingFeeState struct { Symbol string `json:"symbol"` AssetID uint32 `json:"assetID"` Confs uint32 `json:"confs"` }
PendingFeeState conveys a pending registration fee's asset and current confirmation count.
type PreAccelerate ¶ added in v0.5.0
type PreAccelerate struct { SwapRate uint64 `json:"swapRate"` SuggestedRate uint64 `json:"suggestedRate"` SuggestedRange asset.XYRange `json:"suggestedRange"` EarlyAcceleration *asset.EarlyAcceleration `json:"earlyAcceleration,omitempty"` }
PreAccelerate gives information that the user can use to decide on how much to accelerate stuck swap transactions in an order.
type RegisterForm ¶
type RegisterForm struct { Addr string `json:"url"` AppPass encode.PassBytes `json:"appPass"` Fee uint64 `json:"fee"` Asset *uint32 `json:"assetID,omitempty"` // do not default to 0 // Cert can be a string, which is interpreted as a filepath, or a []byte, // which is interpreted as the file contents of the certificate. Cert interface{} `json:"cert"` }
RegisterForm is information necessary to register an account on a DEX.
type RegisterResult ¶
RegisterResult holds data returned from Register.
type RemainderUpdate ¶ added in v0.4.0
type RemainderUpdate struct { Token string `json:"token"` Qty float64 `json:"qty"` QtyAtomic uint64 `json:"qtyAtomic"` }
RemainderUpdate is an update to the quantity for an order on the order book. Replaced RemainingUpdate, which had a float Qty in conventional units.
type SecurityNote ¶ added in v0.4.0
type SecurityNote struct {
db.Notification
}
SecurityNote is a note regarding application security, credentials, or authentication.
type SendNote ¶ added in v0.5.0
type SendNote struct {
db.Notification
}
SendNote is a notification regarding a requested send or withdraw.
type ServerNotifyNote ¶
type ServerNotifyNote struct {
db.Notification
}
ServerNotifyNote is a notification containing a server-originating message.
type SpotPriceNote ¶ added in v0.4.0
type SpotPriceNote struct { db.Notification Host string `json:"host"` Spots map[string]*msgjson.Spot `json:"spots"` }
SpotPriceNote is a notification of an update to the market's spot price.
type SupportedAsset ¶
type SupportedAsset struct { ID uint32 `json:"id"` Symbol string `json:"symbol"` Wallet *WalletState `json:"wallet"` Info *asset.WalletInfo `json:"info"` }
SupportedAsset is data about an asset and possibly the wallet associated with it.
type Topic ¶ added in v0.4.0
Topic is a language-independent unique ID for a Notification.
const ( TopicFeePaymentInProgress Topic = "FeePaymentInProgress" TopicRegUpdate Topic = "RegUpdate" TopicFeePaymentError Topic = "FeePaymentError" TopicAccountRegistered Topic = "AccountRegistered" TopicAccountUnlockError Topic = "AccountUnlockError" TopicFeeCoinError Topic = "FeeCoinError" TopicWalletConnectionWarning Topic = "WalletConnectionWarning" TopicWalletUnlockError Topic = "WalletUnlockError" TopicWalletPeersWarning Topic = "WalletPeersWarning" TopicWalletCommsWarning Topic = "WalletCommsWarning" TopicWalletPeersRestored Topic = "WalletPeersRestored" )
const ( TopicOrderLoadFailure Topic = "OrderLoadFailure" TopicOrderPlaced Topic = "OrderPlaced" TopicYoloPlaced Topic = "YoloPlaced" TopicMissingMatches Topic = "MissingMatches" TopicWalletMissing Topic = "WalletMissing" TopicMatchErrorCoin Topic = "MatchErrorCoin" TopicMatchErrorContract Topic = "MatchErrorContract" TopicMatchRecoveryError Topic = "MatchRecoveryError" TopicOrderCoinError Topic = "OrderCoinError" TopicOrderCoinFetchError Topic = "OrderCoinFetchError" TopicPreimageSent Topic = "PreimageSent" TopicCancelPreimageSent Topic = "CancelPreimageSent" TopicMissedCancel Topic = "MissedCancel" TopicOrderBooked Topic = "OrderBooked" TopicNoMatch Topic = "NoMatch" TopicOrderCanceled Topic = "OrderCanceled" TopicCancel Topic = "Cancel" TopicMatchesMade Topic = "MatchesMade" TopicSwapSendError Topic = "SwapSendError" TopicInitError Topic = "InitError" TopicReportRedeemError Topic = "ReportRedeemError" TopicSwapsInitiated Topic = "SwapsInitiated" TopicRedemptionError Topic = "RedemptionError" TopicMatchComplete Topic = "MatchComplete" TopicRefundFailure Topic = "RefundFailure" TopicMatchesRefunded Topic = "MatchesRefunded" TopicMatchRevoked Topic = "MatchRevoked" TopicOrderRevoked Topic = "OrderRevoked" TopicOrderAutoRevoked Topic = "OrderAutoRevoked" TopicMatchRecovered Topic = "MatchRecovered" TopicCancellingOrder Topic = "CancellingOrder" TopicOrderStatusUpdate Topic = "OrderStatusUpdate" TopicMatchResolutionError Topic = "MatchResolutionError" TopicFailedCancel Topic = "FailedCancel" TopicOrderLoaded Topic = "OrderLoaded" TopicOrderRetired Topic = "OrderRetired" )
const ( TopicMarketSuspendScheduled Topic = "MarketSuspendScheduled" TopicMarketSuspended Topic = "MarketSuspended" TopicMarketSuspendedWithPurge Topic = "MarketSuspendedWithPurge" TopicMarketResumeScheduled Topic = "MarketResumeScheduled" TopicMarketResumed Topic = "MarketResumed" TopicPenalized Topic = "Penalized" TopicDEXNotification Topic = "DEXNotification" )
const TopicBalanceUpdated Topic = "BalanceUpdated"
const TopicEpoch Topic = "Epoch"
const TopicFiatRatesUpdate Topic = "fiatrateupdate"
const TopicSpotsUpdate Topic = "SpotsUpdate"
const (
TopicUpgradeNeeded Topic = "UpgradeNeeded"
)
const TopicWalletState Topic = "WalletState"
type TradeForm ¶
type TradeForm struct { Host string `json:"host"` IsLimit bool `json:"isLimit"` Sell bool `json:"sell"` Base uint32 `json:"base"` Quote uint32 `json:"quote"` Qty uint64 `json:"qty"` Rate uint64 `json:"rate"` TifNow bool `json:"tifnow"` Options map[string]string `json:"options"` }
TradeForm is used to place a market or limit order
type UpgradeNote ¶ added in v0.4.0
type UpgradeNote struct {
db.Notification
}
UpgradeNote is a notification containing a .
type User ¶
type User struct { Exchanges map[string]*Exchange `json:"exchanges"` Initialized bool `json:"inited"` SeedGenerationTime uint64 `json:"seedgentime"` Assets map[uint32]*SupportedAsset `json:"assets"` FiatRates map[uint32]float64 `json:"fiatRates"` }
User is information about the user's wallets and DEX accounts.
type WalletBalance ¶
type WalletBalance struct { *db.Balance // OrderLocked is the total amount of funds that is currently locked // for swap, but not actually swapped yet. This amount is also included // in the `Locked` balance value. OrderLocked uint64 `json:"orderlocked"` // ContractLocked is the total amount of funds locked in unspent // (i.e. unredeemed / unrefunded) swap contracts. ContractLocked uint64 `json:"contractlocked"` }
WalletBalance is an exchange wallet's balance which includes contractlocked amounts in addition to other balance details stored in db.
type WalletConfigNote ¶
type WalletConfigNote struct { db.Notification Wallet *WalletState `json:"wallet"` }
WalletConfigNote is a notification regarding a change in wallet configuration.
type WalletForm ¶
WalletForm is information necessary to create a new exchange wallet. The ConfigText, if provided, will be parsed for wallet connection settings.
type WalletState ¶
type WalletState struct { Symbol string `json:"symbol"` AssetID uint32 `json:"assetID"` Version uint32 `json:"version"` WalletType string `json:"type"` Traits asset.WalletTrait `json:"traits"` Open bool `json:"open"` Running bool `json:"running"` Balance *WalletBalance `json:"balance"` Address string `json:"address"` Units string `json:"units"` Encrypted bool `json:"encrypted"` PeerCount uint32 `json:"peerCount"` Synced bool `json:"synced"` SyncProgress float32 `json:"syncProgress"` }
WalletState is the current status of an exchange wallet.
type WalletStateNote ¶
type WalletStateNote WalletConfigNote
WalletStateNote is a notification regarding a change in wallet state, including: creation, locking, unlocking, and connect. This is intended to be a Data Severity notification.