@GET('^/api/v1/get_order')
    @authenticated
    def get_order(self, request):
        #TODO: if this is either a funded direct payment sale or complete moderated sale but
        #TODO: the payout tx has not hit the blockchain, rebroadcast.

        filename = request.args["order_id"][0] + ".json"
        if os.path.exists(os.path.join(DATA_FOLDER, "purchases", "unfunded", filename)):
            file_path = os.path.join(DATA_FOLDER, "purchases", "unfunded", filename)
            status = self.db.purchases.get_status(request.args["order_id"][0])
        elif os.path.exists(os.path.join(DATA_FOLDER, "purchases", "in progress", filename)):
            file_path = os.path.join(DATA_FOLDER, "purchases", "in progress", filename)
            status = self.db.purchases.get_status(request.args["order_id"][0])
        elif os.path.exists(os.path.join(DATA_FOLDER, "purchases", "trade receipts", filename)):
            file_path = os.path.join(DATA_FOLDER, "purchases", "trade receipts", filename)
            status = self.db.purchases.get_status(request.args["order_id"][0])
        elif os.path.exists(os.path.join(DATA_FOLDER, "store", "contracts", "unfunded", filename)):
            file_path = os.path.join(DATA_FOLDER, "store", "contracts", "unfunded", filename)
            status = self.db.sales.get_status(request.args["order_id"][0])
        elif os.path.exists(os.path.join(DATA_FOLDER, "store", "contracts", "in progress", filename)):
            file_path = os.path.join(DATA_FOLDER, "store", "contracts", "in progress", filename)
            status = self.db.sales.get_status(request.args["order_id"][0])
        elif os.path.exists(os.path.join(DATA_FOLDER, "store", "contracts", "trade receipts", filename)):
            file_path = os.path.join(DATA_FOLDER, "store", "contracts", "trade receipts", filename)
            status = self.db.sales.get_status(request.args["order_id"][0])
        elif os.path.exists(os.path.join(DATA_FOLDER, "cases", filename)):
            file_path = os.path.join(DATA_FOLDER, "cases", filename)
            status = 4
        else:
            request.write(json.dumps({}, indent=4))
            request.finish()
            return server.NOT_DONE_YET

        with open(file_path, 'r') as filename:
            order = json.load(filename, object_pairs_hook=OrderedDict)

        if status == 0 or status == 2:
            check_order_for_payment(request.args["order_id"][0], self.db, self.protocol.blockchain,
                                    self.mserver.protocol.get_notification_listener(),
                                    self.protocol.testnet)

        def return_order():
            request.setHeader('content-type', "application/json")
            request.write(json.dumps(sanitize_html(order), indent=4))
            request.finish()

        def height_fetched(ec, chain_height):
            payment_address = order["buyer_order"]["order"]["payment"]["address"]
            txs = []
            def history_fetched(ec, history):
                if ec:
                    return_order()
                elif timeout.active():
                    timeout.cancel()
                    for tx_type, txid, i, height, value in history:  # pylint: disable=W0612
                        tx = {
                            "txid": txid.encode("hex"),
                            "value": round(float(value) / 100000000, 8),
                            "confirmations": chain_height - height + 1 if height != 0 else 0
                        }

                        if tx_type == obelisk.PointIdent.Output:
                            tx["type"] = "incoming"
                        else:
                            tx["type"] = "outgoing"
                        txs.append(tx)
                    order["bitcoin_txs"] = txs
                    request.setHeader('content-type', "application/json")
                    request.write(json.dumps(order, indent=4))
                    request.finish()
            self.protocol.blockchain.fetch_history2(payment_address, history_fetched)

        if self.protocol.blockchain.connected:
            self.protocol.blockchain.fetch_last_height(height_fetched)
            timeout = reactor.callLater(4, return_order)
        else:
            return_order()
        return server.NOT_DONE_YET
dataset/ETHPy150Open OpenBazaar/OpenBazaar-Server/api/restapi.py/OpenBazaarAPI.get_order/original