ethsigner

package
v1.1.13 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransactionTypeLegacy byte = 0x00
	TransactionType2930   byte = 0x01 // unused
	TransactionType1559   byte = 0x02
)

Variables

This section is empty.

Functions

This section is empty.

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 (*Transaction) AddEIP155HashValues

func (t *Transaction) AddEIP155HashValues(rlpList rlp.List, chainID int64) rlp.List

func (*Transaction) Build1559

func (t *Transaction) Build1559(chainID int64) rlp.List

func (*Transaction) BuildLegacy

func (t *Transaction) BuildLegacy() rlp.List

func (*Transaction) Sign

func (t *Transaction) Sign(signer secp256k1.Signer, chainID int64) ([]byte, error)

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

func (t *Transaction) SignEIP1559(signer secp256k1.Signer, chainID int64) ([]byte, error)

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

func (t *Transaction) SignLegacyEIP155(signer secp256k1.Signer, chainID int64) ([]byte, error)

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

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)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL