westwallet

package module
v0.0.0-...-5833e92 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

README

westwallet-golang-api
=====================
.. image:: https://godoc.org/github.com/WestWallet/westwallet-golang-api?status.svg
    :alt: godoc
    :target: http://godoc.org/github.com/WestWallet/westwallet-golang-api

westwallet-golang-api is a `WestWallet Public API <https://westwallet.io/api_docs>`_ wrapper for Go programming language. Use it for building payment solutions.

Installing
----------

Install with go get:

.. code-block:: text

    go get github.com/westwallet/westwallet-golang-api


Create withdrawal example
-------------------------

.. code-block:: Go

    package main

    import (
        "fmt"
        westwallet "github.com/westwallet/westwallet-golang-api"
    )
    // Sending 0.1 ETH to 0x57689002367b407f031f1BB5Ef2923F103015A32
    client := westwallet.APIClient{
        Key:      "your_public_key",
        Secret:   "your_private_key",
    }
    transaction, err := client.CreateWithdrawal(
        "ETH", "0.1", "0x57689002367b407f031f1BB5Ef2923F103015A32", "", ""
    )
    fmt.Println(err)
    if err != nil {
        panic(err)
    }
    fmt.Println(transaction)


Generate address example
-------------------------

.. code-block:: Go

    package main

    import (
        "fmt"
        westwallet "github.com/westwallet/westwallet-golang-api"
    )
    client := westwallet.APIClient{
        Key:      "your_public_key",
        Secret:   "your_private_key",
    }
    address, err := client.GenerateAddress("BTC", "", "")
    if err != nil {
        panic(err)
    }
    fmt.Println(address.Address)

Documentation
-------------
* API: https://westwallet.io/api_docs

Other languages
---------------
* Python: https://github.com/WestWallet/westwallet-python-api
* JavaScript: https://github.com/WestWallet/westwallet-js-api
* PHP: https://github.com/WestWallet/westwallet-php-api

Documentation

Index

Constants

View Source
const (
	// ENDPOINT defaults to https://api.westwallet.io
	// but can be overridden for test purposes
	ENDPOINT = "https://api.westwallet.io"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIAddress

type APIAddress struct {
	Address  string
	DestTag  string
	Currency string
	Label    string
	Error    string
}

type APIBalance

type APIBalance struct {
	Balance  string
	Currency string
	Error    string
}

type APIClient

type APIClient struct {
	Key      string
	Secret   string
	Endpoint string
}

APIClient is the interface for most of the API calls If Endpoint aren't defined the library will use the default https://api.westwallet.io

func (*APIClient) Authenticate

func (a *APIClient) Authenticate(path string, req *http.Request, body interface{}) error

Authenticate works with the Fetch call and adds certain Headers to the http request. This includes the actual API key and the timestamp of the request. Also a signature which is encoded with hmac and the API secret key.

func (*APIClient) CreateWithdrawal

func (a *APIClient) CreateWithdrawal(currency string, amount string, address string, destTag string, description string) (transaction APITransaction, err error)

CreateWithdrawal requires currency, amount, address, destTag, description and returns an APITransaction struct

func (*APIClient) Fetch

func (a *APIClient) Fetch(method, path string, body interface{}, result interface{}) error

Fetch works as a wrapper for all kind of http requests. It requires a http method and a relative path to the API endpoint. It will try to decode all results into a single interface type which you can provide.

func (*APIClient) GenerateAddress

func (a *APIClient) GenerateAddress(currency string, ipnURL string, description string) (address APIAddress, err error)

GenerateAddress requires an currency code and optional ipnURL and descripton and returns an APIAddresses struct

func (*APIClient) TransactionInfo

func (a *APIClient) TransactionInfo(id int) (transaction APITransaction, err error)

TransactionInfo requires id and returns an APITransaction struct

func (*APIClient) WalletBalance

func (a *APIClient) WalletBalance(currency string) (balance APIBalance, err error)

WalletBalance requires currency and returns an APIBalance struct

func (*APIClient) WalletBalances

func (a *APIClient) WalletBalances() (balances map[string]string, err error)

WalletBalances requires currency and returns an APIBalance struct

type APITransaction

type APITransaction struct {
	ID                      int
	Amount                  string
	Address                 string
	DestTag                 string
	Currency                string
	Status                  string
	Type                    string
	BlockchainConfirmations int
	BlockchainHash          string
	Error                   string
}

type AccountBlockedError

type AccountBlockedError struct {
}

func (*AccountBlockedError) Error

func (e *AccountBlockedError) Error() string

type BadAddressError

type BadAddressError struct {
}

func (*BadAddressError) Error

func (e *BadAddressError) Error() string

type BadDestTagError

type BadDestTagError struct {
}

func (*BadDestTagError) Error

func (e *BadDestTagError) Error() string

type CurrencyNotFoundError

type CurrencyNotFoundError struct {
}

func (*CurrencyNotFoundError) Error

func (e *CurrencyNotFoundError) Error() string

type InsufficientFundsError

type InsufficientFundsError struct {
}

func (*InsufficientFundsError) Error

func (e *InsufficientFundsError) Error() string

type MaxWithdrawError

type MaxWithdrawError struct {
}

func (*MaxWithdrawError) Error

func (e *MaxWithdrawError) Error() string

type MinWithdrawError

type MinWithdrawError struct {
}

func (*MinWithdrawError) Error

func (e *MinWithdrawError) Error() string

type NotAllowedError

type NotAllowedError struct {
}

func (*NotAllowedError) Error

func (e *NotAllowedError) Error() string

type TransactionNotFoundError

type TransactionNotFoundError struct {
}

func (*TransactionNotFoundError) Error

func (e *TransactionNotFoundError) Error() string

type WestWalletAPIError

type WestWalletAPIError struct {
	S string
}

func (*WestWalletAPIError) Error

func (e *WestWalletAPIError) Error() string

type WrongCredentialsError

type WrongCredentialsError struct {
}

func (*WrongCredentialsError) Error

func (e *WrongCredentialsError) Error() string

Jump to

Keyboard shortcuts

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