coinpayments

package
v1.56.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// CurrencyLTCT defines LTCT, coins used for testing purpose.
	CurrencyLTCT = monetary.NewCurrency("LTCT test coins", "LTCT", 8)
)
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 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 GetTransactionKeyFromURL added in v1.40.3

func GetTransactionKeyFromURL(rawurl string) (string, error)

GetTransactionKeyFromURL 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      decimal.Decimal
	CurrencyIn  *monetary.Currency
	CurrencyOut *monetary.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 CurrencyRateInfo added in v0.26.0

type CurrencyRateInfo struct {
	IsFiat     bool
	RateBTC    decimal.Decimal
	TXFee      decimal.Decimal
	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[CurrencySymbol]CurrencyRateInfo

CurrencyRateInfos maps currency to currency rate info.

func (CurrencyRateInfos) ForCurrency added in v1.40.3

func (infos CurrencyRateInfos) ForCurrency(currency *monetary.Currency) (info CurrencyRateInfo, ok bool)

ForCurrency allows lookup into a CurrencyRateInfos map by currency object, instead of by its coinpayments.net-specific symbol.

type CurrencySymbol added in v1.40.3

type CurrencySymbol string

CurrencySymbol is a symbol for a currency as recognized by coinpayments.net.

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         monetary.Amount
	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             CurrencySymbol
	Amount           decimal.Decimal
	Received         decimal.Decimal
	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