internal

package
v0.3.14 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateNonce

func GenerateNonce() int64

func MakeAuthHeader

func MakeAuthHeader(apiKey, secretKey, method, path string, params map[string]interface{}) http.Header

func Sign

func Sign(secret, verb, uri string, nonce int64, payload string) string

Sign Generates an API signature.

A signature is HMAC_SHA256(secret, verb + path + nonce + data), hex encoded.
Verb must be uppercased, url is relative, nonce must be an increasing 64-bit integer
and the data, if present, must be JSON without whitespace between keys.

For example, in psuedocode (and in real code below):

verb=POST
uri=/api/v1/order
nonce=1416993995705
data={"symbol":"XBTZ14","quantity":1,"price":395.01}
signature = HEX(HMAC_SHA256(secret, 'POST/api/v1/order1416993995705{"symbol":"XBTZ14","quantity":1,"price":395.01}'))

Types

type Client

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

func NewClient

func NewClient(endpoint, apiKey, secretKey string) *Client

func (Client) RequestMap

func (c Client) RequestMap(method, path string, params map[string]interface{}, resp interface{}, needSign bool) (err error)

func (Client) RequestStruct

func (c Client) RequestStruct(method, path string, param, resp interface{}, needSign bool) error

Jump to

Keyboard shortcuts

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