types

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: GPL-3.0 Imports: 16 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// DenomDneroWei is the basic unit of dnero, 1 Dnero = 10^18 DneroWei
	DenomDneroWei string = "DneroWei"

	// DenomDTokenWei is the basic unit of dnero, 1 Dnero = 10^18 DneroWei
	DenomDTokenWei string = "DTokenWei"

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

	// MaximumTxGasLimit is the maximum gas limit for a smart contract transaction
	//MaximumTxGasLimit uint64 = 2e6
	MaximumTxGasLimit uint64 = 10e6

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

	// MinimumGasPrice is the minimum gas price for a smart contract transaction
	MinimumGasPriceJune2021 uint64 = 4e12

	// MaximumTxGasLimit is the maximum gas limit for a smart contract transaction
	MaximumTxGasLimitJune2021 uint64 = 20e6

	// MinimumTransactionFeeDTokenWei specifies the minimum fee for a regular transaction
	MinimumTransactionFeeDTokenWeiJune2021 uint64 = 3e17

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

	// ValidatorDneroGenerationRateDenominator is used for calculating the generation rate of Dnero for validators
	// ValidatorDneroGenerationRateNumerator / ValidatorDneroGenerationRateDenominator is the amount of DneroWei
	// generated per existing DneroWei per new block
	ValidatorDneroGenerationRateDenominator int64 = 1e11

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

	// ValidatorDTokenGenerationRateDenominator is used for calculating the generation rate of DToken for validators
	// ValidatorDTokenGenerationRateNumerator / ValidatorDTokenGenerationRateDenominator is the amount of DTokenWei
	// generated per existing DneroWei per new block
	ValidatorDTokenGenerationRateDenominator int64 = 1e9

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

	// RegularDTokenGenerationRateDenominator is used for calculating the generation rate of DToken for other types of accounts
	// RegularDTokenGenerationRateNumerator / RegularDTokenGenerationRateDenominator is the amount of DTokenWei
	// generated per existing DneroWei per new block
	RegularDTokenGenerationRateDenominator 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 (
	GasRegularTx         uint64 = 10000
	GasRegularTxJune2021 uint64 = 80000
)
View Source
const CHAIN_ID_OFFSET int64 = 5466 //360

For replay attack protection https://chainid.network/

Variables

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

Functions

func FromBytes

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

func Fuzz

func Fuzz(data []byte) int

func GetMaxGasLimit added in v1.0.0

func GetMaxGasLimit(blockHeight uint64) *big.Int

func GetMinimumGasPrice added in v1.0.0

func GetMinimumGasPrice(blockHeight uint64) *big.Int

func GetMinimumTransactionFeeDTokenWei added in v1.0.0

func GetMinimumTransactionFeeDTokenWei(blockHeight uint64) *big.Int

func GetSendTxMinimumTransactionFeeDTokenWei added in v1.0.0

func GetSendTxMinimumTransactionFeeDTokenWei(numAccountsAffected uint64, blockHeight uint64) *big.Int

Special handling for many-to-many SendTx

func MapChainID added in v1.1.0

func MapChainID(chainIDStr string, blockHeight uint64) *big.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) IsASmartContract

func (acc *Account) IsASmartContract() bool

IsASmartContract indicates if the account is a smart contract 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 {
	DneroWei  *big.Int
	DTokenWei *big.Int
}

func NewCoins

func NewCoins(dnero int64, dtoken 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 {
	DneroWei  *common.JSONBig `json:"dnerowei"`
	DTokenWei *common.JSONBig `json:"dtokenwei"`
}

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/sentry
}

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 DepositStakeTxV1

type DepositStakeTxV1 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/sentry

	BlsPubkey *bls.PublicKey    `rlp:"nil"`
	BlsPop    *bls.Signature    `rlp:"nil"`
	HolderSig *crypto.Signature `rlp:"nil"`
}

func (*DepositStakeTxV1) AssertIsTx

func (_ *DepositStakeTxV1) AssertIsTx()

func (*DepositStakeTxV1) SetSignature

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

func (*DepositStakeTxV1) SignBytes

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

func (*DepositStakeTxV1) String

func (tx *DepositStakeTxV1) String() string

type EthereumTxWrapper

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"`
}

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 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:"reserve_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
	TxDepositStakeV2
)

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/sentry
}

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