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%
2.4 KB · 86 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/// Represents a Nervos address.13public final class NervosAddress: Address {1415    /// Compares two addresses for equality.16    ///17    /// - Parameter lhs: The first address to compare.18    /// - Parameter rhs: The second address to compare.19    /// - Returns: bool indicating the addresses are equal.20    public static func == (lhs: NervosAddress, rhs: NervosAddress) -> Bool {21        return TWNervosAddressEqual(lhs.rawValue, rhs.rawValue)22    }2324    /// Determines if the string is a valid Nervos address.25    ///26    /// - Parameter string: string to validate.27    /// - Returns: bool indicating if the address is valid.28    public static func isValidString(string: String) -> Bool {29        let stringString = TWStringCreateWithNSString(string)30        defer {31            TWStringDelete(stringString)32        }33        return TWNervosAddressIsValidString(stringString)34    }3536    /// Returns the address string representation.37    ///38    /// - Parameter address: Address to get the string representation of.39    public var description: String {40        return TWStringNSString(TWNervosAddressDescription(rawValue))41    }4243    /// Returns the Code hash44    ///45    /// - Parameter address: Address to get the keyhash data of.46    public var codeHash: Data {47        return TWDataNSData(TWNervosAddressCodeHash(rawValue))48    }4950    /// Returns the address hash type51    ///52    /// - Parameter address: Address to get the hash type of.53    public var hashType: String {54        return TWStringNSString(TWNervosAddressHashType(rawValue))55    }5657    /// Returns the address args data.58    ///59    /// - Parameter address: Address to get the args data of.60    public var args: Data {61        return TWDataNSData(TWNervosAddressArgs(rawValue))62    }6364    let rawValue: OpaquePointer6566    init(rawValue: OpaquePointer) {67        self.rawValue = rawValue68    }6970    public init?(string: String) {71        let stringString = TWStringCreateWithNSString(string)72        defer {73            TWStringDelete(stringString)74        }75        guard let rawValue = TWNervosAddressCreateWithString(stringString) else {76            return nil77        }78        self.rawValue = rawValue79    }8081    deinit {82        TWNervosAddressDelete(rawValue)83    }8485}86