Documentation ¶
Index ¶
- Constants
- func AddEIP155HashValuesToRLPList(rlpList rlp.List, chainID int64) rlp.List
- type EIP712Result
- 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) FinalizeEIP1559WithSignature(signaturePayload *TransactionSignaturePayload, sig *secp256k1.SignatureData) ([]byte, error)
- func (t *Transaction) FinalizeLegacyEIP155WithSignature(signaturePayload *TransactionSignaturePayload, sig *secp256k1.SignatureData, ...) ([]byte, error)
- func (t *Transaction) FinalizeLegacyOriginalWithSignature(signaturePayload *TransactionSignaturePayload, sig *secp256k1.SignatureData) ([]byte, error)
- 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 TransactionWithOriginalPayload
- func RecoverEIP1559Transaction(ctx context.Context, rawTx ethtypes.HexBytes0xPrefix, chainID int64) (*ethtypes.Address0xHex, *TransactionWithOriginalPayload, error)
- func RecoverLegacyRawTransaction(ctx context.Context, rawTx ethtypes.HexBytes0xPrefix, chainID int64) (*ethtypes.Address0xHex, *TransactionWithOriginalPayload, error)
- func RecoverRawTransaction(ctx context.Context, rawTx ethtypes.HexBytes0xPrefix, chainID int64) (*ethtypes.Address0xHex, *TransactionWithOriginalPayload, error)
- type Wallet
- type WalletTypedData
Constants ¶
const ( TransactionTypeLegacy byte = 0x00 TransactionType2930 byte = 0x01 // unused TransactionType1559 byte = 0x02 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EIP712Result ¶ added in v1.1.11
type EIP712Result struct { Hash ethtypes.HexBytes0xPrefix `ffstruct:"EIP712Result" json:"hash"` SignatureRSV ethtypes.HexBytes0xPrefix `ffstruct:"EIP712Result" json:"signatureRSV"` V ethtypes.HexInteger `ffstruct:"EIP712Result" json:"v"` R ethtypes.HexBytes0xPrefix `ffstruct:"EIP712Result" json:"r"` S ethtypes.HexBytes0xPrefix `ffstruct:"EIP712Result" json:"s"` }
func SignTypedDataV4 ¶ added in v1.1.11
func SignTypedDataV4(ctx context.Context, signer secp256k1.SignerDirect, payload *eip712.TypedData) (*EIP712Result, error)
type Transaction ¶
type Transaction struct { From json.RawMessage `ffstruct:"EthTransaction" json:"from,omitempty"` // only here as a possible input to signing key selection (eth_sendTransaction) Nonce *ethtypes.HexInteger `ffstruct:"EthTransaction" json:"nonce,omitempty"` GasPrice *ethtypes.HexInteger `ffstruct:"EthTransaction" json:"gasPrice,omitempty"` MaxPriorityFeePerGas *ethtypes.HexInteger `ffstruct:"EthTransaction" json:"maxPriorityFeePerGas,omitempty"` MaxFeePerGas *ethtypes.HexInteger `ffstruct:"EthTransaction" json:"maxFeePerGas,omitempty"` GasLimit *ethtypes.HexInteger `ffstruct:"EthTransaction" json:"gas,omitempty"` // note this is required for some methods (eth_estimateGas) To *ethtypes.Address0xHex `ffstruct:"EthTransaction" json:"to,omitempty"` Value *ethtypes.HexInteger `ffstruct:"EthTransaction" json:"value,omitempty"` Data ethtypes.HexBytes0xPrefix `ffstruct:"EthTransaction" json:"data"` }
func DecodeEIP1559SignaturePayload ¶ added in v1.1.19
func DecodeEIP1559SignaturePayload(ctx context.Context, rawTx ethtypes.HexBytes0xPrefix, chainID int64) (*Transaction, error)
func (*Transaction) AddEIP155HashValues ¶
func (*Transaction) BuildLegacy ¶
func (t *Transaction) BuildLegacy() rlp.List
func (*Transaction) FinalizeEIP1559WithSignature ¶ added in v1.1.14
func (t *Transaction) FinalizeEIP1559WithSignature(signaturePayload *TransactionSignaturePayload, sig *secp256k1.SignatureData) ([]byte, error)
func (*Transaction) FinalizeLegacyEIP155WithSignature ¶ added in v1.1.14
func (t *Transaction) FinalizeLegacyEIP155WithSignature(signaturePayload *TransactionSignaturePayload, sig *secp256k1.SignatureData, chainID int64) ([]byte, error)
func (*Transaction) FinalizeLegacyOriginalWithSignature ¶ added in v1.1.14
func (t *Transaction) FinalizeLegacyOriginalWithSignature(signaturePayload *TransactionSignaturePayload, sig *secp256k1.SignatureData) ([]byte, error)
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 TransactionWithOriginalPayload ¶ added in v1.1.14
type TransactionWithOriginalPayload struct { *Transaction Payload []byte `json:"-"` }
func RecoverEIP1559Transaction ¶ added in v1.1.14
func RecoverEIP1559Transaction(ctx context.Context, rawTx ethtypes.HexBytes0xPrefix, chainID int64) (*ethtypes.Address0xHex, *TransactionWithOriginalPayload, error)
func RecoverLegacyRawTransaction ¶ added in v1.1.14
func RecoverLegacyRawTransaction(ctx context.Context, rawTx ethtypes.HexBytes0xPrefix, chainID int64) (*ethtypes.Address0xHex, *TransactionWithOriginalPayload, error)
func RecoverRawTransaction ¶ added in v1.1.14
func RecoverRawTransaction(ctx context.Context, rawTx ethtypes.HexBytes0xPrefix, chainID int64) (*ethtypes.Address0xHex, *TransactionWithOriginalPayload, error)
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
type WalletTypedData ¶ added in v1.1.11
type WalletTypedData interface { Wallet SignTypedDataV4(ctx context.Context, from ethtypes.Address0xHex, payload *eip712.TypedData) (*EIP712Result, error) }