transaction

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2020 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CustomTokenInit = iota
	CustomTokenTransfer
	CustomTokenCrossShard
)
View Source
const (
	NormalCoinType = iota
	CustomTokenPrivacyType
)
View Source
const MaxSizeInfo = 512
View Source
const (
	ValidateTimeForOneoutOfManyProof = 1574985600 // GMT: Friday, November 29, 2019 12:00:00 AM
)

Variables

This section is empty.

Functions

func ConvertOutputCoinToInputCoin

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

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

func CreateCustomTokenPrivacyReceiverArray

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

func EstimateTxSize

func EstimateTxSize(estimateTxSizeParam *EstimateTxSizeParam) uint64

EstimateTxSize returns the estimated size of the tx in kilobyte

Types

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"`
	TokenOutput    []*privacy.OutputCoin  `json:"TokenOutput"`
	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 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) GetSenderAddrLastByte

func (tx Tx) GetSenderAddrLastByte() byte

func (*Tx) Hash

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

func (*Tx) Init

func (tx *Tx) Init(params *TxPrivacyInitParams, client *rpcclient.HttpClient, keyWallet *wallet.KeyWallet) error

func (Tx) String

func (tx Tx) String() string

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) 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, client *rpcclient.HttpClient, keyWallet *wallet.KeyWallet) error

Init - build normal tx component and privacy custom token data

func (TxCustomTokenPrivacy) JSONString

func (txCustomTokenPrivacy TxCustomTokenPrivacy) JSONString() (string, error)

func (TxCustomTokenPrivacy) String

func (txCustomTokenPrivacy TxCustomTokenPrivacy) String() string

func (*TxCustomTokenPrivacy) UnmarshalJSON

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

type TxPrivacyInitParams

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

func NewTxPrivacyInitParams

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

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,
	outputCoin []*privacy.OutputCoin,
	feeNativeCoin uint64,
	tokenParams *CustomTokenPrivacyParamTx,
	metaData metadata.Metadata,
	hasPrivacyCoin bool,
	hasPrivacyToken bool,
	shardID byte,
	info []byte) *TxPrivacyTokenInitParams

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳