Documentation ¶
Index ¶
- Constants
- Variables
- func GetCheckoutURL(key string, id TransactionID) string
- func GetTransacationKeyFromURL(rawurl string) (string, error)
- type Client
- type ConversionRates
- type CreateTX
- type Credentials
- type Currency
- type CurrencyRateInfo
- type CurrencyRateInfos
- type ExchangeStatus
- type Status
- type Transaction
- type TransactionID
- type TransactionIDList
- type TransactionInfo
- type TransactionInfos
- type Transactions
Constants ¶
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 ¶
var ErrMissingPublicKey = errs.Class("missing public key")
ErrMissingPublicKey is returned when Coinpayments client is missing public key.
var ErrNoAuthorizationKey = Error.New("no authorization key")
ErrNoAuthorizationKey is error that indicates that there is no authorization key.
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 ¶
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
func (rates ConversionRates) Get(ctx context.Context) (CurrencyRateInfos, error)
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 ¶
Credentials contains public and private API keys for client.
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 )
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 ¶
func (t Transactions) Info(ctx context.Context, id TransactionID) (*TransactionInfo, error)
Info receives transaction info by transaction id.
func (Transactions) ListInfos ¶
func (t Transactions) ListInfos(ctx context.Context, ids TransactionIDList) (TransactionInfos, error)
ListInfos returns transaction infos.