Documentation ¶
Index ¶
- Constants
- Variables
- func GetDurationTime(timestamp int32) int
- func GetTime() int32
- func GetTransactionTime(timestamp int32) time.Time
- func LoadActiveConfiguration(arknetwork ArkNetworkType) string
- type AccountData
- type AccountQueryParams
- type AccountResponse
- type ArkApiResponseError
- type ArkClient
- func (s *ArkClient) CalculateVotersProfit(params DelegateQueryParams, shareRatio float64, blocklist string) []DelegateDataProfit
- func (s *ArkClient) GetAccount(params AccountQueryParams) (AccountResponse, *http.Response, error)
- func (s *ArkClient) GetActivePeer() Peer
- func (s *ArkClient) GetAllPeers() (PeerResponse, ArkApiResponseError, *http.Response)
- func (s *ArkClient) GetConnectedPeerStatus() (model.PeerStatus, *http.Response, error)
- func (s *ArkClient) GetDelegate(params DelegateQueryParams) (DelegateResponse, *http.Response, error)
- func (s *ArkClient) GetDelegateVoteWeight(params DelegateQueryParams) (int, *http.Response, error)
- func (s *ArkClient) GetDelegateVoters(params DelegateQueryParams) (DelegateVoters, *http.Response, error)
- func (s *ArkClient) GetForgedData(params DelegateQueryParams) (ForgedDetails, *http.Response, error)
- func (s *ArkClient) GetFullBlocksFromPeer(lastBlockHeight int) (model.BlockResponse, ArkApiResponseError, *http.Response)
- func (s *ArkClient) GetPeer(params PeerQueryParams) (PeerResponse, *http.Response, error)
- func (s *ArkClient) GetPeerHeight() (model.BlockHeightResponse, ArkApiResponseError, *http.Response)
- func (s *ArkClient) GetRandomXPeers(numberOfPeers int) []Peer
- func (s *ArkClient) GetTransaction(params TransactionQueryParams) (TransactionResponse, *http.Response, error)
- func (s *ArkClient) GetTransactionUnconfirmed(params TransactionQueryParams) (TransactionResponse, *http.Response, error)
- func (s *ArkClient) GetVoteDuration(address string) int
- func (s *ArkClient) ListDelegates(params DelegateQueryParams) (DelegateResponse, *http.Response, error)
- func (s *ArkClient) ListPeers(params PeerQueryParams) (PeerResponse, *http.Response, error)
- func (s *ArkClient) ListTransaction(params TransactionQueryParams) (TransactionResponse, *http.Response, error)
- func (s *ArkClient) ListTransactionUnconfirmed(params TransactionQueryParams) (TransactionResponse, *http.Response, error)
- func (s *ArkClient) PostTransaction(payload TransactionPayload) (PostTransactionResponse, *http.Response, error)
- func (s *ArkClient) SetActiveConfiguration(arkNetwork ArkNetworkType) *ArkClient
- func (s *ArkClient) SwitchPeer() *ArkClient
- type ArkEnvParams
- type ArkNetworkType
- type DelegateData
- type DelegateDataProfit
- type DelegateQueryParams
- type DelegateResponse
- type DelegateVoters
- type Fees
- type ForgedDetails
- type Network
- type Peer
- type PeerQueryParams
- type PeerResponse
- type PostTransactionResponse
- type Transaction
- func CreateDelegate(username, passphrase, secondPassphrase string) *Transaction
- func CreateSecondSignature(passphrase, secondPassphrase string) *Transaction
- func CreateTransaction(recipientID string, satoshiAmount int64, ...) *Transaction
- func CreateVote(updown, delegatePubKey, passphrase, secondPassphrase string) *Transaction
- type TransactionPayload
- type TransactionQueryParams
- type TransactionResponse
- type TransactionType
Constants ¶
const ( //MAINNET connection MAINNET = iota //DEVNET connection DEVNET )
const ( SENDARK = 0 SECONDSIGNATURE = 1 CREATEDELEGATE = 2 VOTE = 3 MULTISIGNATURE = 4 )
const (
SATOSHI = 100000000
)
TO HELP DIVIDE TODO rename
Variables ¶
var BaseURL = ""
BaseURL holds the IP,PORT of the connected peer used for the communication
var EnvironmentParams = new(ArkEnvParams)
EnvironmentParams - Global ARK EnvironmentParams read from acitve peers
Functions ¶
func GetDurationTime ¶
GetDurationTime Calculates duration between now and provided timestamp
func GetTime ¶
func GetTime() int32
GetTime return time slot difference in secods. This timestamp is added to the transaction.
func GetTransactionTime ¶
GetTransactionTime from timestamp
func LoadActiveConfiguration ¶
func LoadActiveConfiguration(arknetwork ArkNetworkType) string
LoadActiveConfiguration reads arknetwork parameters from the Network and fills the EnvironmentParams structure selected and connected peer address is returned
Types ¶
type AccountData ¶
type AccountData struct { Address string `json:"address"` UnconfirmedBalance string `json:"unconfirmedBalance"` Balance string `json:"balance"` PublicKey string `json:"publicKey"` UnconfirmedSignature int `json:"unconfirmedSignature"` SecondSignature int `json:"secondSignature"` SecondPublicKey interface{} `json:"secondPublicKey"` Multisignatures []interface{} `json:"multisignatures"` UMultisignatures []interface{} `json:"u_multisignatures"` }
AccountData structure
type AccountQueryParams ¶
type AccountQueryParams struct {
Address string `url:"address,omitempty"`
}
AccountQueryParams structure
type AccountResponse ¶
type AccountResponse struct { Success bool `json:"success"` Account AccountData `json:"account"` }
AccountResponse structure
type ArkApiResponseError ¶
type ArkApiResponseError struct { Success bool `json:"success,omitempty"` Message string `json:"message,omitempty"` ErrorMessage string `json:"error,omitempty"` Data string `json:"data,omitempty"` ErrorObj error `json:"ignore"` }
ArkApiResponseError struct to hold error response from api node
func (ArkApiResponseError) Error ¶
func (e ArkApiResponseError) Error() string
Error interface function
type ArkClient ¶
type ArkClient struct {
// contains filtered or unexported fields
}
ArkClient sling rest pointer
func NewArkClient ¶
NewArkClient creations with supported network
func NewArkClientFromPeer ¶ added in v0.7.0
NewArkClientFromPeer creations with supported network
func TestMethodNewArkClient ¶ added in v0.6.0
TestMethodNewArkClient creations with supported network A test method for local node testing when implementid Not for production use
func (*ArkClient) CalculateVotersProfit ¶
func (s *ArkClient) CalculateVotersProfit(params DelegateQueryParams, shareRatio float64, blocklist string) []DelegateDataProfit
CalculateVotersProfit returns voter calculation details - based on settings
func (*ArkClient) GetAccount ¶
func (s *ArkClient) GetAccount(params AccountQueryParams) (AccountResponse, *http.Response, error)
GetAccount by address function returns list of peers from ArkNode
func (*ArkClient) GetActivePeer ¶ added in v0.6.0
GetActivePeer returns active peer connected doesn't call rest to update it updates when calling SwitchPeer or Network is Changed
func (*ArkClient) GetAllPeers ¶ added in v0.6.0
func (s *ArkClient) GetAllPeers() (PeerResponse, ArkApiResponseError, *http.Response)
GetAllPeers function returns list of peers from ArkNode
func (*ArkClient) GetConnectedPeerStatus ¶ added in v0.6.0
GetConnectedPeerStatus function returns connected peer status
func (*ArkClient) GetDelegate ¶
func (s *ArkClient) GetDelegate(params DelegateQueryParams) (DelegateResponse, *http.Response, error)
GetDelegate function returns a delegate
func (*ArkClient) GetDelegateVoteWeight ¶
GetDelegateVoteWeight function returns a summary of ARK voted for selected delegate
func (*ArkClient) GetDelegateVoters ¶
func (s *ArkClient) GetDelegateVoters(params DelegateQueryParams) (DelegateVoters, *http.Response, error)
GetDelegateVoters function returns a delegate
func (*ArkClient) GetForgedData ¶
func (s *ArkClient) GetForgedData(params DelegateQueryParams) (ForgedDetails, *http.Response, error)
GetForgedData details
func (*ArkClient) GetFullBlocksFromPeer ¶ added in v0.6.0
func (s *ArkClient) GetFullBlocksFromPeer(lastBlockHeight int) (model.BlockResponse, ArkApiResponseError, *http.Response)
GetFullBlocksFromPeer function returns a full list of blocks from current last block on. A random number of blocks is returned, due to ddos measures
func (*ArkClient) GetPeer ¶
func (s *ArkClient) GetPeer(params PeerQueryParams) (PeerResponse, *http.Response, error)
GetPeer function returns one peer with params
func (*ArkClient) GetPeerHeight ¶ added in v0.6.0
func (s *ArkClient) GetPeerHeight() (model.BlockHeightResponse, ArkApiResponseError, *http.Response)
GetPeerHeight function returns node peer height.
func (*ArkClient) GetRandomXPeers ¶ added in v0.7.0
GetRandomXPeers returns requested number of randomly selected peers from healthy peer list used in multiplethreadbroadcast
func (*ArkClient) GetTransaction ¶
func (s *ArkClient) GetTransaction(params TransactionQueryParams) (TransactionResponse, *http.Response, error)
GetTransaction function returns list of peers from ArkNode
func (*ArkClient) GetTransactionUnconfirmed ¶
func (s *ArkClient) GetTransactionUnconfirmed(params TransactionQueryParams) (TransactionResponse, *http.Response, error)
GetTransactionUnconfirmed function returns list of peers from ArkNode
func (*ArkClient) GetVoteDuration ¶ added in v0.7.5
GetVoteDuration returns vote duration in HOURS
func (*ArkClient) ListDelegates ¶
func (s *ArkClient) ListDelegates(params DelegateQueryParams) (DelegateResponse, *http.Response, error)
ListDelegates function returns list of delegtes. The top 51 delegates are returned
func (*ArkClient) ListPeers ¶
func (s *ArkClient) ListPeers(params PeerQueryParams) (PeerResponse, *http.Response, error)
ListPeers function returns list of peers from ArkNode
func (*ArkClient) ListTransaction ¶
func (s *ArkClient) ListTransaction(params TransactionQueryParams) (TransactionResponse, *http.Response, error)
ListTransaction function returns list of peers from ArkNode
func (*ArkClient) ListTransactionUnconfirmed ¶
func (s *ArkClient) ListTransactionUnconfirmed(params TransactionQueryParams) (TransactionResponse, *http.Response, error)
ListTransactionUnconfirmed function returns list of peers from ArkNode
func (*ArkClient) PostTransaction ¶
func (s *ArkClient) PostTransaction(payload TransactionPayload) (PostTransactionResponse, *http.Response, error)
PostTransaction to selected ARKNetwork
func (*ArkClient) SetActiveConfiguration ¶
func (s *ArkClient) SetActiveConfiguration(arkNetwork ArkNetworkType) *ArkClient
SetActiveConfiguration sets a new client connection, switches network and reads network settings from peer usage - must reassing new pointer value: arkapi = arkapi.SetActiveConfiguration(MAINNET)
func (*ArkClient) SwitchPeer ¶ added in v0.6.0
SwitchPeer switches client connection to another node usage: must reassing pointer: arkapi = arkapi.SwitchPeer()
type ArkEnvParams ¶
type ArkEnvParams struct { Success bool `json:"success"` Network Network `json:"network"` Fees Fees `json:"fees"` }
ArkEnvParams structure to hold parameters from autoconfigure structure is filled from peers at arkclient init call
type DelegateData ¶
type DelegateData struct { Username string `json:"username"` Address string `json:"address"` PublicKey string `json:"publicKey"` Vote string `json:"vote"` Producedblocks int `json:"producedblocks"` Missedblocks int `json:"missedblocks"` Rate int `json:"rate"` Approval float64 `json:"approval"` Productivity float64 `json:"productivity"` }
DelegateData holds parsed json from api calls. It is used in upper DelegateResponse struct
type DelegateDataProfit ¶
type DelegateDataProfit struct { Address string VoteWeight float64 EarnedAmount100 float64 //100 earned amount. EarnedAmountXX float64 //XX share to be payed VoteDuration int //Duration of vote in Hours }
DelegateDataProfit structure - returns calculated profits based on input parameters
type DelegateQueryParams ¶
type DelegateQueryParams struct { UserName string `url:"username,omitempty"` PublicKey string `url:"publicKey,omitempty"` Offset int `url:"offset,omitempty"` OrderBy string `url:"orderBy,omitempty"` Limit int `url:"limit,omitempty"` }
DelegateQueryParams - when set, they are automatically added to get requests
type DelegateResponse ¶
type DelegateResponse struct { Success bool `json:"success,omitempty"` Delegates []DelegateData `json:"delegates,omitempty"` SingleDelegate DelegateData `json:"delegate,omitempty"` TotalCount int `json:"totalCount,omitempty"` }
DelegateResponse data - received from api-call.
type DelegateVoters ¶
type DelegateVoters struct { Success bool `json:"success"` Accounts []struct { Username string `json:"username"` Address string `json:"address"` PublicKey string `json:"publicKey"` Balance string `json:"balance"` } `json:"accounts"` }
DelegateVoters struct to hold voters for a publicKey(delegate)
type Fees ¶
type Fees struct { Send int64 `json:"send"` Vote int64 `json:"vote"` SecondSignature int64 `json:"secondsignature"` Delegate int64 `json:"delegate"` MultiSignature int64 `json:"multisignature"` }
Fees constant parameters for active configuration
type ForgedDetails ¶
type ForgedDetails struct { Success bool `json:"success"` Fees string `json:"fees"` Rewards string `json:"rewards"` Forged string `json:"forged"` }
ForgedDetails structureto hold delegate details
type Network ¶
type Network struct { Nethash string `json:"nethash"` Token string `json:"token"` Symbol string `json:"symbol"` Explorer string `json:"explorer"` AddressVersion byte `json:"version"` //this is address generator version!!! Type ArkNetworkType //holding ark networktype ActivePeer Peer PeerList []Peer }
Network parameters
type Peer ¶
type Peer struct { IP string `json:"ip"` Port int `json:"port"` Version string `json:"version,omitempty"` Os string `json:"os,omitempty"` Height int `json:"height,omitempty"` Status string `json:"status"` Delay int `json:"delay"` }
Peer structure to hold peer data
type PeerQueryParams ¶
type PeerQueryParams struct { Status string `url:"status,omitempty"` //State of peer. OK, ETIMEOUT,... Os string `url:"os,omitempty"` //OS of peer. (String) Version string `url:"version,omitempty"` //Version of peer. (String) Limit int `url:"limit,omitempty"` //Limit to show. Max limit is 100. (Integer) OrderBy string `url:"orderBy,omitempty"` //Name of column to order. After column name must go 'desc' or 'asc' to choose order type. (String) Offset int `url:"offset,omitempty"` IP string `url:"ip,omitempty"` Port int `url:"port,omitempty"` }
PeerQueryParams - when set, they are automatically added to get requests
type PeerResponse ¶
type PeerResponse struct { Success bool `json:"success"` Peers []Peer `json:"peers"` SinglePeer Peer `json:"peer"` }
PeerResponse structure for call /peer/list
type PostTransactionResponse ¶
type PostTransactionResponse struct { Success bool `json:"success"` Message string `json:"message"` Error string `json:"error"` TransactionIDs []string `json:"transactionIds"` }
PostTransactionResponse structure for call /peer/list
type Transaction ¶
type Transaction struct { ID string `json:"id,omitempty"` Timestamp int32 `json:"timestamp,omitempty"` RecipientID string `json:"recipientId,omitempty"` Amount int64 `json:"amount,omitempty"` Asset map[string]string `json:"asset,omitempty"` Fee int64 `json:"fee,omitempty"` Type byte `json:"type"` VendorField string `json:"vendorField,omitempty"` Signature string `json:"signature,omitempty"` SignSignature string `json:"signSignature,omitempty"` SenderPublicKey string `json:"senderPublicKey,omitempty"` SecondSenderPublicKey string `json:"secondSenderPublicKey,omitempty"` RequesterPublicKey string `json:"requesterPublicKey,omitempty"` Blockid string `json:"blockid,omitempty"` Height int `json:"height,omitempty"` SenderID string `json:"senderId,omitempty"` Confirmations int `json:"confirmations,omitempty"` }
Transaction struct - represents structure of ARK.io blockchain transaction It is used to post transaction to mainnet and to receive results from arkapi Empty fields are emmited by default
func CreateDelegate ¶
func CreateDelegate(username, passphrase, secondPassphrase string) *Transaction
CreateDelegate creates and returns new Transaction struct...
func CreateSecondSignature ¶
func CreateSecondSignature(passphrase, secondPassphrase string) *Transaction
CreateSecondSignature creates and returns new Transaction struct...
func CreateTransaction ¶
func CreateTransaction(recipientID string, satoshiAmount int64, vendorField, passphrase, secondPassphrase string) *Transaction
CreateTransaction creates and returns new Transaction struct...
func CreateVote ¶
func CreateVote(updown, delegatePubKey, passphrase, secondPassphrase string) *Transaction
CreateVote transaction used to vote for a chosen Delegate if updown value = "+" vot is given to the specified PublicKey if updown value = "-" vot is taken from the specified PublicKey
func (*Transaction) SecondVerify ¶
func (tx *Transaction) SecondVerify() error
SecondVerify function verifies if tx is validly signed if return == nill verification was succesfull
func (*Transaction) ToJSON ¶
func (tx *Transaction) ToJSON() string
ToJSON converts transaction object to JSON string
func (*Transaction) Verify ¶
func (tx *Transaction) Verify() error
Verify function verifies if tx is validly signed if return == nill verification was succesfull
type TransactionPayload ¶
type TransactionPayload struct {
Transactions []*Transaction `json:"transactions"`
}
TransactionPayload - list of tx to send to network
type TransactionQueryParams ¶
type TransactionQueryParams struct { ID string `url:"id,omitempty"` BlockID string `url:"blockId,omitempty"` SenderID string `url:"senderId,omitempty"` RecipientID string `url:"recipientId,omitempty"` Limit int `url:"limit,omitempty"` Offset int `url:"offset,omitempty"` OrderBy string `url:"orderBy,omitempty"` //"Name of column to order. After column name must go 'desc' or 'asc' to choose order type, prefix for column name is t_. Example: orderBy=t_timestamp:desc (String)" Type TransactionType `url:"type,omitempty"` }
TransactionQueryParams for returing filtered list of transactions
type TransactionResponse ¶
type TransactionResponse struct { Success bool `json:"success"` Transactions []Transaction `json:"transactions"` SingleTransaction Transaction `json:"transaction"` Count string `json:"count"` Error string `json:"error"` }
TransactionResponse structure holds parsed jsong reply from ark-node when calling list methods the Transactions [] has results when calling get methods the transaction object (Single) has results