Documentation ¶
Index ¶
- Constants
- type Acknowledgement
- type Asset
- type Audit
- type Bond
- type BondAsset
- type BondExpiredNotification
- type BookOrderNote
- type Bytes
- type CancelOrder
- type Candle
- type CandlesRequest
- type Coin
- type ConfigResult
- type Connect
- type ConnectResult
- type EpochOrderNote
- type EpochReportNote
- type Error
- type FeeAsset
- type Init
- type LimitOrder
- type Market
- type MarketOrder
- type MarketStatus
- type Match
- type MatchProofNote
- type MatchRequest
- type MatchStatusResult
- type Message
- type MessageType
- type NoMatch
- type NotifyFee
- type NotifyFeeResult
- type OrderBook
- type OrderBookSubscription
- type OrderNote
- type OrderResult
- type OrderStatus
- type OrderStatusRequest
- type Penalty
- type PenaltyNote
- type PostBond
- type PostBondResult
- type PreValidateBond
- type PreValidateBondResult
- type Prefix
- type PreimageRequest
- type PreimageResponse
- type Redeem
- type RedeemSig
- type Redemption
- type Register
- type RegisterResult
- type ResponsePayload
- type RevokeMatch
- type RevokeOrder
- type Signable
- type Signature
- type Spot
- type Stampable
- type TierChangedNotification
- type Trade
- type TradeNote
- type TradeResumption
- type TradeSuspension
- type UnbookOrderNote
- type UnsubOrderBook
- type UpdateRemainingNote
- type WireCandles
Constants ¶
const ( RPCErrorUnspecified = iota // 0 RPCParseError // 1 RPCUnknownRoute // 2 RPCInternal // 3 RPCQuarantineClient // 4 RPCVersionUnsupported // 5 RPCUnknownMatch // 6 RPCInternalError // 7 RPCInitError // 8 RPCLoginError // 9 RPCLogoutError // 10 RPCCreateWalletError // 11 RPCOpenWalletError // 12 RPCWalletExistsError // 13 RPCCloseWalletError // 14 RPCGetFeeError // 15, obsolete, kept for order RPCRegisterError // 16 RPCArgumentsError // 17 RPCTradeError // 18 RPCCancelError // 19 RPCFundTransferError // 20 RPCOrderBookError // 21 SignatureError // 22 SerializationError // 23 TransactionUndiscovered // 24 ContractError // 25 SettlementSequenceError // 26 ResultLengthError // 27 IDMismatchError // 28 RedemptionError // 29 IDTypeError // 30 AckCountError // 31 UnknownResponseID // 32 OrderParameterError // 33 UnknownMarketError // 34 ClockRangeError // 35 FundingError // 36 CoinAuthError // 37 UnknownMarket // 38 NotSubscribedError // 39 AuthenticationError // 41 PubKeyParseError // 42 FeeError // 43 InvalidPreimage // 44 PreimageCommitmentMismatch // 45 UnknownMessageType // 46 AccountClosedError // 47 MarketNotRunningError // 48 TryAgainLaterError // 49 AccountNotFoundError // 50 UnpaidAccountError // 51 InvalidRequestError // 52 OrderQuantityTooHigh // 53 HTTPRouteError // 54 AccountExistsError // 56 AccountSuspendedError // 57 deprecated, kept for order RPCExportSeedError // 58 TooManyRequestsError // 59 RPCGetDEXConfigError // 60 RPCDiscoverAcctError // 61 RPCWalletRescanError // 62 RPCDeleteArchivedRecordsError // 63 DuplicateRequestError // 64 RPCToggleWalletStatusError // 65 BondError // 66 BondAlreadyConfirmingError // 67 RPCWalletPeersError // 68 RPCNotificationsError // 69 RPCPostBondError // 70 RPCWalletDefinitionError // 71 )
Error codes
const ( // MatchRoute is the route of a DEX-originating request-type message notifying // the client of a match and initiating swap negotiation. MatchRoute = "match" // NoMatchRoute is the route of a DEX-originating notification-type message // notifying the client that an order did not match during its match cycle. NoMatchRoute = "nomatch" // MatchStatusRoute is the route of a client-originating request-type // message to retrieve match data from the DEX. MatchStatusRoute = "match_status" // OrderStatusRoute is the route of a client-originating request-type // message to retrieve order data from the DEX. OrderStatusRoute = "order_status" // InitRoute is the route of a client-originating request-type message // notifying the DEX, and subsequently the match counter-party, of the details // of a swap contract. InitRoute = "init" // AuditRoute is the route of a DEX-originating request-type message relaying // swap contract details (from InitRoute) from one client to the other. AuditRoute = "audit" // RedeemRoute is the route of a client-originating request-type message // notifying the DEX, and subsequently the match counter-party, of the details // of a redemption transaction. RedeemRoute = "redeem" // RedemptionRoute is the route of a DEX-originating request-type message // relaying redemption transaction (from RedeemRoute) details from one client // to the other. RedemptionRoute = "redemption" // RevokeMatchRoute is a DEX-originating notification-type message informing // a client that a match has been revoked. RevokeMatchRoute = "revoke_match" // RevokeOrderRoute is a DEX-originating notification-type message informing // a client that an order has been revoked. RevokeOrderRoute = "revoke_order" // LimitRoute is the client-originating request-type message placing a limit // order. LimitRoute = "limit" // MarketRoute is the client-originating request-type message placing a market // order. MarketRoute = "market" // CancelRoute is the client-originating request-type message placing a cancel // order. CancelRoute = "cancel" // OrderBookRoute is the client-originating request-type message subscribing // to an order book update notification feed. OrderBookRoute = "orderbook" // UnsubOrderBookRoute is client-originating request-type message cancelling // an order book subscription. UnsubOrderBookRoute = "unsub_orderbook" // BookOrderRoute is the DEX-originating notification-type message informing // the client to add the order to the order book. BookOrderRoute = "book_order" // UnbookOrderRoute is the DEX-originating notification-type message informing // the client to remove an order from the order book. UnbookOrderRoute = "unbook_order" // EpochOrderRoute is the DEX-originating notification-type message informing // the client about an order added to the epoch queue. EpochOrderRoute = "epoch_order" // UpdateRemainingRoute is the DEX-originating notification-type message that // updates the remaining amount of unfilled quantity on a standing limit order. UpdateRemainingRoute = "update_remaining" // EpochReportRoute is the DEX-originating notification-type message that // indicates the end of an epoch's book updates and provides stats for // maintaining a candlestick cache. EpochReportRoute = "epoch_report" // ConnectRoute is a client-originating request-type message seeking // authentication so that the connection can be used for trading. ConnectRoute = "connect" // RegisterRoute is the client-originating request-type message initiating a // new client registration. DEPRECATED with bonds (V0PURGE) RegisterRoute = "register" // NotifyFeeRoute is the client-originating request-type message informing the // DEX that the fee has been paid and has the requisite number of // confirmations. DEPRECATED with bonds (V0PURGE) NotifyFeeRoute = "notifyfee" // PostBondRoute is the client-originating request used to post a new // fidelity bond. This can create a new account or it can add bond to an // existing account. PostBondRoute = "postbond" // PreValidateBondRoute is the client-originating request used to // pre-validate a fidelity bond transaction before broadcasting it (and // locking funds for months). PreValidateBondRoute = "prevalidatebond" // BondExpiredRoute is a server-originating notification when a bond expires // according to the configure bond expiry duration and the bond's lock time. BondExpiredRoute = "bondexpired" // TierChangeRoute is a server-originating notification sent to a connected // user who's tier changes for any reason. TierChangeRoute = "tierchange" // (TODO: use in many auth mgr events) // ConfigRoute is the client-originating request-type message requesting the // DEX configuration information. ConfigRoute = "config" // MatchProofRoute is the DEX-originating notification-type message // delivering match cycle results to the client. MatchProofRoute = "match_proof" // PreimageRoute is the DEX-originating request-type message requesting the // preimages for the client's epoch orders. PreimageRoute = "preimage" // SuspensionRoute is the DEX-originating request-type message informing the // client of an upcoming trade suspension. This is part of the // subscription-based orderbook notification feed. SuspensionRoute = "suspension" // ResumptionRoute is the DEX-originating request-type message informing the // client of an upcoming trade resumption. This is part of the // subscription-based orderbook notification feed. ResumptionRoute = "resumption" // NotifyRoute is the DEX-originating notification-type message // delivering text messages from the operator. NotifyRoute = "notify" // PenaltyRoute is the DEX-originating notification-type message // informing of a broken rule and the resulting penalty. PenaltyRoute = "penalty" // SpotsRoute is the client-originating HTTP or WebSocket request to get the // spot price and volume for the DEX's markets. SpotsRoute = "spots" // FeeRateRoute is the client-originating request asking for the most // recently recorded transaction fee estimate for an asset. FeeRateRoute = "fee_rate" // PriceFeedRoute is the client-originating request subscribing to the // market overview feed. PriceFeedRoute = "price_feed" // PriceUpdateRoute is a dex-originating notification updating the current // spot price for a market. PriceUpdateRoute = "price_update" // CandlesRoute is the HTTP request to get the set of candlesticks // representing market activity history. CandlesRoute = "candles" )
Routes are destinations for a "payload" of data. The type of data being delivered, and what kind of action is expected from the receiving party, is completely dependent on the route. The route designation is a string sent as the "route" parameter of a JSON-encoded Message.
const ( BuyOrderNum = 1 SellOrderNum = 2 StandingOrderNum = 1 ImmediateOrderNum = 2 LimitOrderNum = 1 MarketOrderNum = 2 CancelOrderNum = 3 )
Certain order properties are specified with the following constants. These properties include buy/sell (side), standing/immediate (force), limit/market/cancel (order type).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Acknowledgement ¶
Acknowledgement is the 'result' field in a response to a request that requires an acknowledgement. It is typically a signature of some serialized data associated with the request.
type Asset ¶
type Asset struct { Symbol string `json:"symbol"` ID uint32 `json:"id"` Version uint32 `json:"version"` MaxFeeRate uint64 `json:"maxfeerate"` SwapConf uint16 `json:"swapconf"` UnitInfo dex.UnitInfo `json:"unitinfo"` // The swap/redeem size fields are DEPRECATED. They are implied by version. // The values provided by the server in these fields should not be used by // client wallets, which know the structure of their own transactions. SwapSize uint64 `json:"swapsize"` SwapSizeBase uint64 `json:"swapsizebase"` RedeemSize uint64 `json:"redeemsize"` // The Asset LotSize and RateStep fields are DEPRECATED. They are now // market specific. LotSize uint64 `json:"lotsize,omitempty"` RateStep uint64 `json:"ratestep,omitempty"` }
Asset describes an asset and its variables, and is returned as part of a ConfigResult.
type Audit ¶
type Audit struct { Signature OrderID Bytes `json:"orderid"` MatchID Bytes `json:"matchid"` Time uint64 `json:"timestamp"` CoinID Bytes `json:"coinid"` Contract Bytes `json:"contract"` TxData Bytes `json:"txdata"` }
Audit is the payload for a DEX-originating AuditRoute request.
type Bond ¶ added in v0.6.0
type Bond struct { Version uint16 `json:"version"` Amount uint64 `json:"amount"` Expiry uint64 `json:"expiry"` // when it expires, not the lock time CoinID Bytes `json:"coinID"` // NOTE: ID capitalization not consistent with other payloads, but internally consistent with assetID AssetID uint32 `json:"assetID"` }
Bond is information on a fidelity bond. This is part of the ConnectResult and PostBondResult payloads.
type BondAsset ¶ added in v0.6.0
type BondAsset struct { Version uint16 `json:"version"` // latest version supported ID uint32 `json:"id"` Confs uint32 `json:"confs"` Amt uint64 `json:"amount"` // to be implied by bond version? }
BondAsset describes an asset for which fidelity bonds are supported.
type BondExpiredNotification ¶ added in v0.6.0
type BondExpiredNotification struct { Signature AccountID Bytes `json:"accountID"` AssetID uint32 `json:"assetid"` BondCoinID Bytes `json:"coinid"` Tier int64 `json:"tier"` }
BondExpiredNotification is a notification from a server when a bond tx expires.
func (*BondExpiredNotification) Serialize ¶ added in v0.6.0
func (bc *BondExpiredNotification) Serialize() []byte
Serialize serializes the BondExpiredNotification data.
type BookOrderNote ¶
BookOrderNote is the payload for a DEX-originating notification-type message informing the client to add the order to the order book.
type CancelOrder ¶
CancelOrder is the payload for the CancelRoute, which places a cancel order.
func (*CancelOrder) Serialize ¶
func (c *CancelOrder) Serialize() []byte
Serialize serializes the CancelOrder data.
type Candle ¶ added in v0.2.0
type Candle struct { StartStamp uint64 `json:"startStamp"` EndStamp uint64 `json:"endStamp"` MatchVolume uint64 `json:"matchVolume"` QuoteVolume uint64 `json:"quoteVolume"` HighRate uint64 `json:"highRate"` LowRate uint64 `json:"lowRate"` StartRate uint64 `json:"startRate"` EndRate uint64 `json:"endRate"` }
Candle is a statistical history of a specified period of market activity.
type CandlesRequest ¶ added in v0.2.0
type CandlesRequest struct { BaseID uint32 `json:"baseID"` QuoteID uint32 `json:"quoteID"` BinSize string `json:"binSize"` NumCandles int `json:"numCandles,omitempty"` // default and max defined in apidata. }
CandlesRequest is a data API request for market history.
type Coin ¶
type Coin struct { ID Bytes `json:"coinid"` PubKeys []Bytes `json:"pubkeys"` Sigs []Bytes `json:"sigs"` Redeem Bytes `json:"redeem"` }
Coin is information for validating funding coins. Some number of Coins must be included with both Limit and Market payloads.
type ConfigResult ¶
type ConfigResult struct { // APIVersion is the server's communications API version, but we may // consider APIVersions []uint16, with versioned routes e.g. "initV2". // APIVersions []uint16 `json:"apivers"` APIVersion uint16 `json:"apiver"` DEXPubKey dex.Bytes `json:"pubkey"` CancelMax float64 `json:"cancelmax"` BroadcastTimeout uint64 `json:"btimeout"` Assets []*Asset `json:"assets"` Markets []*Market `json:"markets"` BinSizes []string `json:"binSizes"` // Just apidata.BinSizes for now. BondAssets map[string]*BondAsset `json:"bondAssets"` // BondExpiry defines the duration of time remaining until lockTime below // which a bond is considered expired. As such, bonds should be created with // a considerably longer lockTime. NOTE: BondExpiry in the config response // is temporary, removed when APIVersion reaches BondAPIVersion and we have // codified the expiries for each network (main,test,sim). Until then, the // value will be considered variable, and we will communicate to the clients // what we expect at any given time. BondAsset.Amt may also become implied // by bond version. BondExpiry uint64 `json:"DEV_bondExpiry"` RegFees map[string]*FeeAsset `json:"regFees"` }
ConfigResult is the successful result for the ConfigRoute.
type Connect ¶
type Connect struct { Signature AccountID Bytes `json:"accountid"` APIVersion uint16 `json:"apiver"` Time uint64 `json:"timestamp"` }
Connect is the payload for a client-originating ConnectRoute request.
type ConnectResult ¶
type ConnectResult struct { Sig Bytes `json:"sig"` ActiveOrderStatuses []*OrderStatus `json:"activeorderstatuses"` ActiveMatches []*Match `json:"activematches"` Score int32 `json:"score"` Tier *int64 `json:"tier"` // 1+ means bonded and may trade, a function of active bond amounts and conduct, nil legacy ActiveBonds []*Bond `json:"activeBonds"` LegacyFeePaid *bool `json:"legacyFeePaid"` // not set by legacy server Suspended *bool `json:"suspended,omitempty"` // DEPRECATED - implied by tier<1 }
ConnectResult is the result for the ConnectRoute request.
TODO: Include penalty data as specified in the spec.
type EpochOrderNote ¶
type EpochOrderNote struct { BookOrderNote Commit Bytes `json:"com"` OrderType uint8 `json:"otype"` Epoch uint64 `json:"epoch"` TargetID Bytes `json:"target,omitempty"` // omit for cancel orders }
EpochOrderNote is the DEX-originating notification-type message informing the client about an order added to the epoch queue.
type EpochReportNote ¶ added in v0.2.0
type EpochReportNote struct { MarketID string `json:"marketid"` Epoch uint64 `json:"epoch"` BaseFeeRate uint64 `json:"baseFeeRate"` QuoteFeeRate uint64 `json:"quoteFeeRate"` // MatchSummary: [rate, quantity]. Quantity is signed. Negative means that // the maker was a sell order. MatchSummary [][2]int64 `json:"matchSummary"` Candle }
EpochReportNote is a report about an epoch sent after all of the epoch's book updates. Like TradeResumption, and TradeSuspension when Persist is true, Seq is omitted since it doesn't modify the book.
type Error ¶
Error is returned as part of the Response to indicate that an error occurred during method execution.
type FeeAsset ¶ added in v0.4.0
type FeeAsset struct { ID uint32 `json:"id"` Confs uint32 `json:"confs"` Amt uint64 `json:"amount"` }
FeeAsset describes an asset for which registration fees are supported.
type Init ¶
type Init struct { Signature OrderID Bytes `json:"orderid"` MatchID Bytes `json:"matchid"` CoinID Bytes `json:"coinid"` Contract Bytes `json:"contract"` }
Init is the payload for a client-originating InitRoute request.
type LimitOrder ¶
LimitOrder is the payload for the LimitRoute, which places a limit order.
func (*LimitOrder) Serialize ¶
func (l *LimitOrder) Serialize() []byte
Serialize serializes the Limit data.
type Market ¶
type Market struct { Name string `json:"name"` Base uint32 `json:"base"` Quote uint32 `json:"quote"` EpochLen uint64 `json:"epochlen"` LotSize uint64 `json:"lotsize"` RateStep uint64 `json:"ratestep"` MarketBuyBuffer float64 `json:"buybuffer"` MarketStatus `json:"status"` }
Market describes a market and its variables, and is returned as part of a ConfigResult. The market's status (running, start epoch, and any planned final epoch before suspend) are also provided.
type MarketOrder ¶
MarketOrder is the payload for the MarketRoute, which places a market order.
func (*MarketOrder) Serialize ¶
func (m *MarketOrder) Serialize() []byte
Serialize serializes the MarketOrder data.
type MarketStatus ¶
type MarketStatus struct { StartEpoch uint64 `json:"startepoch"` FinalEpoch uint64 `json:"finalepoch,omitempty"` Persist *bool `json:"persistbook,omitempty"` // nil and omitted when finalepoch is omitted }
MarketStatus describes the status of the market, where StartEpoch is when the market started or will start. FinalEpoch is a when the market will suspend if it is running, or when the market suspended if it is presently stopped.
type Match ¶
type Match struct { Signature OrderID Bytes `json:"orderid"` MatchID Bytes `json:"matchid"` Quantity uint64 `json:"qty"` Rate uint64 `json:"rate"` ServerTime uint64 `json:"tserver"` Address string `json:"address"` FeeRateBase uint64 `json:"feeratebase"` FeeRateQuote uint64 `json:"feeratequote"` // Status and Side are provided for convenience and are not part of the // match serialization. Status uint8 `json:"status"` Side uint8 `json:"side"` }
Match is the params for a DEX-originating MatchRoute request.
type MatchProofNote ¶
type MatchProofNote struct { MarketID string `json:"marketid"` Epoch uint64 `json:"epoch"` Preimages []Bytes `json:"preimages"` Misses []Bytes `json:"misses"` CSum Bytes `json:"csum"` Seed Bytes `json:"seed"` }
MatchProofNote is the match_proof notification payload.
type MatchRequest ¶
type MatchRequest struct { Base uint32 `json:"base"` Quote uint32 `json:"quote"` MatchID Bytes `json:"matchid"` }
MatchRequest details a match for the MatchStatusRoute request. The actual payload is a []MatchRequest.
type MatchStatusResult ¶
type MatchStatusResult struct { MatchID Bytes `json:"matchid"` Status uint8 `json:"status"` MakerContract Bytes `json:"makercontract,omitempty"` TakerContract Bytes `json:"takercontract,omitempty"` MakerSwap Bytes `json:"makerswap,omitempty"` TakerSwap Bytes `json:"takerswap,omitempty"` MakerRedeem Bytes `json:"makerredeem,omitempty"` TakerRedeem Bytes `json:"takerredeem,omitempty"` Secret Bytes `json:"secret,omitempty"` Active bool `json:"active"` // MakerTxData and TakerTxData will only be populated by the server when the // match status is MakerSwapCast and TakerSwapCast, respectively. MakerTxData Bytes `json:"makertx,omitempty"` TakerTxData Bytes `json:"takertx,omitempty"` }
MatchStatusResult is the successful result for the MatchStatusRoute request.
type Message ¶
type Message struct { // Type is the message type. Type MessageType `json:"type"` // Route is used for requests and notifications, and specifies a handler for // the message. Route string `json:"route,omitempty"` // ID is a unique number that is used to link a response to a request. ID uint64 `json:"id,omitempty"` // Payload is any data attached to the message. How Payload is decoded // depends on the Route. Payload json.RawMessage `json:"payload,omitempty"` }
Message is the primary messaging type for websocket communications.
func DecodeMessage ¶
DecodeMessage decodes a *Message from JSON-formatted bytes. Note that *Message may be nil even if error is nil, when the message is JSON null, []byte("null").
func NewNotification ¶
NewNotification encodes the payload and creates a Notification-type *Message.
func NewRequest ¶
NewRequest is the constructor for a Request-type *Message.
func NewResponse ¶
NewResponse encodes the result and creates a Response-type *Message.
func (*Message) Response ¶
func (msg *Message) Response() (*ResponsePayload, error)
Response attempts to decode the payload to a *ResponsePayload. Response will return an error if the Type is not Response. It is an error if the Message's Payload is []byte("null").
func (*Message) Unmarshal ¶
Unmarshal unmarshals the Payload field into the provided interface. Note that the payload interface must contain a pointer. If it is a pointer to a pointer, it may become nil for a Message.Payload of []byte("null").
func (*Message) UnmarshalResult ¶
UnmarshalResult is a convenience method for decoding the Result field of a ResponsePayload.
type MessageType ¶
type MessageType uint8
MessageType indicates the type of message. MessageType is typically the first switch checked when examining a message, and how the rest of the message is decoded depends on its MessageType.
const ( InvalidMessageType MessageType = iota // 0 Request // 1 Response // 2 Notification // 3 )
There are presently three recognized message types: request, response, and notification.
func (MessageType) String ¶
func (mt MessageType) String() string
String satisfies the Stringer interface for translating the MessageType code into a description, primarily for logging.
type NoMatch ¶
type NoMatch struct {
OrderID Bytes `json:"orderid"`
}
NoMatch is the payload for a server-originating NoMatchRoute notification.
type NotifyFee ¶
type NotifyFee struct { Signature AccountID Bytes `json:"accountid"` CoinID Bytes `json:"coinid"` Time uint64 `json:"timestamp"` }
NotifyFee is the payload for a client-originating NotifyFeeRoute request.
type NotifyFeeResult ¶
type NotifyFeeResult struct {
Signature
}
NotifyFeeResult is the result for the response to NotifyFee. Though it embeds Signature, it does not satisfy the Signable interface, as it has no need for serialization.
type OrderBook ¶
type OrderBook struct { MarketID string `json:"marketid"` Seq uint64 `json:"seq"` Epoch uint64 `json:"epoch"` // MarketStatus `json:"status"`// maybe // DRAFT NOTE: We might want to use a different structure for bulk updates. // Sending a struct of arrays rather than an array of structs could // potentially cut the encoding effort and encoded size substantially. Orders []*BookOrderNote `json:"orders"` BaseFeeRate uint64 `json:"baseFeeRate"` QuoteFeeRate uint64 `json:"quoteFeeRate"` // RecentMatches is [rate, qty, timestamp]. Quantity is signed. // Negative means that the maker was a sell order. RecentMatches [][3]int64 `json:"recentMatches"` }
OrderBook is the response to a successful OrderBookSubscription.
type OrderBookSubscription ¶
OrderBookSubscription is the payload for a client-originating request to the OrderBookRoute, intializing an order book feed.
type OrderNote ¶
type OrderNote struct { Seq uint64 `json:"seq,omitempty"` // May be empty when part of an OrderBook. MarketID string `json:"marketid,omitempty"` // May be empty when part of an OrderBook. OrderID Bytes `json:"oid"` }
OrderNote is part of a notification about any type of order.
type OrderResult ¶
type OrderResult struct { Sig Bytes `json:"sig"` OrderID Bytes `json:"orderid"` ServerTime uint64 `json:"tserver"` }
OrderResult is returned from the order-placing routes.
type OrderStatus ¶
OrderStatus is the current status of an order.
type OrderStatusRequest ¶
type OrderStatusRequest struct { Base uint32 `json:"base"` Quote uint32 `json:"quote"` OrderID Bytes `json:"orderid"` }
OrderStatusRequest details an order for the OrderStatusRoute request. The actual payload is a []OrderStatusRequest.
type Penalty ¶
type Penalty struct { Rule account.Rule `json:"rule"` Time uint64 `json:"timestamp"` Duration uint64 `json:"duration,omitempty"` // DEPRECATED with bonding tiers, but must remain in serialization until v1 (V0PURGE) Details string `json:"details"` }
Penalty is part of the payload for a dex-originating Penalty notification and part of the connect response.
type PenaltyNote ¶
PenaltyNote is the payload of a Penalty notification.
func (*PenaltyNote) Serialize ¶
func (n *PenaltyNote) Serialize() []byte
Serialize serializes the PenaltyNote data.
type PostBond ¶ added in v0.6.0
type PostBond struct { Signature AcctPubKey Bytes `json:"acctPubKey"` // acctID = blake256(blake256(acctPubKey)) AssetID uint32 `json:"assetID"` Version uint16 `json:"version"` CoinID Bytes `json:"coinid"` }
PostBond requests that server accept a confirmed bond payment, specified by the provided CoinID, for a certain account.
type PostBondResult ¶ added in v0.6.0
type PostBondResult struct { Signature // message is BondID | AccountID AccountID Bytes `json:"accountID"` AssetID uint32 `json:"assetID"` Amount uint64 `json:"amount"` Expiry uint64 `json:"expiry"` // not locktime, but time when bond expires for dex BondID Bytes `json:"bondID"` Tier int64 `json:"tier"` }
PostBondResult is the response to the client's PostBond request. If Active is true, the bond was applied to the account; if false it is not confirmed, but was otherwise validated.
func (*PostBondResult) Serialize ¶ added in v0.6.0
func (pbr *PostBondResult) Serialize() []byte
Serialize serializes the PostBondResult data for the signature.
type PreValidateBond ¶ added in v0.6.0
type PreValidateBond struct { Signature AcctPubKey Bytes `json:"acctPubKey"` // acctID = blake256(blake256(acctPubKey)) AssetID uint32 `json:"assetID"` Version uint16 `json:"version"` RawTx Bytes `json:"tx"` }
PreValidateBond may provide the unsigned bond transaction for validation prior to broadcasting the signed transaction. If they skip pre-validation, and the broadcasted transaction is rejected, the client would have needlessly locked funds.
func (*PreValidateBond) Serialize ¶ added in v0.6.0
func (pb *PreValidateBond) Serialize() []byte
Serialize serializes the PreValidateBond data for the signature.
type PreValidateBondResult ¶ added in v0.6.0
type PreValidateBondResult struct { // Signature is the result of signing the serialized PreValidateBondResult // concatenated with the RawTx. Signature AccountID Bytes `json:"accountID"` AssetID uint32 `json:"assetID"` Amount uint64 `json:"amount"` Expiry uint64 `json:"expiry"` // not locktime, but time when bond expires for dex }
PreValidateBondResult is the response to the client's PreValidateBond request.
func (*PreValidateBondResult) Serialize ¶ added in v0.6.0
func (pbr *PreValidateBondResult) Serialize() []byte
Serialize serializes the PreValidateBondResult data for the signature.
type Prefix ¶
type Prefix struct { Signature AccountID Bytes `json:"accountid"` Base uint32 `json:"base"` Quote uint32 `json:"quote"` OrderType uint8 `json:"ordertype"` ClientTime uint64 `json:"tclient"` ServerTime uint64 `json:"tserver"` Commit Bytes `json:"com"` }
Prefix is a common structure shared among order type payloads.
type PreimageRequest ¶
type PreimageRequest struct { OrderID Bytes `json:"orderid"` Commitment Bytes `json:"commit"` CommitChecksum Bytes `json:"csum"` }
PreimageRequest is the server-originating preimage request payload.
type PreimageResponse ¶
type PreimageResponse struct {
Preimage Bytes `json:"pimg"`
}
PreimageResponse is the client-originating preimage response payload.
type Redeem ¶
type Redeem struct { Signature OrderID Bytes `json:"orderid"` MatchID Bytes `json:"matchid"` CoinID Bytes `json:"coinid"` Secret Bytes `json:"secret"` }
Redeem are the params for a client-originating RedeemRoute request.
type RedeemSig ¶ added in v0.5.0
RedeemSig is a signature proving ownership of the redeeming address. This is only necessary as part of a Trade if the asset received is account-based.
type Redemption ¶
Redemption is the payload for a DEX-originating RedemptionRoute request.
func (*Redemption) Serialize ¶
func (r *Redemption) Serialize() []byte
Serialize serializes the Redemption data.
type Register ¶
type Register struct { Signature PubKey Bytes `json:"pubkey"` Time uint64 `json:"timestamp"` Asset *uint32 `json:"feeAsset,omitempty"` // default to 42 if not set by client }
Register is the payload for the RegisterRoute request.
type RegisterResult ¶
type RegisterResult struct { Signature DEXPubKey Bytes `json:"pubkey"` // ClientPubKey is excluded from the JSON payload to save bandwidth. The // client must add it back to verify the server's signature. ClientPubKey Bytes `json:"-"` AssetID *uint32 `json:"feeAsset,omitempty"` // default to 42 if not set by server Address string `json:"address"` Fee uint64 `json:"fee"` Time uint64 `json:"timestamp"` }
RegisterResult is the result for the response to Register.
func (*RegisterResult) Serialize ¶
func (r *RegisterResult) Serialize() []byte
Serialize serializes the RegisterResult data.
type ResponsePayload ¶
type ResponsePayload struct { // Result is the payload, if successful, else nil. Result json.RawMessage `json:"result,omitempty"` // Error is the error, or nil if none was encountered. Error *Error `json:"error,omitempty"` }
ResponsePayload is the payload for a Response-type Message.
type RevokeMatch ¶
RevokeMatch are the params for a DEX-originating RevokeMatchRoute request.
func (*RevokeMatch) Serialize ¶
func (rev *RevokeMatch) Serialize() []byte
Serialize serializes the RevokeMatch data.
type RevokeOrder ¶
RevokeOrder are the params for a DEX-originating RevokeOrderRoute notification.
func (*RevokeOrder) Serialize ¶
func (rev *RevokeOrder) Serialize() []byte
Serialize serializes the RevokeOrder data.
type Signature ¶
type Signature struct {
Sig Bytes `json:"sig"`
}
Signature partially implements Signable, and can be embedded by types intended to satisfy Signable, which must themselves implement the Serialize method.
type Spot ¶ added in v0.2.0
type Spot struct { Stamp uint64 `json:"stamp"` BaseID uint32 `json:"baseID"` QuoteID uint32 `json:"quoteID"` Rate uint64 `json:"rate"` BookVolume uint64 `json:"bookVolume"` Change24 float64 `json:"change24"` Vol24 uint64 `json:"vol24"` High24 uint64 `json:"high24"` Low24 uint64 `json:"low24"` }
Spot is a snapshot of a market at the end of a match cycle. A slice of Spot are sent as the response to the SpotsRoute request.
type TierChangedNotification ¶ added in v0.6.0
type TierChangedNotification struct { Signature // AccountID Bytes `json:"accountID"` Tier int64 `json:"tier"` Reason string `json:"reason"` }
TierChangedNotification is the dex-originating notification send when the user's tier changes as a result of account conduct violations. Tier change due to bond expiry is communicated with a BondExpiredNotification.
func (*TierChangedNotification) Serialize ¶ added in v0.6.0
func (tc *TierChangedNotification) Serialize() []byte
Serialize serializes the TierChangedNotification data.
type Trade ¶
type Trade struct { Side uint8 `json:"side"` Quantity uint64 `json:"ordersize"` Coins []*Coin `json:"coins"` Address string `json:"address"` RedeemSig *RedeemSig `json:"redeemsig,omitempty"` // account-based assets only. not serialized. }
Trade is common to Limit and Market Payloads.
type TradeNote ¶
type TradeNote struct { Side uint8 `json:"side,omitempty"` Quantity uint64 `json:"qty,omitempty"` Rate uint64 `json:"rate,omitempty"` TiF uint8 `json:"tif,omitempty"` Time uint64 `json:"time,omitempty"` }
TradeNote is part of a notification that includes information about a limit or market order.
type TradeResumption ¶
type TradeResumption struct { MarketID string `json:"marketid"` ResumeTime uint64 `json:"resumetime,omitempty"` // only set in advance of resume StartEpoch uint64 `json:"startepoch"` }
TradeResumption is the ResumptionRoute notification payload. It is part of the orderbook subscription.
type TradeSuspension ¶
type TradeSuspension struct { MarketID string `json:"marketid"` Seq uint64 `json:"seq,omitempty"` // only set at suspend time and if Persist==false SuspendTime uint64 `json:"suspendtime,omitempty"` // only set in advance of suspend FinalEpoch uint64 `json:"finalepoch"` Persist bool `json:"persistbook"` }
TradeSuspension is the SuspensionRoute notification payload. It is part of the orderbook subscription.
type UnbookOrderNote ¶
type UnbookOrderNote OrderNote
UnbookOrderNote is the DEX-originating notification-type message informing the client to remove an order from the order book.
type UnsubOrderBook ¶
type UnsubOrderBook struct {
MarketID string `json:"marketid"`
}
UnsubOrderBook is the payload for a client-originating request to the UnsubOrderBookRoute, terminating an order book subscription.
type UpdateRemainingNote ¶
UpdateRemainingNote is the DEX-originating notification-type message informing the client about an update to a booked order's remaining quantity.
type WireCandles ¶ added in v0.2.0
type WireCandles struct { StartStamps []uint64 `json:"startStamps"` EndStamps []uint64 `json:"endStamps"` MatchVolumes []uint64 `json:"matchVolumes"` QuoteVolumes []uint64 `json:"quoteVolumes"` HighRates []uint64 `json:"highRates"` LowRates []uint64 `json:"lowRates"` StartRates []uint64 `json:"startRates"` EndRates []uint64 `json:"endRates"` }
WireCandles are Candles encoded as a series of integer arrays, as opposed to an array of candles. WireCandles encode smaller than []Candle, since the property names are not repeated for each candle.
func NewWireCandles ¶ added in v0.2.0
func NewWireCandles(n int) *WireCandles
NewWireCandles prepares a *WireCandles with slices of capacity n.
func (*WireCandles) Candles ¶ added in v0.2.0
func (wc *WireCandles) Candles() []*Candle
Candles converts the WireCandles to []*Candle.