Documentation
¶
Index ¶
- Variables
- func AccountFromBase58(s string) (types.Account, error)
- func AccountFromString(s string) (types.Account, error)
- func AccountToBase58(a types.Account) string
- func DeriveAccountFromMnemonicBip39(mnemonic string) (types.Account, error)
- func DeriveAccountFromMnemonicBip44(mnemonic string) (types.Account, error)
- func DeriveAccountsListFromMnemonicBip44(mnemonic string, count int) ([]types.Account, error)
- func DeriveTokenAccount(base58WalletAddr, base58MintAddr string) (common.PublicKey, error)
- func DeriveTokenAccountPubkey(wallet, mint common.PublicKey) (common.PublicKey, error)
- func DeriveTokenLockAccount(walletAddress, tokenMintAddress common.PublicKey) (common.PublicKey, error)
- func FindBurnerPubkey() (common.PublicKey, error)
- func NewAccount() types.Account
- func NewAccountFromSeed(seed []byte) (types.Account, error)
- func NewMnemonic(len MnemonicLength) (string, error)
- func PublicKeyFromBase58(s string) common.PublicKey
- func PublicKeyFromString(s string) common.PublicKey
- func ValidateSolanaWalletAddr(addr string) error
- type MnemonicLength
Constants ¶
This section is empty.
Variables ¶
var ( ErrCreateBip39Entropy = errors.New("failed to create bip39 entropy") ErrCreateBip39Mnemonic = errors.New("failed to create bip39 mnemonic") ErrCreateBip39SeedFromMnemonic = errors.New("failed to create bip39 seed from mnemonic") ErrCreateAccountFromSeed = errors.New("failed to create account from seed") ErrDecodeBase58ToAccount = errors.New("failed to decode base58 to account") ErrDeriveKeyFromSeed = errors.New("failed to derive key from seed") ErrInvalidPublicKey = errors.New("invalid base58 public key") ErrInvalidPublicKeyLength = errors.New("invalid public key length") ErrNewMnemonic = errors.New("failed to create new mnemonic") ErrDeriveAccountFromMnemonicBip44 = errors.New("failed to derive account from mnemonic bip44") ErrDeriveAccountsListFromMnemonicBip44 = errors.New("failed to derive accounts list from mnemonic bip44") ErrDeriveAccountFromMnemonicBip39 = errors.New("failed to derive account from mnemonic bip39") ErrDeriveTokenAccount = errors.New("failed to derive associated token account") ErrInvalidWalletAddress = errors.New("invalid wallet address: must be a base58 encoded public key") )
Predefiend errors
Functions ¶
func AccountFromBase58 ¶
FromBase58 creates an Solana account from a base58 encoded string
func AccountFromString ¶
AccountFromString creates an Solana account from a base58 encoded string. Alias for AccountFromBase58
func AccountToBase58 ¶
ToBase58 converts an Solana account to a base58 encoded string
func DeriveAccountFromMnemonicBip39 ¶
DeriveAccountFromMnemonicBip39 derives an Solana account from a mnemonic phrase Compatible with BIP39 (solana cli tool)
func DeriveAccountFromMnemonicBip44 ¶
DeriveAccountFromMnemonicBip44 derives an Solana account from a mnemonic phrase Compatible with BIP44 (phantom wallet)
func DeriveAccountsListFromMnemonicBip44 ¶
DeriveAccountsListFromMnemonicBip44 derives a list of Solana accounts from a mnemonic phrase Compatible with BIP44 (phantom wallet)
func DeriveTokenAccount ¶
DeriveTokenAccount derives an associated token account from a Solana account and a mint address. This is a wrapper around the FindAssociatedTokenAddress function from the solana-go-sdk. base58WalletAddr is the base58 encoded address of the Solana account. base58MintAddr is the base58 encoded address of the token mint. The function returns the base58 encoded address of the token account or an error.
func DeriveTokenAccountPubkey ¶
DeriveTokenAccountPubkey derives an associated token account from a Solana account and a mint address. This is a wrapper around the FindAssociatedTokenAddress function from the solana-go-sdk.
func DeriveTokenLockAccount ¶
func DeriveTokenLockAccount(walletAddress, tokenMintAddress common.PublicKey) (common.PublicKey, error)
DeriveTokenLockAccount derives an associated token holder account from a Solana account and a mint address.
func FindBurnerPubkey ¶
FindBurnerPubkey returns the pubkey of the burner account
func NewAccountFromSeed ¶
NewAccountFromSeed creates a new Solana account from a seed
func NewMnemonic ¶
func NewMnemonic(len MnemonicLength) (string, error)
NewMnemonic generates a new mnemonic phrase
func PublicKeyFromBase58 ¶
PublicKeyFromBase58 converts a base58 encoded public key to a PublicKey type Alias for PublicKeyFromString
func PublicKeyFromString ¶
PublicKeyFromString converts a string to a PublicKey type Wrapper around the common.PublicKeyFromString function from the solana-go-sdk
func ValidateSolanaWalletAddr ¶
ValidateSolanaWalletAddr validates a Solana wallet address. Returns an error if the address is invalid, nil otherwise.
Types ¶
type MnemonicLength ¶
type MnemonicLength int
Mnemonic length type
const ( MnemonicLength12 MnemonicLength = 128 // 128 bits of entropy MnemonicLength24 MnemonicLength = 256 // 256 bits of entropy )
Predefined mnemonic lengths