golos

package module
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 11 Imported by: 0

README

asuleymanov/golos-go

GoDoc Go Report Card

Golang RPC client library for Golos.

Usage

import "github.com/asuleymanov/golos-go"

Example

This is just a code snippet. Please check the examples directory for more complete and ready to use examples.

package main

import (
	"fmt"

	"github.com/asuleymanov/golos-go"
)

func main() {
	cls, _ := golos.NewClient("wss://golos.lexa.host/ws")
	defer cls.Close()

  fmt.Println("Config --> ")
  fmt.Printf("%#v \n",cls.Config)
  fmt.Println("")
  fmt.Println("")
  
  fmt.Println("DatabaseInfo --> ")
  ans,err:= cls.API.GetDatabaseInfo()
  fmt.Printf("%#v \n Error : %s\n",ans,err)
  fmt.Println("")
  fmt.Println("")
  
  fmt.Println("ChainProperties --> ")
  ans1,err1:= cls.API.GetChainProperties()
  fmt.Printf("%#v \n Error : %s\n",ans1,err1)
  fmt.Println("")
  fmt.Println("")
}

Package Organisation

You need to create a Client object to be able to do anything. Then you just need to call NewClient().

License

MIT, see the LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInitializeTransport = errors.New("Failed to initialize transport.")
)
View Source
var (
	//OpTypeKey include a description of the operation and the key needed to sign it
	OpTypeKey = make(map[operations.OpType][]string)
)

Functions

func GenerateProposalOperation

func GenerateProposalOperation(ops []operations.Operation) operations.ProposalObjects

GenerateProposalOperation generate []Operation to ProposalOperations

func JSONOpString

func JSONOpString(v []operations.Operation) (string, error)

JSONOpString generate Operations to String

func JSONTrxString

func JSONTrxString(v *transactions.SignedTransaction) (string, error)

JSONTrxString generate Trx to String

func SetAsset

func SetAsset(amount float64, symbol string) *types.Asset

SetAsset returns data of type Asset

Types

type Client

type Client struct {
	API *api.API

	Config api.Config

	// Current keys for operations
	CurrentKeys *Keys
	// contains filtered or unexported fields
}

Client can be used to access GOLOS remote APIs. There is a function for every available GOLOS API, for example, Client.API.GetDatabaseInfo() corresponds to database_api -> get_database_info.

func NewClient

func NewClient(apiURL string) (*Client, error)

NewClient creates a new RPC client that use the given CallCloser internally. Initialize only server present API. Absent API initialized as nil value.

func (*Client) Close

func (client *Client) Close() error

Close should be used to close the client when no longer needed. It simply calls Close() on the underlying CallCloser.

func (*Client) GetTrx

func (client *Client) GetTrx(strx []operations.Operation) (*operations.Transaction, error)

func (*Client) SendTrx

func (client *Client) SendTrx(username string, strx []operations.Operation) (*types.OperationResponse, error)

SendTrx generates and sends an array of transactions to VIZ.

func (*Client) SetAsyncProtocol

func (client *Client) SetAsyncProtocol(value bool)

SetAsyncProtocol enables or disables the asynchronous operation protocol

func (*Client) SetKeys

func (client *Client) SetKeys(keys *Keys)

SetKeys you can specify keys for signing transactions.

func (*Client) SigningKeys

func (client *Client) SigningKeys(trx operations.Operation) ([][]byte, error)

SigningKeys returns the key from the CurrentKeys

type Keys

type Keys struct {
	PKey []string
	AKey []string
	OKey []string
	MKey []string
}

Keys is used as a keystroke for a specific user. Only a few keys can be set.

Directories

Path Synopsis
encoding
wif
example
rfc6979
Package rfc6979 is an implementation of RFC 6979's deterministic DSA.
Package rfc6979 is an implementation of RFC 6979's deterministic DSA.

Jump to

Keyboard shortcuts

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