Documentation ¶
Index ¶
- func InitConversion(tx *Tx, params *TxConvertVer1ToVer2InitParams) error
- func InitTokenConversion(txToken *TxToken, params *TxTokenConvertVer1ToVer2InitParams) error
- type CustomTokenConversionParams
- type SigPubKey
- type Tx
- func (tx *Tx) CheckData(transactionStateDB *statedb.StateDB) error
- func (tx *Tx) GetReceiverData() ([]privacy.Coin, error)
- func (tx Tx) GetTxActualSize() uint64
- func (tx Tx) GetTxBurnData() (bool, privacy.Coin, *common.Hash, error)
- func (tx Tx) GetTxFullBurnData() (bool, privacy.Coin, privacy.Coin, *common.Hash, error)
- func (tx Tx) GetTxMintData() (bool, privacy.Coin, *common.Hash, error)
- func (tx Tx) Hash() *common.Hash
- func (tx Tx) HashWithoutMetadataSig() *common.Hash
- func (tx *Tx) Init(paramsInterface interface{}) error
- func (tx *Tx) InitTxSalary(otaCoin *privacy.CoinV2, privateKey *privacy.PrivateKey, ...) error
- func (tx Tx) IsSalaryTx() bool
- func (tx Tx) ListOTAHashH() []common.Hash
- func (tx *Tx) LoadData(transactionStateDB *statedb.StateDB) error
- func (tx Tx) ValidateSanityData(chainRetriever metadata.ChainRetriever, ...) (bool, error)
- func (tx *Tx) ValidateSanityDataByItSelf() (bool, error)
- func (tx *Tx) ValidateSanityDataWithBlockchain(chainRetriever metadata.ChainRetriever, ...) (bool, error)
- func (tx Tx) ValidateTransaction(boolParams map[string]bool, transactionStateDB *statedb.StateDB, ...) (bool, []privacy.Proof, error)
- func (tx Tx) ValidateTxByItself(boolParams map[string]bool, transactionStateDB *statedb.StateDB, ...) (bool, error)
- func (tx *Tx) ValidateTxCorrectness(transactionStateDB *statedb.StateDB) (bool, error)
- func (tx *Tx) ValidateTxSalary(db *statedb.StateDB) (bool, error)
- func (tx *Tx) ValidateTxWithBlockChain(chainRetriever metadata.ChainRetriever, ...) error
- func (tx Tx) ValidateTxWithCurrentMempool(mr metadata.MempoolRetriever) error
- func (tx *Tx) Verify(boolParams map[string]bool, transactionStateDB *statedb.StateDB, ...) (bool, error)
- func (tx Tx) VerifyMinerCreatedTxBeforeGettingInBlock(mintdata *metadata.MintData, shardID byte, bcr metadata.ChainRetriever, ...) (bool, error)
- func (tx *Tx) VerifySigTx(transactionStateDB *statedb.StateDB) (bool, error)
- type TxConvertVer1ToVer2InitParams
- type TxToken
- func (txToken *TxToken) CalculateTxValue() uint64
- func (txToken *TxToken) CheckData(transactionStateDB *statedb.StateDB) error
- func (txToken TxToken) CheckTxVersion(maxTxVersion int8) bool
- func (txToken TxToken) GetCachedActualSize() *uint64
- func (txToken TxToken) GetCachedHash() *common.Hash
- func (txToken TxToken) GetInfo() []byte
- func (txToken TxToken) GetLockTime() int64
- func (txToken TxToken) GetMetadata() metadata.Metadata
- func (txToken TxToken) GetMetadataType() int
- func (txToken TxToken) GetPrivateKey() []byte
- func (txToken TxToken) GetProof() privacy.Proof
- func (txToken *TxToken) GetReceiverData() ([]privacy.Coin, error)
- func (txToken TxToken) GetReceivers() ([][]byte, []uint64)
- func (txToken TxToken) GetSenderAddrLastByte() byte
- func (txToken TxToken) GetSig() []byte
- func (txToken TxToken) GetSigPubKey() []byte
- func (txToken TxToken) GetTokenID() *common.Hash
- func (txToken *TxToken) GetTransferData() (bool, []byte, uint64, *common.Hash)
- func (txToken TxToken) GetTxActualSize() uint64
- func (txToken *TxToken) GetTxBase() metadata.Transaction
- func (txToken *TxToken) GetTxBurnData() (bool, privacy.Coin, *common.Hash, error)
- func (txToken TxToken) GetTxFee() uint64
- func (txToken TxToken) GetTxFeeToken() uint64
- func (txToken *TxToken) GetTxFullBurnData() (bool, privacy.Coin, privacy.Coin, *common.Hash, error)
- func (txToken *TxToken) GetTxMintData() (bool, privacy.Coin, *common.Hash, error)
- func (txToken *TxToken) GetTxNormal() metadata.Transaction
- func (txToken *TxToken) GetTxTokenData() tx_generic.TxTokenData
- func (txToken TxToken) GetType() string
- func (txToken *TxToken) GetValidationEnv() metadata.ValidationEnviroment
- func (txToken TxToken) GetVersion() int8
- func (txToken *TxToken) Hash() *common.Hash
- func (txToken TxToken) HashWithoutMetadataSig() *common.Hash
- func (txToken *TxToken) Init(paramsInterface interface{}) error
- func (txToken *TxToken) InitTxTokenSalary(otaCoin *privacy.CoinV2, privKey *privacy.PrivateKey, stateDB *statedb.StateDB, ...) error
- func (txToken *TxToken) IsCoinsBurning(bcr metadata.ChainRetriever, retriever metadata.ShardViewRetriever, ...) bool
- func (txToken TxToken) IsPrivacy() bool
- func (txToken TxToken) IsSalaryTx() bool
- func (txToken TxToken) ListOTAHashH() []common.Hash
- func (txToken TxToken) ListSerialNumbersHashH() []common.Hash
- func (txToken *TxToken) LoadData(transactionStateDB *statedb.StateDB) error
- func (txToken *TxToken) SetCachedActualSize(sz *uint64)
- func (txToken *TxToken) SetCachedHash(h *common.Hash)
- func (txToken *TxToken) SetGetSenderAddrLastByte(b byte)
- func (txToken *TxToken) SetInfo(info []byte)
- func (txToken *TxToken) SetLockTime(locktime int64)
- func (txToken *TxToken) SetMetadata(meta metadata.Metadata)
- func (txToken *TxToken) SetPrivateKey(sk []byte)
- func (txToken *TxToken) SetProof(proof privacy.Proof)
- func (txToken *TxToken) SetSig(sig []byte)
- func (txToken *TxToken) SetSigPubKey(sigPubkey []byte)
- func (txToken *TxToken) SetTxBase(inTx metadata.Transaction) error
- func (txToken *TxToken) SetTxFee(fee uint64)
- func (txToken *TxToken) SetTxNormal(inTx metadata.Transaction) error
- func (txToken *TxToken) SetTxTokenData(data tx_generic.TxTokenData) error
- func (txToken *TxToken) SetType(t string)
- func (txToken *TxToken) SetValidationEnv(valEnv metadata.ValidationEnviroment)
- func (txToken *TxToken) SetVersion(version int8)
- func (txToken TxToken) String() string
- func (txToken *TxToken) UnmarshalJSON(data []byte) error
- func (txToken *TxToken) ValidateDoubleSpendWithBlockchain(shardID byte, stateDB *statedb.StateDB, tokenID *common.Hash) error
- func (txToken TxToken) ValidateSanityData(chainRetriever metadata.ChainRetriever, ...) (bool, error)
- func (txToken *TxToken) ValidateSanityDataByItSelf() (bool, error)
- func (txToken *TxToken) ValidateSanityDataWithBlockchain(chainRetriever metadata.ChainRetriever, ...) (bool, error)
- func (txToken *TxToken) ValidateSanityDataWithMetadata() (bool, error)
- func (txToken TxToken) ValidateTransaction(boolParams map[string]bool, transactionStateDB *statedb.StateDB, ...) (bool, []privacy.Proof, error)
- func (txToken TxToken) ValidateTxByItself(boolParams map[string]bool, transactionStateDB *statedb.StateDB, ...) (bool, error)
- func (txToken *TxToken) ValidateTxCorrectness(transactionStateDB *statedb.StateDB) (bool, error)
- func (txToken *TxToken) ValidateTxSalary(db *statedb.StateDB) (bool, error)
- func (txToken *TxToken) ValidateTxWithBlockChain(chainRetriever metadata.ChainRetriever, ...) error
- func (txToken *TxToken) ValidateTxWithCurrentMempool(mr metadata.MempoolRetriever) error
- func (txToken TxToken) ValidateType() bool
- func (txToken *TxToken) Verify(boolParams map[string]bool, transactionStateDB *statedb.StateDB, ...) (bool, error)
- func (txToken *TxToken) VerifyMinerCreatedTxBeforeGettingInBlock(mintData *metadata.MintData, shardID byte, bcr metadata.ChainRetriever, ...) (bool, error)
- type TxTokenConvertVer1ToVer2InitParams
- type TxTokenDataVersion2
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitConversion ¶
func InitConversion(tx *Tx, params *TxConvertVer1ToVer2InitParams) error
func InitTokenConversion ¶
func InitTokenConversion(txToken *TxToken, params *TxTokenConvertVer1ToVer2InitParams) error
Types ¶
type CustomTokenConversionParams ¶
type CustomTokenConversionParams struct {
// contains filtered or unexported fields
}
type SigPubKey ¶
SigPubKey defines the public key to sign ring signatures in version 2. It is an array of coin indexes.
type Tx ¶
type Tx struct {
tx_generic.TxBase
}
Tx struct for version 2 contains the same fields as before
func (*Tx) CheckData ¶
Retrieve ring from database using sigpubkey and last column commitment (last column = sumOutputCoinCommitment + fee)
func (*Tx) GetReceiverData ¶
GetReceiverData returns output coins for this function
func (Tx) GetTxActualSize ¶
GetTxActualSize returns the size of this TX. It is the length of its JSON form.
func (Tx) GetTxFullBurnData ¶
func (Tx) Hash ¶
nolint:revive // skip linter since this function modifies a value receiver Hash returns the hash of this transaction. All non-signature fields are marshalled into JSON before hashing
func (Tx) HashWithoutMetadataSig ¶
HashWithoutMetadataSig returns the hash of this transaction, but it leaves out the metadata's own signature field. It is used to verify that metadata signature.
func (*Tx) InitTxSalary ¶
func (tx *Tx) InitTxSalary(otaCoin *privacy.CoinV2, privateKey *privacy.PrivateKey, stateDB *statedb.StateDB, metaData metadata.Metadata) error
InitTxSalary is used to create a "mint" transaction of version 2. The minting rule is covered inside the metadata.
func (Tx) IsSalaryTx ¶
func (Tx) ListOTAHashH ¶
func (*Tx) LoadData ¶
Retrieve ring from database using sigpubkey and last column commitment (last column = sumOutputCoinCommitment + fee)
func (Tx) ValidateSanityData ¶
func (tx Tx) ValidateSanityData(chainRetriever metadata.ChainRetriever, shardViewRetriever metadata.ShardViewRetriever, beaconViewRetriever metadata.BeaconViewRetriever, beaconHeight uint64) (bool, error)
func (*Tx) ValidateSanityDataByItSelf ¶
func (*Tx) ValidateSanityDataWithBlockchain ¶
func (tx *Tx) ValidateSanityDataWithBlockchain( chainRetriever metadata.ChainRetriever, shardViewRetriever metadata.ShardViewRetriever, beaconViewRetriever metadata.BeaconViewRetriever, beaconHeight uint64, ) ( bool, error, )
func (Tx) ValidateTransaction ¶
func (Tx) ValidateTxByItself ¶
func (*Tx) ValidateTxCorrectness ¶
func (*Tx) ValidateTxSalary ¶
ValidateTxSalary checks the following conditions for salary transactions (s, rs):
- the signature is valid
- the number of output coins is 1
- all fields of the output coins are valid
- the commitment has been calculated correctly
- the ota has not existed
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) Verify ¶
func (tx *Tx) Verify(boolParams map[string]bool, transactionStateDB *statedb.StateDB, bridgeStateDB *statedb.StateDB, shardID byte, tokenID *common.Hash) (bool, error)
Verify is the sub-function for ValidateTransaction. It is called in the verification flow of most transactions, excluding some special TX types. It takes in boolParams to reflect some big differences across code versions; and db pointer, shard ID & token ID to get coins from the chain database.
func (Tx) VerifyMinerCreatedTxBeforeGettingInBlock ¶
func (tx Tx) VerifyMinerCreatedTxBeforeGettingInBlock(mintdata *metadata.MintData, shardID byte, bcr metadata.ChainRetriever, accumulatedValues *metadata.AccumulatedValues, retriever metadata.ShardViewRetriever, viewRetriever metadata.BeaconViewRetriever) (bool, error)
VerifyMinerCreatedTxBeforeGettingInBlock checks that a transaction was created by a miner
type TxConvertVer1ToVer2InitParams ¶
type TxConvertVer1ToVer2InitParams struct {
// contains filtered or unexported fields
}
func NewTxConvertVer1ToVer2InitParams ¶
func NewTxConvertVer1ToVer2InitParams(senderSK *privacy.PrivateKey, paymentInfo []*privacy.PaymentInfo, inputCoins []privacy.PlainCoin, fee uint64, stateDB *statedb.StateDB, tokenID *common.Hash, metaData metadata.Metadata, info []byte) *TxConvertVer1ToVer2InitParams
type TxToken ¶
type TxToken struct { Tx Tx `json:"Tx"` TokenData TxTokenDataVersion2 `json:"TxTokenPrivacyData"` // contains filtered or unexported fields }
TxToken is the struct for pToken transaction. Its attributes:
- Tx describes a PRV transfer (typically the fee payment) - TokenData describes a pToken transfer / creation
func (*TxToken) CalculateTxValue ¶
func (TxToken) CheckTxVersion ¶
func (TxToken) GetCachedActualSize ¶
not supported
func (TxToken) GetInfo ¶
GetInfo returns the transaction's extra information. A pToken transaction only has one Info.
func (TxToken) GetLockTime ¶
GetLockTime returns the transaction's time. A pToken transaction only has one LockTime.
func (TxToken) GetMetadata ¶
GetMetadataType returns the transaction's metadata. A pToken transaction only has one metadata.
func (TxToken) GetMetadataType ¶
GetMetadataType returns the metadata type. A pToken transaction only has one metadata.
func (TxToken) GetPrivateKey ¶
GetPrivateKey returns the private key being used to sign this TxToken. The private key is always cleared after signing.
func (TxToken) GetReceivers ¶
func (TxToken) GetSenderAddrLastByte ¶
GetSenderAddrLastByte returns the SHARD ID of this transaction sender. It uses this legacy function name for compatibility purposes.
func (TxToken) GetTokenID ¶
GetTokenID returns the token ID for this TxToken.
func (*TxToken) GetTransferData ¶
func (TxToken) GetTxActualSize ¶
GetTxActualSize returns the size of this TxToken. It is the length of its JSON form.
func (*TxToken) GetTxBase ¶
func (txToken *TxToken) GetTxBase() metadata.Transaction
GetTxBase returns the Tx field in this TxToken as a generic Transaction.
func (*TxToken) GetTxBurnData ¶
func (TxToken) GetTxFee ¶
GetTxFee returns the fee of this TxToken (fee is in PRV). A pToken transaction only has one Fee.
func (TxToken) GetTxFeeToken ¶
GetTxFeeToken is a filler function to satisfy the interface. It returns zero since paying fee in pToken is no longer supported.
func (*TxToken) GetTxFullBurnData ¶
func (*TxToken) GetTxMintData ¶
func (*TxToken) GetTxNormal ¶
func (txToken *TxToken) GetTxNormal() metadata.Transaction
GetTxNormal returns a Transaction describing the "token" part of this TxToken.
func (*TxToken) GetTxTokenData ¶
func (txToken *TxToken) GetTxTokenData() tx_generic.TxTokenData
func (TxToken) GetType ¶
GetType returns the transaction type. A pToken transaction only has one Type (TokenData's Type is a separate enum).
func (*TxToken) GetValidationEnv ¶
func (txToken *TxToken) GetValidationEnv() metadata.ValidationEnviroment
func (*TxToken) Hash ¶
Hash returns the hash of this object. For TxToken, we just concatenate the hash of its fields, then hash that again.
func (TxToken) HashWithoutMetadataSig ¶
func (*TxToken) Init ¶
Init uses the information in the parameter to create a valid, signed pToken transaction.
func (*TxToken) InitTxTokenSalary ¶
func (txToken *TxToken) InitTxTokenSalary(otaCoin *privacy.CoinV2, privKey *privacy.PrivateKey, stateDB *statedb.StateDB, metaData metadata.Metadata, coinID *common.Hash, coinName string) error
InitTxTokenSalary creates a transaction that "mints" some pToken. The minting rule is covered by the metadata.
func (*TxToken) IsCoinsBurning ¶
func (txToken *TxToken) IsCoinsBurning(bcr metadata.ChainRetriever, retriever metadata.ShardViewRetriever, viewRetriever metadata.BeaconViewRetriever, beaconHeight uint64) bool
func (TxToken) IsSalaryTx ¶
IsSalaryTx checks if the transaction is a token salary transaction. A token salary transaction is a transaction produced by shard committees with the following conditions:
- mintable is true, tokenType is CustomTokenInit - PRV proof is nil - no input token - only output token
func (TxToken) ListOTAHashH ¶
func (TxToken) ListSerialNumbersHashH ¶
func (*TxToken) SetCachedActualSize ¶
func (*TxToken) SetGetSenderAddrLastByte ¶
func (*TxToken) SetLockTime ¶
func (*TxToken) SetMetadata ¶
func (*TxToken) SetPrivateKey ¶
func (*TxToken) SetTxBase ¶
func (txToken *TxToken) SetTxBase(inTx metadata.Transaction) error
SetTxBase tries to set the Tx field to inTx. It can fail when inTx has the wrong version.
func (*TxToken) SetTxNormal ¶
func (txToken *TxToken) SetTxNormal(inTx metadata.Transaction) error
SetTxNormal extracts the data in inTx & puts it in the TokenData of this TxToken
func (*TxToken) SetTxTokenData ¶
func (txToken *TxToken) SetTxTokenData(data tx_generic.TxTokenData) error
func (*TxToken) SetValidationEnv ¶
func (txToken *TxToken) SetValidationEnv(valEnv metadata.ValidationEnviroment)
func (*TxToken) SetVersion ¶
func (*TxToken) UnmarshalJSON ¶
func (*TxToken) ValidateDoubleSpendWithBlockchain ¶
func (TxToken) ValidateSanityData ¶
func (txToken TxToken) ValidateSanityData(chainRetriever metadata.ChainRetriever, shardViewRetriever metadata.ShardViewRetriever, beaconViewRetriever metadata.BeaconViewRetriever, beaconHeight uint64) (bool, error)
ValidateSanityData performs sanity checks for this TxToken (including its descendant fields & metadata)
func (*TxToken) ValidateSanityDataByItSelf ¶
func (*TxToken) ValidateSanityDataWithBlockchain ¶
func (txToken *TxToken) ValidateSanityDataWithBlockchain( chainRetriever metadata.ChainRetriever, shardViewRetriever metadata.ShardViewRetriever, beaconViewRetriever metadata.BeaconViewRetriever, beaconHeight uint64, ) ( bool, error, )
func (*TxToken) ValidateSanityDataWithMetadata ¶
func (TxToken) ValidateTransaction ¶
func (txToken TxToken) ValidateTransaction(boolParams map[string]bool, transactionStateDB *statedb.StateDB, bridgeStateDB *statedb.StateDB, shardID byte, tokenID *common.Hash) (bool, []privacy.Proof, error)
ValidateTransaction does the same verification as ValidateTxByItself, but it works with Bulletproof batching.
func (TxToken) ValidateTxByItself ¶
func (txToken TxToken) ValidateTxByItself(boolParams map[string]bool, transactionStateDB *statedb.StateDB, bridgeStateDB *statedb.StateDB, chainRetriever metadata.ChainRetriever, shardID byte, shardViewRetriever metadata.ShardViewRetriever, beaconViewRetriever metadata.BeaconViewRetriever) (bool, error)
ValidateTxByItself does most of the verification for TxToken, including bulletproofs, signatures & metadata. This depends on the chain state defined by shard ID & db pointer, as well as boolParams (which handles code version differences)
func (*TxToken) ValidateTxCorrectness ¶
func (*TxToken) ValidateTxSalary ¶
ValidateTxSalary checks the following conditions for minteable transactions:
- the signature is valid
- all fields of the output coins are valid: commitment, assetTag, etc,.
- the commitment has been calculated correctly
- the ota has not existed
func (*TxToken) ValidateTxWithBlockChain ¶
func (txToken *TxToken) ValidateTxWithBlockChain(chainRetriever metadata.ChainRetriever, shardViewRetriever metadata.ShardViewRetriever, beaconViewRetriever metadata.BeaconViewRetriever, shardID byte, stateDB *statedb.StateDB) error
func (*TxToken) ValidateTxWithCurrentMempool ¶
func (txToken *TxToken) ValidateTxWithCurrentMempool(mr metadata.MempoolRetriever) error
func (TxToken) ValidateType ¶
func (*TxToken) Verify ¶
func (txToken *TxToken) Verify(boolParams map[string]bool, transactionStateDB *statedb.StateDB, bridgeStateDB *statedb.StateDB, shardID byte, tokenID *common.Hash) (bool, error)
Verify is the sub-function for ValidateTransaction. This is in the verification flow of most TXs (excluding some special types).
func (*TxToken) VerifyMinerCreatedTxBeforeGettingInBlock ¶
func (txToken *TxToken) VerifyMinerCreatedTxBeforeGettingInBlock(mintData *metadata.MintData, shardID byte, bcr metadata.ChainRetriever, accumulatedValues *metadata.AccumulatedValues, retriever metadata.ShardViewRetriever, viewRetriever metadata.BeaconViewRetriever) (bool, error)
type TxTokenConvertVer1ToVer2InitParams ¶
type TxTokenConvertVer1ToVer2InitParams struct {
// contains filtered or unexported fields
}
func NewTxTokenConvertVer1ToVer2InitParams ¶
func NewTxTokenConvertVer1ToVer2InitParams(senderSK *privacy.PrivateKey, feeInputs []privacy.PlainCoin, feePayments []*privacy.PaymentInfo, tokenInputs []privacy.PlainCoin, tokenPayments []*privacy.PaymentInfo, fee uint64, stateDB *statedb.StateDB, bridgeStateDB *statedb.StateDB, tokenID *common.Hash, metaData metadata.Metadata, info []byte) *TxTokenConvertVer1ToVer2InitParams
type TxTokenDataVersion2 ¶
type TxTokenDataVersion2 struct { PropertyID common.Hash PropertyName string PropertySymbol string SigPubKey []byte `json:"SigPubKey,omitempty"` // 33 bytes Sig []byte `json:"Sig,omitempty"` // Proof privacy.Proof Type int Mintable bool }
TxTokenDataVersion2 contains the token data for a pToken transaction (input / output coins, signature, token ID, type of transfer, ...). Unlike the previous version, this does not have a *Tx field in it; this avoids duplication of data.
func (TxTokenDataVersion2) Hash ¶
func (td TxTokenDataVersion2) Hash() (*common.Hash, error)
Hash returns the hash of this object. All non-signature fields are marshalled to JSON beforehand.
func (TxTokenDataVersion2) ToCompatTokenData ¶
func (td TxTokenDataVersion2) ToCompatTokenData(ttx metadata.Transaction) tx_generic.TxTokenData
ToCompatTokenData uses the data from TxToken to construct a TxTokenData of the previous version (for compatibility).