coinpayments

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2019 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoAuthorizationKey = Error.New("no authorization key")

ErrNoAuthorizationKey is error that indicates that there is no authorization key.

View Source
var Error = errs.Class("coinpayments client error")

Error is error class API errors.

Functions

func GetTransacationKeyFromURL

func GetTransacationKeyFromURL(rawurl string) (string, error)

GetTransacationKeyFromURL parses provided raw url string and extracts authorization key from it. Returns ErrNoAuthorizationKey if there is no authorization key and error if rawurl cannot be parsed.

Types

type Client

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

Client handles base API processing.

func NewClient

func NewClient(creds Credentials) *Client

NewClient creates new instance of client with provided credentials.

func (*Client) Transactions

func (c *Client) Transactions() Transactions

Transactions returns transactions API.

type CreateTX

type CreateTX struct {
	Amount      big.Float
	CurrencyIn  Currency
	CurrencyOut Currency
	BuyerEmail  string
}

CreateTX defines parameters for transaction creating.

type Credentials

type Credentials struct {
	PublicKey  string
	PrivateKey string
}

Credentials contains public and private API keys for client.

type Currency

type Currency string

Currency is a type wrapper for defined currencies.

const (
	// CurrencyUSD defines USD.
	CurrencyUSD Currency = "USD"
	// CurrencyLTCT defines LTCT, coins used for testing purpose.
	CurrencyLTCT Currency = "LTCT"
)

func (Currency) String

func (c Currency) String() string

String returns Currency string representation

type Status

type Status int

Status is a type wrapper for transaction statuses.

const (
	// StatusCancelled defines cancelled or timeout transaction.
	StatusCancelled Status = -1
	// StatusPending defines pending transaction which is waiting for buyer funds.
	StatusPending Status = 0
	// StatusReceived defines transaction which successfully received required amount of funds.
	StatusReceived Status = 1
)

func (Status) Int

func (s Status) Int() int

Int returns int representation of status.

func (Status) String

func (s Status) String() string

String returns string representation of status.

type Transaction

type Transaction struct {
	ID             TransactionID
	Address        string
	Amount         big.Float
	DestTag        string
	ConfirmsNeeded int
	Timeout        time.Duration
	CheckoutURL    string
	StatusURL      string
	QRCodeURL      string
}

Transaction contains data returned on transaction creation.

func (*Transaction) UnmarshalJSON

func (tx *Transaction) UnmarshalJSON(b []byte) error

UnmarshalJSON handles json unmarshaling for transaction.

type TransactionID

type TransactionID string

TransactionID is type wrapper for transaction id.

func (TransactionID) String

func (id TransactionID) String() string

String returns string representation of transaction id.

type TransactionIDList

type TransactionIDList []TransactionID

TransactionIDList is a type wrapper for list of transactions.

func (TransactionIDList) Encode

func (list TransactionIDList) Encode() string

Encode returns encoded string representation of transaction id list.

type TransactionInfo

type TransactionInfo struct {
	Address          string
	Coin             Currency
	Amount           big.Float
	Received         big.Float
	ConfirmsReceived int
	Status           Status
	ExpiresAt        time.Time
	CreatedAt        time.Time
}

TransactionInfo holds transaction information.

func (*TransactionInfo) UnmarshalJSON

func (info *TransactionInfo) UnmarshalJSON(b []byte) error

UnmarshalJSON handles json unmarshaling for transaction info.

type TransactionInfos

type TransactionInfos map[TransactionID]TransactionInfo

TransactionInfos is map of transaction infos by transaction id.

func (*TransactionInfos) UnmarshalJSON

func (infos *TransactionInfos) UnmarshalJSON(b []byte) error

UnmarshalJSON handles json unmarshaling for TransactionInfos.

type Transactions

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

Transactions defines transaction related API methods.

func (Transactions) Create

func (t Transactions) Create(ctx context.Context, params CreateTX) (*Transaction, error)

Create creates new transaction.

func (Transactions) Info

Info receives transaction info by transaction id.

func (Transactions) ListInfos

ListInfos returns up to 25 transaction infos.

Jump to

Keyboard shortcuts

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