tx_ver2

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: 20 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitConversion

func InitConversion(tx *Tx, params *TxConvertVer1ToVer2InitParams) error

InitConversion creates a conversion transaction that converts PRV UTXOs v1 to v2. A conversion transaction is a special PRV transaction of version 2. It is non-private, meaning that all details of the transaction are publicly visible.

  • InputCoins: PlainCoin V1
  • OutputCoins: CoinV2
  • Signature: Schnorr signature with no privacy.

func InitTokenConversion

func InitTokenConversion(txToken *TxToken, params *TxTokenConvertVer1ToVer2InitParams) error

InitTokenConversion creates a token conversion transaction that converts token UTXOs v1 to v2. A token conversion transaction is a special token transaction of version 2. It pays the transaction fee in PRV and it is required that the account has enough PRV v2 to pay the fee. This transaction is non-private, meaning that all details of the transaction are publicly visible.

  • TxBase: A PRV transaction V2
  • TxNormal:
  • InputCoins: PlainCoin V1
  • OutputCoins: CoinV2
  • Signature: Schnorr signature with no privacy.

Types

type CustomTokenConversionParams

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

CustomTokenConversionParams describes the parameters needed to create a token conversion transaction.

type SigPubKey

type SigPubKey struct {
	Indexes [][]*big.Int
}

SigPubKey represents the sigPubKey of a Tx. Unlike a transaction v1, a SigPubKey of a transaction v2 is the list of indices of input coins and the decoys used in the transaction.

func (SigPubKey) Bytes

func (sigPub SigPubKey) Bytes() ([]byte, error)

Bytes returns the byte-representation of a SigPubKey.

func (*SigPubKey) SetBytes

func (sigPub *SigPubKey) SetBytes(b []byte) error

SetBytes recovers a SigPubKey from its byte data.

type Tx

type Tx struct {
	tx_generic.TxBase
}

Tx implements a PRV transaction v2. It is a embedded TxBase with some overridden functions. A transaction v2 is mainly composed of

  • OTA: different output coins have different public key, even if they belong to the same user.
  • MLSAG: a ring signature scheme used to anonymize the true sender.
  • BulletProofs: a range proof used to prove that a value lies within an interval without revealing it.

By default, a transaction v2 is private, meaning that most of the stuff is hidden to public observers.

func (*Tx) GetReceiverData

func (tx *Tx) GetReceiverData() ([]coin.Coin, error)

GetReceiverData returns a list of output coins of a Tx. Unlike the case of a transaction v1, we do not know which coins are the sent-back coins, therefore, we return all of them.

func (Tx) GetTxActualSize

func (tx Tx) GetTxActualSize() uint64

GetTxActualSize returns the size of a Tx in kb.

func (Tx) GetTxBurnData

func (tx Tx) GetTxBurnData() (bool, coin.Coin, *common.Hash, error)

GetTxBurnData returns the burning data (token only) of a Tx.

func (Tx) GetTxFullBurnData

func (tx Tx) GetTxFullBurnData() (bool, coin.Coin, coin.Coin, *common.Hash, error)

GetTxFullBurnData is the same as GetTxBurnData.

func (Tx) GetTxMintData

func (tx Tx) GetTxMintData() (bool, coin.Coin, *common.Hash, error)

GetTxMintData returns the minting data of a Tx.

func (Tx) Hash

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

Hash calculates the hash of a Tx.

func (Tx) HashWithoutMetadataSig

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

HashWithoutMetadataSig calculates the hash of a Tx with out adding the signature of its metadata.

func (*Tx) Init

func (tx *Tx) Init(txParams interface{}) error

Init creates a PRV transaction version 2 from the given parameter. The input parameter should be a *tx_generic.TxPrivacyInitParams.

func (*Tx) InitTxSalary

func (tx *Tx) InitTxSalary(otaCoin *coin.CoinV2, privateKey *key.PrivateKey, metaData metadata.Metadata) error

InitTxSalary creates a PRV salary transaction to an OTA address.

func (Tx) ListOTAHashH

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

ListOTAHashH returns the hash list of all OTA keys in a Tx.

type TxConvertVer1ToVer2InitParams

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

TxConvertVer1ToVer2InitParams consists of parameters used to create a new PRV conversion transaction.

func NewTxConvertVer1ToVer2InitParams

func NewTxConvertVer1ToVer2InitParams(senderSK *key.PrivateKey,
	paymentInfo []*key.PaymentInfo,
	inputCoins []coin.PlainCoin,
	fee uint64,
	tokenID *common.Hash,
	metaData metadata.Metadata,
	info []byte,
	kvArgs map[string]interface{}) *TxConvertVer1ToVer2InitParams

NewTxConvertVer1ToVer2InitParams creates a new TxConvertVer1ToVer2InitParams from the given parameters.

type TxToken

type TxToken struct {
	Tx        Tx                  `json:"Tx"`
	TokenData TxTokenDataVersion2 `json:"TxTokenPrivacyData"`
	// contains filtered or unexported fields
}

TxToken represents a token transaction of version 2. A token transaction v2 consists of 2 sub-transactions

  • TxBase: PRV sub-transaction for paying the transaction fee. All transactions v2 pay fees in PRV.
  • TxNormal: the token sub-transaction to transfer token.

func (*TxToken) CalculateTxValue

func (txToken *TxToken) CalculateTxValue() uint64

CalculateTxValue calculates total output values.

func (TxToken) CheckTxVersion

func (txToken TxToken) CheckTxVersion(maxTxVersion int8) bool

CheckTxVersion checks if the version of a TxToken is valid.

func (TxToken) GetInfo

func (txToken TxToken) GetInfo() []byte

GetInfo returns the info of a TxToken.

func (TxToken) GetLockTime

func (txToken TxToken) GetLockTime() int64

GetLockTime returns the lock-time of a TxToken.

func (TxToken) GetMetadata

func (txToken TxToken) GetMetadata() metadata.Metadata

GetMetadata returns the metadata of a TxToken.

func (TxToken) GetMetadataType

func (txToken TxToken) GetMetadataType() int

GetMetadataType returns the metadata type of a TxToken.

func (TxToken) GetPrivateKey

func (txToken TxToken) GetPrivateKey() []byte

GetPrivateKey returns the sender's private key.

func (TxToken) GetProof

func (txToken TxToken) GetProof() privacy.Proof

GetProof not supported.

func (*TxToken) GetReceiverData

func (txToken *TxToken) GetReceiverData() ([]coin.Coin, error)

GetReceiverData returns the output coins of a TxToken.

func (TxToken) GetReceivers

func (txToken TxToken) GetReceivers() ([][]byte, []uint64)

GetReceivers not supported.

func (TxToken) GetSenderAddrLastByte

func (txToken TxToken) GetSenderAddrLastByte() byte

GetSenderAddrLastByte returns the last byte of the sender of a TxToken.

func (TxToken) GetSig

func (txToken TxToken) GetSig() []byte

GetSig not supported.

func (TxToken) GetSigPubKey

func (txToken TxToken) GetSigPubKey() []byte

GetSigPubKey not supported.

func (TxToken) GetTokenID

func (txToken TxToken) GetTokenID() *common.Hash

GetTokenID returns the tokenID of a TxToken.

func (*TxToken) GetTransferData

func (txToken *TxToken) GetTransferData() (bool, []byte, uint64, *common.Hash)

GetTransferData returns the transferred data of a TxToken.

func (TxToken) GetTxActualSize

func (txToken TxToken) GetTxActualSize() uint64

GetTxActualSize returns the size of a TxToken in kb.

func (*TxToken) GetTxBase

func (txToken *TxToken) GetTxBase() metadata.Transaction

GetTxBase returns the PRV sub-transaction of a TxToken.

func (*TxToken) GetTxBurnData

func (txToken *TxToken) GetTxBurnData() (bool, coin.Coin, *common.Hash, error)

GetTxBurnData returns the burning (token only) of a TxToken.

func (TxToken) GetTxFee

func (txToken TxToken) GetTxFee() uint64

GetTxFee returns the PRV fee of a TxToken.

func (TxToken) GetTxFeeToken

func (txToken TxToken) GetTxFeeToken() uint64

GetTxFeeToken returns the token fee of a TxToken. All transactions v2 pay fees in PRV, so it returns 0.

func (*TxToken) GetTxFullBurnData

func (txToken *TxToken) GetTxFullBurnData() (bool, coin.Coin, coin.Coin, *common.Hash, error)

GetTxFullBurnData returns the full burning data (both PRV and token) of a TxToken.

func (*TxToken) GetTxMintData

func (txToken *TxToken) GetTxMintData() (bool, coin.Coin, *common.Hash, error)

GetTxMintData returns the minting data of a TxToken.

func (*TxToken) GetTxNormal

func (txToken *TxToken) GetTxNormal() metadata.Transaction

GetTxNormal returns the token sub-transaction of a TxToken.

func (*TxToken) GetTxTokenData

func (txToken *TxToken) GetTxTokenData() tx_generic.TxTokenData

GetTxTokenData returns the token data of a TxToken.

func (TxToken) GetType

func (txToken TxToken) GetType() string

GetType returns the transaction type of a TxToken.

func (TxToken) GetVersion

func (txToken TxToken) GetVersion() int8

GetVersion returns the version of a TxToken.

func (*TxToken) Hash

func (txToken *TxToken) Hash() *common.Hash

Hash calculates the hash of a TxToken.

func (TxToken) HashWithoutMetadataSig

func (txToken TxToken) HashWithoutMetadataSig() *common.Hash

HashWithoutMetadataSig calculates the hash of a TxToken with out adding the signature of its metadata.

func (*TxToken) Init

func (txToken *TxToken) Init(txTokenParams interface{}) error

Init creates a token transaction version 2 from the given parameter. The input parameter should be a *tx_generic.TxTokenParams.

func (TxToken) IsPrivacy

func (txToken TxToken) IsPrivacy() bool

IsPrivacy checks if a TxToken is a private transaction.

func (TxToken) IsSalaryTx

func (txToken TxToken) IsSalaryTx() bool

IsSalaryTx checks if a TxToken is a salary transaction.

func (TxToken) ListOTAHashH

func (txToken TxToken) ListOTAHashH() []common.Hash

ListOTAHashH returns the hash list of all OTA keys in a TxToken.

func (TxToken) ListSerialNumbersHashH

func (txToken TxToken) ListSerialNumbersHashH() []common.Hash

ListSerialNumbersHashH returns the hash list of all serial numbers in a TxToken.

func (*TxToken) SetGetSenderAddrLastByte

func (txToken *TxToken) SetGetSenderAddrLastByte(v byte)

SetGetSenderAddrLastByte sets v as the sender's last byte of a TxToken.

func (*TxToken) SetInfo

func (txToken *TxToken) SetInfo(v []byte)

SetInfo sets v as the info of a TxToken.

func (*TxToken) SetLockTime

func (txToken *TxToken) SetLockTime(v int64)

SetLockTime sets v as the lock-time of a TxToken.

func (*TxToken) SetMetadata

func (txToken *TxToken) SetMetadata(v metadata.Metadata)

SetMetadata sets v the metadata of a TxToken.

func (*TxToken) SetPrivateKey

func (txToken *TxToken) SetPrivateKey(v []byte)

SetPrivateKey sets v as the private key of a TxToken.

func (*TxToken) SetProof

func (txToken *TxToken) SetProof(privacy.Proof)

SetProof not supported.

func (*TxToken) SetSig

func (txToken *TxToken) SetSig([]byte)

SetSig not supported.

func (*TxToken) SetSigPubKey

func (txToken *TxToken) SetSigPubKey([]byte)

SetSigPubKey not supported.

func (*TxToken) SetTxBase

func (txToken *TxToken) SetTxBase(v metadata.Transaction) error

SetTxBase sets v as the TxBase of a TxToken.

func (*TxToken) SetTxFee

func (txToken *TxToken) SetTxFee(v uint64)

SetTxFee sets v as the PRV fee of a TxToken.

func (*TxToken) SetTxNormal

func (txToken *TxToken) SetTxNormal(v metadata.Transaction) error

SetTxNormal sets v as the TxNormal of a TxToken.

func (*TxToken) SetTxTokenData

func (txToken *TxToken) SetTxTokenData(v tx_generic.TxTokenData) error

SetTxTokenData sets v as the token data of a TxToken.

func (*TxToken) SetType

func (txToken *TxToken) SetType(v string)

SetType sets v as the transaction type of a TxToken.

func (*TxToken) SetVersion

func (txToken *TxToken) SetVersion(v int8)

SetVersion sets v as the version of a TxToken.

func (TxToken) String

func (txToken TxToken) String() string

String returns the string-representation of a TxToken.

func (*TxToken) UnmarshalJSON

func (txToken *TxToken) UnmarshalJSON(data []byte) error

UnmarshalJSON does the JSON-unmarshalling operation for a TxToken.

type TxTokenConvertVer1ToVer2InitParams

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

TxTokenConvertVer1ToVer2InitParams consists of parameters used to create a new token conversion transaction.

func NewTxTokenConvertVer1ToVer2InitParams

func NewTxTokenConvertVer1ToVer2InitParams(senderSK *key.PrivateKey,
	feeInputs []coin.PlainCoin,
	feePayments []*key.PaymentInfo,
	tokenInputs []coin.PlainCoin,
	tokenPayments []*key.PaymentInfo,
	fee uint64,
	tokenID *common.Hash,
	metaData metadata.Metadata,
	info []byte,
	kvArgs map[string]interface{}) *TxTokenConvertVer1ToVer2InitParams

NewTxTokenConvertVer1ToVer2InitParams creates a new TxTokenConvertVer1ToVer2InitParams from the given parameters.

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 represents all data of a token transaction v2.

func (TxTokenDataVersion2) Hash

func (td TxTokenDataVersion2) Hash() (*common.Hash, error)

Hash calculates the hash of a TxTokenDataVersion2.

func (TxTokenDataVersion2) ToCompatTokenData

ToCompatTokenData creates a TxTokenData from a TxTokenDataVersion2 and the given transaction.

Jump to

Keyboard shortcuts

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