TRTLServices

package module
v0.0.0-...-715c33b Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2018 License: AGPL-3.0 Imports: 8 Imported by: 0

README

Go Report Card GoDoc

TRTL Service Golang API Interface

This wrapper allows you to easily interact with the TRTL Services 0.9.0 API to quickly develop applications that interact with the TurtleCoin Network.

Table of Contents

  1. Installation
  2. Intialization
  3. Documentation
    1. Methods

Installation

go get github.com/trtl-services/ts-api-go

Intialization

import (
    "fmt"

    "github.com/trtl-services/ts-api-go"
)

TS := TRTLServices.TSwrapper {
    token: "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoidGVzdCIsImFwcElkIjo0LCJ1c2VySWQiOjYsInBlcm1pc3Npb25zIjpbImFkZHJlc3M6bmV3Il0sImlhdCI6MTUzNjU4NTM2NywiZXhwIjoxNTM5MTc3MzY3LCJhdWQiOiJ0dXJ0bGV3YWxsZXQuaW8iLCJpc3MiOiJUUlRMIFNlcnZpY2VzIiwianRpIjoiMzMifQ.AEHXmvTo8RfNuZ15Y3IGPRhZPaJxFSmOZvVv2YGN9L4We7bXslIPxhMv_n_5cNW8sIgE2Fr-46OTb5H5AFgpjA",
    timeout: 2000
}

Documentation

API documentation is available at https://trtl.services/documentation

Methods

createAddress()

Create a new TRTL addresses

response, err := TS.createAddress()
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(response)
}
getAddress(address)

Get address details by address

response, err := TS.getAddress("TRTLuxH78akDMCsXycnU5HjJE6zPCgM4KRNNQSboqh1yiTnvxuhNVUL9tK92j9kurSKdXVHFmjSRkaNBxM6Nb3G8eQGL7aj113A")
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(response)
}
deleteAddress(address)

Delete a selected TRTL address

response, err := TS.deleteAddress("TRTLuxH78akDMCsXycnU5HjJE6zPCgM4KRNNQSboqh1yiTnvxuhNVUL9tK92j9kurSKdXVHFmjSRkaNBxM6Nb3G8eQGL7aj113A")
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(response)
}
getAddresses()

View all addresses.

response, err := TS.getAddresses()
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(response)
}
scanAddress(address, blockIndex)

Scan an address for transactions between a 100 block range starting from the specified blockIndex.

response, err := TS.scanAddress("TRTLuxH78akDMCsXycnU5HjJE6zPCgM4KRNNQSboqh1yiTnvxuhNVUL9tK92j9kurSKdXVHFmjSRkaNBxM6Nb3G8eQGL7aj113A", 899093)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(response)
}
getAddressKeys(address)

Get the public and secret spend key of an address.

response, err := TS.getAddressKeys("TRTLuxH78akDMCsXycnU5HjJE6zPCgM4KRNNQSboqh1yiTnvxuhNVUL9tK92j9kurSKdXVHFmjSRkaNBxM6Nb3G8eQGL7aj113A")
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(response)
}
integrateAddress(address, paymentId)

Create an integrated address with an address and payment ID.

response, err := TS.getAddressKeys("TRTLuxH78akDMCsXycnU5HjJE6zPCgM4KRNNQSboqh1yiTnvxuhNVUL9tK92j9kurSKdXVHFmjSRkaNBxM6Nb3G8eQGL7aj113A", "7d89a2d16365a1198c46db5bbe1af03d2b503a06404f39496d1d94a0a46f8804")
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(response)
}
getIntegratedAddresses(address)

Get all integrated addresses by address.

response, err := TS.getIntegratedAddresses("TRTLuxH78akDMCsXycnU5HjJE6zPCgM4KRNNQSboqh1yiTnvxuhNVUL9tK92j9kurSKdXVHFmjSRkaNBxM6Nb3G8eQGL7aj113A", "7d89a2d16365a1198c46db5bbe1af03d2b503a06404f39496d1d94a0a46f8804")
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(response)
}
getFee(amount)

Calculate the TRTL Services fee for an amount specified in TRTL with two decimal points.

response, err := TS.getFee(1092.19)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(response)
}
createTransfer()

Send a TRTL transaction with an address with the amount specified two decimal points.

response, err := TS.createTransfer(
    "TRTLuxH78akDMCsXycnU5HjJE6zPCgM4KRNNQSboqh1yiTnvxuhNVUL9tK92j9kurSKdXVHFmjSRkaNBxM6Nb3G8eQGL7aj113A", "TRTLuzAzNs1E1RBFhteX56A5353vyHuSJ5AYYQfoN97PNbcMDvwQo4pUWHs7SYpuD9ThvA7AD3r742kwTmWh5o9WFaB9JXH8evP",
    1000.00,
    1.00,
    "",
    "",
)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(response)
}
getTransfer()

Get a transaction details specified by transaction hash.

response, err := TS.getTransfer("EohMUzR1DELyeQM9RVVwpmn5Y1DP0lh1b1ZpLQrfXQsgtvGHnDdJSG31nX2yESYZ")
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(response)
}
getWallet()

Get wallet container info and health check.

response, err := TS.getWallet()
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(response)
}
getStatus()

Get the current status of the TRTL Services infrastructure.

response, err := TS.getStatus()
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(response)
}

License

Copyright (C) 2018 Rashed Mohammed, Fexra, The TurtleCoin Developers

Please see the included LICENSE file for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TSwrapper

type TSwrapper struct {
	Token   string
	Timeout int
	// contains filtered or unexported fields
}

TSwrapper structure contains the url, token and timeout info for the TRTL Services

func (*TSwrapper) CreateAddress

func (service *TSwrapper) CreateAddress() (*bytes.Buffer, error)

CreateAddress method creates a new TRTL address

func (*TSwrapper) CreateTransfer

func (service *TSwrapper) CreateTransfer(
	fromAddress string,
	toAddress string,
	amount float64,
	fee float64,
	paymentID string,
	extra string) (*bytes.Buffer, error)

CreateTransfer method sends a TRTL transaction with an address with the amount specified two decimal points.

func (*TSwrapper) DeleteAddress

func (service *TSwrapper) DeleteAddress(address string) (*bytes.Buffer, error)

DeleteAddress method deletes the specified address

func (*TSwrapper) GetAddress

func (service *TSwrapper) GetAddress(address string) (*bytes.Buffer, error)

GetAddress method gets the address details of the specified address

func (*TSwrapper) GetAddressKeys

func (service *TSwrapper) GetAddressKeys(address string) (*bytes.Buffer, error)

GetAddressKeys method gets the public and secret spend keys of the specified address

func (*TSwrapper) GetAddresses

func (service *TSwrapper) GetAddresses() (*bytes.Buffer, error)

GetAddresses method views all addresses associated with the API token

func (*TSwrapper) GetFee

func (service *TSwrapper) GetFee(amount float64) (*bytes.Buffer, error)

GetFee method calculates the TRTL Services fee for an amount specified in TRTL with two decimal points.

func (*TSwrapper) GetIntegratedAddresses

func (service *TSwrapper) GetIntegratedAddresses(address string) (*bytes.Buffer, error)

GetIntegratedAddresses mthod returns all integrated address associated with the given normal address

func (*TSwrapper) GetStatus

func (service *TSwrapper) GetStatus() (*bytes.Buffer, error)

GetStatus method gets the current status of the TRTL Services infrastructure

func (*TSwrapper) GetTransfer

func (service *TSwrapper) GetTransfer(transactionHash string) (*bytes.Buffer, error)

GetTransfer method gets transaction details specified by transaction hash.

func (*TSwrapper) GetWallet

func (service *TSwrapper) GetWallet() (*bytes.Buffer, error)

GetWallet method gets wallet container info and health check

func (*TSwrapper) IntegrateAddress

func (service *TSwrapper) IntegrateAddress(address string, paymentID string) (*bytes.Buffer, error)

IntegrateAddress method creates an integrated address with specified paymentID

func (*TSwrapper) ScanAddress

func (service *TSwrapper) ScanAddress(address string, blockIndex int) (*bytes.Buffer, error)

ScanAddress method scans an address for transactions between a 100 block range starting from the specified blockIndex.

Jump to

Keyboard shortcuts

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