UNPKG

p-sdk-wallet

Version:

A comprehensive wallet SDK for React Native (pwc), supporting multi-chain and multi-account features.

72 lines (71 loc) 2.82 kB
import { Keypair } from '@solana/web3.js'; /** * Solana keyring for managing multiple Solana accounts * derived from a single mnemonic phrase using BIP-44 derivation paths. * Supports Solana blockchain with Ed25519 keypairs. */ export declare class SolanaKeyring { readonly type = "Solana"; private keypairs; accounts: string[]; private mnemonic; /** * Creates a new SolanaKeyring instance from a mnemonic phrase. * @param mnemonic - The mnemonic phrase (12, 15, 18, 21, or 24 words) * @throws Error if the mnemonic is invalid */ constructor(mnemonic: string); /** * Initializes the keyring by generating the seed and creating the first account. * @param mnemonic - The mnemonic phrase to initialize from */ private initializeFromMnemonic; /** * Derives a Solana keypair at a specific index using BIP-44 derivation. * @param seed - The seed buffer to derive from * @param index - The account index to derive (0-based) * @returns The derived Solana keypair */ private deriveKeypair; /** * Adds a new Solana account derived from the mnemonic at the next available index. * @returns Promise resolving to the public key address of the newly created account * @throws Error if account derivation fails or duplicate address is generated */ addNewAccount(): Promise<string>; /** * Gets the private key for a given address managed by this keyring. * @param address - The account's public key address to get the private key for * @returns Promise resolving to the private key as a hex string * @throws Error if the address is not found in this keyring */ getPrivateKeyForAddress(address: string): Promise<string>; /** * Returns the mnemonic phrase. USE WITH CAUTION - this exposes sensitive data. * @returns The mnemonic phrase as a string */ getMnemonic(): string; /** * Serializes the keyring data for encryption and storage. * @returns An object containing the keyring type and mnemonic */ serialize(): any; /** * Deserializes data into a SolanaKeyring instance. * @param data - The serialized keyring data * @returns Promise resolving to a new SolanaKeyring instance * @throws Error if the data is invalid or missing required fields */ static deserialize(data: any): Promise<SolanaKeyring>; /** * Gets the Solana keypair for a given address. * @param address - The account's public key address * @returns The Solana keypair or undefined if not found */ getKeypair(address: string): Keypair | undefined; /** * Gets all keypairs managed by this keyring. * @returns Array of all Solana keypairs */ getAllKeypairs(): Keypair[]; }