zcncore

package
v1.8.6 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 45 Imported by: 11

Documentation

Index

Constants

View Source
const (
	REGISTER_CLIENT                  = `/v1/client/put`
	GET_CLIENT                       = `/v1/client/get`
	PUT_TRANSACTION                  = `/v1/transaction/put`
	TXN_VERIFY_URL                   = `/v1/transaction/get/confirmation?hash=`
	GET_BALANCE                      = `/v1/client/get/balance?client_id=`
	GET_BLOCK_INFO                   = `/v1/block/get?`
	GET_MAGIC_BLOCK_INFO             = `/v1/block/magic/get?`
	GET_LATEST_FINALIZED             = `/v1/block/get/latest_finalized`
	GET_LATEST_FINALIZED_MAGIC_BLOCK = `/v1/block/get/latest_finalized_magic_block`
	GET_CHAIN_STATS                  = `/v1/chain/get/stats`

	VESTINGSC_PFX = `/v1/screst/` + VestingSmartContractAddress

	GET_VESTING_CONFIG       = VESTINGSC_PFX + `/vesting-config`
	GET_VESTING_POOL_INFO    = VESTINGSC_PFX + `/getPoolInfo`
	GET_VESTING_CLIENT_POOLS = VESTINGSC_PFX + `/getClientPools`

	FAUCETSC_PFX        = `/v1/screst/` + FaucetSmartContractAddress
	GET_FAUCETSC_CONFIG = FAUCETSC_PFX + `/faucet-config`

	MINERSC_PFX          = `/v1/screst/` + MinerSmartContractAddress
	GET_MINERSC_NODE     = MINERSC_PFX + "/nodeStat"
	GET_MINERSC_POOL     = MINERSC_PFX + "/nodePoolStat"
	GET_MINERSC_CONFIG   = MINERSC_PFX + "/configs"
	GET_MINERSC_GLOBALS  = MINERSC_PFX + "/globalSettings"
	GET_MINERSC_USER     = MINERSC_PFX + "/getUserPools"
	GET_MINERSC_MINERS   = MINERSC_PFX + "/getMinerList"
	GET_MINERSC_SHARDERS = MINERSC_PFX + "/getSharderList"
	GET_MINERSC_EVENTS   = MINERSC_PFX + "/getEvents"

	STORAGESC_PFX = "/v1/screst/" + StorageSmartContractAddress

	STORAGESC_GET_SC_CONFIG            = STORAGESC_PFX + "/storage-config"
	STORAGESC_GET_CHALLENGE_POOL_INFO  = STORAGESC_PFX + "/getChallengePoolStat"
	STORAGESC_GET_ALLOCATION           = STORAGESC_PFX + "/allocation"
	STORAGESC_GET_ALLOCATIONS          = STORAGESC_PFX + "/allocations"
	STORAGESC_GET_READ_POOL_INFO       = STORAGESC_PFX + "/getReadPoolStat"
	STORAGESC_GET_STAKE_POOL_INFO      = STORAGESC_PFX + "/getStakePoolStat"
	STORAGESC_GET_STAKE_POOL_USER_INFO = STORAGESC_PFX + "/getUserStakePoolStat"
	STORAGESC_GET_BLOBBERS             = STORAGESC_PFX + "/getblobbers"
	STORAGESC_GET_BLOBBER              = STORAGESC_PFX + "/getBlobber"
	STORAGE_GET_TOTAL_STORED_DATA      = STORAGESC_PFX + "/total-stored-data"
)
View Source
const (
	StorageSmartContractAddress  = `6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d7`
	VestingSmartContractAddress  = `2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead`
	FaucetSmartContractAddress   = `6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d3`
	MultiSigSmartContractAddress = `27b5ef7120252b79f9dd9c05505dd28f328c80f6863ee446daede08a84d651a7`
	MinerSmartContractAddress    = `6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d9`
	ZCNSCSmartContractAddress    = `6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712e0`
	MultiSigRegisterFuncName     = "register"
	MultiSigVoteFuncName         = "vote"
)
View Source
const (
	StatusSuccess      int = 0
	StatusNetworkError int = 1
	// TODO: Change to specific error
	StatusError            int = 2
	StatusRejectedByUser   int = 3
	StatusInvalidSignature int = 4
	StatusAuthError        int = 5
	StatusAuthVerifyFailed int = 6
	StatusAuthTimeout      int = 7
	StatusUnknown          int = -1
)
View Source
const (
	OpGetTokenLockConfig int = iota
	OpGetLockedTokens
	OpGetUserPools
	OpGetUserPoolDetail
	// storage SC ops
	OpStorageSCGetConfig
	OpStorageSCGetChallengePoolInfo
	OpStorageSCGetAllocation
	OpStorageSCGetAllocations
	OpStorageSCGetReadPoolInfo
	OpStorageSCGetStakePoolInfo
	OpStorageSCGetBlobbers
	OpStorageSCGetBlobber
	OpZCNSCGetGlobalConfig
	OpZCNSCGetAuthorizer
	OpZCNSCGetAuthorizerNodes
)
View Source
const NETWORK_ENDPOINT = "/network"
View Source
const (
	SharderEndpointHealthCheck = "/v1/healthcheck"
)
View Source
const TOKEN_UNIT int64 = 1e10

Variables

View Source
var (
	ErrNoAvailableSharders     = errors.New("zcn: no available sharders")
	ErrNoEnoughSharders        = errors.New("zcn: sharders is not enough")
	ErrNoEnoughOnlineSharders  = errors.New("zcn: online sharders is not enough")
	ErrInvalidNumSharder       = errors.New("zcn: number of sharders is invalid")
	ErrNoOnlineSharders        = errors.New("zcn: no any online sharder")
	ErrSharderOffline          = errors.New("zcn: sharder is offline")
	ErrInvalidConsensus        = errors.New("zcn: invalid consensus")
	ErrTransactionNotFound     = errors.New("zcn: transaction not found")
	ErrTransactionNotConfirmed = errors.New("zcn: transaction not confirmed")
)
View Source
var GetEthClient = func() (*ethclient.Client, error) {
	if len(_config.chain.EthNode) == 0 {
		return nil, fmt.Errorf("eth node SDK not initialized")
	}

	Logger.Info("requesting from ", _config.chain.EthNode)
	client, err := ethclient.Dial(_config.chain.EthNode)
	if err != nil {
		return nil, err
	}
	return client, nil
}
View Source
var SignFn = func(hash string) (string, error) {
	sigScheme := zcncrypto.NewSignatureScheme(_config.chain.SignatureScheme)
	sigScheme.SetPrivateKey(_config.wallet.Keys[0].PrivateKey)
	return sigScheme.Sign(hash)
}

Functions

func CheckConfig added in v1.7.1

func CheckConfig() error

func CheckEthHashStatus

func CheckEthHashStatus(hash string) int

CheckEthHashStatus - checking the status of ETH transaction possible values 0 or 1

func CloseLog

func CloseLog()

CloseLog closes log file

func ConvertToToken

func ConvertToToken(value int64) float64

ConvertToToken converts the value to ZCN tokens

func ConvertToValue

func ConvertToValue(token float64) uint64

ConvertToValue converts ZCN tokens to value

func ConvertTokenToUSD

func ConvertTokenToUSD(token float64) (float64, error)

func ConvertUSDToToken

func ConvertUSDToToken(usd float64) (float64, error)

func ConvertZcnTokenToETH

func ConvertZcnTokenToETH(f float64) (float64, error)

ConvertZcnTokenToETH - converting Zcn tokens to Eth

func CreateMSVote

func CreateMSVote(proposal, grpClientID, signerWalletstr, toClientID string, token uint64) (string, error)

CreateMSVote create a vote for multisig

func CreateMSWallet

func CreateMSWallet(t, n int) (string, string, []string, error)

CreateMSWallet returns multisig wallet information

func CreateWallet

func CreateWallet(statusCb WalletCallback) error

CreateWallet creates the wallet for to configure signature scheme. It also registers the wallet again to blockchain.

func CreateWalletFromEthMnemonic

func CreateWalletFromEthMnemonic(mnemonic, password string, statusCb WalletCallback) error

CreateWalletFromEthMnemonic - creating new wallet from Eth mnemonics

func Decrypt

func Decrypt(key, text string) (string, error)

func Encrypt

func Encrypt(key, text string) (string, error)

func EthToTokens

func EthToTokens(tokens float64) int64

TokensToEth - converting eth tokens to wei

func GEthToTokens

func GEthToTokens(gwei float64) int64

func GTokensToEth

func GTokensToEth(tokens int64) float64

func GetAllocation

func GetAllocation(allocID string, cb GetInfoCallback) (err error)

GetAllocation obtains allocation information.

func GetAllocations

func GetAllocations(clientID string, cb GetInfoCallback) (err error)

GetAllocations obtains list of allocations of a user.

func GetBalance

func GetBalance(cb GetBalanceCallback) error

GetBalance retreives wallet balance from sharders

func GetBalanceWallet

func GetBalanceWallet(walletStr string, cb GetBalanceCallback) error

GetBalance retreives wallet balance from sharders

func GetBlobber

func GetBlobber(blobberID string, cb GetInfoCallback) (err error)

GetBlobber obtains blobber information.

func GetBlobbers

func GetBlobbers(cb GetInfoCallback) (err error)

GetBlobbers obtains list of all active blobbers.

func GetBlockByRound

func GetBlockByRound(ctx context.Context, numSharders int, round int64) (b *block.Block, err error)

func GetChainStats

func GetChainStats(ctx context.Context) (b *block.ChainStats, err error)

func GetChallengePoolInfo

func GetChallengePoolInfo(allocID string, cb GetInfoCallback) (err error)

GetChallengePoolInfo obtains challenge pool information for an allocation.

func GetClientID

func GetClientID(pkey string) string

GetClientID -- computes Client ID from publickey

func GetClientWalletID added in v1.5.1

func GetClientWalletID() string

func GetEthBalance

func GetEthBalance(ethAddr string, cb GetBalanceCallback) error

GetEthBalance - getting back balance for ETH wallet

func GetEvents added in v1.3.1

func GetEvents(cb GetInfoCallback, filters map[string]string) (err error)

func GetFaucetSCConfig added in v1.2.86

func GetFaucetSCConfig(cb GetInfoCallback) (err error)

func GetIdForUrl

func GetIdForUrl(url string) string

func GetLatestFinalized

func GetLatestFinalized(ctx context.Context, numSharders int) (b *block.Header, err error)

func GetLatestFinalizedMagicBlock

func GetLatestFinalizedMagicBlock(ctx context.Context, numSharders int) (m *block.MagicBlock, err error)

func GetLogger

func GetLogger() *logger.Logger

func GetMagicBlockByNumber

func GetMagicBlockByNumber(ctx context.Context, numSharders int, number int64) (m *block.MagicBlock, err error)

func GetMinShardersVerify

func GetMinShardersVerify() int

func GetMinerSCConfig

func GetMinerSCConfig(cb GetInfoCallback) (err error)

func GetMinerSCGlobals added in v1.2.86

func GetMinerSCGlobals(cb GetInfoCallback) (err error)

func GetMinerSCNodeInfo

func GetMinerSCNodeInfo(id string, cb GetInfoCallback) (err error)

func GetMinerSCNodePool

func GetMinerSCNodePool(id, poolID string, cb GetInfoCallback) (err error)

func GetMinerSCUserInfo

func GetMinerSCUserInfo(clientID string, cb GetInfoCallback) (err error)

func GetMiners

func GetMiners(cb GetInfoCallback) (err error)

GetMiners obtains list of all active miners.

func GetMultisigPayload

func GetMultisigPayload(mswstr string) (interface{}, error)

GetMultisigPayload given a multisig wallet as a string, makes a multisig wallet payload to register

func GetMultisigVotePayload

func GetMultisigVotePayload(msvstr string) (interface{}, error)

GetMultisigVotePayload given a multisig vote as a string, makes a multisig vote payload to register

func GetNetworkJSON

func GetNetworkJSON() string

func GetNonce added in v1.8.3

func GetNonce(cb GetNonceCallback) error

GetBalance retreives wallet nonce from sharders

func GetReadPoolInfo

func GetReadPoolInfo(clientID string, cb GetInfoCallback) (err error)

GetReadPoolInfo obtains information about read pool of a user.

func GetSharders

func GetSharders(cb GetInfoCallback) (err error)

GetSharders obtains list of all active sharders.

func GetStakePoolInfo

func GetStakePoolInfo(blobberID string, cb GetInfoCallback) (err error)

GetStakePoolInfo obtains information about stake pool of a blobber and related validator.

func GetStakePoolUserInfo

func GetStakePoolUserInfo(clientID string, cb GetInfoCallback) (err error)

GetStakePoolUserInfo for a user.

func GetStorageSCConfig

func GetStorageSCConfig(cb GetInfoCallback) (err error)

GetStorageSCConfig obtains Storage SC configurations.

func GetVersion

func GetVersion() string

GetVersion - returns version string

func GetVestingClientList

func GetVestingClientList(clientID string, cb GetInfoCallback) (err error)

func GetVestingPoolInfo

func GetVestingPoolInfo(poolID string, cb GetInfoCallback) (err error)

func GetVestingSCConfig

func GetVestingSCConfig(cb GetInfoCallback) (err error)

func GetWallet

func GetWallet(walletStr string) (*zcncrypto.Wallet, error)

GetWallet get a wallet object from a wallet string

func GetWalletAddrFromEthMnemonic

func GetWalletAddrFromEthMnemonic(mnemonic string) (string, error)

GetWalletAddrFromEthMnemonic - wallet ETH address from mnemoninnc

func GetWalletClientID

func GetWalletClientID(walletStr string) (string, error)

GetWalletClientID -- given a walletstr return ClientID

func GetZcnUSDInfo

func GetZcnUSDInfo() (float64, error)

GetZcnUSDInfo returns USD value for ZCN token from coinmarketcap.com

func Init

func Init(chainConfigJSON string) error

Init inializes the SDK with miner, sharder and signature scheme provided in configuration provided in JSON format It is used for 0proxy, 0box, 0explorer, andorid, ios : walletJSON is ChainConfig

	 {
     "chain_id":"0afc093ffb509f059c55478bc1a60351cef7b4e9c008a53a6cc8241ca8617dfe",
		"signature_scheme" : "bls0chain",
		"block_worker" : "http://localhost/dns",
		"min_submit" : 50,
		"min_confirmation" : 50,
		"confirmation_chain_length" : 3,
		"num_keys" : 1,
		"eth_node" : "https://ropsten.infura.io/v3/xxxxxxxxxxxxxxx"
	 }

func InitSignatureScheme added in v1.8.5

func InitSignatureScheme(scheme string)

InitSignatureScheme initializes signature scheme only.

func InitZCNSDK

func InitZCNSDK(blockWorker string, signscheme string, configs ...func(*ChainConfig) error) error

InitZCNSDK initializes the SDK with miner, sharder and signature scheme provided.

func IsMnemonicValid

func IsMnemonicValid(mnemonic string) bool

IsMnemonicValid is an utility function to check the mnemonic valid

func IsValidEthAddress

func IsValidEthAddress(ethAddr string) (bool, error)

IsValidEthAddress - multiple checks for valid ETH address

func RecoverOfflineWallet added in v1.8.5

func RecoverOfflineWallet(mnemonic string) (string, error)

RecoverOfflineWallet recovers the previously generated wallet using the mnemonic.

func RecoverWallet

func RecoverWallet(mnemonic string, statusCb WalletCallback) error

RecoverWallet recovers the previously generated wallet using the mnemonic. It also registers the wallet again to block chain.

func RegisterToMiners

func RegisterToMiners(wallet *zcncrypto.Wallet, statusCb WalletCallback) error

RegisterToMiners can be used to register the wallet.

func RegisterWallet

func RegisterWallet(walletString string, cb WalletCallback)

RegisterWallet registers multisig related wallets

func SetAuthUrl

func SetAuthUrl(url string) error

SetAuthUrl will be called by app to set zauth URL to SDK.

func SetLogFile

func SetLogFile(logFile string, verbose bool)

SetLogFile - sets file path to write log verbose - true - console output; false - no console output

func SetLogLevel

func SetLogLevel(lvl int)

SetLogLevel set the log level. lvl - 0 disabled; higher number (upto 4) more verbosity

func SetNetwork

func SetNetwork(miners []string, sharders []string)

func SetWallet added in v1.8.6

func SetWallet(w zcncrypto.Wallet, splitKeyWallet bool) error

SetWallet should be set before any transaction or client specific APIs splitKeyWallet parameter is valid only if SignatureScheme is "BLS0Chain"

func SetWalletInfo

func SetWalletInfo(w string, splitKeyWallet bool) error

SetWalletInfo should be set before any transaction or client specific APIs splitKeyWallet parameter is valid only if SignatureScheme is "BLS0Chain"

func SetupAuth

func SetupAuth(authHost, clientID, clientKey, publicKey, privateKey, localPublicKey string, cb AuthCallback) error

SetupAuth prepare auth app with clientid, key and a set of public, private key and local publickey which is running on PC/Mac.

func Sign added in v1.7.9

func Sign(hash string) (string, error)

func SignWith0Wallet added in v1.7.9

func SignWith0Wallet(hash string, w *zcncrypto.Wallet) (string, error)

func SplitKeys

func SplitKeys(privateKey string, numSplits int) (string, error)

Split keys from the primary master key

func SuggestEthGasPrice

func SuggestEthGasPrice() (int64, error)

SuggestEthGasPrice - return back suggested price for gas

func TokensToEth

func TokensToEth(tokens int64) float64

TokensToEth - converting wei to eth tokens

func TransferEthTokens

func TransferEthTokens(fromPrivKey string, amountTokens, gasPrice int64) (string, error)

TransferEthTokens - transfer ETH tokens to multisign wallet

func UpdateNetworkDetails

func UpdateNetworkDetails() error

func UpdateNetworkDetailsWorker

func UpdateNetworkDetailsWorker(ctx context.Context)

func UpdateRequired

func UpdateRequired(networkDetails *Network) bool

func VerifyContentHash

func VerifyContentHash(metaTxnDataJSON string) (bool, error)

func WithChainID

func WithChainID(id string) func(c *ChainConfig) error

func WithConfirmationChainLength

func WithConfirmationChainLength(m int) func(c *ChainConfig) error

func WithEthereumNode added in v1.3.1

func WithEthereumNode(uri string) func(c *ChainConfig) error

func WithMinConfirmation

func WithMinConfirmation(m int) func(c *ChainConfig) error

func WithMinSubmit

func WithMinSubmit(m int) func(c *ChainConfig) error

func WithParams added in v1.7.1

func WithParams(uri string, params Params) string

Types

type AddAuthorizerPayload added in v1.7.9

type AddAuthorizerPayload struct {
	PublicKey         string                      `json:"public_key"`
	URL               string                      `json:"url"`
	StakePoolSettings AuthorizerStakePoolSettings `json:"stake_pool_settings"` // Used to initially create stake pool
}

type AuthCallback

type AuthCallback interface {
	// This call back gives the status of the Two factor authenticator(zauth) setup.
	OnSetupComplete(status int, err string)
}

AuthCallback needs to be implemented by the caller SetupAuth()

type AuthorizerConfig added in v1.7.1

type AuthorizerConfig struct {
	Fee common.Balance `json:"fee"`
}

type AuthorizerNode added in v1.7.1

type AuthorizerNode struct {
	ID     string            `json:"id"`
	Config *AuthorizerConfig `json:"config"`
}

type AuthorizerStakePoolSettings added in v1.7.9

type AuthorizerStakePoolSettings struct {
	DelegateWallet string         `json:"delegate_wallet"`
	MinStake       common.Balance `json:"min_stake"`
	MaxStake       common.Balance `json:"max_stake"`
	NumDelegates   int            `json:"num_delegates"`
	ServiceCharge  float64        `json:"service_charge"`
}

type Blobber

type Blobber struct {
	ID                common.Key        `json:"id"`
	BaseURL           string            `json:"url"`
	Terms             Terms             `json:"terms"`
	Capacity          common.Size       `json:"capacity"`
	Allocated         common.Size       `json:"allocated"`
	LastHealthCheck   common.Timestamp  `json:"last_health_check"`
	StakePoolSettings StakePoolSettings `json:"stake_pool_settings"`
}

type ChainConfig

type ChainConfig struct {
	ChainID                 string   `json:"chain_id,omitempty"`
	BlockWorker             string   `json:"block_worker"`
	Miners                  []string `json:"miners"`
	Sharders                []string `json:"sharders"`
	SignatureScheme         string   `json:"signature_scheme"`
	MinSubmit               int      `json:"min_submit"`
	MinConfirmation         int      `json:"min_confirmation"`
	ConfirmationChainLength int      `json:"confirmation_chain_length"`
	EthNode                 string   `json:"eth_node"`
}

type ConfirmationStatus added in v1.5.1

type ConfirmationStatus int
const (
	Undefined ConfirmationStatus = iota
	Success
	ChargeableError
)

type CreateAllocationRequest

type CreateAllocationRequest struct {
	DataShards      int              `json:"data_shards"`
	ParityShards    int              `json:"parity_shards"`
	Size            common.Size      `json:"size"`
	Expiration      common.Timestamp `json:"expiration_date"`
	Owner           string           `json:"owner_id"`
	OwnerPublicKey  string           `json:"owner_public_key"`
	Blobbers        []string         `json:"blobbers"`
	ReadPriceRange  PriceRange       `json:"read_price_range"`
	WritePriceRange PriceRange       `json:"write_price_range"`
}

CreateAllocationRequest is information to create allocation.

type DelegatePool added in v1.8.4

type DelegatePool struct {
	Balance      int64  `json:"balance"`
	Reward       int64  `json:"reward"`
	Status       int    `json:"status"`
	RoundCreated int64  `json:"round_created"` // used for cool down
	DelegateID   string `json:"delegate_id"`
}

type GetBalanceCallback

type GetBalanceCallback interface {
	OnBalanceAvailable(status int, value int64, info string)
}

GetBalanceCallback needs to be implemented by the caller of GetBalance() to get the status

type GetClientResponse

type GetClientResponse struct {
	ID           string `json:"id"`
	Version      string `json:"version"`
	CreationDate int    `json:"creation_date"`
	PublicKey    string `json:"public_key"`
}

func GetClientDetails

func GetClientDetails(clientID string) (*GetClientResponse, error)

type GetInfoCallback

type GetInfoCallback interface {
	// OnInfoAvailable will be called when GetLockTokenConfig is complete
	// if status == StatusSuccess then info is valid
	// is status != StatusSuccess then err will give the reason
	OnInfoAvailable(op int, status int, info string, err string)
}

GetInfoCallback needs to be implemented by the caller of GetLockTokenConfig() and GetLockedTokens()

type GetNonceCallback added in v1.8.3

type GetNonceCallback interface {
	OnNonceAvailable(status int, nonce int64, info string)
}

GetNonceCallback needs to be implemented by the caller of GetNonce() to get the status

type GetNonceCallbackStub added in v1.8.3

type GetNonceCallbackStub struct {
}

func (*GetNonceCallbackStub) OnNonceAvailable added in v1.8.3

func (g *GetNonceCallbackStub) OnNonceAvailable(status int, nonce int64, info string)

type InputMap added in v1.2.86

type InputMap struct {
	Fields map[string]string `json:"fields"`
}

type MSTransfer

type MSTransfer struct {
	ClientID   string `json:"from"`
	ToClientID string `json:"to"`
	Amount     uint64 `json:"amount"`
}

MSTransfer - a data structure to hold state transfer from one client to another

type MSVote

type MSVote struct {
	ProposalID string `json:"proposal_id"`

	// Client ID in transfer is that of the multi-sig wallet, not the signer.
	Transfer MSTransfer `json:"transfer"`

	Signature string `json:"signature"`
}

MSVote -- this should mimic the type Vote defined in MultiSig SC

type MSVoteCallback

type MSVoteCallback interface {
	OnVoteComplete(status int, proposal string, err string)
}

MSVoteCallback callback definition multisig Vote function

type MSWallet

type MSWallet struct {
	Id              int                         `json:"id"`
	SignatureScheme string                      `json:"signature_scheme"`
	GroupClientID   string                      `json:"group_client_id"`
	GroupKey        zcncrypto.SignatureScheme   `json:"group_key"`
	SignerClientIDs []string                    `json:"sig_client_ids"`
	SignerKeys      []zcncrypto.SignatureScheme `json:"signer_keys"`
	T               int                         `json:"threshold"`
	N               int                         `json:"num_subkeys"`
}

MSWallet Client data necessary for a multi-sig wallet.

func (*MSWallet) Marshal

func (msw *MSWallet) Marshal() (string, error)

Marshal returns json string

func (*MSWallet) UnmarshalJSON added in v1.3.1

func (msw *MSWallet) UnmarshalJSON(data []byte) error

type Miner

type Miner struct {
	ID         string      `json:"id"`
	N2NHost    string      `json:"n2n_host"`
	Host       string      `json:"host"`
	Port       int         `json:"port"`
	PublicKey  string      `json:"public_key"`
	ShortName  string      `json:"short_name"`
	BuildTag   string      `json:"build_tag"`
	TotalStake int64       `json:"total_stake"`
	Stat       interface{} `json:"stat"`
}

type MinerSCDelegatePool

type MinerSCDelegatePool struct {
	Settings StakePoolSettings `json:"settings"`
}

type MinerSCDelegatePoolInfo

type MinerSCDelegatePoolInfo struct {
	ID         common.Key     `json:"id"`
	Balance    common.Balance `json:"balance"`
	Reward     common.Balance `json:"reward"`      // uncollected reread
	RewardPaid common.Balance `json:"reward_paid"` // total reward all time
	Status     string         `json:"status"`
}

type MinerSCLock

type MinerSCLock struct {
	ID string `json:"id"`
}

type MinerSCMinerInfo

type MinerSCMinerInfo struct {
	SimpleMiner         `json:"simple_miner"`
	MinerSCDelegatePool `json:"stake_pool"`
}

type MinerSCNodes

type MinerSCNodes struct {
	Nodes []Node `json:"Nodes"`
}

type MinerSCUnlock

type MinerSCUnlock struct {
	ID     string `json:"id"`
	PoolID string `json:"pool_id"`
}

type MinerSCUserPoolsInfo

type MinerSCUserPoolsInfo struct {
	Pools map[string][]*MinerSCDelegatePoolInfo `json:"pools"`
}

type MultisigSCWallet

type MultisigSCWallet struct {
	ClientID        string `json:"client_id"`
	SignatureScheme string `json:"signature_scheme"`
	PublicKey       string `json:"public_key"`

	SignerThresholdIDs []string `json:"signer_threshold_ids"`
	SignerPublicKeys   []string `json:"signer_public_keys"`

	NumRequired int `json:"num_required"`
}

MultisigSCWallet --this should mimic MultisigWallet definition in MultiSig SC

type Network

type Network struct {
	Miners   []string `json:"miners"`
	Sharders []string `json:"sharders"`
}

func GetNetwork

func GetNetwork() *Network

func GetNetworkDetails

func GetNetworkDetails() (*Network, error)

type Node

type Node struct {
	Miner     Miner `json:"simple_miner"`
	StakePool `json:"stake_pool"`
}

type NonceCache added in v1.8.3

type NonceCache struct {
	// contains filtered or unexported fields
}

func NewNonceCache added in v1.8.3

func NewNonceCache() *NonceCache

func (*NonceCache) Evict added in v1.8.3

func (nc *NonceCache) Evict(clientId string)

func (*NonceCache) GetNextNonce added in v1.8.3

func (nc *NonceCache) GetNextNonce(clientId string) int64

func (*NonceCache) Set added in v1.8.3

func (nc *NonceCache) Set(clientId string, nonce int64)

type Params

type Params map[string]string

func (Params) Query

func (p Params) Query() string

type PriceRange

type PriceRange struct {
	Min common.Balance `json:"min"`
	Max common.Balance `json:"max"`
}

PriceRange represents a price range allowed by user to filter blobbers.

type Provider added in v1.7.1

type Provider int
const (
	ProviderMiner Provider = iota + 1
	ProviderSharder
	ProviderBlobber
	ProviderValidator
	ProviderAuthorizer
)

type QueryResult added in v1.8.4

type QueryResult struct {
	Content    []byte
	StatusCode int
	Error      error
}

type QueryResultHandle added in v1.8.4

type QueryResultHandle func(result QueryResult) bool

QueryResultHandle handle query response, return true if it is a consensus-result

type SCCollectReward added in v1.7.1

type SCCollectReward struct {
	ProviderId   string   `json:"provider_id"`
	PoolId       string   `json:"pool_id"`
	ProviderType Provider `json:"provider_type"`
}

type SendTxnData added in v1.4.1

type SendTxnData struct {
	Note string `json:"note"`
}

type SimpleMiner added in v1.8.4

type SimpleMiner struct {
	ID string `json:"id"`
}

type SmartContractExecutor added in v1.8.5

type SmartContractExecutor interface {
	// ExecuteSmartContract implements wrapper for smart contract function
	ExecuteSmartContract(address, methodName string, input interface{}, val uint64) (*transaction.Transaction, error)
}

type StakePool added in v1.8.4

type StakePool struct {
	Pools    map[string]*DelegatePool `json:"pools"`
	Reward   int64                    `json:"rewards"`
	Settings StakePoolSettings        `json:"settings"`
	Minter   int                      `json:"minter"`
}

type StakePoolSettings

type StakePoolSettings struct {
	DelegateWallet string         `json:"delegate_wallet"`
	MinStake       common.Balance `json:"min_stake"`
	MaxStake       common.Balance `json:"max_stake"`
	NumDelegates   int            `json:"num_delegates"`
	ServiceCharge  float64        `json:"service_charge"`
}

type Terms

type Terms struct {
	ReadPrice        common.Balance `json:"read_price"`  // tokens / GB
	WritePrice       common.Balance `json:"write_price"` // tokens / GB
	MinLockDemand    float64        `json:"min_lock_demand"`
	MaxOfferDuration time.Duration  `json:"max_offer_duration"`
}

type Transaction

type Transaction struct {
	// contains filtered or unexported fields
}

func NewMSTransaction

func NewMSTransaction(walletstr string, cb TransactionCallback) (*Transaction, error)

NewMSTransaction new transaction object for multisig operation

func (*Transaction) CancelAllocation

func (t *Transaction) CancelAllocation(allocID string, fee uint64) (
	err error)

CancelAllocation transaction.

func (*Transaction) CreateAllocation

func (t *Transaction) CreateAllocation(car *CreateAllocationRequest,
	lock uint64, fee uint64) (err error)

CreateAllocation transaction.

func (*Transaction) CreateReadPool

func (t *Transaction) CreateReadPool(fee uint64) (err error)

CreateReadPool for current user.

func (*Transaction) ExecuteFaucetSCWallet

func (t *Transaction) ExecuteFaucetSCWallet(walletStr string, methodName string, input []byte) error

ExecuteFaucetSCWallet implements the Faucet Smart contract for a given wallet

func (*Transaction) ExecuteSmartContract

func (t *Transaction) ExecuteSmartContract(address, methodName string, input interface{}, val uint64) (*transaction.Transaction, error)

func (*Transaction) FaucetUpdateConfig added in v1.2.86

func (t *Transaction) FaucetUpdateConfig(ip *InputMap) (err error)

func (*Transaction) FinalizeAllocation

func (t *Transaction) FinalizeAllocation(allocID string, fee uint64) (
	err error)

FinalizeAllocation transaction.

func (*Transaction) GetTransactionError

func (t *Transaction) GetTransactionError() string

func (*Transaction) GetTransactionHash

func (t *Transaction) GetTransactionHash() string

func (*Transaction) GetTransactionNonce added in v1.8.3

func (t *Transaction) GetTransactionNonce() int64

GetTransactionNonce returns nonce

func (*Transaction) GetVerifyConfirmationStatus added in v1.5.1

func (t *Transaction) GetVerifyConfirmationStatus() ConfirmationStatus

func (*Transaction) GetVerifyError

func (t *Transaction) GetVerifyError() string

func (*Transaction) GetVerifyOutput

func (t *Transaction) GetVerifyOutput() string

func (*Transaction) Hash added in v1.8.3

func (t *Transaction) Hash() string

func (*Transaction) MinerSCCollectReward added in v1.7.1

func (t *Transaction) MinerSCCollectReward(providerId, poolId string, providerType Provider) error

func (*Transaction) MinerSCDeleteMiner added in v1.2.86

func (t *Transaction) MinerSCDeleteMiner(info *MinerSCMinerInfo) (err error)

func (*Transaction) MinerSCDeleteSharder added in v1.2.86

func (t *Transaction) MinerSCDeleteSharder(info *MinerSCMinerInfo) (err error)

func (*Transaction) MinerSCLock

func (t *Transaction) MinerSCLock(nodeID string, lock uint64) (err error)

func (*Transaction) MinerSCMinerSettings added in v1.2.85

func (t *Transaction) MinerSCMinerSettings(info *MinerSCMinerInfo) (err error)

func (*Transaction) MinerSCSharderSettings added in v1.2.85

func (t *Transaction) MinerSCSharderSettings(info *MinerSCMinerInfo) (err error)

func (*Transaction) MinerSCUnlock added in v1.7.9

func (t *Transaction) MinerSCUnlock(nodeID, poolID string) (err error)

func (*Transaction) MinerScUpdateConfig added in v1.2.86

func (t *Transaction) MinerScUpdateConfig(ip *InputMap) (err error)

func (*Transaction) MinerScUpdateGlobals added in v1.2.86

func (t *Transaction) MinerScUpdateGlobals(ip *InputMap) (err error)

func (*Transaction) Output

func (t *Transaction) Output() []byte

func (*Transaction) ReadPoolLock

func (t *Transaction) ReadPoolLock(allocID, blobberID string,
	duration int64, lock, fee uint64) (err error)

ReadPoolLock locks tokens for current user and given allocation, using given duration. If blobberID is not empty, then tokens will be locked for given allocation->blobber only.

func (*Transaction) ReadPoolUnlock

func (t *Transaction) ReadPoolUnlock(poolID string, fee uint64) (err error)

ReadPoolUnlock for current user and given pool.

func (*Transaction) RegisterMultiSig

func (t *Transaction) RegisterMultiSig(walletstr string, mswallet string) error

RegisterMultiSig register a multisig wallet with the SC.

func (*Transaction) RegisterVote

func (t *Transaction) RegisterVote(signerwalletstr string, msvstr string) error

RegisterVote register a multisig wallet with the SC.

func (*Transaction) Send

func (t *Transaction) Send(toClientID string, val uint64, desc string) error

func (*Transaction) SendWithSignatureHash

func (t *Transaction) SendWithSignatureHash(toClientID string, val uint64, desc string, sig string, CreationDate int64, hash string) error

func (*Transaction) SetTransactionCallback

func (t *Transaction) SetTransactionCallback(cb TransactionCallback) error

func (*Transaction) SetTransactionFee

func (t *Transaction) SetTransactionFee(txnFee uint64) error

func (*Transaction) SetTransactionHash

func (t *Transaction) SetTransactionHash(hash string) error

func (*Transaction) SetTransactionNonce added in v1.8.3

func (t *Transaction) SetTransactionNonce(txnNonce int64) error

func (*Transaction) StakePoolLock

func (t *Transaction) StakePoolLock(blobberID string, lock, fee uint64) (
	err error)

StakePoolLock used to lock tokens in a stake pool of a blobber.

func (*Transaction) StakePoolUnlock

func (t *Transaction) StakePoolUnlock(blobberID, poolID string,
	fee uint64) (err error)

StakePoolUnlock by blobberID and poolID.

func (*Transaction) StorageSCCollectReward added in v1.7.1

func (t *Transaction) StorageSCCollectReward(providerId, poolId string, providerType Provider) error

func (*Transaction) StorageScUpdateConfig added in v1.2.86

func (t *Transaction) StorageScUpdateConfig(ip *InputMap) (err error)

func (*Transaction) StoreData

func (t *Transaction) StoreData(data string) error

func (*Transaction) UpdateAllocation

func (t *Transaction) UpdateAllocation(allocID string, sizeDiff int64,
	expirationDiff int64, lock, fee uint64) (err error)

UpdateAllocation transaction.

func (*Transaction) UpdateBlobberSettings

func (t *Transaction) UpdateBlobberSettings(b *Blobber, fee uint64) (err error)

UpdateBlobberSettings update settings of a blobber.

func (*Transaction) UpdateValidatorSettings added in v1.8.5

func (t *Transaction) UpdateValidatorSettings(v *Validator, fee uint64) (err error)

UpdateValidatorSettings update settings of a validator.

func (*Transaction) Verify

func (t *Transaction) Verify() error

func (*Transaction) VestingAdd

func (t *Transaction) VestingAdd(ar *VestingAddRequest, value uint64) (
	err error)

func (*Transaction) VestingDelete

func (t *Transaction) VestingDelete(poolID string) (err error)

func (*Transaction) VestingStop

func (t *Transaction) VestingStop(sr *VestingStopRequest) (err error)

func (*Transaction) VestingTrigger

func (t *Transaction) VestingTrigger(poolID string) (err error)

func (*Transaction) VestingUnlock

func (t *Transaction) VestingUnlock(poolID string) (err error)

func (*Transaction) VestingUpdateConfig

func (t *Transaction) VestingUpdateConfig(vscc *InputMap) (err error)

func (*Transaction) WritePoolLock

func (t *Transaction) WritePoolLock(allocID string, lock, fee uint64) (err error)

WritePoolLock locks tokens for current user and given allocation, using given duration. If blobberID is not empty, then tokens will be locked for given allocation->blobber only.

func (*Transaction) WritePoolUnlock

func (t *Transaction) WritePoolUnlock(allocID string, fee uint64) (
	err error)

WritePoolUnlock for current user and given pool.

func (*Transaction) ZCNSCAddAuthorizer added in v1.7.9

func (t *Transaction) ZCNSCAddAuthorizer(ip *AddAuthorizerPayload) (err error)

func (*Transaction) ZCNSCUpdateAuthorizerConfig added in v1.7.1

func (t *Transaction) ZCNSCUpdateAuthorizerConfig(ip *AuthorizerNode) (err error)

func (*Transaction) ZCNSCUpdateGlobalConfig added in v1.7.1

func (t *Transaction) ZCNSCUpdateGlobalConfig(ip *InputMap) (err error)

type TransactionCallback

type TransactionCallback interface {
	OnTransactionComplete(t *Transaction, status int)
	OnVerifyComplete(t *Transaction, status int)
	OnAuthComplete(t *Transaction, status int)
}

TransactionCallback needs to be implemented by the caller for transaction related APIs

type TransactionQuery added in v1.8.4

type TransactionQuery struct {
	// contains filtered or unexported fields
}

func NewTransactionQuery added in v1.8.4

func NewTransactionQuery(sharders []string) (*TransactionQuery, error)

func (*TransactionQuery) FromAll added in v1.8.4

func (tq *TransactionQuery) FromAll(ctx context.Context, query string, handle QueryResultHandle) error

FromAll query transaction from all sharders whatever it is selected or offline in previous queires, and return consensus result

func (*TransactionQuery) FromAny added in v1.8.4

func (tq *TransactionQuery) FromAny(ctx context.Context, query string) (QueryResult, error)

FromAny query transaction from any sharder that is not selected in previous queires. use any used sharder if there is not any unused sharder

func (*TransactionQuery) GetConsensusConfirmation added in v1.8.4

func (tq *TransactionQuery) GetConsensusConfirmation(ctx context.Context, numSharders int, txnHash string) (*blockHeader, map[string]json.RawMessage, *blockHeader, error)

func (*TransactionQuery) GetFastConfirmation added in v1.8.4

func (tq *TransactionQuery) GetFastConfirmation(ctx context.Context, txnHash string) (*blockHeader, map[string]json.RawMessage, *blockHeader, error)

GetFastConfirmation get txn confirmation from a random online sharder

func (*TransactionQuery) GetInfo added in v1.8.4

func (tq *TransactionQuery) GetInfo(ctx context.Context, query string) (*QueryResult, error)

func (*TransactionQuery) Reset added in v1.8.4

func (tq *TransactionQuery) Reset()

type TransactionScheme

type TransactionScheme interface {
	SmartContractExecutor

	// SetTransactionCallback implements storing the callback
	// used to call after the transaction or verification is completed
	SetTransactionCallback(cb TransactionCallback) error
	// Send implements sending token to a given clientid
	Send(toClientID string, val uint64, desc string) error
	// StoreData implements store the data to blockchain
	StoreData(data string) error
	// ExecuteFaucetSCWallet implements the `Faucet Smart contract` for a given wallet
	ExecuteFaucetSCWallet(walletStr string, methodName string, input []byte) error
	// GetTransactionHash implements retrieval of hash of the submitted transaction
	GetTransactionHash() string
	//RegisterMultiSig registers a group wallet and subwallets with MultisigSC
	RegisterMultiSig(walletstr, mswallet string) error
	// SetTransactionHash implements verify a previous transaction status
	SetTransactionHash(hash string) error
	// SetTransactionFee implements method to set the transaction fee
	SetTransactionFee(txnFee uint64) error
	// SetTransactionNonce implements method to set the transaction nonce
	SetTransactionNonce(txnNonce int64) error
	// Verify implements verify the transaction
	Verify() error
	// GetVerifyConfirmationStatus implements the verification status from sharders
	GetVerifyConfirmationStatus() ConfirmationStatus
	// GetVerifyOutput implements the verification output from sharders
	GetVerifyOutput() string
	// GetTransactionError implements error string in case of transaction failure
	GetTransactionError() string
	// GetVerifyError implements error string in case of verify failure error
	GetVerifyError() string
	// GetTransactionNonce returns nonce
	GetTransactionNonce() int64

	// Output of transaction.
	Output() []byte

	// Hash Transaction status regardless of status
	Hash() string

	VestingTrigger(poolID string) error
	VestingStop(sr *VestingStopRequest) error
	VestingUnlock(poolID string) error
	VestingAdd(ar *VestingAddRequest, value uint64) error
	VestingDelete(poolID string) error
	VestingUpdateConfig(*InputMap) error

	MinerSCCollectReward(string, string, Provider) error
	MinerSCMinerSettings(*MinerSCMinerInfo) error
	MinerSCSharderSettings(*MinerSCMinerInfo) error
	MinerSCLock(minerID string, lock uint64) error
	MinerSCUnlock(minerID, poolID string) error
	MinerScUpdateConfig(*InputMap) error
	MinerScUpdateGlobals(*InputMap) error
	MinerSCDeleteMiner(*MinerSCMinerInfo) error
	MinerSCDeleteSharder(*MinerSCMinerInfo) error

	StorageSCCollectReward(string, string, Provider) error
	FinalizeAllocation(allocID string, fee uint64) error
	CancelAllocation(allocID string, fee uint64) error
	CreateAllocation(car *CreateAllocationRequest, lock uint64, fee uint64) error //
	CreateReadPool(fee uint64) error
	ReadPoolLock(allocID string, blobberID string, duration int64, lock uint64, fee uint64) error
	ReadPoolUnlock(poolID string, fee uint64) error
	StakePoolLock(blobberID string, lock uint64, fee uint64) error
	StakePoolUnlock(blobberID string, poolID string, fee uint64) error
	UpdateBlobberSettings(blobber *Blobber, fee uint64) error
	UpdateValidatorSettings(validator *Validator, fee uint64) error
	UpdateAllocation(allocID string, sizeDiff int64, expirationDiff int64, lock uint64, fee uint64) error
	WritePoolLock(allocID string, lock uint64, fee uint64) error
	WritePoolUnlock(allocID string, fee uint64) error
	StorageScUpdateConfig(*InputMap) error

	FaucetUpdateConfig(*InputMap) error

	// ZCNSCUpdateGlobalConfig updates global config
	ZCNSCUpdateGlobalConfig(*InputMap) error
	// ZCNSCUpdateAuthorizerConfig updates authorizer config by ID
	ZCNSCUpdateAuthorizerConfig(*AuthorizerNode) error
	// ZCNSCAddAuthorizer adds authorizer
	ZCNSCAddAuthorizer(*AddAuthorizerPayload) error
}

TransactionScheme implements few methods for block chain.

Note: to be buildable on MacOSX all arguments should have names.

func NewTransaction

func NewTransaction(cb TransactionCallback, txnFee uint64, nonce int64) (TransactionScheme, error)

NewTransaction allocation new generic transaction object for any operation

type TransactionWithAuth

type TransactionWithAuth struct {
	// contains filtered or unexported fields
}

func (*TransactionWithAuth) CancelAllocation

func (ta *TransactionWithAuth) CancelAllocation(allocID string, fee uint64) (
	err error)

CancelAllocation transaction.

func (*TransactionWithAuth) CreateAllocation

func (ta *TransactionWithAuth) CreateAllocation(car *CreateAllocationRequest,
	lock uint64, fee uint64) (err error)

CreateAllocation transaction.

func (*TransactionWithAuth) CreateReadPool

func (ta *TransactionWithAuth) CreateReadPool(fee uint64) (err error)

CreateReadPool for current user.

func (*TransactionWithAuth) ExecuteFaucetSCWallet

func (ta *TransactionWithAuth) ExecuteFaucetSCWallet(walletStr string, methodName string, input []byte) error

ExecuteFaucetSCWallet impements the Faucet Smart contract for a given wallet

func (*TransactionWithAuth) ExecuteSmartContract

func (ta *TransactionWithAuth) ExecuteSmartContract(address, methodName string, input interface{}, val uint64) (*transaction.Transaction, error)

func (*TransactionWithAuth) FaucetUpdateConfig added in v1.2.86

func (ta *TransactionWithAuth) FaucetUpdateConfig(
	ip *InputMap,
) (err error)

func (*TransactionWithAuth) FinalizeAllocation

func (ta *TransactionWithAuth) FinalizeAllocation(allocID string, fee uint64) (
	err error)

FinalizeAllocation transaction.

func (*TransactionWithAuth) GetTransactionError

func (ta *TransactionWithAuth) GetTransactionError() string

func (*TransactionWithAuth) GetTransactionHash

func (ta *TransactionWithAuth) GetTransactionHash() string

func (*TransactionWithAuth) GetTransactionNonce added in v1.8.3

func (ta *TransactionWithAuth) GetTransactionNonce() int64

GetTransactionNonce returns nonce

func (*TransactionWithAuth) GetVerifyConfirmationStatus added in v1.5.1

func (ta *TransactionWithAuth) GetVerifyConfirmationStatus() ConfirmationStatus

func (*TransactionWithAuth) GetVerifyError

func (ta *TransactionWithAuth) GetVerifyError() string

func (*TransactionWithAuth) GetVerifyOutput

func (ta *TransactionWithAuth) GetVerifyOutput() string

func (*TransactionWithAuth) Hash added in v1.8.3

func (ta *TransactionWithAuth) Hash() string

func (*TransactionWithAuth) MinerSCCollectReward added in v1.7.1

func (ta *TransactionWithAuth) MinerSCCollectReward(providerId, poolId string, providerType Provider) error

func (*TransactionWithAuth) MinerSCDeleteMiner added in v1.2.86

func (ta *TransactionWithAuth) MinerSCDeleteMiner(info *MinerSCMinerInfo) (
	err error)

func (*TransactionWithAuth) MinerSCDeleteSharder added in v1.2.86

func (ta *TransactionWithAuth) MinerSCDeleteSharder(info *MinerSCMinerInfo) (
	err error)

func (*TransactionWithAuth) MinerSCLock

func (ta *TransactionWithAuth) MinerSCLock(minerID string, lock uint64) (err error)

func (*TransactionWithAuth) MinerSCMinerSettings added in v1.2.85

func (ta *TransactionWithAuth) MinerSCMinerSettings(info *MinerSCMinerInfo) (
	err error)

func (*TransactionWithAuth) MinerSCSharderSettings added in v1.2.85

func (ta *TransactionWithAuth) MinerSCSharderSettings(info *MinerSCMinerInfo) (
	err error)

func (*TransactionWithAuth) MinerSCUnlock added in v1.7.9

func (ta *TransactionWithAuth) MinerSCUnlock(nodeID, poolID string) (
	err error)

func (*TransactionWithAuth) MinerScUpdateConfig added in v1.2.86

func (ta *TransactionWithAuth) MinerScUpdateConfig(
	ip *InputMap,
) (err error)

func (*TransactionWithAuth) MinerScUpdateGlobals added in v1.2.86

func (ta *TransactionWithAuth) MinerScUpdateGlobals(
	ip *InputMap,
) (err error)

func (*TransactionWithAuth) Output

func (ta *TransactionWithAuth) Output() []byte

func (*TransactionWithAuth) ReadPoolLock

func (ta *TransactionWithAuth) ReadPoolLock(allocID, blobberID string,
	duration int64, lock, fee uint64) (err error)

ReadPoolLock locks tokens for current user and given allocation, using given duration. If blobberID is not empty, then tokens will be locked for given allocation->blobber only.

func (*TransactionWithAuth) ReadPoolUnlock

func (ta *TransactionWithAuth) ReadPoolUnlock(poolID string, fee uint64) (
	err error)

ReadPoolUnlock for current user and given pool.

func (*TransactionWithAuth) RegisterMultiSig

func (ta *TransactionWithAuth) RegisterMultiSig(walletstr string, mswallet string) error

RegisterMultiSig register a multisig wallet with the SC.

func (*TransactionWithAuth) Send

func (ta *TransactionWithAuth) Send(toClientID string, val uint64, desc string) error

func (*TransactionWithAuth) SetTransactionCallback

func (ta *TransactionWithAuth) SetTransactionCallback(cb TransactionCallback) error

func (*TransactionWithAuth) SetTransactionFee

func (ta *TransactionWithAuth) SetTransactionFee(txnFee uint64) error

func (*TransactionWithAuth) SetTransactionHash

func (ta *TransactionWithAuth) SetTransactionHash(hash string) error

func (*TransactionWithAuth) SetTransactionNonce added in v1.8.3

func (ta *TransactionWithAuth) SetTransactionNonce(txnNonce int64) error

func (*TransactionWithAuth) StakePoolLock

func (ta *TransactionWithAuth) StakePoolLock(blobberID string,
	lock, fee uint64) (err error)

StakePoolLock used to lock tokens in a stake pool of a blobber.

func (*TransactionWithAuth) StakePoolUnlock

func (ta *TransactionWithAuth) StakePoolUnlock(blobberID, poolID string,
	fee uint64) (err error)

StakePoolUnlock by blobberID and poolID.

func (*TransactionWithAuth) StorageSCCollectReward added in v1.7.1

func (ta *TransactionWithAuth) StorageSCCollectReward(providerId, poolId string, providerType Provider) error

func (*TransactionWithAuth) StorageScUpdateConfig added in v1.2.86

func (ta *TransactionWithAuth) StorageScUpdateConfig(
	ip *InputMap,
) (err error)

func (*TransactionWithAuth) StoreData

func (ta *TransactionWithAuth) StoreData(data string) error

func (*TransactionWithAuth) UpdateAllocation

func (ta *TransactionWithAuth) UpdateAllocation(allocID string, sizeDiff int64,
	expirationDiff int64, lock, fee uint64) (err error)

UpdateAllocation transaction.

func (*TransactionWithAuth) UpdateBlobberSettings

func (ta *TransactionWithAuth) UpdateBlobberSettings(blob *Blobber, fee uint64) (
	err error)

UpdateBlobberSettings update settings of a blobber.

func (*TransactionWithAuth) UpdateValidatorSettings added in v1.8.5

func (ta *TransactionWithAuth) UpdateValidatorSettings(v *Validator, fee uint64) (
	err error)

UpdateValidatorSettings update settings of a validator.

func (*TransactionWithAuth) Verify

func (ta *TransactionWithAuth) Verify() error

func (*TransactionWithAuth) VestingAdd

func (ta *TransactionWithAuth) VestingAdd(ar *VestingAddRequest,
	value uint64) (err error)

func (*TransactionWithAuth) VestingDelete

func (ta *TransactionWithAuth) VestingDelete(poolID string) (err error)

func (*TransactionWithAuth) VestingStop

func (ta *TransactionWithAuth) VestingStop(sr *VestingStopRequest) (err error)

func (*TransactionWithAuth) VestingTrigger

func (ta *TransactionWithAuth) VestingTrigger(poolID string) (err error)

func (*TransactionWithAuth) VestingUnlock

func (ta *TransactionWithAuth) VestingUnlock(poolID string) (err error)

func (*TransactionWithAuth) VestingUpdateConfig

func (ta *TransactionWithAuth) VestingUpdateConfig(
	ip *InputMap,
) (err error)

func (*TransactionWithAuth) WritePoolLock

func (ta *TransactionWithAuth) WritePoolLock(allocID string, lock, fee uint64) (err error)

WritePoolLock locks tokens for current user and given allocation, using given duration. If blobberID is not empty, then tokens will be locked for given allocation->blobber only.

func (*TransactionWithAuth) WritePoolUnlock

func (ta *TransactionWithAuth) WritePoolUnlock(allocID string, fee uint64) (
	err error)

WritePoolUnlock for current user and given pool.

func (*TransactionWithAuth) ZCNSCAddAuthorizer added in v1.7.9

func (ta *TransactionWithAuth) ZCNSCAddAuthorizer(ip *AddAuthorizerPayload) (err error)

func (*TransactionWithAuth) ZCNSCUpdateAuthorizerConfig added in v1.7.1

func (ta *TransactionWithAuth) ZCNSCUpdateAuthorizerConfig(ip *AuthorizerNode) (err error)

func (*TransactionWithAuth) ZCNSCUpdateGlobalConfig added in v1.7.1

func (ta *TransactionWithAuth) ZCNSCUpdateGlobalConfig(ip *InputMap) (err error)

type Validator added in v1.8.5

type Validator struct {
	ID                common.Key        `json:"id"`
	BaseURL           string            `json:"url"`
	StakePoolSettings StakePoolSettings `json:"stake_pool_settings"`
}

type VestingAddRequest

type VestingAddRequest struct {
	Description  string           `json:"description"`  // allow empty
	StartTime    common.Timestamp `json:"start_time"`   //
	Duration     time.Duration    `json:"duration"`     //
	Destinations []*VestingDest   `json:"destinations"` //
}

type VestingClientList

type VestingClientList struct {
	Pools []common.Key `json:"pools"`
}

type VestingDest

type VestingDest struct {
	ID     common.Key     `json:"id"`     // destination ID
	Amount common.Balance `json:"amount"` // amount to vest for the destination
}

type VestingDestInfo

type VestingDestInfo struct {
	ID     common.Key       `json:"id"`     // identifier
	Wanted common.Balance   `json:"wanted"` // wanted amount for entire period
	Earned common.Balance   `json:"earned"` // can unlock
	Vested common.Balance   `json:"vested"` // already vested
	Last   common.Timestamp `json:"last"`   // last time unlocked
}

type VestingPoolInfo

type VestingPoolInfo struct {
	ID           common.Key         `json:"pool_id"`      // pool ID
	Balance      common.Balance     `json:"balance"`      // real pool balance
	Left         common.Balance     `json:"left"`         // owner can unlock
	Description  string             `json:"description"`  // description
	StartTime    common.Timestamp   `json:"start_time"`   // from
	ExpireAt     common.Timestamp   `json:"expire_at"`    // until
	Destinations []*VestingDestInfo `json:"destinations"` // receivers
	ClientID     common.Key         `json:"client_id"`    // owner
}

type VestingSCConfig

type VestingSCConfig struct {
	MinLock              common.Balance `json:"min_lock"`
	MinDuration          time.Duration  `json:"min_duration"`
	MaxDuration          time.Duration  `json:"max_duration"`
	MaxDestinations      int            `json:"max_destinations"`
	MaxDescriptionLength int            `json:"max_description_length"`
}

type VestingStopRequest

type VestingStopRequest struct {
	PoolID      common.Key `json:"pool_id"`
	Destination common.Key `json:"destination"`
}

type WalletCallback

type WalletCallback interface {
	OnWalletCreateComplete(status int, wallet string, err string)
}

WalletCallback needs to be implmented for wallet creation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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