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.9 KB · 63 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/// Non-core transaction utility methods, like building a transaction using an external signature.13public struct TransactionCompiler {1415    /// Obtains pre-signing hashes of a transaction.16    ///17    /// We provide a default `PreSigningOutput` in TransactionCompiler.proto. 18    /// For some special coins, such as bitcoin, we will create a custom `PreSigningOutput` object in its proto file.19    /// - Parameter coin: coin type.20    /// - Parameter txInputData: The serialized data of a signing input21    /// - Returns: serialized data of a proto object `PreSigningOutput` includes hash.22    public static func preImageHashes(coinType: CoinType, txInputData: Data) -> Data {23        let txInputDataData = TWDataCreateWithNSData(txInputData)24        defer {25            TWDataDelete(txInputDataData)26        }27        return TWDataNSData(TWTransactionCompilerPreImageHashes(TWCoinType(rawValue: coinType.rawValue), txInputDataData))28    }2930    /// Compiles a complete transation with one or more external signatures.31    /// 32    /// Puts together from transaction input and provided public keys and signatures. The signatures must match the hashes33    /// returned by TWTransactionCompilerPreImageHashes, in the same order. The publicKeyHash attached34    /// to the hashes enable identifying the private key needed for signing the hash.35    /// - Parameter coin: coin type.36    /// - Parameter txInputData: The serialized data of a signing input.37    /// - Parameter signatures: signatures to compile, using TWDataVector.38    /// - Parameter publicKeys: public keys for signers to match private keys, using TWDataVector.39    /// - Returns: serialized data of a proto object `SigningOutput`.40    public static func compileWithSignatures(coinType: CoinType, txInputData: Data, signatures: DataVector, publicKeys: DataVector) -> Data {41        let txInputDataData = TWDataCreateWithNSData(txInputData)42        defer {43            TWDataDelete(txInputDataData)44        }45        return TWDataNSData(TWTransactionCompilerCompileWithSignatures(TWCoinType(rawValue: coinType.rawValue), txInputDataData, signatures.rawValue, publicKeys.rawValue))46    }474849    public static func compileWithSignaturesAndPubKeyType(coinType: CoinType, txInputData: Data, signatures: DataVector, publicKeys: DataVector, pubKeyType: PublicKeyType) -> Data {50        let txInputDataData = TWDataCreateWithNSData(txInputData)51        defer {52            TWDataDelete(txInputDataData)53        }54        return TWDataNSData(TWTransactionCompilerCompileWithSignaturesAndPubKeyType(TWCoinType(rawValue: coinType.rawValue), txInputDataData, signatures.rawValue, publicKeys.rawValue, TWPublicKeyType(rawValue: pubKeyType.rawValue)))55    }565758    init() {59    }606162}63