transaction

package
v0.0.0-...-dbbd7c7 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: MIT Imports: 23 Imported by: 10

Documentation

Index

Constants

View Source
const (
	CustomTokenInit = iota
	CustomTokenTransfer
	CustomTokenCrossShard
)
View Source
const (
	NormalCoinType = iota
	CustomTokenPrivacyType
)
View Source
const (
	UnexpectedError = iota
	WrongTokenTxTypeError
	CustomTokenExistedError
	WrongInputError
	WrongSigError
	DoubleSpendError
	TxNotExistError
	RandomCommitmentError
	InvalidSanityDataPRVError
	InvalidSanityDataPrivacyTokenError
	InvalidDoubleSpendPRVError
	InvalidDoubleSpendPrivacyTokenError
	InputCoinIsVeryLargeError
	PaymentInfoIsVeryLargeError
	TokenIDInvalidError
	TokenIDExistedError
	TokenIDExistedByCrossShardError
	PrivateKeySenderInvalidError
	SignTxError
	DecompressPaymentAddressError
	CanNotGetCommitmentFromIndexError
	CanNotDecompressCommitmentFromIndexError
	InitWithnessError
	WithnessProveError
	EncryptOutputError
	DecompressSigPubKeyError
	InitTxSignatureFromBytesError
	VerifyTxSigFailError
	DuplicatedOutputSndError
	SndExistedError
	InputCommitmentIsNotExistedError
	TxProofVerifyFailError
	VerifyOneOutOfManyProofFailedErr
	BatchTxProofVerifyFailError
	VerifyMinerCreatedTxBeforeGettingInBlockError
	CommitOutputCoinError

	NormalTokenPRVJsonError
	NormalTokenJsonError

	PrivacyTokenInitPRVError
	PrivacyTokenInitTokenDataError
	PrivacyTokenPRVJsonError
	PrivacyTokenJsonError
	PrivacyTokenTxTypeNotHandleError

	ExceedSizeTx
	ExceedSizeInfoTxError
	ExceedSizeInfoOutCoinError

	RejectInvalidLockTime
	RejectTxSize
	RejectTxVersion
	RejectTxPublickeySigSize
	RejectTxType
	RejectTxInfoSize
	RejectTxMedataWithBlockChain
)
View Source
const MaxSizeInfo = 512
View Source
const (
	ValidateTimeForOneoutOfManyProof = 1574985600 // GMT: Friday, November 29, 2019 12:00:00 AM
)

Variables

View Source
var ErrCodeMessage = map[int]struct {
	Code    int
	Message string
}{

	UnexpectedError:                               {-1000, "Unexpected error"},
	WrongTokenTxTypeError:                         {-1001, "Can't handle this TokenTxType"},
	CustomTokenExistedError:                       {-1002, "This token is existed in network"},
	WrongInputError:                               {-1003, "Wrong input transaction"},
	WrongSigError:                                 {-1004, "Wrong signature"},
	DoubleSpendError:                              {-1005, "Double spend"},
	TxNotExistError:                               {-1006, "Not exist tx for this"},
	RandomCommitmentError:                         {-1007, "Number of list commitments indices must be corresponding with number of input coins"},
	InputCoinIsVeryLargeError:                     {-1008, "Input coins in tx are very large: %d"},
	PaymentInfoIsVeryLargeError:                   {-1009, "Input coins in tx are very large: %d"},
	TokenIDInvalidError:                           {-1010, "Invalid TokenID: %+v"},
	PrivateKeySenderInvalidError:                  {-1011, "Invalid private key"},
	SignTxError:                                   {-1012, "Can not sign tx"},
	DecompressPaymentAddressError:                 {-1013, "Can not decompress public key from payment address %+v"},
	CanNotGetCommitmentFromIndexError:             {-1014, "Can not get commitment from index=%d shardID=%+v"},
	CanNotDecompressCommitmentFromIndexError:      {-1015, "Can not get commitment from index=%d shardID=%+v value=%+v"},
	InitWithnessError:                             {-1016, "Can not init witness for privacy with param: %s"},
	WithnessProveError:                            {-1017, "Can not prove with witness hashPrivacy=%+v param: %+s"},
	EncryptOutputError:                            {-1018, "Can not encrypt output"},
	DecompressSigPubKeyError:                      {-1019, "Can not decompress sig pubkey of tx"},
	InitTxSignatureFromBytesError:                 {-1020, "Can not init signature for tx from bytes"},
	VerifyTxSigFailError:                          {-1021, "Verify signature of tx is fail"},
	DuplicatedOutputSndError:                      {-1022, "Duplicate output"},
	SndExistedError:                               {-1023, "Snd existed: %s"},
	InputCommitmentIsNotExistedError:              {-1024, "Input's commitment is not existed"},
	TxProofVerifyFailError:                        {-1025, "Can not verify proof of tx %s"},
	VerifyMinerCreatedTxBeforeGettingInBlockError: {-1026, "Verify Miner Created Tx Before Getting In Block error"},
	CommitOutputCoinError:                         {-1027, "Commit all output error"},
	TokenIDExistedError:                           {-1028, "This token is existed in network"},
	TokenIDExistedByCrossShardError:               {-1029, "This token is existed in network by cross shard"},
	ExceedSizeInfoTxError:                         {-1030, "Size of tx info exceed max size info"},
	ExceedSizeInfoOutCoinError:                    {-1031, "Size of output coin's info exceed max size info"},
	ExceedSizeTx:                                  {-1032, "Size of tx info exceed max size of tx"},
	RejectInvalidLockTime:                         {-1033, "Wrong tx locktime"},
	RejectTxSize:                                  {-1034, "Tx size is too large"},
	RejectTxVersion:                               {-1035, "Wrong version tx"},
	RejectTxPublickeySigSize:                      {-1036, "Wrong tx Sig PK"},
	RejectTxType:                                  {-1037, "Wrong tx type"},
	RejectTxInfoSize:                              {-1038, "Wrong tx info length"},
	RejectTxMedataWithBlockChain:                  {-1039, "Reject invalid metadata with blockchain"},
	BatchTxProofVerifyFailError:                   {-1040, "Can not verify proof of batch txs %s"},
	VerifyOneOutOfManyProofFailedErr:              {-1041, "Verify one out of many proof failed"},

	InvalidSanityDataPRVError:  {-2000, "Invalid sanity data for PRV"},
	InvalidDoubleSpendPRVError: {-2001, "Double spend PRV in blockchain"},

	InvalidSanityDataPrivacyTokenError:  {-3000, "Invalid sanity data for privacy Token"},
	InvalidDoubleSpendPrivacyTokenError: {-3001, "Double spend privacy Token in blockchain"},
	PrivacyTokenJsonError:               {-3002, "Json data error"},
	PrivacyTokenPRVJsonError:            {-3003, "Json data error"},
	PrivacyTokenInitPRVError:            {-3004, "Init tx for PRV error"},
	PrivacyTokenTxTypeNotHandleError:    {-3005, "Can not handle this tx type for privacy token"},
	PrivacyTokenInitTokenDataError:      {-3006, "Can not init data for privacy token tx"},

	NormalTokenPRVJsonError: {-4000, "Json data error"},
	NormalTokenJsonError:    {-4001, "Json data error"},
}

Global instant to use

Functions

func BuildCoinBaseTxByCoinID

func BuildCoinBaseTxByCoinID(params *BuildCoinBaseTxByCoinIDParams) (metadata.Transaction, error)

func CheckSNDerivatorExistence

func CheckSNDerivatorExistence(tokenID *common.Hash, snd *privacy.Scalar, stateDB *statedb.StateDB) (bool, error)

CheckSNDerivatorExistence return true if snd exists in snDerivators list

func ConvertOutputCoinToInputCoin

func ConvertOutputCoinToInputCoin(usableOutputsOfOld []*privacy.OutputCoin) []*privacy.InputCoin

ConvertOutputCoinToInputCoin - convert output coin from old tx to input coin for new tx

func CreateCustomTokenPrivacyBurningReceiverArray

func CreateCustomTokenPrivacyBurningReceiverArray(dataReceiver interface{}, bcr metadata.ChainRetriever, beaconHeight uint64) ([]*privacy.PaymentInfo, int64, error)

func CreateCustomTokenPrivacyReceiverArray

func CreateCustomTokenPrivacyReceiverArray(dataReceiver interface{}) ([]*privacy.PaymentInfo, int64, error)

CreateCustomTokenReceiverArray - parse data frm rpc request to create a list vout for preparing to create a custom token tx data interface is a map[paymentt-address]{transferring-amount}

func CreateCustomTokenPrivacyReceiverArrayV2

func CreateCustomTokenPrivacyReceiverArrayV2(dataReceiver interface{}) ([]*privacy.PaymentInfo, int64, error)

CreateCustomTokenReceiverArray - parse data frm rpc request to create a list vout for preparing to create a custom token tx data interface is a map[paymentt-address]{transferring-amount}

func EstimateTxSize

func EstimateTxSize(estimateTxSizeParam *EstimateTxSizeParam) uint64

EstimateTxSize returns the estimated size of the tx in kilobyte

func NewBatchTransaction

func NewBatchTransaction(txs []metadata.Transaction) *batchTransaction

func RandomCommitmentsProcess

func RandomCommitmentsProcess(param *RandomCommitmentsProcessParam) (commitmentIndexs []uint64, myCommitmentIndexs []uint64, commitments [][]byte)

RandomCommitmentsProcess - process list commitments and useable tx to create a list commitment random which be used to create a proof for new tx result contains commitmentIndexs = [{1,2,3,4,myindex1,6,7,8}{9,10,11,12,13,myindex2,15,16}...] myCommitmentIndexs = [4, 13, ...]

Types

type BuildCoinBaseTxByCoinIDParams

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

func NewBuildCoinBaseTxByCoinIDParams

func NewBuildCoinBaseTxByCoinIDParams(payToAddress *privacy.PaymentAddress,
	amount uint64,
	payByPrivateKey *privacy.PrivateKey,
	stateDB *statedb.StateDB,
	meta metadata.Metadata,
	coinID common.Hash,
	txType int,
	coinName string,
	shardID byte,
	bridgeStateDB *statedb.StateDB) *BuildCoinBaseTxByCoinIDParams

type CustomTokenPrivacyParamTx

type CustomTokenPrivacyParamTx struct {
	PropertyID     string                 `json:"TokenID"`
	PropertyName   string                 `json:"TokenName"`
	PropertySymbol string                 `json:"TokenSymbol"`
	Amount         uint64                 `json:"TokenAmount"`
	TokenTxType    int                    `json:"TokenTxType"`
	Receiver       []*privacy.PaymentInfo `json:"TokenReceiver"`
	TokenInput     []*privacy.InputCoin   `json:"TokenInput"`
	Mintable       bool                   `json:"TokenMintable"`
	Fee            uint64                 `json:"TokenFee"`
}

CustomTokenParamTx - use for rpc request json body

type EstimateTxSizeParam

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

func NewEstimateTxSizeParam

func NewEstimateTxSizeParam(numInputCoins, numPayments int,
	hasPrivacy bool, metadata metadata.Metadata,
	privacyCustomTokenParams *CustomTokenPrivacyParamTx,
	limitFee uint64) *EstimateTxSizeParam

type RandomCommitmentsProcessParam

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

func NewRandomCommitmentsProcessParam

func NewRandomCommitmentsProcessParam(usableInputCoins []*privacy.InputCoin, randNum int, stateDB *statedb.StateDB, shardID byte, tokenID *common.Hash) *RandomCommitmentsProcessParam

type TransactionError

type TransactionError struct {
	Code    int
	Message string
	// contains filtered or unexported fields
}

func NewTransactionErr

func NewTransactionErr(key int, err error, params ...interface{}) *TransactionError

func (TransactionError) Error

func (e TransactionError) Error() string

type TransactionLogger

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

func (*TransactionLogger) Init

func (transactionLogger *TransactionLogger) Init(inst common.Logger)

type Tx

type Tx struct {
	// Basic data, required
	Version  int8   `json:"Version"`
	Type     string `json:"Type"` // Transaction type
	LockTime int64  `json:"LockTime"`
	Fee      uint64 `json:"Fee"` // Fee applies: always consant
	Info     []byte // 512 bytes
	// Sign and Privacy proof, required
	SigPubKey            []byte `json:"SigPubKey, omitempty"` // 33 bytes
	Sig                  []byte `json:"Sig, omitempty"`       //
	Proof                *zkp.PaymentProof
	PubKeyLastByteSender byte
	// Metadata, optional
	Metadata metadata.Metadata
	// contains filtered or unexported fields
}

func (Tx) CalculateBurningTxValue

func (tx Tx) CalculateBurningTxValue(bcr metadata.ChainRetriever, retriever metadata.ShardViewRetriever, viewRetriever metadata.BeaconViewRetriever, beaconHeight uint64) (bool, uint64)

func (Tx) CalculateTxValue

func (tx Tx) CalculateTxValue() uint64

func (Tx) CheckCMExistence

func (tx Tx) CheckCMExistence(cm []byte, stateDB *statedb.StateDB, shardID byte, tokenID *common.Hash) (bool, error)

CheckCMExistence returns true if cm exists in cm list

func (Tx) CheckTxVersion

func (tx Tx) CheckTxVersion(maxTxVersion int8) bool

func (Tx) GetFullTxValues

func (tx Tx) GetFullTxValues() (uint64, uint64)

GetFullTxValues returns both prv and ptoken values

func (Tx) GetInfo

func (tx Tx) GetInfo() []byte

GetMetadata returns metadata of tx is existed

func (Tx) GetLockTime

func (tx Tx) GetLockTime() int64

func (Tx) GetMetadata

func (tx Tx) GetMetadata() metadata.Metadata

GetMetadata returns metadata of tx is existed

func (Tx) GetMetadataFromVinsTx

func (tx Tx) GetMetadataFromVinsTx(bcr metadata.ChainRetriever, retriever metadata.ShardViewRetriever, viewRetriever metadata.BeaconViewRetriever) (metadata.Metadata, error)

func (Tx) GetMetadataType

func (tx Tx) GetMetadataType() int

GetMetadataType returns the type of underlying metadata if is existed

func (Tx) GetProof

func (tx Tx) GetProof() *zkp.PaymentProof

func (Tx) GetReceivers

func (tx Tx) GetReceivers() ([][]byte, []uint64)

func (Tx) GetSender

func (tx Tx) GetSender() []byte

func (Tx) GetSenderAddrLastByte

func (tx Tx) GetSenderAddrLastByte() byte

func (Tx) GetSigPubKey

func (tx Tx) GetSigPubKey() []byte

func (Tx) GetTokenID

func (tx Tx) GetTokenID() *common.Hash

func (Tx) GetTokenReceivers

func (tx Tx) GetTokenReceivers() ([][]byte, []uint64)

func (Tx) GetTokenUniqueReceiver

func (tx Tx) GetTokenUniqueReceiver() (bool, []byte, uint64)

func (Tx) GetTransferData

func (tx Tx) GetTransferData() (bool, []byte, uint64, *common.Hash)

func (Tx) GetTxActualSize

func (tx Tx) GetTxActualSize() uint64

GetTxActualSize computes the actual size of a given transaction in kilobyte

func (Tx) GetTxFee

func (tx Tx) GetTxFee() uint64

func (Tx) GetTxFeeToken

func (tx Tx) GetTxFeeToken() uint64

func (Tx) GetType

func (tx Tx) GetType() string

GetType returns the type of the transaction

func (Tx) GetUniqueReceiver

func (tx Tx) GetUniqueReceiver() (bool, []byte, uint64)

func (*Tx) Hash

func (tx *Tx) Hash() *common.Hash

func (*Tx) Init

func (tx *Tx) Init(params *TxPrivacyInitParams) error

Init - init value for tx from inputcoin(old output coin from old tx) create new outputcoin and build privacy proof if not want to create a privacy tx proof, set hashPrivacy = false database is used like an interface which use to query info from transactionStateDB in building tx

func (*Tx) InitForASM

func (tx *Tx) InitForASM(params *TxPrivacyInitParamsForASM, serverTime int64) error

func (*Tx) InitTxSalary

func (tx *Tx) InitTxSalary(salary uint64, receiverAddr *privacy.PaymentAddress, privateKey *privacy.PrivateKey, stateDB *statedb.StateDB, metaData metadata.Metadata) error

InitTxSalary Init salary transaction #1 - salary: #2 - receiverAddr: #3 - privKey: #4 - snDerivators:

func (Tx) IsCoinsBurning

func (tx Tx) IsCoinsBurning(bcr metadata.ChainRetriever, retriever metadata.ShardViewRetriever, viewRetriever metadata.BeaconViewRetriever, beaconHeight uint64) bool

func (Tx) IsFullBurning

func (tx Tx) IsFullBurning(
	bcr metadata.ChainRetriever,
	retriever metadata.ShardViewRetriever,
	viewRetriever metadata.BeaconViewRetriever,
	beaconHeight uint64,
) bool

IsFullBurning returns whether the tx is full burning tx

func (Tx) IsPrivacy

func (tx Tx) IsPrivacy() bool

func (Tx) IsSalaryTx

func (tx Tx) IsSalaryTx() bool

func (Tx) ListSerialNumbersHashH

func (tx Tx) ListSerialNumbersHashH() []common.Hash

func (*Tx) SetMetadata

func (tx *Tx) SetMetadata(meta metadata.Metadata)

SetMetadata sets metadata to tx

func (Tx) String

func (tx Tx) String() string

func (*Tx) UnmarshalJSON

func (tx *Tx) UnmarshalJSON(data []byte) error

func (Tx) ValidateDoubleSpendWithBlockchain

func (tx Tx) ValidateDoubleSpendWithBlockchain(
	shardID byte,
	stateDB *statedb.StateDB,
	tokenID *common.Hash,
) error

ValidateDoubleSpend - check double spend for any transaction type

func (Tx) ValidateSanityData

func (tx Tx) ValidateSanityData(chainRetriever metadata.ChainRetriever, shardViewRetriever metadata.ShardViewRetriever, beaconViewRetriever metadata.BeaconViewRetriever, beaconHeight uint64) (bool, error)

func (*Tx) ValidateTransaction

func (tx *Tx) ValidateTransaction(hasPrivacy bool, transactionStateDB *statedb.StateDB, bridgeStateDB *statedb.StateDB, shardID byte, tokenID *common.Hash, isBatch bool, isNewTransaction bool) (bool, error)

ValidateTransaction returns true if transaction is valid: - Verify tx signature - Verify the payment proof

func (Tx) ValidateTxByItself

func (tx Tx) ValidateTxByItself(hasPrivacy bool, transactionStateDB *statedb.StateDB, bridgeStateDB *statedb.StateDB, chainRetriever metadata.ChainRetriever, shardID byte, isNewTransaction bool, shardViewRetriever metadata.ShardViewRetriever, beaconViewRetriever metadata.BeaconViewRetriever) (bool, error)

func (Tx) ValidateTxReturnStaking

func (tx Tx) ValidateTxReturnStaking(stateDB *statedb.StateDB) bool

func (Tx) ValidateTxSalary

func (tx Tx) ValidateTxSalary(stateDB *statedb.StateDB) (bool, error)

func (Tx) ValidateTxWithBlockChain

func (tx Tx) ValidateTxWithBlockChain(chainRetriever metadata.ChainRetriever, shardViewRetriever metadata.ShardViewRetriever, beaconViewRetriever metadata.BeaconViewRetriever, shardID byte, stateDB *statedb.StateDB) error

func (Tx) ValidateTxWithCurrentMempool

func (tx Tx) ValidateTxWithCurrentMempool(mr metadata.MempoolRetriever) error

func (Tx) ValidateType

func (tx Tx) ValidateType() bool

func (Tx) VerifyMinerCreatedTxBeforeGettingInBlock

func (tx Tx) VerifyMinerCreatedTxBeforeGettingInBlock(txsInBlock []metadata.Transaction, txsUsed []int, insts [][]string, instsUsed []int, shardID byte, bcr metadata.ChainRetriever, accumulatedValues *metadata.AccumulatedValues, retriever metadata.ShardViewRetriever, viewRetriever metadata.BeaconViewRetriever) (bool, error)

type TxCustomTokenPrivacy

type TxCustomTokenPrivacy struct {
	Tx                                    // inherit from normal tx of P(supporting privacy) with a high fee to ensure that tx could contain a big data of privacy for token
	TxPrivacyTokenData TxPrivacyTokenData `json:"TxTokenPrivacyData"` // supporting privacy format
	// contains filtered or unexported fields
}

TxCustomTokenPrivacy is class tx which is inherited from P tx(supporting privacy) for fee and contain data(with supporting privacy format) to support issuing and transfer a custom token(token from end-user, look like erc-20) Dev or end-user can use this class tx to create an token type which use personal purpose TxCustomTokenPrivacy is an advance format of TxNormalToken so that user need to spend a lot fee to create this class tx

func (TxCustomTokenPrivacy) CalculateBurningTxValue

func (txCustomTokenPrivacy TxCustomTokenPrivacy) CalculateBurningTxValue(bcr metadata.ChainRetriever, retriever metadata.ShardViewRetriever, viewRetriever metadata.BeaconViewRetriever, beaconHeight uint64) (bool, uint64)

func (TxCustomTokenPrivacy) CalculateTxValue

func (txCustomTokenPrivacy TxCustomTokenPrivacy) CalculateTxValue() uint64

CalculateTxValue - get tx value for pToken

func (TxCustomTokenPrivacy) GetFullTxValues

func (txCustomTokenPrivacy TxCustomTokenPrivacy) GetFullTxValues() (uint64, uint64)

GetFullTxValues returns both prv and ptoken values

func (TxCustomTokenPrivacy) GetProof

func (txCustomTokenPrivacy TxCustomTokenPrivacy) GetProof() *zkp.PaymentProof

GetProof - return proof PRV of tx

func (TxCustomTokenPrivacy) GetSigPubKey

func (txCustomTokenPrivacy TxCustomTokenPrivacy) GetSigPubKey() []byte

GetSigPubKey - return sig pubkey for pToken

func (TxCustomTokenPrivacy) GetTokenID

func (txCustomTokenPrivacy TxCustomTokenPrivacy) GetTokenID() *common.Hash

func (TxCustomTokenPrivacy) GetTokenReceivers

func (txCustomTokenPrivacy TxCustomTokenPrivacy) GetTokenReceivers() ([][]byte, []uint64)

GetTokenReceivers - return receivers in tx, who receive token

func (TxCustomTokenPrivacy) GetTokenUniqueReceiver

func (txCustomTokenPrivacy TxCustomTokenPrivacy) GetTokenUniqueReceiver() (bool, []byte, uint64)

GetTokenUniqueReceiver

func (TxCustomTokenPrivacy) GetTransferData

func (txCustomTokenPrivacy TxCustomTokenPrivacy) GetTransferData() (bool, []byte, uint64, *common.Hash)

GetTransferData

func (TxCustomTokenPrivacy) GetTxActualSize

func (txCustomTokenPrivacy TxCustomTokenPrivacy) GetTxActualSize() uint64

GetTxActualSize computes the virtual size of a given transaction size of this tx = (normal TxNormal size) + (custom token data size)

func (TxCustomTokenPrivacy) GetTxFee

func (tx TxCustomTokenPrivacy) GetTxFee() uint64

GetTxFee - return fee PRV of Tx which contain privacy token Tx

func (TxCustomTokenPrivacy) GetTxFeeToken

func (tx TxCustomTokenPrivacy) GetTxFeeToken() uint64

GetTxFeeToken - return Token Fee use to pay for privacy token Tx

func (TxCustomTokenPrivacy) GetTxPrivacyTokenActualSize

func (tx TxCustomTokenPrivacy) GetTxPrivacyTokenActualSize() uint64

func (*TxCustomTokenPrivacy) Hash

func (txCustomTokenPrivacy *TxCustomTokenPrivacy) Hash() *common.Hash

Hash returns the hash of all fields of the transaction

func (*TxCustomTokenPrivacy) Init

func (txCustomTokenPrivacy *TxCustomTokenPrivacy) Init(params *TxPrivacyTokenInitParams) error

Init - build normal tx component and privacy custom token data

func (*TxCustomTokenPrivacy) InitForASM

func (txCustomTokenPrivacy *TxCustomTokenPrivacy) InitForASM(params *TxPrivacyTokenInitParamsForASM, serverTime int64) error

Init - build normal tx component and privacy custom token data

func (TxCustomTokenPrivacy) IsCoinsBurning

func (txCustomTokenPrivacy TxCustomTokenPrivacy) IsCoinsBurning(bcr metadata.ChainRetriever, retriever metadata.ShardViewRetriever, viewRetriever metadata.BeaconViewRetriever, beaconHeight uint64) bool

IsCoinsBurning - checking this is a burning pToken

func (TxCustomTokenPrivacy) IsFullBurning

func (txCustomTokenPrivacy TxCustomTokenPrivacy) IsFullBurning(
	bcr metadata.ChainRetriever,
	retriever metadata.ShardViewRetriever,
	viewRetriever metadata.BeaconViewRetriever,
	beaconHeight uint64,
) bool

IsFullBurning returns whether the tx is full burning tx

func (TxCustomTokenPrivacy) JSONString

func (txCustomTokenPrivacy TxCustomTokenPrivacy) JSONString() string

func (TxCustomTokenPrivacy) ListSerialNumbersHashH

func (txCustomTokenPrivacy TxCustomTokenPrivacy) ListSerialNumbersHashH() []common.Hash

func (TxCustomTokenPrivacy) String

func (txCustomTokenPrivacy TxCustomTokenPrivacy) String() string

func (*TxCustomTokenPrivacy) UnmarshalJSON

func (txCustomTokenPrivacy *TxCustomTokenPrivacy) UnmarshalJSON(data []byte) error

func (TxCustomTokenPrivacy) ValidateSanityData

func (txCustomTokenPrivacy TxCustomTokenPrivacy) ValidateSanityData(chainRetriever metadata.ChainRetriever, shardViewRetriever metadata.ShardViewRetriever, beaconViewRetriever metadata.BeaconViewRetriever, beaconHeight uint64) (bool, error)

ValidateSanityData - validate sanity data of PRV and pToken

func (*TxCustomTokenPrivacy) ValidateTransaction

func (txCustomTokenPrivacy *TxCustomTokenPrivacy) ValidateTransaction(hasPrivacyCoin bool, transactionStateDB *statedb.StateDB, bridgeStateDB *statedb.StateDB, shardID byte, tokenID *common.Hash, isBatch bool, isNewTransaction bool) (bool, error)

ValidateTransaction - verify proof, signature, ... of PRV and pToken

func (TxCustomTokenPrivacy) ValidateTxByItself

func (txCustomTokenPrivacy TxCustomTokenPrivacy) ValidateTxByItself(hasPrivacyCoin bool, transactionStateDB *statedb.StateDB, bridgeStateDB *statedb.StateDB, chainRetriever metadata.ChainRetriever, shardID byte, isNewTransaction bool, shardViewRetriever metadata.ShardViewRetriever, beaconViewRetriever metadata.BeaconViewRetriever) (bool, error)

ValidateTxByItself - validate tx by itself, check signature, proof,... and metadata

func (TxCustomTokenPrivacy) ValidateTxWithBlockChain

func (txCustomTokenPrivacy TxCustomTokenPrivacy) ValidateTxWithBlockChain(chainRetriever metadata.ChainRetriever, shardViewRetriever metadata.ShardViewRetriever, beaconViewRetriever metadata.BeaconViewRetriever, shardID byte, stateDB *statedb.StateDB) error

func (TxCustomTokenPrivacy) ValidateTxWithCurrentMempool

func (txCustomTokenPrivacy TxCustomTokenPrivacy) ValidateTxWithCurrentMempool(mr metadata.MempoolRetriever) error

ValidateTxWithCurrentMempool - validate for serrial number use in tx is double with other tx in mempool

func (TxCustomTokenPrivacy) ValidateType

func (txCustomTokenPrivacy TxCustomTokenPrivacy) ValidateType() bool

ValidateType - check type of tx

func (TxCustomTokenPrivacy) VerifyMinerCreatedTxBeforeGettingInBlock

func (txCustomTokenPrivacy TxCustomTokenPrivacy) VerifyMinerCreatedTxBeforeGettingInBlock(txsInBlock []metadata.Transaction, txsUsed []int, insts [][]string, instsUsed []int, shardID byte, bcr metadata.ChainRetriever, accumulatedValues *metadata.AccumulatedValues, retriever metadata.ShardViewRetriever, viewRetriever metadata.BeaconViewRetriever) (bool, error)

VerifyMinerCreatedTxBeforeGettingInBlock

type TxPrivacyInitParams

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

func NewTxPrivacyInitParams

func NewTxPrivacyInitParams(senderSK *privacy.PrivateKey,
	paymentInfo []*privacy.PaymentInfo,
	inputCoins []*privacy.InputCoin,
	fee uint64,
	hasPrivacy bool,
	stateDB *statedb.StateDB,
	tokenID *common.Hash,
	metaData metadata.Metadata,
	info []byte) *TxPrivacyInitParams

type TxPrivacyInitParamsForASM

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

func NewTxPrivacyInitParamsForASM

func NewTxPrivacyInitParamsForASM(
	senderSK *privacy.PrivateKey,
	paymentInfo []*privacy.PaymentInfo,
	inputCoins []*privacy.InputCoin,
	fee uint64,
	hasPrivacy bool,
	tokenID *common.Hash,
	metaData metadata.Metadata,
	info []byte,
	commitmentIndices []uint64,
	commitmentBytes [][]byte,
	myCommitmentIndices []uint64,
	sndOutputs []*privacy.Scalar) *TxPrivacyInitParamsForASM

func (*TxPrivacyInitParamsForASM) SetMetaData

func (param *TxPrivacyInitParamsForASM) SetMetaData(meta metadata.Metadata)

type TxPrivacyTokenData

type TxPrivacyTokenData struct {
	TxNormal       Tx          // used for privacy functionality
	PropertyID     common.Hash // = hash of TxCustomTokenprivacy data
	PropertyName   string
	PropertySymbol string

	Type     int    // action type
	Mintable bool   // default false
	Amount   uint64 // init amount
}

func (TxPrivacyTokenData) Hash

func (txTokenPrivacyData TxPrivacyTokenData) Hash() (*common.Hash, error)

Hash - return hash of custom token data, be used as Token ID

func (TxPrivacyTokenData) JSONString

func (txTokenPrivacyData TxPrivacyTokenData) JSONString() string

func (TxPrivacyTokenData) String

func (txTokenPrivacyData TxPrivacyTokenData) String() string

type TxPrivacyTokenInitParams

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

func NewTxPrivacyTokenInitParams

func NewTxPrivacyTokenInitParams(senderKey *privacy.PrivateKey,
	paymentInfo []*privacy.PaymentInfo,
	inputCoin []*privacy.InputCoin,
	feeNativeCoin uint64,
	tokenParams *CustomTokenPrivacyParamTx,
	transactionStateDB *statedb.StateDB,
	metaData metadata.Metadata,
	hasPrivacyCoin bool,
	hasPrivacyToken bool,
	shardID byte,
	info []byte,
	bridgeStateDB *statedb.StateDB) *TxPrivacyTokenInitParams

type TxPrivacyTokenInitParamsForASM

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

func NewTxPrivacyTokenInitParamsForASM

func NewTxPrivacyTokenInitParamsForASM(
	senderKey *privacy.PrivateKey,
	paymentInfo []*privacy.PaymentInfo,
	inputCoin []*privacy.InputCoin,
	feeNativeCoin uint64,
	tokenParams *CustomTokenPrivacyParamTx,
	metaData metadata.Metadata,
	hasPrivacyCoin bool,
	hasPrivacyToken bool,
	shardID byte,
	info []byte,
	commitmentIndicesForNativeToken []uint64,
	commitmentBytesForNativeToken [][]byte,
	myCommitmentIndicesForNativeToken []uint64,
	sndOutputsForNativeToken []*privacy.Scalar,

	commitmentIndicesForPToken []uint64,
	commitmentBytesForPToken [][]byte,
	myCommitmentIndicesForPToken []uint64,
	sndOutputsForPToken []*privacy.Scalar) *TxPrivacyTokenInitParamsForASM

func (*TxPrivacyTokenInitParamsForASM) SetMetaData

func (param *TxPrivacyTokenInitParamsForASM) SetMetaData(meta metadata.Metadata)

Jump to

Keyboard shortcuts

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