Documentation ¶
Index ¶
- Constants
- Variables
- func FromBytes(in []byte, a interface{}) error
- func Fuzz(data []byte) int
- func GetMaxGasLimit(blockHeight uint64) *big.Int
- func GetMinimumGasPrice(blockHeight uint64) *big.Int
- func GetMinimumTransactionFeeDTokenWei(blockHeight uint64) *big.Int
- func GetSendTxMinimumTransactionFeeDTokenWei(numAccountsAffected uint64, blockHeight uint64) *big.Int
- func MapChainID(chainIDStr string, blockHeight uint64) *big.Int
- func ParseCoinAmount(in string) (*big.Int, bool)
- func SignSendTx(chainID string, tx *SendTx, accs ...PrivAccount)
- func ToBytes(a interface{}) ([]byte, error)
- func TxID(chainID string, tx Tx) common.Hash
- func TxToBytes(t Tx) ([]byte, error)
- type Account
- func (acc *Account) CheckReleaseFund(currentBlockHeight uint64, reserveSequence uint64) error
- func (acc *Account) CheckReserveFund(collateral Coins, fund Coins, duration uint64, reserveSequence uint64) error
- func (acc *Account) CheckTransferReservedFund(tgtAcc *Account, transferAmount Coins, paymentSequence uint64, ...) error
- func (acc *Account) Copy() *Account
- func (acc *Account) IsASmartContract() bool
- func (acc Account) MarshalJSON() ([]byte, error)
- func (acc *Account) ReleaseExpiredFunds(currentBlockHeight uint64)
- func (acc *Account) ReleaseFund(currentBlockHeight uint64, reserveSequence uint64)
- func (acc *Account) ReserveFund(collateral Coins, fund Coins, resourceIDs []string, endBlockHeight uint64, ...)
- func (acc *Account) String() string
- func (acc *Account) TransferReservedFund(splittedCoinsMap map[*Account]Coins, currentBlockHeight uint64, ...) (shouldSlash bool, slashIntent SlashIntent)
- func (acc *Account) UnmarshalJSON(data []byte) error
- func (acc *Account) UpdateToHeight(height uint64)
- type AccountJSON
- type CoinbaseTx
- func (_ *CoinbaseTx) AssertIsTx()
- func (a CoinbaseTx) MarshalJSON() ([]byte, error)
- func (tx *CoinbaseTx) SetSignature(addr common.Address, sig *crypto.Signature) bool
- func (tx *CoinbaseTx) SignBytes(chainID string) []byte
- func (tx *CoinbaseTx) String() string
- func (a *CoinbaseTx) UnmarshalJSON(data []byte) error
- type CoinbaseTxJSON
- type Coins
- func (coins Coins) CalculatePercentage(percentage uint) Coins
- func (coinsA Coins) IsEqual(coinsB Coins) bool
- func (coinsA Coins) IsGTE(coinsB Coins) bool
- func (coins Coins) IsNonnegative() bool
- func (coins Coins) IsPositive() bool
- func (coins Coins) IsValid() bool
- func (coins Coins) IsZero() bool
- func (c Coins) MarshalJSON() ([]byte, error)
- func (coinsA Coins) Minus(coinsB Coins) Coins
- func (coins Coins) Negative() Coins
- func (coins Coins) NoNil() Coins
- func (coinsA Coins) Plus(coinsB Coins) Coins
- func (coins Coins) String() string
- func (c *Coins) UnmarshalJSON(data []byte) error
- type CoinsJSON
- type DepositStakeTx
- type DepositStakeTxV1
- type EthereumTxWrapper
- type HeightList
- type Log
- type OverspendingProof
- type OverspendingProofJSON
- type PrivAccount
- type ReleaseFundTx
- func (_ *ReleaseFundTx) AssertIsTx()
- func (a ReleaseFundTx) MarshalJSON() ([]byte, error)
- func (tx *ReleaseFundTx) SetSignature(addr common.Address, sig *crypto.Signature) bool
- func (tx *ReleaseFundTx) SignBytes(chainID string) []byte
- func (tx *ReleaseFundTx) String() string
- func (a *ReleaseFundTx) UnmarshalJSON(data []byte) error
- type ReleaseFundTxJSON
- type ReserveFundTx
- func (_ *ReserveFundTx) AssertIsTx()
- func (a ReserveFundTx) MarshalJSON() ([]byte, error)
- func (tx *ReserveFundTx) SetSignature(addr common.Address, sig *crypto.Signature) bool
- func (tx *ReserveFundTx) SignBytes(chainID string) []byte
- func (tx *ReserveFundTx) String() string
- func (a *ReserveFundTx) UnmarshalJSON(data []byte) error
- type ReserveFundTxJSON
- type ReservedFund
- func (reservedFund *ReservedFund) HasResourceID(resourceID string) bool
- func (resv ReservedFund) MarshalJSON() ([]byte, error)
- func (reservedFund *ReservedFund) RecordTransfer(serverPaymentTx *ServicePaymentTx)
- func (resv *ReservedFund) UnmarshalJSON(data []byte) error
- func (reservedFund *ReservedFund) VerifyPaymentSequence(targetAddress common.Address, paymentSequence uint64) error
- type ReservedFundJSON
- type SendTx
- type ServicePaymentTx
- func (_ *ServicePaymentTx) AssertIsTx()
- func (a ServicePaymentTx) MarshalJSON() ([]byte, error)
- func (tx *ServicePaymentTx) SetSourceSignature(sig *crypto.Signature)
- func (tx *ServicePaymentTx) SetTargetSignature(sig *crypto.Signature)
- func (tx *ServicePaymentTx) SignBytes(chainID string) []byte
- func (tx *ServicePaymentTx) SourceSignBytes(chainID string) []byte
- func (tx *ServicePaymentTx) String() string
- func (tx *ServicePaymentTx) TargetSignBytes(chainID string) []byte
- func (tx *ServicePaymentTx) TxBytes() ([]byte, error)
- func (a *ServicePaymentTx) UnmarshalJSON(data []byte) error
- type ServicePaymentTxJSON
- type SlashIntent
- type SlashIntentJSON
- type SlashTx
- type SlashTxJSON
- type SmartContractTx
- func (_ *SmartContractTx) AssertIsTx()
- func (a SmartContractTx) MarshalJSON() ([]byte, error)
- func (tx *SmartContractTx) SetSignature(addr common.Address, sig *crypto.Signature) bool
- func (tx *SmartContractTx) SignBytes(chainID string) []byte
- func (tx *SmartContractTx) String() string
- func (a *SmartContractTx) UnmarshalJSON(data []byte) error
- type SmartContractTxJSON
- type Split
- type SplitRule
- type SplitRuleJSON
- type SplitRuleTx
- func (_ *SplitRuleTx) AssertIsTx()
- func (a SplitRuleTx) MarshalJSON() ([]byte, error)
- func (tx *SplitRuleTx) SetSignature(addr common.Address, sig *crypto.Signature) bool
- func (tx *SplitRuleTx) SignBytes(chainID string) []byte
- func (tx *SplitRuleTx) String() string
- func (a *SplitRuleTx) UnmarshalJSON(data []byte) error
- type SplitRuleTxJSON
- type TransferRecord
- type Tx
- type TxInput
- type TxInputJSON
- type TxOutput
- type TxType
- type WithdrawStakeTx
Constants ¶
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 )
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 )
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 )
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 )
const ( GasRegularTx uint64 = 10000 GasRegularTxJune2021 uint64 = 80000 )
const CHAIN_ID_OFFSET int64 = 5466 //360
For replay attack protection https://chainid.network/
Variables ¶
var ( Zero *big.Int Hundred *big.Int )
var EmptyCodeHash = common.BytesToHash(crypto.Keccak256(nil))
Functions ¶
func GetMaxGasLimit ¶ added in v1.0.0
func GetMinimumGasPrice ¶ added in v1.0.0
func GetMinimumTransactionFeeDTokenWei ¶ added in v1.0.0
func GetSendTxMinimumTransactionFeeDTokenWei ¶ added in v1.0.0
func GetSendTxMinimumTransactionFeeDTokenWei(numAccountsAffected uint64, blockHeight uint64) *big.Int
Special handling for many-to-many SendTx
func ParseCoinAmount ¶
ParseCoinAmount parses a string representation of coin amount.
func SignSendTx ¶
func SignSendTx(chainID string, tx *SendTx, accs ...PrivAccount)
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 (*Account) CheckReleaseFund ¶
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) IsASmartContract ¶
IsASmartContract indicates if the account is a smart contract account
func (Account) MarshalJSON ¶
func (*Account) ReleaseExpiredFunds ¶
ReleaseExpiredFunds releases all expired funds
func (*Account) ReleaseFund ¶
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) 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 (*Account) UpdateToHeight ¶
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 ¶
func (*CoinbaseTx) AssertIsTx ¶
func (_ *CoinbaseTx) AssertIsTx()
func (CoinbaseTx) MarshalJSON ¶
func (a CoinbaseTx) MarshalJSON() ([]byte, error)
func (*CoinbaseTx) SetSignature ¶
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 ¶
func (Coins) CalculatePercentage ¶
CalculatePercentage function calculates amount of coins for the given the percentage
func (Coins) IsNonnegative ¶
func (Coins) IsPositive ¶
func (Coins) MarshalJSON ¶
func (*Coins) UnmarshalJSON ¶
type CoinsJSON ¶
type CoinsJSON struct { DneroWei *common.JSONBig `json:"dnerowei"` DTokenWei *common.JSONBig `json:"dtokenwei"` }
func NewCoinsJSON ¶
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 (*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 (*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.
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
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 (*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 (*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 ¶
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 ¶
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 (*SlashTx) SetSignature ¶
func (*SlashTx) UnmarshalJSON ¶
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 (*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 (*SplitRule) UnmarshalJSON ¶
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 (*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 ¶
func TxFromBytes ¶
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 (TxInput) MarshalJSON ¶
func (*TxInput) UnmarshalJSON ¶
func (TxInput) ValidateBasic ¶
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) ValidateBasic ¶
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 (*WithdrawStakeTx) SignBytes ¶
func (tx *WithdrawStakeTx) SignBytes(chainID string) []byte
func (*WithdrawStakeTx) String ¶
func (tx *WithdrawStakeTx) String() string