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%
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/// Represents a BIP44 DerivationPath in C++.13public final class DerivationPath {1415 /// Returns the purpose enum of a DerivationPath.16 ///17 /// - Parameter path: DerivationPath to get the purpose of.18 /// - Returns: DerivationPathPurpose.19 public var purpose: Purpose {20 return Purpose(rawValue: TWDerivationPathPurpose(rawValue).rawValue)!21 }2223 /// Returns the coin value of a derivation path.24 ///25 /// - Parameter path: DerivationPath to get the coin of.26 /// - Returns: The coin part of the DerivationPath.27 public var coin: UInt32 {28 return TWDerivationPathCoin(rawValue)29 }3031 /// Returns the account value of a derivation path.32 ///33 /// - Parameter path: DerivationPath to get the account of.34 /// - Returns: the account part of a derivation path.35 public var account: UInt32 {36 return TWDerivationPathAccount(rawValue)37 }3839 /// Returns the change value of a derivation path.40 ///41 /// - Parameter path: DerivationPath to get the change of.42 /// - Returns: The change part of a derivation path.43 public var change: UInt32 {44 return TWDerivationPathChange(rawValue)45 }4647 /// Returns the address value of a derivation path.48 ///49 /// - Parameter path: DerivationPath to get the address of.50 /// - Returns: The address part of the derivation path.51 public var address: UInt32 {52 return TWDerivationPathAddress(rawValue)53 }5455 /// Returns the string description of a derivation path.56 ///57 /// - Parameter path: DerivationPath to get the address of.58 /// - Returns: The string description of the derivation path.59 public var description: String {60 return TWStringNSString(TWDerivationPathDescription(rawValue))61 }6263 let rawValue: OpaquePointer6465 init(rawValue: OpaquePointer) {66 self.rawValue = rawValue67 }6869 public init(purpose: Purpose, coin: UInt32, account: UInt32, change: UInt32, address: UInt32) {70 rawValue = TWDerivationPathCreate(TWPurpose(rawValue: purpose.rawValue), coin, account, change, address)71 }7273 public init?(string: String) {74 let stringString = TWStringCreateWithNSString(string)75 defer {76 TWStringDelete(stringString)77 }78 guard let rawValue = TWDerivationPathCreateWithString(stringString) else {79 return nil80 }81 self.rawValue = rawValue82 }8384 deinit {85 TWDerivationPathDelete(rawValue)86 }8788 /// Returns the index component of a DerivationPath.89 ///90 /// - Parameter path: DerivationPath to get the index of.91 /// - Parameter index: The index component of the DerivationPath.92 /// - Returns: DerivationPathIndex or null if index is invalid.93 public func indexAt(index: UInt32) -> DerivationPathIndex? {94 guard let value = TWDerivationPathIndexAt(rawValue, index) else {95 return nil96 }97 return DerivationPathIndex(rawValue: value)98 }99100 /// Returns the indices count of a DerivationPath.101 ///102 /// - Parameter path: DerivationPath to get the indices count of.103 /// - Returns: The indices count of the DerivationPath.104 public func indicesCount() -> UInt32 {105 return TWDerivationPathIndicesCount(rawValue)106 }107108}109