Documentation
¶
Overview ¶
Package txSigner provides Ethereum transaction signing functionality for multichain operations. This package defines interfaces and implementations for signing Ethereum transactions using various methods including direct private keys and AWS KMS integration.
Index ¶
- type AWSKMSSigner
- func (a *AWSKMSSigner) GetAddress() (common.Address, error)
- func (a *AWSKMSSigner) GetNoSendTransactOpts(ctx context.Context, chainID *big.Int) (*bind.TransactOpts, error)
- func (k *AWSKMSSigner) GetPubKey() (*ecdsa.PublicKey, error)
- func (a *AWSKMSSigner) GetTransactOpts(ctx context.Context, chainID *big.Int) (*bind.TransactOpts, error)
- func (k *AWSKMSSigner) SignerFn(chainID *big.Int) bind2.SignerFn
- type ITransactionSigner
- type MockITransactionSigner
- func (_m *MockITransactionSigner) GetAddress() (common.Address, error)
- func (_m *MockITransactionSigner) GetNoSendTransactOpts(ctx context.Context, chainID *big.Int) (*bind.TransactOpts, error)
- func (_m *MockITransactionSigner) GetTransactOpts(ctx context.Context, chainID *big.Int) (*bind.TransactOpts, error)
- type PrivateKeySigner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AWSKMSSigner ¶
type AWSKMSSigner struct {
// contains filtered or unexported fields
}
AWSKMSSigner implements ITransactionSigner using AWS KMS
func NewAWSKMSSigner ¶
func NewAWSKMSSigner(keyID, region string) (*AWSKMSSigner, error)
NewAWSKMSSigner creates a new AWSKMSSigner with the specified KMS key ID and AWS region. This constructor establishes a connection to AWS KMS and derives the Ethereum address by performing a test signature and recovery operation.
Parameters:
- keyID: The AWS KMS key ID or ARN for signing operations
- region: The AWS region where the KMS key is located
Returns:
- *AWSKMSSigner: A new AWS KMS signer instance
- error: An error if the AWS session cannot be created or the key is invalid
func (*AWSKMSSigner) GetAddress ¶
func (a *AWSKMSSigner) GetAddress() (common.Address, error)
GetAddress returns the Ethereum address associated with this KMS key. This method implements the ITransactionSigner interface.
Returns:
- common.Address: The Ethereum address derived from the KMS key
- error: Always returns nil for AWS KMS signers
func (*AWSKMSSigner) GetNoSendTransactOpts ¶ added in v0.0.6
func (a *AWSKMSSigner) GetNoSendTransactOpts(ctx context.Context, chainID *big.Int) (*bind.TransactOpts, error)
func (*AWSKMSSigner) GetPubKey ¶ added in v0.0.7
func (k *AWSKMSSigner) GetPubKey() (*ecdsa.PublicKey, error)
func (*AWSKMSSigner) GetTransactOpts ¶
func (a *AWSKMSSigner) GetTransactOpts(ctx context.Context, chainID *big.Int) (*bind.TransactOpts, error)
GetTransactOpts returns bind.TransactOpts configured for AWS KMS signing. This method implements the ITransactionSigner interface by creating transaction options that use AWS KMS for signing operations.
Parameters:
- ctx: Context for the transaction operation
- chainID: The chain ID for the target blockchain
Returns:
- *bind.TransactOpts: Configured transaction options for AWS KMS signing
- error: An error if the transaction options cannot be created
type ITransactionSigner ¶
type ITransactionSigner interface {
// GetTransactOpts returns bind.TransactOpts configured for the signer.
// The returned TransactOpts contains the necessary authentication and
// signing configuration for submitting transactions to the specified chain.
//
// Parameters:
// - ctx: Context for the operation
// - chainID: The chain ID for the target blockchain
//
// Returns:
// - *bind.TransactOpts: Configured transaction options for the signer
// - error: An error if transaction options cannot be created
GetTransactOpts(ctx context.Context, chainID *big.Int) (*bind.TransactOpts, error)
GetNoSendTransactOpts(ctx context.Context, chainID *big.Int) (*bind.TransactOpts, error)
// GetAddress returns the Ethereum address associated with this signer.
// This address will be used as the 'from' field in transactions.
//
// Returns:
// - common.Address: The Ethereum address of the signer
// - error: An error if the address cannot be determined
GetAddress() (common.Address, error)
}
ITransactionSigner defines the interface for signing Ethereum transactions. Implementations provide the ability to create properly configured transaction options for use with go-ethereum contract bindings, supporting different signing backends like private keys and hardware security modules.
type MockITransactionSigner ¶ added in v0.0.10
MockITransactionSigner is an autogenerated mock type for the ITransactionSigner type
func NewMockITransactionSigner ¶ added in v0.0.10
func NewMockITransactionSigner(t interface {
mock.TestingT
Cleanup(func())
}) *MockITransactionSigner
NewMockITransactionSigner creates a new instance of MockITransactionSigner. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockITransactionSigner) GetAddress ¶ added in v0.0.10
func (_m *MockITransactionSigner) GetAddress() (common.Address, error)
GetAddress provides a mock function with given fields:
func (*MockITransactionSigner) GetNoSendTransactOpts ¶ added in v0.0.10
func (_m *MockITransactionSigner) GetNoSendTransactOpts(ctx context.Context, chainID *big.Int) (*bind.TransactOpts, error)
GetNoSendTransactOpts provides a mock function with given fields: ctx, chainID
func (*MockITransactionSigner) GetTransactOpts ¶ added in v0.0.10
func (_m *MockITransactionSigner) GetTransactOpts(ctx context.Context, chainID *big.Int) (*bind.TransactOpts, error)
GetTransactOpts provides a mock function with given fields: ctx, chainID
type PrivateKeySigner ¶
type PrivateKeySigner struct {
// contains filtered or unexported fields
}
PrivateKeySigner implements ITransactionSigner using a raw private key
func NewPrivateKeySigner ¶
func NewPrivateKeySigner(privateKeyHex string) (*PrivateKeySigner, error)
NewPrivateKeySigner creates a new PrivateKeySigner from a hex-encoded private key. The private key can be provided with or without the "0x" prefix.
Parameters:
- privateKeyHex: A hex-encoded private key string (with or without 0x prefix)
Returns:
- *PrivateKeySigner: A new private key signer instance
- error: An error if the private key cannot be parsed
func (*PrivateKeySigner) GetAddress ¶
func (p *PrivateKeySigner) GetAddress() (common.Address, error)
GetAddress returns the Ethereum address associated with this private key. This method implements the ITransactionSigner interface.
Returns:
- common.Address: The Ethereum address derived from the private key
- error: Always returns nil for private key signers
func (*PrivateKeySigner) GetNoSendTransactOpts ¶ added in v0.0.6
func (p *PrivateKeySigner) GetNoSendTransactOpts(ctx context.Context, chainID *big.Int) (*bind.TransactOpts, error)
func (*PrivateKeySigner) GetTransactOpts ¶
func (p *PrivateKeySigner) GetTransactOpts(ctx context.Context, chainID *big.Int) (*bind.TransactOpts, error)
GetTransactOpts returns bind.TransactOpts configured for the private key signer. This method implements the ITransactionSigner interface by creating transaction options that use the stored private key for signing operations.
Parameters:
- ctx: Context for the transaction operation
- chainID: The chain ID for the target blockchain
Returns:
- *bind.TransactOpts: Configured transaction options for the private key
- error: An error if the transactor cannot be created