Documentation
¶
Index ¶
- type BaseChain
- func (b *BaseChain) CreateWallet(mnemonic string) (*Wallet, error)
- func (b *BaseChain) CreateWalletWithPrivateKey(privateKey string) (*Wallet, error)
- func (b *BaseChain) GetCoinType() core.CoinType
- func (b *BaseChain) GetDecimals() int
- func (b *BaseChain) GetName() string
- func (b *BaseChain) GetPublicKeyFromPrivateKey(privateKey []byte) ([]byte, error)
- func (b *BaseChain) GetSymbol() string
- func (b *BaseChain) GetTransactionHash(encodedTx []byte) (string, error)
- func (b *BaseChain) SetChainName(chainName string)
- func (b *BaseChain) SetCoinType(coinType core.CoinType)
- func (b *BaseChain) SetDecimals(decimals int)
- func (b *BaseChain) SetSymbol(symbol string)
- func (b *BaseChain) ValidateAddress(address string) bool
- type Chain
- type ChainRegistry
- type Signer
- type TransactionInput
- type Wallet
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 ¶
NewBaseChain creates a new BaseChain instance Only requires coinType - all other info is derived from it
func (*BaseChain) CreateWallet ¶
CreateWallet creates a wallet from mnemonic
func (*BaseChain) CreateWalletWithPrivateKey ¶
CreateWalletWithPrivateKey creates a wallet from private key
func (*BaseChain) GetCoinType ¶
GetCoinType returns the chain's coin type
func (*BaseChain) GetDecimals ¶
GetDecimals returns the number of decimals
func (*BaseChain) GetPublicKeyFromPrivateKey ¶
GetPublicKeyFromPrivateKey derives the public key from a private key
func (*BaseChain) GetTransactionHash ¶
GetTransactionHash gets the transaction hash
func (*BaseChain) SetChainName ¶
SetChainName allows chain implementations to override the chain name if needed
func (*BaseChain) SetCoinType ¶
SetCoinType allows chain implementations to override the coin type if needed
func (*BaseChain) SetDecimals ¶
SetDecimals allows chain implementations to override the decimals if needed
func (*BaseChain) SetSymbol ¶
SetSymbol allows chain implementations to override the symbol if needed
func (*BaseChain) ValidateAddress ¶
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