raidenclient

package module
Version: v0.0.0-...-0854145 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2019 License: MIT Imports: 8 Imported by: 0

README

go-raiden-client

GoDoc CircleCI Coverage Status

A client for a Raiden node written in Go. This is meant to be used for backend development environments where you are able to connect to running Raiden node(s).

Getting Started

Get the Raiden client within your go path by using go get github.com/cpurta/go-raiden-client.

You can then start writing some code using the client. Here is an example that will connect to a locally running Raiden node and get our Ethereum address that the node is using.

package main

import (
	"context"
	"log"
	"net/http"

	"github.com/cpurta/go-raiden-client/config"
	"github.com/ethereum/go-ethereum/common"
)

func main() {
	var (
		err          error
		raidenConfig = &config.Config{
			Host:       "http://localhost:5001",
			APIVersion: "v1",
		}

		raidenClient = NewClient(raidenConfig, http.DefaultClient)
		address common.Address
	)

	// get our token address from the raiden node
	if address, err = raidenClient.Address().Get(context.TODO()); err != nil {
		log.Println("there was an error getting raiden address:", err.Error())
	}

	log.Println("raiden address:", address.Hex())
}

Contributing

If you notice some issues please feel free to create one in the repo with as much detailed information on how you encountered your issues and any error messages. If you would like to add on features feel free to fork and submit a pull request.

LICENSE

Distributed under the MIT License

Documentation

Overview

Package raidenclient creates a generic client to access sub-clients that correspond to the various API calls that any Raiden node supports.

Example
var (
	err          error
	raidenConfig = &config.Config{
		Host:       "http://localhost:5001",
		APIVersion: "v1",
	}

	raidenClient = NewClient(raidenConfig, http.DefaultClient)
	address      common.Address
)

// get our token address from the raiden node

if address, err = raidenClient.Address().Get(context.TODO()); err != nil {
	log.Println("there was an error getting raiden token address:", err.Error())
}

log.Println("raiden token address:", address.Hex())
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	AddressClient          *address.Client
	TokensClient           *tokens.Client
	ChannelsClient         *channels.Client
	PaymentsClient         *payments.Client
	ConnectionsClient      *connections.Client
	PendingTransfersClient *pendingtransfers.Client
}

Client provides access to API sub-clients that correspond to the various API calls that a Raiden node supports.

func NewClient

func NewClient(config *config.Config, httpClient *http.Client) *Client

NewClient will return a Raiden client that is able to access all of the API calls that are currently available on a Raiden node. This provides access to the various sub-clients that correspond to the various API calls available.

func (*Client) Address

func (client *Client) Address() *address.Client

Address returns the Address sub-client to access the address being used by the Raiden node.

func (*Client) Channels

func (client *Client) Channels() *channels.Client

Channels returns the Channels sub-client that will be able to open, close and increase the deposit of a micro-payment channel.

func (*Client) Connections

func (client *Client) Connections() *connections.Client

Connections returns the Connections sub-client that will be able to list, join and leave token networks.

func (*Client) Payments

func (client *Client) Payments() *payments.Client

Payments returns the Payments sub-client that will be able to query all of the pending payments.

func (*Client) PendingTransfers

func (client *Client) PendingTransfers() *pendingtransfers.Client

PendingTransfers returns the PendingTransfers sub-client that will be able to query all pending transfers by token or a channel.

func (*Client) Tokens

func (client *Client) Tokens() *tokens.Client

Tokens returns the Tokens sub-client that will be able to register, get, and list token networks.

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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