api

package
v0.1.33 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *Client

func (*Client) Create

func (c *Client) Create(ctx context.Context, req CreateReq) (*Trade, error)

func (*Client) CreateBridge added in v0.1.28

func (c *Client) CreateBridge(ctx context.Context, req CreateReq) (*Trade, error)

CreateBridge calls the Ghost / privacy-routed create endpoint. Some engines (e.g. Zano) require a refund_address; the API rejects without it. The response can be a single Trade or an array of legs — we unmarshal as a generic and pick the first leg as the user-facing trade.

func (*Client) Currencies

func (c *Client) Currencies(ctx context.Context) ([]Currency, error)

func (*Client) Estimate

func (c *Client) Estimate(ctx context.Context, from, fromNet, to, toNet string, amount float64) (*Estimate, error)

func (*Client) EstimateBridge added in v0.1.28

func (c *Client) EstimateBridge(ctx context.Context, from, fromNet, to, toNet string, amount float64) (*Estimate, error)

EstimateBridge calls the Ghost / privacy-routed estimate endpoint. The response shape matches the regular Estimate but each Route carries extra bridge metadata (BridgeLabel, BridgeBadge, BridgeHighlight).

func (*Client) Status

func (c *Client) Status(ctx context.Context, id string) (*Trade, error)

type CreateReq

type CreateReq struct {
	Provider      string  `json:"provider"`
	Engine        string  `json:"engine,omitempty"`
	FromCurrency  string  `json:"from_currency"`
	ToCurrency    string  `json:"to_currency"`
	FromNetwork   string  `json:"from_network,omitempty"`
	ToNetwork     string  `json:"to_network,omitempty"`
	AmountFrom    float64 `json:"amount_from,omitempty"`
	AmountTo      float64 `json:"amount_to,omitempty"`
	AddressTo     string  `json:"address_to"`
	FixedRate     bool    `json:"fixed_rate,omitempty"`
	HoudiniQuote  any     `json:"_houdiniQuote,omitempty"`
	AddressMemo   string  `json:"address_memo,omitempty"`
	RefundAddress string  `json:"refund_address,omitempty"`
	Source        string  `json:"source,omitempty"`
}

type Currency

type Currency struct {
	ID       string   `json:"id"`
	Ticker   string   `json:"ticker"`
	Network  string   `json:"network"`
	Name     string   `json:"name"`
	Image    string   `json:"image,omitempty"`
	Minimum  float64  `json:"minimum,omitempty"`
	Maximum  float64  `json:"maximum,omitempty"`
	Memo     bool     `json:"memo,omitempty"`
	Engine   string   `json:"engine,omitempty"`
	Engines  []string `json:"engines,omitempty"`
	Priority int      `json:"priority,omitempty"`
}

type Estimate

type Estimate struct {
	ID         string  `json:"id"`
	Rate       float64 `json:"rate"`
	AmountFrom float64 `json:"amount_from"`
	AmountTo   float64 `json:"amount_to"`
	Min        float64 `json:"min"`
	Max        float64 `json:"max"`
	Provider   string  `json:"provider"`
	Engine     string  `json:"engine"`
	KYCRating  string  `json:"kyc_rating"`
	ETA        int     `json:"eta"`
	Routes     []Route `json:"routes"`
}

type Option

type Option func(*Client)

func WithAPIKey

func WithAPIKey(k string) Option

func WithBase

func WithBase(s string) Option

func WithTimeout

func WithTimeout(d time.Duration) Option

type Route

type Route struct {
	Provider     string  `json:"provider"`
	Engine       string  `json:"engine"`
	AmountTo     float64 `json:"amount_to"`
	AmountFrom   float64 `json:"amount_from"`
	KYC          string  `json:"kyc"`
	LogPolicy    string  `json:"log_policy"`
	ETA          int     `json:"eta"`
	Fixed        bool    `json:"fixed"`
	Spread       float64 `json:"spread,omitempty"`
	HoudiniQuote any     `json:"_houdiniQuote,omitempty"`
	// Bridge / Ghost-only metadata. Populated by /v2/exchange/bridge/estimate.
	BridgeLabel     string `json:"bridgeLabel,omitempty"`
	BridgeBadge     string `json:"bridgeBadge,omitempty"`
	BridgeHighlight string `json:"bridgeHighlight,omitempty"`
	RequiresRefund  bool   `json:"requiresRefund,omitempty"`
}

type Trade

type Trade struct {
	ID             string  `json:"id"`
	TradeID        string  `json:"trade_id,omitempty"`
	Status         string  `json:"status"`
	Engine         string  `json:"engine"`
	Provider       string  `json:"provider"`
	FromTicker     string  `json:"fromTicker"`
	FromNetwork    string  `json:"fromNetwork"`
	FromAmount     float64 `json:"fromAmount"`
	ToTicker       string  `json:"toTicker"`
	ToNetwork      string  `json:"toNetwork"`
	ToAmount       float64 `json:"toAmount"`
	DepositAddress string  `json:"depositAddress"`
	DepositMemo    string  `json:"depositMemo,omitempty"`
	AddressUser    string  `json:"address_user"`
	TxIn           string  `json:"txIn,omitempty"`
	TxOut          string  `json:"txOut,omitempty"`
	OrderURL       string  `json:"orderUrl,omitempty"`
}

Jump to

Keyboard shortcuts

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