WalletUtils
public final class WalletUtils : Sendable
Implements SEP-0005 - Key Derivation Methods for Stellar Accounts.
This class provides BIP-39 mnemonic generation and BIP-44 hierarchical deterministic key derivation for Stellar accounts. It allows creating multiple accounts from a single seed phrase, enabling secure wallet backups and account management.
Typical Usage
// Generate a 12-word mnemonic
let mnemonic = WalletUtils.generate12WordMnemonic()
// Derive first account (index 0)
let keyPair0 = try WalletUtils.createKeyPair(
mnemonic: mnemonic,
passphrase: nil,
index: 0
)
// Derive second account (index 1)
let keyPair1 = try WalletUtils.createKeyPair(
mnemonic: mnemonic,
passphrase: nil,
index: 1
)
See also:
-
Generates a 12 word Mnemonic.
Declaration
Swift
public static func generate12WordMnemonic(language: WordList = .english) -> String -
Generates a 24 word Mnemonic.
Declaration
Swift
public static func generate24WordMnemonic(language: WordList = .english) -> String -
Creates a new KeyPair from the given mnemonic and index.
Declaration
Swift
public static func createKeyPair(mnemonic: String, passphrase: String?, index: Int) throws -> KeyPairParameters
mnemonicThe mnemonic string.
passphraseThe passphrase.
indexThe index of the wallet to generate.
View on GitHub
Install in Dash