txSigner

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: MIT Imports: 13 Imported by: 0

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

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 from the public key associated with the specified KMS key.

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

	// 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 KMSTransactor

type KMSTransactor struct {
	// contains filtered or unexported fields
}

KMSTransactor wraps AWS KMS operations for transaction signing

func (*KMSTransactor) SignerFn

func (k *KMSTransactor) SignerFn(address common.Address, tx *types.Transaction) (*types.Transaction, error)

SignerFn implements the bind.SignerFn signature for KMS signing

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

Jump to

Keyboard shortcuts

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