Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateNetworkFee(tx *Transaction, feePerByte uint64) uint64
- func RlpSize(v interface{}) int
- type EthTx
- func (t *EthTx) DecodeBinary(r *nio.BinReader)
- func (t *EthTx) EncodeBinary(w *nio.BinWriter)
- func (t *EthTx) IsValid() error
- func (t EthTx) MarshalJSON() ([]byte, error)
- func (t *EthTx) UnmarshalJSON(data []byte) error
- func (t *EthTx) Verify(chainId uint64) (err error)
- func (t *EthTx) WithSignature(chainId uint64, sig []byte) error
- type EthTxJson
- type NeoTx
- func (t *NeoTx) Bytes() ([]byte, error)
- func (t *NeoTx) DecodeBinary(br *io.BinReader)
- func (t *NeoTx) DecodeHashableFields(buf []byte) error
- func (t *NeoTx) EncodeBinary(bw *io.BinWriter)
- func (t *NeoTx) EncodeHashableFields() ([]byte, error)
- func (t *NeoTx) Hash() common.Hash
- func (t NeoTx) MarshalJSON() ([]byte, error)
- func (t *NeoTx) Size() int
- func (t *NeoTx) UnmarshalJSON(data []byte) error
- type NeoTxJson
- type Transaction
- func (t *Transaction) AccessList() types.AccessList
- func (t *Transaction) Bytes() ([]byte, error)
- func (t Transaction) Cost() *big.Int
- func (t *Transaction) Data() []byte
- func (t *Transaction) DecodeBinary(r *io.BinReader)
- func (t *Transaction) EncodeBinary(w *io.BinWriter)
- func (t Transaction) FeePerByte() uint64
- func (t *Transaction) From() common.Address
- func (t *Transaction) Gas() uint64
- func (t *Transaction) GasPrice() *big.Int
- func (t *Transaction) Hash() common.Hash
- func (t Transaction) IsValid() error
- func (t Transaction) MarshalJSON() ([]byte, error)
- func (t *Transaction) Nonce() uint64
- func (t Transaction) SignHash(chainId uint64) common.Hash
- func (t *Transaction) Size() int
- func (t *Transaction) To() *common.Address
- func (t *Transaction) UnmarshalJSON(b []byte) error
- func (t *Transaction) Value() *big.Int
- func (t *Transaction) Verify(chainId uint64) error
- func (t *Transaction) WithSignature(chainId uint64, sig []byte) error
- func (t *Transaction) WithWitness(witness Witness) error
- type Witness
- func (w Witness) Address() common.Address
- func (w *Witness) DecodeBinary(br *io.BinReader)
- func (w *Witness) EncodeBinary(bw *io.BinWriter)
- func (w Witness) MarshalJSON() ([]byte, error)
- func (w *Witness) UnmarshalJSON(b []byte) error
- func (w *Witness) VerifyHashable(chainId uint64, hh hash.Hashable) error
Constants ¶
View Source
const ( EthTxType = byte(0) NeoTxType = byte(1) SignatureLength = 64 MaxScriptLength = math.MaxUint16 MaxTransactionSize = 102400 EthLegacyBaseLength = 100 )
View Source
const ( // MaxInvocationScript is the maximum length of allowed invocation // script. It should fit 11/21 multisignature for the committee. MaxInvocationScript = 1024 // MaxVerificationScript is the maximum allowed length of verification // script. It should be appropriate for 11/21 multisignature committee. MaxVerificationScript = 1024 )
Variables ¶
View Source
var ( ErrNegativeValue = errors.New("negative value") ErrZeroFromAddress = errors.New("zero from address") ErrWitnessUnmatch = errors.New("witness not match from") )
Various errors for transaction validation.
View Source
var ( ErrInvalidTxType = errors.New("invalid tx type") ErrTipVeryHigh = errors.New("max priority fee per gas higher than 2^256-1") ErrFeeCapVeryHigh = errors.New("max fee per gas higher than 2^256-1") ErrTipAboveFeeCap = errors.New("max priority fee per gas higher than max fee per gas") ErrValueVeryHigh = errors.New("value higher than 2^256-1") ErrGasPriceVeryHigh = errors.New("gas price higher than 2^256-1") )
View Source
var ( ErrInvalidSignature = errors.New("invalid signature") ErrInvalidSignatureCount = errors.New("invalid signatures count") )
View Source
var (
ErrInvalidChainID = errors.New("invalid chainId")
)
View Source
var (
ErrNoSender = errors.New("no sender in trimmed tx")
)
ErrInvalidWitnessNum returns when the number of witnesses does not match signers.
View Source
var (
ErrUnsupportType = errors.New("unsupport tx type")
)
Functions ¶
func CalculateNetworkFee ¶
func CalculateNetworkFee(tx *Transaction, feePerByte uint64) uint64
Types ¶
type EthTx ¶
type EthTx struct { types.Transaction ChainID uint64 Sender common.Address }
func NewEthTxFromBytes ¶
func (*EthTx) DecodeBinary ¶
func (*EthTx) EncodeBinary ¶
func (EthTx) MarshalJSON ¶
func (*EthTx) UnmarshalJSON ¶
type EthTxJson ¶
type EthTxJson struct { Type hexutil.Uint `json:"type"` Hash common.Hash `json:"hash"` Nonce hexutil.Uint64 `json:"nonce"` GasPrice *hexutil.Big `json:"gasPrice,omitempty"` GasTipCap *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"` GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"` Gas hexutil.Uint64 `json:"gas"` To *common.Address `json:"to"` Value hexutil.Big `json:"value"` AccessList *types.AccessList `json:"accessList,omitempty"` Data hexutil.Bytes `json:"input"` V hexutil.Big `json:"v"` R hexutil.Big `json:"r"` S hexutil.Big `json:"s"` ChainID hexutil.Uint `json:"chainId"` Sender common.Address `json:"from"` }
type NeoTx ¶
type NeoTx struct { Nonce uint64 GasPrice *big.Int Gas uint64 From common.Address To *common.Address Value *big.Int Data []byte Witness Witness Trimmed bool // contains filtered or unexported fields }
func NewNeoTxFromBytes ¶
func (*NeoTx) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*NeoTx) DecodeHashableFields ¶
DecodeHashableFields decodes a part of transaction which should be hashed.
func (*NeoTx) EncodeBinary ¶
EncodeBinary implements Serializable interface.
func (*NeoTx) EncodeHashableFields ¶
EncodeHashableFields returns serialized transaction's fields which are hashed.
func (NeoTx) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
func (*NeoTx) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface.
type NeoTxJson ¶
type NeoTxJson struct { TxID common.Hash `json:"hash"` Size hexutil.Uint `json:"size"` Nonce hexutil.Uint64 `json:"nonce"` GasPrice hexutil.Big `json:"gasPrice"` Gas hexutil.Uint64 `json:"gas"` From common.Address `json:"from"` To *common.Address `json:"to"` Value hexutil.Big `json:"value"` Data hexutil.Bytes `json:"input"` Witness Witness `json:"witness"` R hexutil.Big `json:"r"` S hexutil.Big `json:"s"` V hexutil.Big `json:"v"` }
transactionJSON is a wrapper for NeoTx and used for correct marhalling of transaction.Data.
type Transaction ¶
type Transaction struct { Type byte EthTx *EthTx NeoTx *NeoTx Trimmed bool // contains filtered or unexported fields }
func NewTransactionFromBytes ¶
func NewTransactionFromBytes(b []byte) (*Transaction, error)
func NewTrimmedTX ¶
func NewTrimmedTX(hash common.Hash) *Transaction
func NewTx ¶
func NewTx(t interface{}) *Transaction
func (*Transaction) AccessList ¶
func (t *Transaction) AccessList() types.AccessList
func (*Transaction) Bytes ¶
func (t *Transaction) Bytes() ([]byte, error)
func (Transaction) Cost ¶
func (t Transaction) Cost() *big.Int
func (*Transaction) Data ¶
func (t *Transaction) Data() []byte
func (*Transaction) DecodeBinary ¶
func (t *Transaction) DecodeBinary(r *io.BinReader)
func (*Transaction) EncodeBinary ¶
func (t *Transaction) EncodeBinary(w *io.BinWriter)
func (Transaction) FeePerByte ¶
func (t Transaction) FeePerByte() uint64
func (*Transaction) From ¶
func (t *Transaction) From() common.Address
func (*Transaction) Gas ¶
func (t *Transaction) Gas() uint64
func (*Transaction) GasPrice ¶
func (t *Transaction) GasPrice() *big.Int
func (*Transaction) Hash ¶
func (t *Transaction) Hash() common.Hash
func (Transaction) IsValid ¶
func (t Transaction) IsValid() error
func (Transaction) MarshalJSON ¶
func (t Transaction) MarshalJSON() ([]byte, error)
func (*Transaction) Nonce ¶
func (t *Transaction) Nonce() uint64
func (*Transaction) Size ¶
func (t *Transaction) Size() int
func (*Transaction) To ¶
func (t *Transaction) To() *common.Address
func (*Transaction) UnmarshalJSON ¶
func (t *Transaction) UnmarshalJSON(b []byte) error
func (*Transaction) Value ¶
func (t *Transaction) Value() *big.Int
func (*Transaction) Verify ¶
func (t *Transaction) Verify(chainId uint64) error
func (*Transaction) WithSignature ¶
func (t *Transaction) WithSignature(chainId uint64, sig []byte) error
func (*Transaction) WithWitness ¶
func (t *Transaction) WithWitness(witness Witness) error
type Witness ¶
Witness contains 2 scripts.
func (*Witness) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*Witness) EncodeBinary ¶
EncodeBinary implements Serializable interface.
func (Witness) MarshalJSON ¶
func (*Witness) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.