types

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DenomThetaWei is the basic unit of theta, 1 Theta = 10^18 ThetaWei
	DenomThetaWei string = "ThetaWei"

	// DenomTFuelWei is the basic unit of theta, 1 Theta = 10^18 ThetaWei
	DenomTFuelWei string = "TFuelWei"

	// MinimumGasPrice is the minimum gas price for a smart contract transaction
	MinimumGasPrice uint64 = 1e8

	// MinimumTransactionFeeTFuelWei specifies the minimum fee for a regular transaction
	MinimumTransactionFeeTFuelWei uint64 = 1e12

	// MaxAccountsAffectedPerTx specifies the max number of accounts one transaction is allowed to modify to avoid spamming
	MaxAccountsAffectedPerTx = 512
)
View Source
const (
	// ValidatorThetaGenerationRateNumerator is used for calculating the generation rate of Theta for validators
	//ValidatorThetaGenerationRateNumerator int64 = 317
	ValidatorThetaGenerationRateNumerator int64 = 0 // ZERO inflation for Theta

	// ValidatorThetaGenerationRateDenominator is used for calculating the generation rate of Theta for validators
	// ValidatorThetaGenerationRateNumerator / ValidatorThetaGenerationRateDenominator is the amount of ThetaWei
	// generated per existing ThetaWei per new block
	ValidatorThetaGenerationRateDenominator int64 = 1e11

	// ValidatorTFuelGenerationRateNumerator is used for calculating the generation rate of TFuel for validators
	ValidatorTFuelGenerationRateNumerator int64 = 0 // ZERO initial inflation for TFuel

	// ValidatorTFuelGenerationRateDenominator is used for calculating the generation rate of TFuel for validators
	// ValidatorTFuelGenerationRateNumerator / ValidatorTFuelGenerationRateDenominator is the amount of TFuelWei
	// generated per existing ThetaWei per new block
	ValidatorTFuelGenerationRateDenominator int64 = 1e9

	// RegularTFuelGenerationRateNumerator is used for calculating the generation rate of TFuel for other types of accounts
	//RegularTFuelGenerationRateNumerator int64 = 1900
	RegularTFuelGenerationRateNumerator int64 = 0 // ZERO initial inflation for TFuel

	// RegularTFuelGenerationRateDenominator is used for calculating the generation rate of TFuel for other types of accounts
	// RegularTFuelGenerationRateNumerator / RegularTFuelGenerationRateDenominator is the amount of TFuelWei
	// generated per existing ThetaWei per new block
	RegularTFuelGenerationRateDenominator int64 = 1e10
)
View Source
const (

	// ServiceRewardVerificationBlockDelay gives the block delay for service certificate verification
	ServiceRewardVerificationBlockDelay uint64 = 2

	// ServiceRewardFulfillmentBlockDelay gives the block delay for service reward fulfillment
	ServiceRewardFulfillmentBlockDelay uint64 = 4
)
View Source
const (

	// MaximumTargetAddressesForStakeBinding gives the maximum number of target addresses that can be associated with a bound stake
	MaximumTargetAddressesForStakeBinding uint = 1024

	// MaximumFundReserveDuration indicates the maximum duration (in terms of number of blocks) of reserving fund
	MaximumFundReserveDuration uint64 = 12 * 3600

	// MinimumFundReserveDuration indicates the minimum duration (in terms of number of blocks) of reserving fund
	MinimumFundReserveDuration uint64 = 300

	// ReservedFundFreezePeriodDuration indicates the freeze duration (in terms of number of blocks) of the reserved fund
	ReservedFundFreezePeriodDuration uint64 = 5
)
View Source
const (
	GasSendTxPerAccount   uint64 = 5000
	GasReserveFundTx      uint64 = 10000
	GasReleaseFundTx      uint64 = 10000
	GasServicePaymentTx   uint64 = 10000
	GasSplitRuleTx        uint64 = 10000
	GasUpdateValidatorsTx uint64 = 10000
	GasDepositStakeTx     uint64 = 10000
	GasWidthdrawStakeTx   uint64 = 10000
)

Gas of regular transactions

Variables

View Source
var (
	Zero    *big.Int
	Hundred *big.Int
)

Functions

func FromBytes

func FromBytes(in []byte, a interface{}) error

func Fuzz added in v1.0.2

func Fuzz(data []byte) int

func ParseCoinAmount

func ParseCoinAmount(in string) (*big.Int, bool)

ParseCoinAmount parses a string representation of coin amount.

func SignSendTx

func SignSendTx(chainID string, tx *SendTx, accs ...PrivAccount)

func ToBytes

func ToBytes(a interface{}) ([]byte, error)

func TxID

func TxID(chainID string, tx Tx) common.Hash

func TxToBytes

func TxToBytes(t Tx) ([]byte, error)

Types

type Account

type Account struct {
	Address                common.Address
	Sequence               uint64
	Balance                Coins
	ReservedFunds          []ReservedFund // TODO: replace the slice with map
	LastUpdatedBlockHeight uint64

	// Smart contract
	Root     common.Hash `json:"root"`      // merkle root of the storage trie
	CodeHash common.Hash `json:"code_hash"` // hash of the smart contract code
}

func NewAccount

func NewAccount(address common.Address) *Account

func (*Account) CheckReleaseFund

func (acc *Account) CheckReleaseFund(currentBlockHeight uint64, reserveSequence uint64) error

CheckReleaseFund verifies inputs for ReleaseFund

func (*Account) CheckReserveFund

func (acc *Account) CheckReserveFund(collateral Coins, fund Coins, duration uint64, reserveSequence uint64) error

CheckReserveFund verifies inputs for ReserveFund.

func (*Account) CheckTransferReservedFund

func (acc *Account) CheckTransferReservedFund(tgtAcc *Account, transferAmount Coins, paymentSequence uint64, currentBlockHeight uint64, reserveSequence uint64) error

CheckTransferReservedFund verifies inputs for SplitReservedFund

func (*Account) Copy

func (acc *Account) Copy() *Account

func (Account) MarshalJSON

func (acc Account) MarshalJSON() ([]byte, error)

func (*Account) ReleaseExpiredFunds

func (acc *Account) ReleaseExpiredFunds(currentBlockHeight uint64)

ReleaseExpiredFunds releases all expired funds

func (*Account) ReleaseFund

func (acc *Account) ReleaseFund(currentBlockHeight uint64, reserveSequence uint64)

ReleaseFund releases the fund reserved for service payment

func (*Account) ReserveFund

func (acc *Account) ReserveFund(collateral Coins, fund Coins, resourceIDs []string, endBlockHeight uint64, reserveSequence uint64)

ReserveFund reserves the given amount of fund for subsequence service payments

func (*Account) String

func (acc *Account) String() string

func (*Account) TransferReservedFund

func (acc *Account) TransferReservedFund(splittedCoinsMap map[*Account]Coins, currentBlockHeight uint64,
	reserveSequence uint64, servicePaymentTx *ServicePaymentTx) (shouldSlash bool, slashIntent SlashIntent)

TransferReservedFund transfers the specified amount of reserved fund to the accounts participated in the payment split, and send remainder back to the source account (i.e. the acount itself)

func (*Account) UnmarshalJSON

func (acc *Account) UnmarshalJSON(data []byte) error

func (*Account) UpdateToHeight

func (acc *Account) UpdateToHeight(height uint64)

type AccountJSON

type AccountJSON struct {
	Sequence               common.JSONUint64 `json:"sequence"`
	Balance                Coins             `json:"coins"`
	ReservedFunds          []ReservedFund    `json:"reserved_funds"`
	LastUpdatedBlockHeight common.JSONUint64 `json:"last_updated_block_height"`
	Root                   common.Hash       `json:"root"`
	CodeHash               common.Hash       `json:"code"`
}

func NewAccountJSON

func NewAccountJSON(acc Account) AccountJSON

func (AccountJSON) Account

func (acc AccountJSON) Account() Account

type CoinbaseTx

type CoinbaseTx struct {
	Proposer    TxInput
	Outputs     []TxOutput
	BlockHeight uint64
}

func (*CoinbaseTx) AssertIsTx

func (_ *CoinbaseTx) AssertIsTx()

func (CoinbaseTx) MarshalJSON

func (a CoinbaseTx) MarshalJSON() ([]byte, error)

func (*CoinbaseTx) SetSignature

func (tx *CoinbaseTx) SetSignature(addr common.Address, sig *crypto.Signature) bool

func (*CoinbaseTx) SignBytes

func (tx *CoinbaseTx) SignBytes(chainID string) []byte

func (*CoinbaseTx) String

func (tx *CoinbaseTx) String() string

func (*CoinbaseTx) UnmarshalJSON

func (a *CoinbaseTx) UnmarshalJSON(data []byte) error

type CoinbaseTxJSON

type CoinbaseTxJSON struct {
	Proposer    TxInput           `json:"proposer"`
	Outputs     []TxOutput        `json:"outputs"`
	BlockHeight common.JSONUint64 `json:"block_height"`
}

func NewCoinbaseTxJSON

func NewCoinbaseTxJSON(a CoinbaseTx) CoinbaseTxJSON

func (CoinbaseTxJSON) CoinbaseTx

func (a CoinbaseTxJSON) CoinbaseTx() CoinbaseTx

type Coins

type Coins struct {
	ThetaWei *big.Int
	TFuelWei *big.Int
}

func NewCoins

func NewCoins(theta int64, tfuel int64) Coins

NewCoins is a convenient method for creating small amount of coins.

func (Coins) CalculatePercentage

func (coins Coins) CalculatePercentage(percentage uint) Coins

CalculatePercentage function calculates amount of coins for the given the percentage

func (Coins) IsEqual

func (coinsA Coins) IsEqual(coinsB Coins) bool

func (Coins) IsGTE

func (coinsA Coins) IsGTE(coinsB Coins) bool

func (Coins) IsNonnegative

func (coins Coins) IsNonnegative() bool

func (Coins) IsPositive

func (coins Coins) IsPositive() bool

func (Coins) IsValid

func (coins Coins) IsValid() bool

func (Coins) IsZero

func (coins Coins) IsZero() bool

func (Coins) MarshalJSON

func (c Coins) MarshalJSON() ([]byte, error)

func (Coins) Minus

func (coinsA Coins) Minus(coinsB Coins) Coins

func (Coins) Negative

func (coins Coins) Negative() Coins

func (Coins) NoNil

func (coins Coins) NoNil() Coins

func (Coins) Plus

func (coinsA Coins) Plus(coinsB Coins) Coins

Currently appends an empty coin ...

func (Coins) String

func (coins Coins) String() string

func (*Coins) UnmarshalJSON

func (c *Coins) UnmarshalJSON(data []byte) error

type CoinsJSON

type CoinsJSON struct {
	ThetaWei *common.JSONBig `json:"thetawei"`
	TFuelWei *common.JSONBig `json:"tfuelwei"`
}

func NewCoinsJSON

func NewCoinsJSON(coin Coins) CoinsJSON

func (CoinsJSON) Coins

func (c CoinsJSON) Coins() Coins

type DepositStakeTx

type DepositStakeTx struct {
	Fee     Coins    `json:"fee"`     // Fee
	Source  TxInput  `json:"source"`  // source staker account
	Holder  TxOutput `json:"holder"`  // stake holder account
	Purpose uint8    `json:"purpose"` // purpose e.g. stake for validator/guardian
}

func (*DepositStakeTx) AssertIsTx

func (_ *DepositStakeTx) AssertIsTx()

func (*DepositStakeTx) SetSignature

func (tx *DepositStakeTx) SetSignature(addr common.Address, sig *crypto.Signature) bool

func (*DepositStakeTx) SignBytes

func (tx *DepositStakeTx) SignBytes(chainID string) []byte

func (*DepositStakeTx) String

func (tx *DepositStakeTx) String() string

type EthereumTxWrapper added in v1.0.3

type EthereumTxWrapper struct {
	AccountNonce uint64          `json:"nonce"    gencodec:"required"`
	Price        *big.Int        `json:"gasPrice" gencodec:"required"`
	GasLimit     uint64          `json:"gas"      gencodec:"required"`
	Recipient    *common.Address `json:"to"       rlp:"nil"` // nil means contract creation
	Amount       *big.Int        `json:"value"    gencodec:"required"`
	Payload      []byte          `json:"input"    gencodec:"required"`
}

type HeightList

type HeightList struct {
	Heights []uint64
}

func (*HeightList) Append

func (hl *HeightList) Append(height uint64)

func (*HeightList) Contains

func (hl *HeightList) Contains(height uint64) bool

type Log

type Log struct {
	// Consensus fields:
	// address of the contract that generated the event
	Address common.Address `json:"address" gencodec:"required"`
	// list of topics provided by the contract.
	Topics []common.Hash `json:"topics" gencodec:"required"`
	// supplied by the contract, usually ABI-encoded
	Data []byte `json:"data" gencodec:"required"`

	// Derived fields. These fields are filled in by the node
	// but not secured by consensus.
	// block in which the transaction was included
	BlockNumber uint64 `json:"blockNumber"`
	// hash of the transaction
	TxHash common.Hash `json:"transactionHash" gencodec:"required"`
	// index of the transaction in the block
	TxIndex uint `json:"transactionIndex" gencodec:"required"`
	// hash of the block in which the transaction was included
	BlockHash common.Hash `json:"blockHash"`
	// index of the log in the receipt
	Index uint `json:"logIndex" gencodec:"required"`

	// The Removed field is true if this log was reverted due to a chain reorganisation.
	// You must pay attention to this field if you receive logs through a filter query.
	Removed bool `json:"removed"`
}

Log represents a contract log event. These events are generated by the LOG opcode and stored/indexed by the node.

func (*Log) DecodeRLP

func (l *Log) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder.

func (*Log) EncodeRLP

func (l *Log) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder.

type LogForStorage

type LogForStorage Log

LogForStorage is a wrapper around a Log that flattens and parses the entire content of a log including non-consensus fields.

func (*LogForStorage) DecodeRLP

func (l *LogForStorage) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder.

func (*LogForStorage) EncodeRLP

func (l *LogForStorage) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder.

type OverspendingProof

type OverspendingProof struct {
	ReserveSequence uint64
	ServicePayments []ServicePaymentTx
}

OverspendingProof contains the proof that the ReservedFund has been overly spent

func (OverspendingProof) MarshalJSON

func (a OverspendingProof) MarshalJSON() ([]byte, error)

func (*OverspendingProof) UnmarshalJSON

func (a *OverspendingProof) UnmarshalJSON(data []byte) error

type OverspendingProofJSON

type OverspendingProofJSON struct {
	ReserveSequence common.JSONUint64
	ServicePayments []ServicePaymentTx
}

func NewOverspendingProofJSON

func NewOverspendingProofJSON(a OverspendingProof) OverspendingProofJSON

func (OverspendingProofJSON) OverspendingProof

func (a OverspendingProofJSON) OverspendingProof() OverspendingProof

type PrivAccount

type PrivAccount struct {
	PrivKey *crypto.PrivateKey
	Account
}

func MakeAcc

func MakeAcc(secret string) PrivAccount

func MakeAccWithInitBalance

func MakeAccWithInitBalance(secret string, initBalance Coins) PrivAccount

func PrivAccountFromSecret

func PrivAccountFromSecret(secret string) PrivAccount

Creates a PrivAccount from secret. The amount is not set.

func RandAccounts

func RandAccounts(num int, minAmount int64, maxAmount int64) []PrivAccount

Make `num` random accounts

func (*PrivAccount) Sign

func (pa *PrivAccount) Sign(msg []byte) *crypto.Signature

type ReleaseFundTx

type ReleaseFundTx struct {
	Fee             Coins   // Fee
	Source          TxInput // source account
	ReserveSequence uint64
}

func (*ReleaseFundTx) AssertIsTx

func (_ *ReleaseFundTx) AssertIsTx()

func (ReleaseFundTx) MarshalJSON

func (a ReleaseFundTx) MarshalJSON() ([]byte, error)

func (*ReleaseFundTx) SetSignature

func (tx *ReleaseFundTx) SetSignature(addr common.Address, sig *crypto.Signature) bool

func (*ReleaseFundTx) SignBytes

func (tx *ReleaseFundTx) SignBytes(chainID string) []byte

func (*ReleaseFundTx) String

func (tx *ReleaseFundTx) String() string

func (*ReleaseFundTx) UnmarshalJSON

func (a *ReleaseFundTx) UnmarshalJSON(data []byte) error

type ReleaseFundTxJSON

type ReleaseFundTxJSON struct {
	Fee             Coins             `json:"fee"`    // Fee
	Source          TxInput           `json:"source"` // source account
	ReserveSequence common.JSONUint64 `json:"reserve_sequence"`
}

func NewReleaseFundTxJSON

func NewReleaseFundTxJSON(a ReleaseFundTx) ReleaseFundTxJSON

func (ReleaseFundTxJSON) ReleaseFundTx

func (a ReleaseFundTxJSON) ReleaseFundTx() ReleaseFundTx

type ReserveFundTx

type ReserveFundTx struct {
	Fee         Coins    // Fee
	Source      TxInput  // Source account
	Collateral  Coins    // Collateral for the micropayment pool
	ResourceIDs []string // List of resource ID
	Duration    uint64
}

func (*ReserveFundTx) AssertIsTx

func (_ *ReserveFundTx) AssertIsTx()

func (ReserveFundTx) MarshalJSON

func (a ReserveFundTx) MarshalJSON() ([]byte, error)

func (*ReserveFundTx) SetSignature

func (tx *ReserveFundTx) SetSignature(addr common.Address, sig *crypto.Signature) bool

func (*ReserveFundTx) SignBytes

func (tx *ReserveFundTx) SignBytes(chainID string) []byte

func (*ReserveFundTx) String

func (tx *ReserveFundTx) String() string

func (*ReserveFundTx) UnmarshalJSON

func (a *ReserveFundTx) UnmarshalJSON(data []byte) error

type ReserveFundTxJSON

type ReserveFundTxJSON struct {
	Fee         Coins             `json:"fee"`          // Fee
	Source      TxInput           `json:"source"`       // Source account
	Collateral  Coins             `json:"collateral"`   // Collateral for the micropayment pool
	ResourceIDs []string          `json:"resource_ids"` // List of resource ID
	Duration    common.JSONUint64 `json:"duration"`
}

func NewReserveFundTxJSON

func NewReserveFundTxJSON(a ReserveFundTx) ReserveFundTxJSON

func (ReserveFundTxJSON) ReserveFundTx

func (a ReserveFundTxJSON) ReserveFundTx() ReserveFundTx

type ReservedFund

type ReservedFund struct {
	Collateral      Coins
	InitialFund     Coins
	UsedFund        Coins
	ResourceIDs     []string // List of resource ID
	EndBlockHeight  uint64
	ReserveSequence uint64           // sequence number of the corresponding ReserveFundTx transaction
	TransferRecords []TransferRecord // signed ServerPaymentTransactions
}

func (*ReservedFund) HasResourceID

func (reservedFund *ReservedFund) HasResourceID(resourceID string) bool

func (ReservedFund) MarshalJSON

func (resv ReservedFund) MarshalJSON() ([]byte, error)

func (*ReservedFund) RecordTransfer

func (reservedFund *ReservedFund) RecordTransfer(serverPaymentTx *ServicePaymentTx)

func (*ReservedFund) UnmarshalJSON

func (resv *ReservedFund) UnmarshalJSON(data []byte) error

func (*ReservedFund) VerifyPaymentSequence

func (reservedFund *ReservedFund) VerifyPaymentSequence(targetAddress common.Address, paymentSequence uint64) error

TODO: this implementation is not very efficient

type ReservedFundJSON

type ReservedFundJSON struct {
	Collateral      Coins             `json:"collateral"`
	InitialFund     Coins             `json:"initial_fund"`
	UsedFund        Coins             `json:"used_fund"`
	ResourceIDs     []string          `json:"resource_ids"` // List of resource ID
	EndBlockHeight  common.JSONUint64 `json:"end_block_height"`
	ReserveSequence common.JSONUint64 `json:"reserve_sequence"` // sequence number of the corresponding ReserveFundTx transaction
	TransferRecords []TransferRecord  `json:"transfer_records"` // signed ServerPaymentTransactions
}

func NewReservedFundJSON

func NewReservedFundJSON(resv ReservedFund) ReservedFundJSON

func (ReservedFundJSON) ReservedFund

func (resv ReservedFundJSON) ReservedFund() ReservedFund

type SendTx

type SendTx struct {
	Fee     Coins      `json:"fee"` // Fee
	Inputs  []TxInput  `json:"inputs"`
	Outputs []TxOutput `json:"outputs"`
}

func MakeSendTx

func MakeSendTx(seq int, accOut PrivAccount, accsIn ...PrivAccount) *SendTx

func (*SendTx) AssertIsTx

func (_ *SendTx) AssertIsTx()

func (*SendTx) SetSignature

func (tx *SendTx) SetSignature(addr common.Address, sig *crypto.Signature) bool

func (*SendTx) SignBytes

func (tx *SendTx) SignBytes(chainID string) []byte

func (*SendTx) String

func (tx *SendTx) String() string

type ServicePaymentTx

type ServicePaymentTx struct {
	Fee             Coins   // Fee
	Source          TxInput // source account
	Target          TxInput // target account
	PaymentSequence uint64  // each on-chain settlement needs to increase the payment sequence by 1
	ReserveSequence uint64  // ReserveSequence to locate the ReservedFund
	ResourceID      string  // The corresponding resourceID
}

func (*ServicePaymentTx) AssertIsTx

func (_ *ServicePaymentTx) AssertIsTx()

func (ServicePaymentTx) MarshalJSON

func (a ServicePaymentTx) MarshalJSON() ([]byte, error)

func (*ServicePaymentTx) SetSourceSignature

func (tx *ServicePaymentTx) SetSourceSignature(sig *crypto.Signature)

func (*ServicePaymentTx) SetTargetSignature

func (tx *ServicePaymentTx) SetTargetSignature(sig *crypto.Signature)

func (*ServicePaymentTx) SignBytes

func (tx *ServicePaymentTx) SignBytes(chainID string) []byte

SignBytes this method only exists to satisfy the interface and should never be called. Call SourceSignBytes or TargetSignBytes instead.

func (*ServicePaymentTx) SourceSignBytes

func (tx *ServicePaymentTx) SourceSignBytes(chainID string) []byte

func (*ServicePaymentTx) String

func (tx *ServicePaymentTx) String() string

func (*ServicePaymentTx) TargetSignBytes

func (tx *ServicePaymentTx) TargetSignBytes(chainID string) []byte

func (*ServicePaymentTx) TxBytes

func (tx *ServicePaymentTx) TxBytes() ([]byte, error)

TxBytes returns the transaction data as well as all signatures It should return an error if Sign was never called

func (*ServicePaymentTx) UnmarshalJSON

func (a *ServicePaymentTx) UnmarshalJSON(data []byte) error

type ServicePaymentTxJSON

type ServicePaymentTxJSON struct {
	Fee             Coins             `json:"fee"`              // Fee
	Source          TxInput           `json:"source"`           // source account
	Target          TxInput           `json:"target"`           // target account
	PaymentSequence common.JSONUint64 `json:"payment_sequence"` // each on-chain settlement needs to increase the payment sequence by 1
	ReserveSequence common.JSONUint64 `json:"reserve_sequence"` // ReserveSequence to locate the ReservedFund
	ResourceID      string            `json:"resource_id"`      // The corresponding resourceID
}

func NewServicePaymentTxJSON

func NewServicePaymentTxJSON(a ServicePaymentTx) ServicePaymentTxJSON

func (ServicePaymentTxJSON) ServicePaymentTx

func (a ServicePaymentTxJSON) ServicePaymentTx() ServicePaymentTx

type SlashIntent

type SlashIntent struct {
	Address         common.Address
	ReserveSequence uint64
	Proof           common.Bytes
}

SlashIntent contains the address, reserve sequence of the account to be slashed, and the proof why the account should be slashed

func (SlashIntent) MarshalJSON

func (s SlashIntent) MarshalJSON() ([]byte, error)

func (*SlashIntent) String

func (si *SlashIntent) String() string

func (*SlashIntent) UnmarshalJSON

func (s *SlashIntent) UnmarshalJSON(data []byte) error

type SlashIntentJSON

type SlashIntentJSON struct {
	Address         common.Address
	ReserveSequence common.JSONUint64
	Proof           common.Bytes
}

func NewSlashIntentJSON

func NewSlashIntentJSON(s SlashIntent) SlashIntentJSON

func (SlashIntentJSON) SlashIntent

func (s SlashIntentJSON) SlashIntent() SlashIntent

type SlashTx

type SlashTx struct {
	Proposer        TxInput
	SlashedAddress  common.Address
	ReserveSequence uint64
	SlashProof      common.Bytes
}

func (*SlashTx) AssertIsTx

func (_ *SlashTx) AssertIsTx()

func (SlashTx) MarshalJSON

func (a SlashTx) MarshalJSON() ([]byte, error)

func (*SlashTx) SetSignature

func (tx *SlashTx) SetSignature(addr common.Address, sig *crypto.Signature) bool

func (*SlashTx) SignBytes

func (tx *SlashTx) SignBytes(chainID string) []byte

func (*SlashTx) String

func (tx *SlashTx) String() string

func (*SlashTx) UnmarshalJSON

func (a *SlashTx) UnmarshalJSON(data []byte) error

type SlashTxJSON

type SlashTxJSON struct {
	Proposer        TxInput           `json:"proposer"`
	SlashedAddress  common.Address    `json:"slashed_address"`
	ReserveSequence common.JSONUint64 `json:"reserved_sequence"`
	SlashProof      common.Bytes      `json:"slash_proof"`
}

func NewSlashTxJSON

func NewSlashTxJSON(a SlashTx) SlashTxJSON

func (SlashTxJSON) SlashTx

func (a SlashTxJSON) SlashTx() SlashTx

type SmartContractTx

type SmartContractTx struct {
	From     TxInput
	To       TxOutput
	GasLimit uint64
	GasPrice *big.Int
	Data     common.Bytes
}

func (*SmartContractTx) AssertIsTx

func (_ *SmartContractTx) AssertIsTx()

func (SmartContractTx) MarshalJSON

func (a SmartContractTx) MarshalJSON() ([]byte, error)

func (*SmartContractTx) SetSignature

func (tx *SmartContractTx) SetSignature(addr common.Address, sig *crypto.Signature) bool

func (*SmartContractTx) SignBytes

func (tx *SmartContractTx) SignBytes(chainID string) []byte

func (*SmartContractTx) String

func (tx *SmartContractTx) String() string

func (*SmartContractTx) UnmarshalJSON

func (a *SmartContractTx) UnmarshalJSON(data []byte) error

type SmartContractTxJSON

type SmartContractTxJSON struct {
	From     TxInput           `json:"from"`
	To       TxOutput          `json:"to"`
	GasLimit common.JSONUint64 `json:"gas_limit"`
	GasPrice *common.JSONBig   `json:"gas_price"`
	Data     common.Bytes      `json:"data"`
}

func NewSmartContractTxJSON

func NewSmartContractTxJSON(a SmartContractTx) SmartContractTxJSON

func (SmartContractTxJSON) SmartContractTx

func (a SmartContractTxJSON) SmartContractTx() SmartContractTx

type Split

type Split struct {
	Address    common.Address // Address to participate in the payment split
	Percentage uint           // An integer between 0 and 100, representing the percentage of the payment the address should get
}

Split contains the particiated address and percentage of the payment the address should get

type SplitRule

type SplitRule struct {
	InitiatorAddress common.Address // Address of the initiator
	ResourceID       string         // ResourceID of the payment to be split
	Splits           []Split        // Splits of the payments
	EndBlockHeight   uint64         // The block height when the split rule expires
}

SplitRule specifies the payment split agreement among differet addresses

func (*SplitRule) MarshalJSON

func (a *SplitRule) MarshalJSON() ([]byte, error)

func (*SplitRule) String

func (sc *SplitRule) String() string

func (*SplitRule) UnmarshalJSON

func (a *SplitRule) UnmarshalJSON(data []byte) error

type SplitRuleJSON

type SplitRuleJSON struct {
	InitiatorAddress common.Address    `json:"initiator_address"` // Address of the initiator
	ResourceID       string            `json:"resource_id"`       // ResourceID of the payment to be split
	Splits           []Split           `json:"splits"`            // Splits of the payments
	EndBlockHeight   common.JSONUint64 `json:"end_block_height"`  // The block height when the split rule expires

}

func NewSplitRuleJSON

func NewSplitRuleJSON(a *SplitRule) *SplitRuleJSON

func (SplitRuleJSON) SplitRule

func (a SplitRuleJSON) SplitRule() SplitRule

type SplitRuleTx

type SplitRuleTx struct {
	Fee        Coins   // Fee
	ResourceID string  // ResourceID of the payment to be split
	Initiator  TxInput // Initiator of the split rule
	Splits     []Split // Agreed splits
	Duration   uint64  // Duration of the payment split in terms of blocks
}

func (*SplitRuleTx) AssertIsTx

func (_ *SplitRuleTx) AssertIsTx()

func (SplitRuleTx) MarshalJSON

func (a SplitRuleTx) MarshalJSON() ([]byte, error)

func (*SplitRuleTx) SetSignature

func (tx *SplitRuleTx) SetSignature(addr common.Address, sig *crypto.Signature) bool

func (*SplitRuleTx) SignBytes

func (tx *SplitRuleTx) SignBytes(chainID string) []byte

func (*SplitRuleTx) String

func (tx *SplitRuleTx) String() string

func (*SplitRuleTx) UnmarshalJSON

func (a *SplitRuleTx) UnmarshalJSON(data []byte) error

type SplitRuleTxJSON

type SplitRuleTxJSON struct {
	Fee        Coins             `json:"fee"`         // Fee
	ResourceID string            `json:"resource_id"` // ResourceID of the payment to be split
	Initiator  TxInput           `json:"initiator"`   // Initiator of the split rule
	Splits     []Split           `json:"splits"`      // Agreed splits
	Duration   common.JSONUint64 `json:"duration"`    // Duration of the payment split in terms of blocks
}

func NewSplitRuleTxJSON

func NewSplitRuleTxJSON(a SplitRuleTx) SplitRuleTxJSON

func (SplitRuleTxJSON) SplitRuleTx

func (a SplitRuleTxJSON) SplitRuleTx() SplitRuleTx

type TransferRecord

type TransferRecord struct {
	ServicePayment ServicePaymentTx `json:"service_payment"`
}

type Tx

type Tx interface {
	AssertIsTx()
	SignBytes(chainID string) []byte
}

func TxFromBytes

func TxFromBytes(raw []byte) (Tx, error)

type TxInput

type TxInput struct {
	Address   common.Address // Hash of the PubKey
	Coins     Coins
	Sequence  uint64            // Must be 1 greater than the last committed TxInput
	Signature *crypto.Signature // Depends on the PubKey type and the whole Tx
}

func Accs2TxInputs

func Accs2TxInputs(seq int, accs ...PrivAccount) []TxInput

func NewTxInput

func NewTxInput(address common.Address, coins Coins, sequence int) TxInput

func (TxInput) MarshalJSON

func (a TxInput) MarshalJSON() ([]byte, error)

func (TxInput) String

func (txIn TxInput) String() string

func (*TxInput) UnmarshalJSON

func (a *TxInput) UnmarshalJSON(data []byte) error

func (TxInput) ValidateBasic

func (txIn TxInput) ValidateBasic() result.Result

type TxInputJSON

type TxInputJSON struct {
	Address   common.Address    `json:"address"`   // Hash of the PubKey
	Coins     Coins             `json:"coins"`     //
	Sequence  common.JSONUint64 `json:"sequence"`  // Must be 1 greater than the last committed TxInput
	Signature *crypto.Signature `json:"signature"` // Depends on the PubKey type and the whole Tx
}

func NewTxInputJSON

func NewTxInputJSON(a TxInput) TxInputJSON

func (TxInputJSON) TxInput

func (a TxInputJSON) TxInput() TxInput

type TxOutput

type TxOutput struct {
	Address common.Address `json:"address"` // Hash of the PubKey
	Coins   Coins          `json:"coins"`   // Amount of coins
}

func Accs2TxOutputs

func Accs2TxOutputs(accs ...PrivAccount) []TxOutput

turn a list of accounts into basic list of transaction outputs

func (TxOutput) String

func (txOut TxOutput) String() string

func (TxOutput) ValidateBasic

func (txOut TxOutput) ValidateBasic() result.Result

type TxType

type TxType uint16
const (
	TxCoinbase TxType = iota
	TxSlash
	TxSend
	TxReserveFund
	TxReleaseFund
	TxServicePayment
	TxSplitRule
	TxSmartContract
	TxDepositStake
	TxWithdrawStake
)

type WithdrawStakeTx

type WithdrawStakeTx struct {
	Fee     Coins    `json:"fee"`     // Fee
	Source  TxInput  `json:"source"`  // source staker account
	Holder  TxOutput `json:"holder"`  // stake holder account
	Purpose uint8    `json:"purpose"` // purpose e.g. stake for validator/guardian
}

func (*WithdrawStakeTx) AssertIsTx

func (_ *WithdrawStakeTx) AssertIsTx()

func (*WithdrawStakeTx) SetSignature

func (tx *WithdrawStakeTx) SetSignature(addr common.Address, sig *crypto.Signature) bool

func (*WithdrawStakeTx) SignBytes

func (tx *WithdrawStakeTx) SignBytes(chainID string) []byte

func (*WithdrawStakeTx) String

func (tx *WithdrawStakeTx) String() string

Jump to

Keyboard shortcuts

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