Documentation ¶
Index ¶
- Constants
- type Transaction
- func (t *Transaction) AddEIP155HashValues(rlpList rlp.List, chainID int64) rlp.List
- func (t *Transaction) Build1559(chainID int64) rlp.List
- func (t *Transaction) BuildLegacy() rlp.List
- func (t *Transaction) Sign(signer secp256k1.Signer, chainID int64) ([]byte, error)
- func (t *Transaction) SignEIP1559(signer secp256k1.Signer, chainID int64) ([]byte, error)
- func (t *Transaction) SignLegacyEIP155(signer secp256k1.Signer, chainID int64) ([]byte, error)
- func (t *Transaction) SignLegacyOriginal(signer secp256k1.Signer) ([]byte, error)
- func (t *Transaction) SignaturePayload(chainID int64) (sp *TransactionSignaturePayload)
- func (t *Transaction) SignaturePayloadEIP1559(chainID int64) *TransactionSignaturePayload
- func (t *Transaction) SignaturePayloadLegacyEIP155(chainID int64) *TransactionSignaturePayload
- func (t *Transaction) SignaturePayloadLegacyOriginal() *TransactionSignaturePayload
- type TransactionSignaturePayload
- type Wallet
Constants ¶
const ( TransactionTypeLegacy byte = 0x00 TransactionType2930 byte = 0x01 // unused TransactionType1559 byte = 0x02 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Transaction ¶
type Transaction struct { From json.RawMessage `json:"from,omitempty"` // only here as a possible input to signing key selection (eth_sendTransaction) Nonce *ethtypes.HexInteger `json:"nonce,omitempty"` GasPrice *ethtypes.HexInteger `json:"gasPrice,omitempty"` MaxPriorityFeePerGas *ethtypes.HexInteger `json:"maxPriorityFeePerGas,omitempty"` MaxFeePerGas *ethtypes.HexInteger `json:"maxFeePerGas,omitempty"` GasLimit *ethtypes.HexInteger `json:"gas"` To *ethtypes.Address0xHex `json:"to,omitempty"` Value *ethtypes.HexInteger `json:"value"` Data ethtypes.HexBytes0xPrefix `json:"data"` }
func (*Transaction) AddEIP155HashValues ¶
func (*Transaction) BuildLegacy ¶
func (t *Transaction) BuildLegacy() rlp.List
func (*Transaction) Sign ¶
Automatically pick signer, based on input fields. - If either of the new EIP-1559 fields are set, use EIP-1559 - By default use EIP-155 signing Never picks legacy-legacy (non EIP-155), or EIP-2930
func (*Transaction) SignEIP1559 ¶
SignEIP1559 uses EIP-1559 transaction structure (with EIP-2718 transaction type byte), with EIP-2930 V value (0 / 1 - direct parity-Y)
func (*Transaction) SignLegacyEIP155 ¶
SignLegacyEIP155 uses legacy transaction structure, with EIP-155 signing V value (2*ChainID + 35 + Y-parity)
func (*Transaction) SignLegacyOriginal ¶
func (t *Transaction) SignLegacyOriginal(signer secp256k1.Signer) ([]byte, error)
SignLegacyOriginal uses legacy transaction structure, with legacy V value (27/28)
func (*Transaction) SignaturePayload ¶ added in v0.9.14
func (t *Transaction) SignaturePayload(chainID int64) (sp *TransactionSignaturePayload)
Returns the bytes that would be used to sign the transaction, without actually perform the signing. Can be used with Recover to verify a signing result.
func (*Transaction) SignaturePayloadEIP1559 ¶ added in v0.9.14
func (t *Transaction) SignaturePayloadEIP1559(chainID int64) *TransactionSignaturePayload
SignaturePayloadEIP1559 returns the rlpList of fields that are signed, along with the full bytes for the signature / TX Hash - which have the transaction type prefixed
func (*Transaction) SignaturePayloadLegacyEIP155 ¶ added in v0.9.14
func (t *Transaction) SignaturePayloadLegacyEIP155(chainID int64) *TransactionSignaturePayload
SignaturePayloadLegacyEIP155 returns the rlpList of fields that are signed, and the bytes. Note that for legacy and EIP-155 transactions (everything prior to EIP-2718), there is no transaction type byte added (so the bytes are exactly rlpList.Encode())
func (*Transaction) SignaturePayloadLegacyOriginal ¶ added in v0.9.14
func (t *Transaction) SignaturePayloadLegacyOriginal() *TransactionSignaturePayload
SignaturePayloadLegacyOriginal returns the rlpList of fields that are signed, and the bytes. Note that for legacy and EIP-155 transactions (everything prior to EIP-2718), there is no transaction type byte added (so the bytes are exactly rlpList.Encode())
type TransactionSignaturePayload ¶ added in v0.9.14
type TransactionSignaturePayload struct {
// contains filtered or unexported fields
}
func (*TransactionSignaturePayload) Bytes ¶ added in v0.9.14
func (sp *TransactionSignaturePayload) Bytes() []byte
func (*TransactionSignaturePayload) Hash ¶ added in v0.9.14
func (sp *TransactionSignaturePayload) Hash() ethtypes.HexBytes0xPrefix
type Wallet ¶
type Wallet interface { Sign(ctx context.Context, txn *Transaction, chainID int64) ([]byte, error) // SignPrivateTxn(ctx context.Context, addr ethtypes.Address, ptx *Transaction, chainID int64) ([]byte, error) Initialize(ctx context.Context) error GetAccounts(ctx context.Context) ([]*ethtypes.Address0xHex, error) Refresh(ctx context.Context) error Close() error }
Wallet is the common interface can be implemented across wallet/signing capabilities