jsonresult

package
v1.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2021 License: MIT Imports: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WaitingPDEContributionPrefix = []byte("waitingpdecontribution-")
	PDEPoolPrefix                = []byte("pdepool-")
	PDESharePrefix               = []byte("pdeshare-")
	PDETradingFeePrefix          = []byte("pdetradingfee-")
	PDETradeFeePrefix            = []byte("pdetradefee-")
	PDEContributionStatusPrefix  = []byte("pdecontributionstatus-")
	PDETradeStatusPrefix         = []byte("pdetradestatus-")
	PDEWithdrawalStatusPrefix    = []byte("pdewithdrawalstatus-")
	PDEFeeWithdrawalStatusPrefix = []byte("pdefeewithdrawalstatus-")
)

Functions

func BuildPDEPoolForPairKey

func BuildPDEPoolForPairKey(
	beaconHeight uint64,
	token1IDStr string,
	token2IDStr string,
) []byte

BuildPDEPoolForPairKey builds a pDEX pool-key for a pair of tokenIDs at the given beacon height.

func EncodeBase58Check

func EncodeBase58Check(b []byte) string

EncodeBase58Check returns the base58-encoded string for a given byte slice.

func MakeProof

func MakeProof(txType string, version int8, isTxNormal bool) privacy.Proof

MakeProof returns an empty proof associated with the input version and tx type.

func NewTxNormalFromTxNormalRPC

func NewTxNormalFromTxNormalRPC(data TxNormalRPC) (metadata.Transaction, error)

NewTxNormalFromTxNormalRPC creates a txNormal object from RPC-resulting data.

func ParseTxDetail

func ParseTxDetail(txDetail TransactionDetail) (metadata.Transaction, error)

ParseTxDetail parses a transaction detail into a transaction object.

func ParseTxTokenData

func ParseTxTokenData(txTokenData []byte) (tx_generic.TxTokenData, error)

ParseTxTokenData parses a RPC token detail into a TxTokenData object.

Types

type BeaconBestState

type BeaconBestState struct {
	BestBlockHash                          common.Hash                 `json:"BestBlockHash"`         // The hash of the block.
	PreviousBestBlockHash                  common.Hash                 `json:"PreviousBestBlockHash"` // The hash of the block.
	BestShardHash                          map[byte]common.Hash        `json:"BestShardHash"`
	BestShardHeight                        map[byte]uint64             `json:"BestShardHeight"`
	Epoch                                  uint64                      `json:"Epoch"`
	BeaconHeight                           uint64                      `json:"BeaconHeight"`
	BeaconProposerIndex                    int                         `json:"BeaconProposerIndex"`
	BeaconCommittee                        []string                    `json:"BeaconCommittee"`
	BeaconPendingValidator                 []string                    `json:"BeaconPendingValidator"`
	CandidateShardWaitingForCurrentRandom  []string                    `json:"CandidateShardWaitingForCurrentRandom"` // snapshot shard candidate list, waiting to be shuffled in this current epoch
	CandidateBeaconWaitingForCurrentRandom []string                    `json:"CandidateBeaconWaitingForCurrentRandom"`
	CandidateShardWaitingForNextRandom     []string                    `json:"CandidateShardWaitingForNextRandom"` // shard candidate list, waiting to be shuffled in next epoch
	CandidateBeaconWaitingForNextRandom    []string                    `json:"CandidateBeaconWaitingForNextRandom"`
	RewardReceiver                         map[string]string           `json:"RewardReceiver"`        // key: incognito public key of committee, value: payment address reward receiver
	ShardCommittee                         map[byte][]string           `json:"ShardCommittee"`        // current committee and validator of all shard
	ShardPendingValidator                  map[byte][]string           `json:"ShardPendingValidator"` // pending candidate waiting for swap to get in committee of all shard
	AutoStaking                            map[string]bool             `json:"AutoStaking"`
	StakingTx                              map[string]common.Hash      `json:"StakingTx"`
	CurrentRandomNumber                    int64                       `json:"CurrentRandomNumber"`
	CurrentRandomTimeStamp                 int64                       `json:"CurrentRandomTimeStamp"` // random timestamp for this epoch
	IsGetRandomNumber                      bool                        `json:"IsGetRandomNumber"`
	MaxBeaconCommitteeSize                 int                         `json:"MaxBeaconCommitteeSize"`
	MinBeaconCommitteeSize                 int                         `json:"MinBeaconCommitteeSize"`
	MaxShardCommitteeSize                  int                         `json:"MaxShardCommitteeSize"`
	MinShardCommitteeSize                  int                         `json:"MinShardCommitteeSize"`
	ActiveShards                           int                         `json:"ActiveShards"`
	LastCrossShardState                    map[byte]map[byte]uint64    `json:"LastCrossShardState"`
	ShardHandle                            map[byte]bool               `json:"ShardHandle"` // lock sync.RWMutex
	CommitteeEngineVersion                 uint                        `json:"CommitteeEngineVersion"`
	NumberOfMissingSignature               map[string]MissingSignature `json:"MissingSignature"`        // lock sync.RWMutex
	MissingSignaturePenalty                map[string]Penalty          `json:"MissingSignaturePenalty"` // lock sync.RWMutex
}

BeaconBestState describes the best state of the beacon chain.

type BestBlockItem

type BestBlockItem struct {
	Height              uint64 `json:"Height"`
	Hash                string `json:"Hash"`
	TotalTxs            uint64 `json:"TotalTxs"`
	BlockProducer       string `json:"BlockProducer"`
	ValidationData      string `json:"ValidationData"`
	Epoch               uint64 `json:"Epoch"`
	Time                int64  `json:"Time"`
	RemainingBlockEpoch uint64 `json:"RemainingBlockEpoch"`
	EpochBlock          uint64 `json:"EpochBlock"`
}

BestBlockItem describes the information of a best block.

type BestBlockResult

type BestBlockResult struct {
	BestBlocks map[int]BestBlockItem `json:"BestBlocks"`
}

BestBlockResult represents the best block detail of each shard chain and the beacon chain.

type BlockHashResult

type BlockHashResult struct {
	BestBlockHashes map[int]string `json:"BestBlockHashes"`
}

BlockHashResult represents the best block hash of each shard chain and the beacon chain.

type BlockInfo

type BlockInfo struct {
	Height  uint64 `json:"BlockHeight"`
	Hash    string `json:"BlockHash"`
	PreHash string `json:"PreHash"`
}

BlockInfo consists of simplified information of a block.

type CreateTransactionResult

type CreateTransactionResult struct {
	Base58CheckData string
	TxID            string
	ShardID         byte
}

CreateTransactionResult describes an RPC-result of creating PRV transactions.

type CreateTransactionTokenResult

type CreateTransactionTokenResult struct {
	Base58CheckData string
	ShardID         byte   `json:"ShardID"`
	TxID            string `json:"TxID"`
	TokenID         string `json:"TokenID"`
	TokenName       string `json:"TokenName"`
	TokenAmount     uint64 `json:"TokenAmount"`
}

CreateTransactionTokenResult describes an RPC-result of creating token transactions.

type CurrentPDEState

type CurrentPDEState struct {
	WaitingPDEContributions map[string]*PDEContribution `json:"WaitingPDEContributions"`
	PDEPoolPairs            map[string]*PoolInfo        `json:"PDEPoolPairs"`
	PDEShares               map[string]uint64           `json:"PDEShares"`
	PDETradingFees          map[string]uint64           `json:"PDETradingFees"`
	BeaconTimeStamp         int64                       `json:"BeaconTimeStamp"`
}

CurrentPDEState describes the state of the pDEX at a specific beacon height.

type ICoinInfo

type ICoinInfo interface {
	GetVersion() uint8
	GetCommitment() *crypto.Point
	GetInfo() []byte
	GetPublicKey() *crypto.Point
	GetValue() uint64
	GetKeyImage() *crypto.Point
	GetRandomness() *crypto.Scalar
	GetShardID() (uint8, error)
	GetSNDerivator() *crypto.Scalar
	GetCoinDetailEncrypted() []byte
	IsEncrypted() bool
	GetTxRandom() *coin.TxRandom
	GetSharedRandom() *crypto.Scalar
	GetSharedConcealRandom() *crypto.Scalar
	GetAssetTag() *crypto.Point
	MarshalJSON() ([]byte, error)
	UnmarshalJSON(data []byte) error
	Bytes() []byte
	SetBytes(bytes []byte) error
	DoesCoinBelongToKeySet(keySet *key.KeySet) (bool, *crypto.Point)
}

ICoinInfo describes all methods of an RPC output coin.

func NewCoinFromJsonOutCoin

func NewCoinFromJsonOutCoin(jsonOutCoin OutCoin) (ICoinInfo, *big.Int, error)

NewCoinFromJsonOutCoin returns an ICoinInfo, and an index from an OutCoin.

type InstructionProof

type InstructionProof struct {
	Instruction  string // Hex-encoded swap inst
	BeaconHeight string // Hex encoded height of the block contains the inst
	BridgeHeight string

	BeaconInstPath       []string // Hex encoded path of the inst in merkle tree
	BeaconInstPathIsLeft []bool   // Indicate if it is the left or right node
	BeaconInstRoot       string   // Hex encoded root of the inst merkle tree
	BeaconBlkData        string   // Hex encoded hash of the block meta
	BeaconSigs           []string // Hex encoded signature (r, s, v)
	BeaconSigIndices     []int    `json:"BeaconSigIdxs"` // Indices of signer

	BridgeInstPath       []string
	BridgeInstPathIsLeft []bool
	BridgeInstRoot       string
	BridgeBlkData        string
	BridgeSigs           []string
	BridgeSigIndices     []int `json:"BridgeSigIdxs"`
}

InstructionProof describes the proof of a instruction in the beacon chain.

type ListOutputCoins

type ListOutputCoins struct {
	FromHeight uint64               `json:"FromHeight"`
	ToHeight   uint64               `json:"ToHeight"`
	Outputs    map[string][]OutCoin `json:"Outputs"`
}

ListOutputCoins is a list of output coins returned by an RPC response.

type MiningInfoResult

type MiningInfoResult struct {
	ShardHeight         uint64 `json:"ShardHeight"`
	BeaconHeight        uint64 `json:"BeaconHeight"`
	CurrentShardBlockTx int    `json:"CurrentShardBlockTx"`
	PoolSize            int    `json:"PoolSize"`
	Chain               string `json:"Chain"`
	ShardID             int    `json:"ShardID"`
	Layer               string `json:"Layer"`
	Role                string `json:"Role"`
	MiningPublicKey     string `json:"MiningPublickey"`
	IsEnableMining      bool   `json:"IsEnableMining"`
}

MiningInfoResult describes the mining info of a node.

type MissingSignature

type MissingSignature struct {
	Total   uint
	Missing uint
}

MissingSignature keeps track of the number of missing signatures of a BeaconBestState.

type NodePoolInfo

type NodePoolInfo struct {
	Info map[int][]BlockInfo `json:"Info"`
}

NodePoolInfo describes the information of a node.

type OutCoin

type OutCoin struct {
	Version              string `json:"Version"`
	Index                string `json:"Index"`
	PublicKey            string `json:"PublicKey"`
	Commitment           string `json:"Commitment"`
	CoinCommitment       string `json:"CoinCommitment"`
	SNDerivator          string `json:"SNDerivator"`
	KeyImage             string `json:"KeyImage"`
	Randomness           string `json:"Randomness"`
	Value                string `json:"Value"`
	Info                 string `json:"Info"`
	SharedRandom         string `json:"SharedRandom,omitempty"`
	SharedConcealRandom  string `json:"SharedConcealRandom,omitempty"`
	TxRandom             string `json:"TxRandom,omitempty"`
	CoinDetailsEncrypted string `json:"CoinDetailsEncrypted,omitempty"`
	AssetTag             string `json:"AssetTag,omitempty"`
}

OutCoin is a struct to parse raw-data returned by an RPC response into an output coin.

func NewOutCoin

func NewOutCoin(outCoin ICoinInfo) OutCoin

NewOutCoin creates a new OutCoin from the given ICoinInfo.

func (*OutCoin) Conceal

func (outCoin *OutCoin) Conceal()

Conceal removes all fields of an OutCoin leaving only the version, commitment and public key. It is usually used to enhance privacy before being sent to the remote server.

type PDEContribution

type PDEContribution struct {
	ContributorAddressStr string
	TokenIDStr            string
	Amount                uint64
	TxReqID               common.Hash
}

PDEContribution describes a contribution on the pDEX.

type Penalty

type Penalty struct {
	MinPercent   uint
	Time         int64
	ForceUnStake bool
}

Penalty keeps track of the node-penalties of a BeaconBestState.

type PoolInfo

type PoolInfo struct {
	Token1IDStr     string
	Token1PoolValue uint64
	Token2IDStr     string
	Token2PoolValue uint64
}

PoolInfo represents a pDEX pool of two tokenIDs.

type RandomCommitmentAndPublicKeyResult

type RandomCommitmentAndPublicKeyResult struct {
	CommitmentIndices []uint64 `json:"CommitmentIndices"`
	PublicKeys        []string `json:"PublicKeys"`
	Commitments       []string `json:"Commitments"`
	AssetTags         []string `json:"AssetTags"`
}

RandomCommitmentAndPublicKeyResult represents the response to a request retrieving random decoys for transactions of version 2.

type RandomCommitmentResult

type RandomCommitmentResult struct {
	CommitmentIndices   []uint64 `json:"CommitmentIndices"`
	MyCommitmentIndices []uint64 `json:"MyCommitmentIndexs"`
	Commitments         []string `json:"Commitments"`
}

RandomCommitmentResult represents the response to a request retrieving random decoys for transactions of version 1.

type ShardBestState

type ShardBestState struct {
	BestBlockHash          common.Hash       `json:"BestBlockHash"` // hash of block.
	BestBeaconHash         common.Hash       `json:"BestBeaconHash"`
	BeaconHeight           uint64            `json:"BeaconHeight"`
	ShardID                byte              `json:"ShardID"`
	Epoch                  uint64            `json:"Epoch"`
	ShardHeight            uint64            `json:"ShardHeight"`
	MaxShardCommitteeSize  int               `json:"MaxShardCommitteeSize"`
	MinShardCommitteeSize  int               `json:"MinShardCommitteeSize"`
	ShardProposerIdx       int               `json:"ShardProposerIdx"`
	ShardCommittee         []string          `json:"ShardCommittee"`
	ShardPendingValidator  []string          `json:"ShardPendingValidator"`
	BestCrossShard         map[byte]uint64   `json:"BestCrossShard"` // Best cross shard block by heigh
	StakingTx              map[string]string `json:"StakingTx"`
	NumTxns                uint64            `json:"NumTxns"`                // The number of txns in the block.
	TotalTxns              uint64            `json:"TotalTxns"`              // The total number of txns in the chain.
	TotalTxnsExcludeSalary uint64            `json:"TotalTxnsExcludeSalary"` // for testing and benchmark
	ActiveShards           int               `json:"ActiveShards"`
	MetricBlockHeight      uint64            `json:"MetricBlockHeight"`
	CommitteeFromBlock     common.Hash       `json:"CommitteeFromBlock"`
	CommitteeEngineVersion uint              `json:"CommitteeEngineVersion"`
}

ShardBestState describes the best state result of a shard.

type ShardCommitteeState

type ShardCommitteeState struct {
	Root       string   `json:"root"`
	ShardID    uint64   `json:"shardID"`
	Committee  []string `json:"committee"`
	Substitute []string `json:"substitute"`
}

ShardCommitteeState describes a committee state of a shard.

type SyncInfo

type SyncInfo struct {
	IsSync      bool
	LastInsert  string
	BlockHeight uint64
	BlockTime   string
	BlockHash   string
}

SyncInfo describes the sync information of a node.

type SyncStats

type SyncStats struct {
	Beacon SyncInfo
	Shard  map[int]*SyncInfo
}

SyncStats describes the sync statistics of a node.

type TransactionDetail

type TransactionDetail struct {
	BlockHash   string `json:"BlockHash"`
	BlockHeight uint64 `json:"BlockHeight"`
	TxSize      uint64 `json:"TxSize"`
	Index       uint64 `json:"Index"`
	ShardID     byte   `json:"ShardID"`
	Hash        string `json:"Hash"`
	Version     int8   `json:"Version"`
	Type        string `json:"Type"` // Transaction type
	LockTime    string `json:"LockTime"`
	RawLockTime int64  `json:"RawLockTime,omitempty"`
	Fee         uint64 `json:"Fee"` // Fee applies: always consant
	Image       string `json:"Image"`

	IsPrivacy bool   `json:"IsPrivacy"`
	Proof     string `json:"Proof"`
	//ProofDetail     ProofDetail   `json:"ProofDetail"`
	InputCoinPubKey string `json:"InputCoinPubKey"`
	SigPubKey       string `json:"SigPubKey,omitempty"`    // 64 bytes
	RawSigPubKey    []byte `json:"RawSigPubKey,omitempty"` // 64 bytes
	Sig             string `json:"Sig,omitempty"`          // 64 bytes

	Metadata                 string `json:"Metadata"`
	CustomTokenData          string `json:"CustomTokenData"`
	PrivacyCustomTokenID     string `json:"PrivacyCustomTokenID"`
	PrivacyCustomTokenName   string `json:"PrivacyCustomTokenName"`
	PrivacyCustomTokenSymbol string `json:"PrivacyCustomTokenSymbol"`
	PrivacyCustomTokenData   string `json:"PrivacyCustomTokenData"`
	//PrivacyCustomTokenProofDetail ProofDetail `json:"PrivacyCustomTokenProofDetail"`
	PrivacyCustomTokenIsPrivacy bool   `json:"PrivacyCustomTokenIsPrivacy"`
	PrivacyCustomTokenFee       uint64 `json:"PrivacyCustomTokenFee"`

	IsInMempool bool `json:"IsInMempool"`
	IsInBlock   bool `json:"IsInBlock"`

	Info string `json:"Info"`
}

TransactionDetail describes the detail of a transaction returned by an RPC response.

type TxNormalRPC

type TxNormalRPC struct {
	Version              int8
	Type                 string
	LockTime             int64
	Fee                  uint64
	Info                 []byte
	SigPubKey            string
	Sig                  string
	Proof                string
	PubKeyLastByteSender byte
	Metadata             string
}

TxNormalRPC describes the detail of a TxNormal returned by an RPC response.

Jump to

Keyboard shortcuts

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