chain_abstraction

package
v0.0.1-gowrapper-test Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseChain

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

BaseChain provides common functionality for all blockchain implementations This struct should be embedded in specific chain implementations to reduce code duplication

func NewBaseChain

func NewBaseChain(coinType core.CoinType) *BaseChain

NewBaseChain creates a new BaseChain instance Only requires coinType - all other info is derived from it

func (*BaseChain) CreateWallet

func (b *BaseChain) CreateWallet(mnemonic string) (*Wallet, error)

CreateWallet creates a wallet from mnemonic

func (*BaseChain) CreateWalletWithPrivateKey

func (b *BaseChain) CreateWalletWithPrivateKey(privateKey string) (*Wallet, error)

CreateWalletWithPrivateKey creates a wallet from private key

func (*BaseChain) GetCoinType

func (b *BaseChain) GetCoinType() core.CoinType

GetCoinType returns the chain's coin type

func (*BaseChain) GetDecimals

func (b *BaseChain) GetDecimals() int

GetDecimals returns the number of decimals

func (*BaseChain) GetName

func (b *BaseChain) GetName() string

GetName returns the chain name

func (*BaseChain) GetPublicKeyFromPrivateKey

func (b *BaseChain) GetPublicKeyFromPrivateKey(privateKey []byte) ([]byte, error)

GetPublicKeyFromPrivateKey derives the public key from a private key

func (*BaseChain) GetSymbol

func (b *BaseChain) GetSymbol() string

GetSymbol returns the chain symbol

func (*BaseChain) GetTransactionHash

func (b *BaseChain) GetTransactionHash(encodedTx []byte) (string, error)

GetTransactionHash gets the transaction hash

func (*BaseChain) SetChainName

func (b *BaseChain) SetChainName(chainName string)

SetChainName allows chain implementations to override the chain name if needed

func (*BaseChain) SetCoinType

func (b *BaseChain) SetCoinType(coinType core.CoinType)

SetCoinType allows chain implementations to override the coin type if needed

func (*BaseChain) SetDecimals

func (b *BaseChain) SetDecimals(decimals int)

SetDecimals allows chain implementations to override the decimals if needed

func (*BaseChain) SetSymbol

func (b *BaseChain) SetSymbol(symbol string)

SetSymbol allows chain implementations to override the symbol if needed

func (*BaseChain) ValidateAddress

func (b *BaseChain) ValidateAddress(address string) bool

ValidateAddress validates an address

type Chain

type Chain interface {
	// Basic chain information
	GetCoinType() core.CoinType
	GetName() string
	GetSymbol() string
	GetDecimals() int

	// Wallet operations
	CreateWallet(mnemonic string) (*Wallet, error)
	CreateWalletWithPrivateKey(privateKey string) (*Wallet, error)
	ValidateAddress(address string) bool

	// Transaction operations
	CreateAndSignTransaction(input interface{}, privateKey []byte) ([]byte, error)

	// External signing operations
	PrepareTransaction(input interface{}) (*TransactionInput, error)
	GetPreimageHash(input *TransactionInput) ([]byte, []byte, error)
	Sign(preimage []byte, privateKey []byte) ([]byte, error)
	CompileTransaction(input *TransactionInput, signatures [][]byte, publicKeys [][]byte) ([]byte, error)

	// Utility operations
	ValidateTransactionInput(input interface{}) error
	GetTransactionHash(encodedTx []byte) (string, error)

	// Test/dev utility: derive public key from private key
	GetPublicKeyFromPrivateKey(privateKey []byte) ([]byte, error)
}

Chain represents a blockchain implementation

type ChainRegistry

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

ChainRegistry manages the registration and retrieval of chain implementations

func NewChainRegistry

func NewChainRegistry() *ChainRegistry

NewChainRegistry creates a new chain registry

func (*ChainRegistry) GetChain

func (r *ChainRegistry) GetChain(coinType core.CoinType) (Chain, error)

GetChain retrieves a chain implementation by coin type

func (*ChainRegistry) ListAvailableChains

func (r *ChainRegistry) ListAvailableChains() []Chain

ListAvailableChains returns all available chains (alias for ListChains)

func (*ChainRegistry) ListChains

func (r *ChainRegistry) ListChains() []Chain

ListChains returns all registered chains

func (*ChainRegistry) RegisterChain

func (r *ChainRegistry) RegisterChain(chain Chain) error

RegisterChain registers a chain implementation

type Signer

type Signer interface {
	GetPublicKey() ([]byte, error)
	Sign(data []byte) ([]byte, error)
	Verify(signature []byte, data []byte, publicKey []byte) bool
}

Signer represents an external signing mechanism

type TransactionInput

type TransactionInput struct {
	ChainType core.CoinType
	InputData []byte
	InputType string
	Metadata  map[string]interface{}
}

TransactionInput represents a generic transaction input

type Wallet

type Wallet struct {
	Address    string
	PrivateKey string
	PublicKey  string
	CoinType   core.CoinType
	ChainName  string
}

Wallet represents a blockchain wallet

Jump to

Keyboard shortcuts

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