Documentation
¶
Index ¶
- Variables
- func Decode(data []byte, dest any) error
- func DecryptData(encrypted, nonce, key []byte) ([]byte, error)
- func DecryptMnemonic(encrypted []byte, passphrase string) (string, error)
- func DeriveAddressFromPrivateKey(privKey *ecdsa.PrivateKey) (map[string]string, error)
- func Encode(value any) ([]byte, error)
- func EncryptData(plaintext, key []byte, encrypted, nonce *[]byte) error
- func EncryptMnemonic(mnemonic, passphrase string) ([]byte, error)
- func FormatFIL(attoFil string) (string, error)
- func GenerateMnemonic(bits int) (string, error)
- func MnemonicToSeed(mnemonic, password string) []byte
- func ParseFIL(fil string) (string, error)
- func ValidateMnemonic(mnemonic string) bool
- type AddressType
- type Balance
- type GasEstimate
- type Manager
- type ManagerOption
- type RPCClient
- func (c *RPCClient) Close()
- func (c *RPCClient) EstimateGas(ctx context.Context, msg *types.Message) (*GasEstimate, error)
- func (c *RPCClient) GetBalance(ctx context.Context, addr address.Address) (*Balance, error)
- func (c *RPCClient) GetChainHead(ctx context.Context) (int64, error)
- func (c *RPCClient) GetNonce(ctx context.Context, addr address.Address) (uint64, error)
- func (c *RPCClient) GetTransaction(ctx context.Context, cidStr string) (*Transaction, error)
- func (c *RPCClient) GetTransactions(ctx context.Context, addr address.Address, limit int) ([]*Transaction, error)
- func (c *RPCClient) SendMessage(ctx context.Context, signedMsg *types.SignedMessage) (string, error)
- func (c *RPCClient) WaitForMessage(ctx context.Context, cidStr string, confidence uint64) (*types.MessageReceipt, error)
- type RPCConfig
- type SendOptions
- type Transaction
- type Wallet
- type WalletStore
Constants ¶
This section is empty.
Variables ¶
var ( ErrWalletNotFound = errors.New("wallet not found") ErrInvalidMnemonic = errors.New("invalid mnemonic phrase") ErrInvalidPassphrase = errors.New("invalid passphrase") ErrInvalidWalletName = errors.New("invalid wallet name") ErrDuplicateWalletName = errors.New("duplicate wallet name") ErrWalletLocked = errors.New("wallet is locked") ErrInsufficientBalance = errors.New("insufficient balance") ErrInvalidAddress = errors.New("invalid address") ErrTransactionFailed = errors.New("transaction failed") )
Functions ¶
func DecryptData ¶
func DecryptMnemonic ¶
DecryptMnemonic decrypts an encrypted mnemonic with a passphrase
func DeriveAddressFromPrivateKey ¶
func DeriveAddressFromPrivateKey(privKey *ecdsa.PrivateKey) (map[string]string, error)
DeriveAddressFromPrivateKey derives Filecoin addresses from private key
func EncryptData ¶
Encrypt data with AES-GCM
func EncryptMnemonic ¶
EncryptMnemonic encrypts a mnemonic phrase with a passphrase
func FormatFIL ¶
FormatFIL converts an attoFIL string to a human-readable FIL string with 6 decimals.
func GenerateMnemonic ¶
GenerateMnemonic generates a new BIP39 mnemonic phrase
func MnemonicToSeed ¶
MnemonicToSeed converts a mnemonic to a seed
func ValidateMnemonic ¶
ValidateMnemonic checks if a mnemonic phrase is valid
Types ¶
type AddressType ¶
type AddressType string
const ( AddressTypeF1 AddressType = "f1" AddressTypeF4 AddressType = "f4" AddressTypeEth AddressType = "0x" )
const ( AddressTypeF1 AddressType = "f1" AddressTypeF4 AddressType = "f4" AddressTypeEth AddressType = "0x" )
type Balance ¶
type Balance struct {
Address string `json:"address"`
Balance string `json:"balance"` // in attoFIL
Nonce uint64 `json:"nonce"`
Timestamp time.Time `json:"timestamp"`
}
Balance represents wallet balance information
type GasEstimate ¶
GasEstimate represents gas estimation for a transaction
type Manager ¶
type Manager interface {
LoadWallets(ctx context.Context) ([]Wallet, error)
CreateWallet(ctx context.Context, walletName, keystorePassphrase string) (*Wallet, error)
RecoverWallet(ctx context.Context, seedPhrase, walletName, password string) (*Wallet, error)
DeleteWallet(walletID string) error
}
func NewManager ¶
func NewManager(dataDir string, opts ...ManagerOption) (Manager, error)
NewManager initializes a Manager with Badger DB and optional configurations
type ManagerOption ¶
type ManagerOption func(*manager) error
func WithOptions ¶
func WithOptions(url, token string) ManagerOption
WithRPC allows setting a custom RPC endpoint and optional token
type RPCClient ¶
type RPCClient struct {
// contains filtered or unexported fields
}
RPCClient wraps Filecoin RPC API interactions with clean lifecycle management.
func NewRPCClient ¶
NewRPCClient creates a new RPC client with validated config and authenticated connection.
func (*RPCClient) EstimateGas ¶
EstimateGas computes gas parameters for a message.
func (*RPCClient) GetBalance ¶
GetBalance returns the current balance and nonce for an address.
func (*RPCClient) GetChainHead ¶
GetChainHead returns the current chain height.
func (*RPCClient) GetTransaction ¶
GetTransaction retrieves full transaction details by CID.
func (*RPCClient) GetTransactions ¶
func (c *RPCClient) GetTransactions(ctx context.Context, addr address.Address, limit int) ([]*Transaction, error)
GetTransactions returns up to `limit` recent transactions involving the address.
func (*RPCClient) SendMessage ¶
func (c *RPCClient) SendMessage(ctx context.Context, signedMsg *types.SignedMessage) (string, error)
SendMessage pushes a signed message to the mempool and returns its CID.
func (*RPCClient) WaitForMessage ¶
func (c *RPCClient) WaitForMessage(ctx context.Context, cidStr string, confidence uint64) (*types.MessageReceipt, error)
WaitForMessage waits for a message to be included in a tipset with given confidence.
type SendOptions ¶
type SendOptions struct {
From address.Address
To address.Address
Value string // in attoFIL
GasLimit *int64
GasFeeCap *string
GasPremium *string
Method uint64
Params []byte
}
SendOptions contains options for sending transactions
type Transaction ¶
type Transaction struct {
Cid string `json:"cid"`
From string `json:"from"`
To string `json:"to"`
Value string `json:"value"`
GasFeeCap string `json:"gas_fee_cap"`
GasPremium string `json:"gas_premium"`
GasLimit int64 `json:"gas_limit"`
Nonce uint64 `json:"nonce"`
Method uint64 `json:"method"`
Params []byte `json:"params,omitempty"`
Timestamp time.Time `json:"timestamp"`
Height int64 `json:"height"`
Status string `json:"status"` // "pending", "confirmed", "failed"
}
Transaction represents a Filecoin transaction
type Wallet ¶
type Wallet struct {
ID string `json:"id"`
IsDefault bool `json:"is_default"`
Name string `json:"name"`
Mnemonic string `json:"-"`
KeyJSON []byte `json:"key_json"`
Addrs map[string]string `json:"addresses"`
Meta map[string]string `json:"metadata"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// contains filtered or unexported fields
}
Wallet represents a Filecoin wallet with encrypted storage
type WalletStore ¶
type WalletStore interface {
// Save stores a wallet securely
Save(wallet *Wallet) error
// Get retrieves a wallet by ID
Get(id string) (*Wallet, error)
// List returns all wallets
List() ([]*Wallet, error)
// Delete removes a wallet
Delete(id string) error
// Update modifies an existing wallet
Update(wallet *Wallet) error
}
WalletStore defines the interface for wallet persistence