def open_dispute(self, order_id, claim):
        """
        Given and order ID we will pull the contract from disk and send it along with the claim
        to both the moderator and other party to the dispute. If either party isn't online we will stick
        it in the DHT for them.
        """
        try:
            file_path = os.path.join(DATA_FOLDER, "purchases", "in progress", order_id + ".json")
            with open(file_path, 'r') as filename:
                contract = json.load(filename, object_pairs_hook=OrderedDict)
                guid = contract["vendor_offer"]["listing"]["id"]["guid"]
                handle = ""
                if "blockchain_id" in contract["vendor_offer"]["listing"]["id"]:
                    handle = contract["vendor_offer"]["listing"]["id"]["blockchain_id"]
                guid_key = contract["vendor_offer"]["listing"]["id"]["pubkeys"]["guid"]
                proof_sig = self.db.purchases.get_proof_sig(order_id)
        except Exception:
            try:
                file_path = os.path.join(DATA_FOLDER, "store", "contracts", "in progress", order_id + ".json")
                with open(file_path, 'r') as filename:
                    contract = json.load(filename, object_pairs_hook=OrderedDict)
                    guid = contract["buyer_order"]["order"]["id"]["guid"]
                    handle = ""
                    if "blockchain_id" in contract["buyer_order"]["order"]["id"]:
                        handle = contract["buyer_order"]["order"]["id"]["blockchain_id"]
                    guid_key = contract["buyer_order"]["order"]["id"]["pubkeys"]["guid"]
                    proof_sig = None
            except Exception:
                return False

        if "dispute" not in contract:
            keychain = KeyChain(self.db)
            contract["dispute"] = {}
            contract["dispute"]["info"] = {}
            contract["dispute"]["info"]["claim"] = claim
            contract["dispute"]["info"]["guid"] = keychain.guid.encode("hex")
            contract["dispute"]["info"]["avatar_hash"] = Profile(self.db).get().avatar_hash.encode("hex")
            if proof_sig:
                contract["dispute"]["info"]["proof_sig"] = base64.b64encode(proof_sig)
            info = json.dumps(contract["dispute"]["info"], indent=4)
            contract["dispute"]["signature"] = base64.b64encode(keychain.signing_key.sign(info)[:64])
            with open(file_path, 'wb') as outfile:
                outfile.write(json.dumps(contract, indent=4))

            if self.db.purchases.get_purchase(order_id) is not None:
                self.db.purchases.update_status(order_id, 4)

            elif self.db.sales.get_sale(order_id) is not None:
                self.db.sales.update_status(order_id, 4)

            avatar_hash = Profile(self.db).get().avatar_hash

            self.db.messages.save_message(guid, handle, "", order_id, "DISPUTE_OPEN",
                                          claim, time.time(), avatar_hash, "", True)

        mod_guid = contract["buyer_order"]["order"]["moderator"]
        for mod in contract["vendor_offer"]["listing"]["moderators"]:
            if mod["guid"] == mod_guid:
                mod_key = mod["pubkeys"]["guid"]

        def get_node(node_to_ask, recipient_guid, public_key):
            def parse_response(response):
                if not response[0]:
                    self.send_message(Node(unhexlify(recipient_guid)),
                                      nacl.signing.VerifyKey(
                                          public_key,
                                          encoder=nacl.encoding.HexEncoder).to_curve25519_public_key().encode(),
                                      objects.PlaintextMessage.Type.Value("DISPUTE_OPEN"),
                                      json.dumps(contract),
                                      order_id,
                                      store_only=True)

            if node_to_ask:
                enc_key = nacl.signing.VerifyKey(
                    public_key, encoder=nacl.encoding.HexEncoder).to_curve25519_public_key()
                skephem = PrivateKey.generate()
                pkephem = skephem.public_key.encode(nacl.encoding.RawEncoder)
                box = Box(skephem, enc_key)
                nonce = nacl.utils.random(Box.NONCE_SIZE)
                ciphertext = box.encrypt(json.dumps(contract, indent=4), nonce)
                d = self.protocol.callDisputeOpen(node_to_ask, pkephem, ciphertext)
                return d.addCallback(parse_response)
            else:
                return parse_response([False])

        self.kserver.resolve(unhexlify(guid)).addCallback(get_node, guid, guid_key)
        self.kserver.resolve(unhexlify(mod_guid)).addCallback(get_node, mod_guid, mod_key)
dataset/ETHPy150Open OpenBazaar/OpenBazaar-Server/market/network.py/Server.open_dispute/original