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%
1.5 KB · 40 lines swift
Raw Blame History
1import Foundation23/// The prepared transaction that can be sent or simulate in SolanaBlockchainClient4public struct PreparedTransaction: Equatable {5    public init(transaction: Transaction, signers: [KeyPair], expectedFee: FeeAmount) {6        self.transaction = transaction7        self.signers = signers8        self.expectedFee = expectedFee9    }1011    public var transaction: Transaction12    public var signers: [KeyPair]13    public var expectedFee: FeeAmount1415    public mutating func sign() throws {16        try transaction.sign(signers: signers)17    }1819    public func serialize() throws -> String {20        var transaction = transaction21        let serializedTransaction = try transaction.serialize().bytes.toBase64()22        #if DEBUG23            Logger.log(event: "serializedTransaction", message: serializedTransaction, logLevel: .debug)24            if let decodedTransaction = transaction.jsonString {25                Logger.log(event: "decodedTransaction", message: decodedTransaction, logLevel: .debug)26            }27        #endif28        return serializedTransaction29    }3031    public func findSignature(publicKey: PublicKey) throws -> String {32        guard let signature = transaction.findSignature(pubkey: publicKey)?.signature33        else {34            Logger.log(event: "SolanaSwift: findSignature", message: "Signature not found", logLevel: .error)35            throw VersionedTransactionError.signatureNotFound36        }37        return Base58.encode(signature.bytes)38    }39}40