SPB Git

spb/os-vault Public

Self-custody, multi-chain crypto wallet for macOS. One recovery phrase, six chain families, zero API keys — nothing leaves your Mac.

Swift 96% Shell 3.4% Makefile 0.6%
1.8 KB · 57 lines swift
Raw Blame History
1import WalletCoreC2import Foundation3// SPDX-License-Identifier: Apache-2.04//5// Copyright © 2017 Trust Wallet.6//7// This is a GENERATED FILE, changes made here WILL BE LOST.8//910import Foundation1112/// Mnemonic validate / lookup functions13public struct Mnemonic {1415    /// Determines whether a BIP39 English mnemonic phrase is valid.16    ///17    /// - Parameter mnemonic: Non-null BIP39 english mnemonic18    /// - Returns: true if the mnemonic is valid, false otherwise19    public static func isValid(mnemonic: String) -> Bool {20        let mnemonicString = TWStringCreateWithNSString(mnemonic)21        defer {22            TWStringDelete(mnemonicString)23        }24        return TWMnemonicIsValid(mnemonicString)25    }2627    /// Determines whether word is a valid BIP39 English mnemonic word.28    ///29    /// - Parameter word: Non-null BIP39 English mnemonic word30    /// - Returns: true if the word is a valid BIP39 English mnemonic word, false otherwise31    public static func isValidWord(word: String) -> Bool {32        let wordString = TWStringCreateWithNSString(word)33        defer {34            TWStringDelete(wordString)35        }36        return TWMnemonicIsValidWord(wordString)37    }3839    /// Return BIP39 English words that match the given prefix. A single string is returned, with space-separated list of words.40    ///41    /// - Parameter prefix: Non-null string prefix42    /// - Returns: Single non-null string, space-separated list of words containing BIP39 words that match the given prefix.43    public static func suggest(prefix: String) -> String {44        let prefixString = TWStringCreateWithNSString(prefix)45        defer {46            TWStringDelete(prefixString)47        }48        return TWStringNSString(TWMnemonicSuggest(prefixString))49    }505152    init() {53    }545556}57