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 Foundation23public struct DerivablePath: Hashable, Codable {4 // MARK: - Nested type56 public enum DerivableType: String, CaseIterable, Codable {7 case bip44Change8 case bip449 case deprecated1011 var prefix: String {12 switch self {13 case .deprecated:14 return "m/501'"15 case .bip44, .bip44Change:16 return "m/44'/501'"17 }18 }19 }2021 // MARK: - Properties2223 public let type: DerivableType24 public let walletIndex: Int25 public let accountIndex: Int?2627 public init(type: DerivablePath.DerivableType, walletIndex: Int, accountIndex: Int? = nil) {28 self.type = type29 self.walletIndex = walletIndex30 self.accountIndex = accountIndex31 }3233 public static var `default`: Self {34 .init(35 type: .bip44Change,36 walletIndex: 0,37 accountIndex: 038 )39 }4041 public var rawValue: String {42 var value = type.prefix43 switch type {44 case .deprecated:45 value += "/\(walletIndex)'/0/\(accountIndex ?? 0)"46 case .bip44:47 value += "/\(walletIndex)'"48 case .bip44Change:49 value += "/\(walletIndex)'/0'"50 }51 return value52 }53}54