
    public static func verifyTransaction(
        signedTx: Transaction, inputIndex: UInt32, utxo: TransactionOutput, blockTimeStamp: UInt32 = UInt32(NSTimeIntervalSince1970)) throws -> Bool {
        // Sanity check: transaction and its input should be consistent.
        guard inputIndex < signedTx.inputs.count else {
            throw ScriptMachineError.exception("Transaction and valid inputIndex are required for script verification.")
        }
        let context = ScriptExecutionContext(transaction: signedTx, utxoToVerify: utxo, inputIndex: inputIndex)!
        context.blockTimeStamp = blockTimeStamp

        let txInput: TransactionInput = signedTx.inputs[Int(inputIndex)]
        guard let unlockScript = Script(data: txInput.signatureScript), let lockScript = Script(data: utxo.lockingScript) else {
            throw ScriptMachineError.error("Both lock script and sig script must be valid.")
        }
