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 an Account in C++ with address, coin type and public key info, an item within a keystore.13public final class Account {1415 /// Returns the address of an account.16 ///17 /// - Parameter account: Account to get the address of.18 public var address: String {19 return TWStringNSString(TWAccountAddress(rawValue))20 }2122 /// Return CoinType enum of an account.23 ///24 /// - Parameter account: Account to get the coin type of.25 public var coin: CoinType {26 return CoinType(rawValue: TWAccountCoin(rawValue).rawValue)!27 }2829 /// Returns the derivation enum of an account.30 ///31 /// - Parameter account: Account to get the derivation enum of.32 public var derivation: Derivation {33 return Derivation(rawValue: TWAccountDerivation(rawValue).rawValue)!34 }3536 /// Returns derivationPath of an account.37 ///38 /// - Parameter account: Account to get the derivation path of.39 public var derivationPath: String {40 return TWStringNSString(TWAccountDerivationPath(rawValue))41 }4243 /// Returns hex encoded publicKey of an account.44 ///45 /// - Parameter account: Account to get the public key of.46 public var publicKey: String {47 return TWStringNSString(TWAccountPublicKey(rawValue))48 }4950 /// Returns Base58 encoded extendedPublicKey of an account.51 ///52 /// - Parameter account: Account to get the extended public key of.53 public var extendedPublicKey: String {54 return TWStringNSString(TWAccountExtendedPublicKey(rawValue))55 }5657 let rawValue: OpaquePointer5859 init(rawValue: OpaquePointer) {60 self.rawValue = rawValue61 }6263 public init?(address: String, coin: CoinType, derivation: Derivation, derivationPath: String, publicKey: String, extendedPublicKey: String) {64 let addressString = TWStringCreateWithNSString(address)65 defer {66 TWStringDelete(addressString)67 }68 let derivationPathString = TWStringCreateWithNSString(derivationPath)69 defer {70 TWStringDelete(derivationPathString)71 }72 let publicKeyString = TWStringCreateWithNSString(publicKey)73 defer {74 TWStringDelete(publicKeyString)75 }76 let extendedPublicKeyString = TWStringCreateWithNSString(extendedPublicKey)77 defer {78 TWStringDelete(extendedPublicKeyString)79 }80 guard let rawValue = TWAccountCreate(addressString, TWCoinType(rawValue: coin.rawValue), TWDerivation(rawValue: derivation.rawValue), derivationPathString, publicKeyString, extendedPublicKeyString) else {81 return nil82 }83 self.rawValue = rawValue84 }8586 deinit {87 TWAccountDelete(rawValue)88 }8990}91