solanawallet

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccountFromBase58

func AccountFromBase58(s string) (types.Account, error)

FromBase58 creates an Solana account from a base58 encoded string

func AccountFromString

func AccountFromString(s string) (types.Account, error)

AccountFromString creates an Solana account from a base58 encoded string. Alias for AccountFromBase58

func AccountToBase58

func AccountToBase58(a types.Account) string

ToBase58 converts an Solana account to a base58 encoded string

func DeriveAccountFromMnemonicBip44

func DeriveAccountFromMnemonicBip44(mnemonic string) (types.Account, error)

DeriveAccountFromMnemonicBip44 derives an Solana account from a mnemonic phrase Compatible with BIP44 (phantom wallet, etc.)

func DeriveTokenAccount

func DeriveTokenAccount(base58WalletAddr, base58MintAddr string) (common.PublicKey, error)

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

func DeriveTokenAccountPubkey(wallet, mint common.PublicKey) (common.PublicKey, error)

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 NewAccount

func NewAccount() types.Account

NewAccount creates a new Solana account

func NewMnemonic

func NewMnemonic(len MnemonicLength) (string, error)

NewMnemonic generates a new mnemonic phrase

func PublicKeyFromBase58

func PublicKeyFromBase58(s string) common.PublicKey

PublicKeyFromBase58 converts a base58 encoded public key to a PublicKey type Alias for PublicKeyFromString

func PublicKeyFromString

func PublicKeyFromString(s string) common.PublicKey

PublicKeyFromString converts a string to a PublicKey type Wrapper around the common.PublicKeyFromString function from the solana-go-sdk

func ValidateSolanaWalletAddr

func ValidateSolanaWalletAddr(addr string) error

ValidateSolanaWalletAddr validates a Solana wallet address. Returns an error if the address is invalid, nil otherwise.

Types

type Client

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

Client is the main struct for the Solana client

func NewClient

func NewClient(salt string) *Client

NewClient creates a new Solana client

func (*Client) DecryptMnemonic

func (c *Client) DecryptMnemonic(encrypted, pin string) (string, error)

DecryptMnemonic decrypts a base58 encoded string with AES-256-GCM and returns the decrypted mnemonic phrase

func (*Client) EnctyptMnemonic

func (c *Client) EnctyptMnemonic(mnemonic, pin string) (string, error)

GenerateMnemonic generates a new mnemonic phrase, encode it to base58 and hash with secret key.

type MnemonicLength

type MnemonicLength int

Mnemonic length type

const (
	MnemonicLength12 MnemonicLength = 128 // 128 bits of entropy, 12 words
	MnemonicLength24 MnemonicLength = 256 // 256 bits of entropy, 24 words
)

Predefined mnemonic lengths

Jump to

Keyboard shortcuts

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