metahash

package module
v0.0.0-...-e005bfe Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: MIT Imports: 10 Imported by: 0

README

MetaHash API GO library

An unofficial Golang library for #MetaHash blockchain.

metahash-go

Requirements
  • GO go 1.12+
Installation
go get -u github.com/xboston/metahash-go
Information
Methods
  • fetch-balance
  • fetch-balances
  • fetch-history
  • get-tx
  • get-last-txs
  • get-blocks
  • get-block-by-number
  • get-block-by-hash
  • get-dump-block-by-number
  • get-dump-block-by-hash
  • get-count-blocks
  • get-last-node-stat-result
  • get-last-node-stat-trust
  • get-all-last-nodes-count
  • get-nodes-raiting
  • get-address-delegations
  • get-forging-sum-all
  • get-forging-sum
  • get-common-balance
  • status
  • mhc_send
  • getinfo
Extra Methods
Usage

You can find usage examples in the examples folder.

License

This package is released under the MIT license.

Documentation

Overview

Package jsonrpc provides a JSON-RPC 2.0 client that sends JSON-RPC requests and receives JSON-RPC responses using HTTP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCommonBalance

func GetCommonBalance() (int64, error)

func GetTotalBlocks

func GetTotalBlocks() (int64, error)

func Params

func Params(params ...interface{}) interface{}

Params is a helper function that uses the same parameter syntax as Call(). But you should consider to always use NewRequest() instead.

e.g. to manually create an RPCRequest object:

request := &RPCRequest{
  Method: "myMethod",
  Params: Params("Alex", 35, true),
}

same with new request: request := NewRequest("myMethod", "Alex", 35, true)

If you know what you are doing you can omit the Params() call but potentially create incorrect rpc requests:

request := &RPCRequest{
  Method: "myMethod",
  Params: 2, <-- invalid since a single primitive value must be wrapped in an array --> no magic without Params()
}

correct:

request := &RPCRequest{
  Method: "myMethod",
  Params: []int{2}, <-- invalid since a single primitive value must be wrapped in an array
}

Types

type AbstractMethod

type AbstractMethod struct {
	Jsonrpc string      `json:"jsonrpc"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params,omitempty"`
}

type AddressDelegations

type AddressDelegations struct {
	Address string `json:"address"`
	States  []struct {
		To    string `json:"to"`
		Value int64  `json:"value"`
		Tx    string `json:"tx"`
	} `json:"states"`
}

func GetAddressDelegations

func GetAddressDelegations(address string, startTx, countTx int64) (*AddressDelegations, error)

type Balance

type Balance struct {
	Address           string `json:"address"`
	Received          int64  `json:"received"`
	Spent             int64  `json:"spent"`
	CountReceived     int64  `json:"count_received"`
	CountSpent        int64  `json:"count_spent"`
	CountTxs          int64  `json:"count_txs"`
	BlockNumber       int64  `json:"block_number"`
	CurrentBlock      int64  `json:"currentBlock"`
	Hash              string `json:"hash"`
	CountDelegatedOps int64  `json:"countDelegatedOps"`
	Delegate          int64  `json:"delegate"`
	Undelegate        int64  `json:"undelegate"`
	Delegated         int64  `json:"delegated"`
	Undelegated       int64  `json:"undelegated"`
	Reserved          int64  `json:"reserved"`
	CountForgedOps    int64  `json:"countForgedOps"`
	Forged            int64  `json:"forged"`
}

func FetchBalance

func FetchBalance(address string) (*Balance, error)

FetchBalance gets the balance information of a given address

func FetchBalances

func FetchBalances(addresses ...string) ([]*Balance, error)

FetchBalances gets the balance information of list of addresses

type BalanceArgs

type BalanceArgs struct {
	Address string `json:"address"`
}

type BalancesArgs

type BalancesArgs struct {
	Addresses []string `json:"addresses"`
}

type Block

type Block struct {
	Type       string `json:"type"`
	Hash       string `json:"hash"`
	PrevHash   string `json:"prev_hash"`
	TxHash     string `json:"tx_hash"`
	Number     int64  `json:"number"`
	TimeStamp  int64  `json:"timestamp"`
	CountTxs   int64  `json:"count_txs"`
	Sign       string `json:"sign"`
	Size       int64  `json:"size"`
	FileName   string `json:"fileName"`
	Signatures []struct {
		From        string `json:"from"`
		To          string `json:"to"`
		Value       int64  `json:"value"`
		Transaction string `json:"transaction"`
		Data        string `json:"data"`
		TimeStamp   int64  `json:"timestamp"`
		Type        string `json:"type"`
		BlockNumber int64  `json:"blockNumber"`
		Signature   string `json:"signature"`
		Publickey   string `json:"publickey"`
		Fee         int64  `json:"fee"`
		RealFee     int64  `json:"realFee"`
		Nonce       int64  `json:"nonce"`
		IntStatus   int64  `json:"intStatus"`
		Status      string `json:"status"`
	} `json:"signatures,omitempty"`
	Txs []*TransactionInfo `json:"txs"`
}

func GetBlockByHash

func GetBlockByHash(blockHash string, startIndex, numTx, blockType int) (*Block, error)

func GetBlockByNumber

func GetBlockByNumber(blockNumber, blockType int64) (*Block, error)

func GetBlockByNumberFilter

func GetBlockByNumberFilter(blockNumber, startTx, numTx, blockType int64) (*Block, error)

func GetBlocks

func GetBlocks(startBlock, numBlocks int64) ([]*Block, error)

type BlockByHashArgs

type BlockByHashArgs struct {
	Hash     string `json:"hash"`
	BeginTx  int64  `json:"beginTx,omitempty"`
	CountTxs int64  `json:"countTxs,omitempty"`
	Type     int8   `json:"type,omitempty"` // 0-4
}

type BlockByNumberArgs

type BlockByNumberArgs struct {
	Number   int64 `json:"number"`
	BeginTx  int64 `json:"beginTx,omitempty"`
	CountTxs int64 `json:"countTxs,omitempty"`
	Type     int8  `json:"type,omitempty"` // 0-4

}

type BlocksArgs

type BlocksArgs struct {
	CountBlocks int64 `json:"countBlocks,omitempty"`
	BeginBlock  int64 `json:"beginBlock,omitempty"`
}

type CommonBalance

type CommonBalance struct {
	Balance int64 `json:"balance"`
}

type CountBlocks

type CountBlocks struct {
	CountBlocks int64 `json:"count_blocks"`
	BeginBlock  int64 `json:"beginBlock"`
}

type CountBlocksArgs

type CountBlocksArgs struct {
}

type DumpBlock

type DumpBlock struct {
	Dump string `json:"dump"`
}

func GetDumpBlockByHash

func GetDumpBlockByHash(blockHash string, isHex bool) (*DumpBlock, error)

func GetDumpBlockByNumber

func GetDumpBlockByNumber(blockNumber int64, isHex bool) (*DumpBlock, error)

type DumpBlockByHashArgs

type DumpBlockByHashArgs struct {
	Hash  string `json:"hash"`
	IsHex bool   `json:"isHex,omitempty"`
}

type DumpBlockByNumberArgs

type DumpBlockByNumberArgs struct {
	Number int64 `json:"number"`
	IsHex  bool  `json:"isHex,omitempty"`
}

type ForginSumArgs

type ForginSumArgs struct {
	BlockIndent int `json:"block_indent"`
}

type ForgingSum

type ForgingSum struct {
	Blocknumber int `json:"blockNumber"`
	Sums        []struct {
		Type  int   `json:"type"`
		Value int64 `json:"value"`
	} `json:"sums"`
}

func GetForgingSum

func GetForgingSum(blockIndent int) (*ForgingSum, error)

func GetForgingSumAll

func GetForgingSumAll() (*ForgingSum, error)

GetForgingSumAll returns sum all types of forging 100; // forging transaction 101; // wallet reward forging transaction 102; // node reward forging transaction 103; // coin reward forging transaction 104; // random reward forging transaction

type HTTPError

type HTTPError struct {
	Code int
	// contains filtered or unexported fields
}

HTTPError represents a error that occurred on HTTP level.

An error of type HTTPError is returned when a HTTP error occurred (status code) and the body could not be parsed to a valid RPCResponse object that holds a RPCError.

Otherwise a RPCResponse object is returned with a RPCError field that is not nil.

func (*HTTPError) Error

func (e *HTTPError) Error() string

Error function is provided to be used as error object.

type HistoryArgs

type HistoryArgs struct {
	Address  string        `json:"address"`
	BeginTx  int64         `json:"beginTx,omitempty"`
	CountTxs int64         `json:"countTxs,omitempty"`
	Filters  HistoryFilter `json:"filters,omitempty"`
}

type HistoryFilter

type HistoryFilter struct {
	IsInput    bool `json:"isInput,omitempty"`    // isInput - Display only isInput transactions
	IsOutput   bool `json:"isOutput,omitempty"`   //isOutput - Display only isOutput transactions
	IsSuccess  bool `json:"isSuccess,omitempty"`  //isSuccess - Display only success transactions
	IsForging  bool `json:"isForging,omitempty"`  //isForging - Display only forging transactions
	IsTest     bool `json:"isTest,omitempty"`     //isTest - Display only test transactions
	IsDelegate bool `json:"isDelegate,omitempty"` //isDelegate - Display only delegation transactions
}

type LastNodeCount

type LastNodeCount struct {
	Nodes []struct {
		Node  string `json:"node"`
		IP    string `json:"ip"`
		Type  string `json:"type"`
		Count int    `json:"count"`
	} `json:"nodes"`
	Day          int `json:"day"`
	Lastblockday int `json:"lastBlockDay"`
}

func GetLastNodeCount

func GetLastNodeCount(counts int) (*LastNodeCount, error)

type LastTxsArgs

type LastTxsArgs struct {
}

type NodeArgs

type NodeArgs struct {
	Address    string `json:"address"`
	BeginTx    int64  `json:"beginTx,omitempty"`
	CountTxs   int64  `json:"countTxs,omitempty"`
	CountTests int    `json:"count_tests,omitempty"`
}

type NodeRaiting

type NodeRaiting struct {
	Address      string `json:"address"`
	Raiting      int    `json:"raiting"`
	Day          int    `json:"day"`
	Lastblockday int    `json:"lastBlockDay"`
}

func GetNodeRaiting

func GetNodeRaiting(address string, countTests int) (*NodeRaiting, error)

type NodeRegistration

type NodeRegistration struct {
	Jsonrpc string `json:"jsonrpc"`
	Method  string `json:"method"`
	Params  struct {
		Host string `json:"host"`
		Name string `json:"name"`
		Type string `json:"type,omitempty"`
	} `json:"params"`
}

внутренние структуры-методы

type NodeStats

type NodeStats struct {
	Address            string `json:"address"`
	Type               string `json:"type"`
	AvgRps             string `json:"avgRps"`
	IsLatency          bool   `json:"isLatency"`
	IP                 string `json:"ip"`
	Geo                string `json:"geo"`
	State              string `json:"state"`
	Timestamp          int    `json:"timestamp"`
	Success            bool   `json:"success"`
	LastBlockTimestamp int    `json:"lastBlockTimestamp"`
}

func GetNodeStats

func GetNodeStats(address string) (*NodeStats, error)

func (*NodeStats) GetTest

func (ns *NodeStats) GetTest() (*NodeStatsState, error)

type NodeStatsState

type NodeStatsState struct {
	ID      string `json:"id"`
	Jsonrpc string `json:"jsonrpc"`
	Method  string `json:"method"`
	Params  struct {
		Type              string `json:"type"`
		Ver               string `json:"ver"`
		Address           string `json:"address"`
		Host              string `json:"host"`
		Blockheightcheck  string `json:"blockHeightCheck"`
		Requestsperminute string `json:"requestsPerMinute"`
		Latency           string `json:"latency"`
		Geo               string `json:"geo"`
		Success           string `json:"success"`
	} `json:"params"`
}

type NodeTest

type NodeTest struct {
	TimeStamp int64  `json:"timestamp"`
	Method    string `json:"method"`
	Params    struct {
		Mhaddr   string `json:"mhaddr"`
		IP       string `json:"ip"`
		QPS      int64  `json:"qps"`
		Rps      int64  `json:"rps"`
		Closed   string `json:"closed"`
		Timeouts string `json:"timeouts"`
		Ver      string `json:"ver"`
		Success  string `json:"success"`
	} `json:"params"`
}

type NodeTrust

type NodeTrust struct {
	Address            string `json:"address"`
	Trust              int64  `json:"trust"`
	Data               string `json:"data"`
	Timestamp          int64  `json:"timestamp"`
	Lastblocktimestamp int64  `json:"lastBlockTimestamp"`
}

func GetLastNodeStatTrust

func GetLastNodeStatTrust(address string) (*NodeTrust, error)

func (*NodeTrust) GetTrustData

func (nt *NodeTrust) GetTrustData() (*NodeTrustData, error)

GetTrustData returns trust and list of delete to and delegate from

type NodeTrustData

type NodeTrustData struct {
	State      int `json:"state"`
	Trust      int `json:"trust"`
	DelegateTo []struct {
		A string `json:"a"`
		V int64  `json:"v"`
	} `json:"delegate_to"`
	DelegatedFrom []struct {
		A string `json:"a"`
		V int64  `json:"v"`
	} `json:"delegated_from"`
}

type RPCClient

type RPCClient interface {
	// Call is used to send a JSON-RPC request to the server endpoint.
	//
	// The spec states, that params can only be an array or an object, no primitive values.
	// So there are a few simple rules to notice:
	//
	// 1. no params: params field is omitted. e.g. Call("getinfo")
	//
	// 2. single params primitive value: value is wrapped in array. e.g. Call("getByID", 1423)
	//
	// 3. single params value array or object: value is unchanged. e.g. Call("storePerson", &Person{Name: "Alex"})
	//
	// 4. multiple params values: always wrapped in array. e.g. Call("setDetails", "Alex, 35, "Germany", true)
	//
	// Examples:
	//   Call("getinfo") -> {"method": "getinfo"}
	//   Call("getPersonId", 123) -> {"method": "getPersonId", "params": [123]}
	//   Call("setName", "Alex") -> {"method": "setName", "params": ["Alex"]}
	//   Call("setMale", true) -> {"method": "setMale", "params": [true]}
	//   Call("setNumbers", []int{1, 2, 3}) -> {"method": "setNumbers", "params": [1, 2, 3]}
	//   Call("setNumbers", 1, 2, 3) -> {"method": "setNumbers", "params": [1, 2, 3]}
	//   Call("savePerson", &Person{Name: "Alex", Age: 35}) -> {"method": "savePerson", "params": {"name": "Alex", "age": 35}}
	//   Call("setPersonDetails", "Alex", 35, "Germany") -> {"method": "setPersonDetails", "params": ["Alex", 35, "Germany"}}
	//
	// for more information, see the examples or the unit tests
	Call(method string, params ...interface{}) (*RPCResponse, error)
	CallWID(method string, params ...interface{}) (*RPCResponse, error)

	// CallRaw is like Call() but without magic in the requests.Params field.
	// The RPCRequest object is sent exactly as you provide it.
	// See docs: NewRequest, RPCRequest, Params()
	//
	// It is recommended to first consider Call() and CallFor()
	CallRaw(request *RPCRequest) (*RPCResponse, error)

	// CallFor is a very handy function to send a JSON-RPC request to the server endpoint
	// and directly specify an object to store the response.
	//
	// out: will store the unmarshaled object, if request was successful.
	// should always be provided by references. can be nil even on success.
	// the behaviour is the same as expected from json.Unmarshal()
	//
	// method and params: see Call() function
	//
	// if the request was not successful (network, http error) or the rpc response returns an error,
	// an error is returned. if it was an JSON-RPC error it can be casted
	// to *RPCError.
	//
	CallFor(out interface{}, method string, params ...interface{}) error

	// CallBatch invokes a list of RPCRequests in a single batch request.
	//
	// Most convenient is to use the following form:
	// CallBatch(RPCRequests{
	//   NewRequest("myMethod1", 1, 2, 3),
	//   NewRequest("myMethod2", "Test"),
	// })
	//
	// You can create the []*RPCRequest array yourself, but it is not recommended and you should notice the following:
	// - field Params is sent as provided, so Params: 2 forms an invalid json (correct would be Params: []int{2})
	// - you can use the helper function Params(1, 2, 3) to use the same format as in Call()
	// - field JSONRPC is overwritten and set to value: "2.0"
	// - field ID is overwritten and set incrementally and maps to the array position (e.g. requests[5].ID == 5)
	//
	//
	// Returns RPCResponses that is of type []*RPCResponse
	// - note that a list of RPCResponses can be received unordered so it can happen that: responses[i] != responses[i].ID
	// - RPCPersponses is enriched with helper functions e.g.: responses.HasError() returns  true if one of the responses holds an RPCError
	CallBatch(requests RPCRequests) (RPCResponses, error)

	// CallBatchRaw invokes a list of RPCRequests in a single batch request.
	// It sends the RPCRequests parameter is it passed (no magic, no id autoincrement).
	//
	// Consider to use CallBatch() instead except you have some good reason not to.
	//
	// CallBatchRaw(RPCRequests{
	//   &RPCRequest{
	//     ID: 123,            // this won't be replaced in CallBatchRaw
	//     JSONRPC: "wrong",   // this won't be replaced in CallBatchRaw
	//     Method: "myMethod1",
	//     Params: []int{1},   // there is no magic, be sure to only use array or object
	//   },
	//   &RPCRequest{
	//     ID: 612,
	//     JSONRPC: "2.0",
	//     Method: "myMethod2",
	//     Params: Params("Alex", 35, true), // you can use helper function Params() (see doc)
	//   },
	// })
	//
	// Returns RPCResponses that is of type []*RPCResponse
	// - note that a list of RPCResponses can be received unordered
	// - the id's must be mapped against the id's you provided
	// - RPCPersponses is enriched with helper functions e.g.: responses.HasError() returns  true if one of the responses holds an RPCError
	CallBatchRaw(requests RPCRequests) (RPCResponses, error)
}

RPCClient sends JSON-RPC requests over HTTP to the provided JSON-RPC backend.

RPCClient is created using the factory function NewClient().

func NewClient

func NewClient(endpoint string) RPCClient

NewClient returns a new RPCClient instance with default configuration.

endpoint: JSON-RPC service URL to which JSON-RPC requests are sent.

func NewClientWithOpts

func NewClientWithOpts(endpoint string, opts *RPCClientOpts) RPCClient

NewClientWithOpts returns a new RPCClient instance with custom configuration.

endpoint: JSON-RPC service URL to which JSON-RPC requests are sent.

opts: RPCClientOpts provide custom configuration

type RPCClientOpts

type RPCClientOpts struct {
	HTTPClient    *http.Client
	CustomHeaders map[string]string
}

RPCClientOpts can be provided to NewClientWithOpts() to change configuration of RPCClient.

HTTPClient: provide a custom http.Client (e.g. to set a proxy, or tls options)

CustomHeaders: provide custom headers, e.g. to set BasicAuth

type RPCError

type RPCError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
	// MetaHash hack
	CountBlocks int64 `json:"countBlocks"`
	KnownBlocks int64 `json:"knownBlocks,omitempty"`
	KnwonBlock  int64 `json:"knwonBlock,omitempty"` // да да
}

RPCError represents a JSON-RPC error object if an RPC error occurred.

Code: holds the error code

Message: holds a short error message

Data: holds additional error data, may be nil

See: http://www.jsonrpc.org/specification#error_object

func (*RPCError) Error

func (e *RPCError) Error() string

Error function is provided to be used as error object.

type RPCRequest

type RPCRequest struct {
	Method  string      `json:"method"`
	Params  interface{} `json:"params,omitempty"`
	ID      int         `json:"id,omitempty"`
	JSONRPC string      `json:"jsonrpc"`
}

RPCRequest represents a JSON-RPC request object.

Method: string containing the method to be invoked

Params: can be nil. if not must be an json array or object

ID: may always set to 1 for single requests. Should be unique for every request in one batch request.

JSONRPC: must always be set to "2.0" for JSON-RPC version 2.0

See: http://www.jsonrpc.org/specification#request_object

Most of the time you shouldn't create the RPCRequest object yourself. The following functions do that for you: Call(), CallFor(), NewRequest()

If you want to create it yourself (e.g. in batch or CallRaw()), consider using Params(). Params() is a helper function that uses the same parameter syntax as Call().

e.g. to manually create an RPCRequest object:

request := &RPCRequest{
  Method: "myMethod",
  Params: Params("Alex", 35, true),
}

If you know what you are doing you can omit the Params() call to avoid some reflection but potentially create incorrect rpc requests:

request := &RPCRequest{
  Method: "myMethod",
  Params: 2, <-- invalid since a single primitive value must be wrapped in an array --> no magic without Params()
}

correct:

request := &RPCRequest{
  Method: "myMethod",
  Params: []int{2}, <-- invalid since a single primitive value must be wrapped in an array
}

func NewRequest

func NewRequest(method string, params ...interface{}) *RPCRequest

NewRequest returns a new RPCRequest that can be created using the same convenient parameter syntax as Call()

e.g. NewRequest("myMethod", "Alex", 35, true)

type RPCRequests

type RPCRequests []*RPCRequest

RPCRequests is of type []*RPCRequest. This type is used to provide helper functions on the request list

type RPCResponse

type RPCResponse struct {
	JSONRPC string      `json:"jsonrpc"`
	Result  interface{} `json:"result,omitempty"`
	ID      int         `json:"id,int"`
	Error   *RPCError   `json:"error,omitempty"`

	// metahash
	Version string      `json:"version,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

RPCResponse represents a JSON-RPC response object.

Result: holds the result of the rpc call if no error occurred, nil otherwise. can be nil even on success.

Error: holds an RPCError object if an error occurred. must be nil on success.

ID: may always be 0 for single requests. is unique for each request in a batch call (see CallBatch())

JSONRPC: must always be set to "2.0" for JSON-RPC version 2.0

See: http://www.jsonrpc.org/specification#response_object

func (*RPCResponse) GetBool

func (RPCResponse *RPCResponse) GetBool() (bool, error)

GetBool converts the rpc response to a bool and returns it.

If result was not a bool an error is returned.

func (*RPCResponse) GetFloat

func (RPCResponse *RPCResponse) GetFloat() (float64, error)

GetFloat converts the rpc response to float64 and returns it.

If result was not an float64 an error is returned.

func (*RPCResponse) GetInt

func (RPCResponse *RPCResponse) GetInt() (int64, error)

GetInt converts the rpc response to an int64 and returns it.

If result was not an integer an error is returned.

func (*RPCResponse) GetObject

func (RPCResponse *RPCResponse) GetObject(toType interface{}) error

GetObject converts the rpc response to an arbitrary type.

The function works as you would expect it from json.Unmarshal()

func (*RPCResponse) GetString

func (RPCResponse *RPCResponse) GetString() (string, error)

GetString converts the rpc response to a string and returns it.

If result was not a string an error is returned.

type RPCResponses

type RPCResponses []*RPCResponse

RPCResponses is of type []*RPCResponse. This type is used to provide helper functions on the result list

func (RPCResponses) AsMap

func (res RPCResponses) AsMap() map[int]*RPCResponse

AsMap returns the responses as map with response id as key.

func (RPCResponses) GetByID

func (res RPCResponses) GetByID(id int) *RPCResponse

GetByID returns the response object of the given id, nil if it does not exist.

func (RPCResponses) HasError

func (res RPCResponses) HasError() bool

HasError returns true if one of the response objects has Error field != nil

type Status

type Status struct {
	ID      int    `json:"id"`
	Result  string `json:"result"`
	Version string `json:"version"`
	GitHash string `json:"git_hash"`
}

type TotalSupply

type TotalSupply struct {
	CirculatingSupply    string `json:"circulating_supply"`     //Number of coins in circulation
	CirculatingSupplyCmc string `json:"circulating_supply_cmc"` //Number of coins in circulation (by CoinMarketCap)
	TotalSupply          string `json:"total_supply"`           //Number of all coins emitted
	TotalSupplyDecimals  string `json:"total_supply_decimals"`  //Number of all coins emitted in micro units
	MaxSupply            string `json:"max_supply"`             //Maximum possible number of coins
	Decimals             int    `json:"decimals"`               //Number of decimal places
	Name                 string `json:"name"`                   //Name of the currency
}

func MetahashSupply

func MetahashSupply() (*TotalSupply, error)

type Transaction

type Transaction struct {
	Transaction TransactionInfo `json:"transaction"`
	CountBlocks int64           `json:"countBlocks"`
	KnownBlocks int64           `json:"knownBlocks"`
}

func GetTransaction

func GetTransaction(txHash string) (*Transaction, error)

GetTransaction returns the transaction details given the transaction hash

type TransactionArgs

type TransactionArgs struct {
	Hash string `json:"hash"`
}

type TransactionInfo

type TransactionInfo struct {
	From         string `json:"from" db:"fromA"`
	To           string `json:"to" db:"toA"`
	Value        int64  `json:"value"`
	Transaction  string `json:"transaction"`
	Data         string `json:"data"`
	TimeStamp    int64  `json:"timestamp" db:"timestamp,int64"`
	Type         string `json:"type" db:"typeTx"`
	BlockNumber  int64  `json:"blockNumber" db:"blockNumber"`
	Signature    string `json:"signature"`
	PublicKey    string `json:"publickey"`
	Fee          int64  `json:"fee"`
	RealFee      int64  `json:"realFee" db:"realFee"`
	Nonce        int64  `json:"nonce"`
	IntStatus    int64  `json:"intStatus" db:"intStatus"`
	Status       string `json:"status"`
	IsDelegate   bool   `json:"isDelegate,omitempty" db:"isDelegate"`
	DelegateInfo struct {
		IsDelegate   bool   `json:"isDelegate"`
		Delegate     int64  `json:"delegate,omitempty"`
		DelegateHash string `json:"delegateHash,omitempty"`
	} `json:"delegate_info,omitempty" db:"-"`
	Delegate     int64  `json:"delegate,omitempty"`
	DelegateHash string `json:"delegateHash,omitempty" db:"delegateHash"`
}

func FetchHistory

func FetchHistory(address string) ([]*TransactionInfo, error)

FetchHistory returns all transactions history of a given address

func FetchHistoryFiter

func FetchHistoryFiter(address string, startIndex, numTrx int64) ([]*TransactionInfo, error)

FetchHistoryRange returns list of transaction history from a given index

func GetLastTransactions

func GetLastTransactions() ([]*TransactionInfo, error)

GetLastTransactions returns the list of last transactions made

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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