coinpayments

package
v1.22.1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2021 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const Precision = 32

Precision is precision amount used to parse currency amount. Set enough precision to to able to handle up to 8 digits after point.

Variables

View Source
var ErrMissingPublicKey = errs.Class("missing public key")

ErrMissingPublicKey is returned when Coinpayments client is missing public key.

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 GetCheckoutURL added in v0.26.0

func GetCheckoutURL(key string, id TransactionID) string

GetCheckoutURL constructs checkout url from auth key and transaction id.

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) ConversionRates added in v0.26.0

func (c *Client) ConversionRates() ConversionRates

ConversionRates returns ConversionRates API.

func (*Client) Transactions

func (c *Client) Transactions() Transactions

Transactions returns transactions API.

type ConversionRates added in v0.26.0

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

ConversionRates collection of API methods for retrieving currency conversion rates.

func (ConversionRates) Get added in v0.26.0

Get returns USD rate for specified currency.

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"
	// CurrencySTORJ defines STORJ tokens.
	CurrencySTORJ Currency = "STORJ"
)

func (Currency) String

func (c Currency) String() string

String returns Currency string representation.

type CurrencyRateInfo added in v0.26.0

type CurrencyRateInfo struct {
	IsFiat     bool
	RateBTC    big.Float
	TXFee      big.Float
	Status     ExchangeStatus
	LastUpdate time.Time
}

CurrencyRateInfo holds currency conversion info.

func (*CurrencyRateInfo) UnmarshalJSON added in v0.26.0

func (rateInfo *CurrencyRateInfo) UnmarshalJSON(b []byte) error

UnmarshalJSON converts JSON string to currency rate info.

type CurrencyRateInfos added in v0.26.0

type CurrencyRateInfos map[Currency]CurrencyRateInfo

CurrencyRateInfos maps currency to currency rate info.

type ExchangeStatus added in v0.26.0

type ExchangeStatus string

ExchangeStatus defines if currency is exchangeable.

const (
	// ExchangeStatusOnline defines exchangeable currency.
	ExchangeStatusOnline ExchangeStatus = "online"
	// ExchangeStatusOffline defines currency that can not be convertible at the moment.
	ExchangeStatusOffline ExchangeStatus = "offline"
)

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
	// StatusCompleted defines transaction which is fully completed.
	StatusCompleted Status = 100
)

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 transaction infos.

Jump to

Keyboard shortcuts

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