• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python contracts.Contract类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中market.contracts.Contract的典型用法代码示例。如果您正苦于以下问题:Python Contract类的具体用法?Python Contract怎么用?Python Contract使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Contract类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: delete_contract

 def delete_contract(self, request):
     if "id" in request.args:
         c = Contract(hash_value=unhexlify(request.args["id"][0]))
         for keyword in c.contract["vendor_offer"]["listing"]["item"]["keywords"]:
             self.kserver.delete(keyword.lower(), c.get_contract_id(),
                                 KeyChain().signing_key.sign(c.get_contract_id())[:64])
         c.delete()
开发者ID:the9ull,项目名称:OpenBazaar-Server,代码行数:7,代码来源:restapi.py


示例2: confirm_order

 def confirm_order(self, request):
     try:
         def respond(success):
             if success:
                 request.write(json.dumps({"success": True}))
                 request.finish()
             else:
                 request.write(json.dumps({"success": False, "reason": "Failed to send order confirmation"}))
                 request.finish()
         file_path = DATA_FOLDER + "store/contracts/in progress/" + request.args["id"][0] + ".json"
         with open(file_path, 'r') as filename:
             order = json.load(filename, object_pairs_hook=OrderedDict)
         c = Contract(self.db, contract=order, testnet=self.protocol.testnet)
         c.add_order_confirmation(self.protocol.blockchain,
                                  request.args["payout_address"][0],
                                  comments=request.args["comments"][0] if "comments" in request.args else None,
                                  shipper=request.args["shipper"][0] if "shipper" in request.args else None,
                                  tracking_number=request.args["tracking_number"][0]
                                  if "tracking_number" in request.args else None,
                                  est_delivery=request.args["est_delivery"][0]
                                  if "est_delivery" in request.args else None,
                                  url=request.args["url"][0] if "url" in request.args else None,
                                  password=request.args["password"][0] if "password" in request.args else None)
         guid = c.contract["buyer_order"]["order"]["id"]["guid"]
         self.mserver.confirm_order(guid, c).addCallback(respond)
         return server.NOT_DONE_YET
     except Exception, e:
         request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
         request.finish()
         return server.NOT_DONE_YET
开发者ID:syntox,项目名称:OpenBazaar-Server,代码行数:30,代码来源:restapi.py


示例3: set_contract

    def set_contract(self, request):
        print request
        c = Contract()
        c.create(
            str(request.args["expiration_date"][0]),
            request.args["metadata_category"][0],
            request.args["title"][0],
            request.args["description"][0],
            request.args["currency_code"][0],
            request.args["price"][0],
            request.args["process_time"][0],
            True if "nsfw" in request.args else False,
            request.args["shipping_origin"][0],
            request.args["ships_to"],
            est_delivery_domestic=request.args["est_delivery_domestic"][0],
            est_delivery_international=request.args["est_delivery_international"][0],
            shipping_currency_code=request.args["shipping_currency_code"][0],
            shipping_domestic=request.args["shipping_domestic"][0],
            shipping_international=request.args["shipping_international"][0],
            keywords=request.args["keywords"] if "keywords" in request.args else None,
            category=request.args["category"][0] if request.args["category"][0] is not "" else None,
            condition=request.args["condition"][0] if request.args["condition"][0] is not "" else None,
            sku=request.args["sku"][0] if request.args["sku"][0] is not "" else None,
            images=request.args["images"],
            free_shipping=True if "free_shipping" in request.args else False)

        for keyword in request.args["keywords"]:
            self.kserver.set(keyword.lower(), c.get_contract_id(), self.kserver.node.getProto().SerializeToString())
开发者ID:the9ull,项目名称:OpenBazaar-Server,代码行数:28,代码来源:restapi.py


示例4: rpc_order

 def rpc_order(self, sender, pubkey, encrypted):
     try:
         box = Box(PrivateKey(self.signing_key.encode(nacl.encoding.RawEncoder)), PublicKey(pubkey))
         order = box.decrypt(encrypted)
         c = Contract(self.db, contract=json.loads(order, object_pairs_hook=OrderedDict),
                      testnet=self.multiplexer.testnet)
         if c.verify(sender.signed_pubkey[64:]):
             self.router.addContact(sender)
             self.log.info("received an order from %s, waiting for payment..." % sender)
             payment_address = c.contract["buyer_order"]["order"]["payment"]["address"]
             chaincode = c.contract["buyer_order"]["order"]["payment"]["chaincode"]
             masterkey_b = c.contract["buyer_order"]["order"]["id"]["pubkeys"]["bitcoin"]
             buyer_key = derive_childkey(masterkey_b, chaincode)
             amount = c.contract["buyer_order"]["order"]["payment"]["amount"]
             listing_hash = c.contract["buyer_order"]["order"]["ref_hash"]
             signature = self.signing_key.sign(
                 str(payment_address) + str(amount) + str(listing_hash) + str(buyer_key))[:64]
             c.await_funding(self.get_notification_listener(), self.multiplexer.blockchain, signature, False)
             return [signature]
         else:
             self.log.warning("received invalid order from %s" % sender)
             return ["False"]
     except Exception:
         self.log.error("unable to decrypt order from %s" % sender)
         return ["False"]
开发者ID:wmpedersen,项目名称:OpenBazaar-Server,代码行数:25,代码来源:protocol.py


示例5: complete_order

 def complete_order(self, request):
     def respond(success):
         if success:
             request.write(json.dumps({"success": True}))
             request.finish()
         else:
             request.write(json.dumps({"success": False, "reason": "Failed to send receipt to vendor"}))
             request.finish()
     file_path = DATA_FOLDER + "purchases/in progress/" + request.args["id"][0] + ".json"
     with open(file_path, 'r') as filename:
         order = json.load(filename, object_pairs_hook=OrderedDict)
     c = Contract(self.db, contract=order, testnet=self.protocol.testnet)
     c.add_receipt(True,
                   self.protocol.blockchain,
                   feedback=request.args["feedback"][0] if "feedback" in request.args else None,
                   quality=request.args["quality"][0] if "quality" in request.args else None,
                   description=request.args["description"][0] if "description" in request.args else None,
                   delivery_time=request.args["delivery_time"][0]
                   if "delivery_time" in request.args else None,
                   customer_service=request.args["customer_service"][0]
                   if "customer_service" in request.args else None,
                   review=request.args["review"][0] if "review" in request.args else "")
     guid = c.contract["vendor_offer"]["listing"]["id"]["guid"]
     self.mserver.complete_order(guid, c).addCallback(respond)
     return server.NOT_DONE_YET
开发者ID:syntox,项目名称:OpenBazaar-Server,代码行数:25,代码来源:restapi.py


示例6: parse_messages

 def parse_messages(messages):
     if messages is not None:
         for message in messages:
             try:
                 value = objects.Value()
                 value.ParseFromString(message)
                 try:
                     box = Box(PrivateKey(self.signing_key.encode()), PublicKey(value.valueKey))
                     ciphertext = value.serializedData
                     plaintext = box.decrypt(ciphertext)
                     p = objects.Plaintext_Message()
                     p.ParseFromString(plaintext)
                     signature = p.signature
                     p.ClearField("signature")
                     verify_key = nacl.signing.VerifyKey(p.signed_pubkey[64:])
                     verify_key.verify(p.SerializeToString(), signature)
                     h = nacl.hash.sha512(p.signed_pubkey)
                     pow_hash = h[64:128]
                     if int(pow_hash[:6], 16) >= 50 or hexlify(p.sender_guid) != h[:40]:
                         raise Exception('Invalid guid')
                     if p.type == objects.Plaintext_Message.Type.Value("ORDER_CONFIRMATION"):
                         c = Contract(self.db, hash_value=unhexlify(p.subject))
                         c.accept_order_confirmation(self.protocol.multiplexer.ws,
                                                     confirmation_json=p.message)
                     else:
                         listener.notify(p.sender_guid, p.encryption_pubkey, p.subject,
                                         objects.Plaintext_Message.Type.Name(p.type), p.message)
                 except Exception:
                     pass
                 signature = self.signing_key.sign(value.valueKey)[:64]
                 self.kserver.delete(self.kserver.node.id, value.valueKey, signature)
             except Exception:
                 pass
开发者ID:atteeela,项目名称:OpenBazaar-Server,代码行数:33,代码来源:network.py


示例7: rpc_order

 def rpc_order(self, sender, pubkey, encrypted):
     try:
         box = Box(self.signing_key.to_curve25519_private_key(), PublicKey(pubkey))
         order = box.decrypt(encrypted)
         c = Contract(self.db, contract=json.loads(order, object_pairs_hook=OrderedDict),
                      testnet=self.multiplexer.testnet)
         v = c.verify(sender.pubkey)
         if v is True:
             self.router.addContact(sender)
             self.log.info("received an order from %s, waiting for payment..." % sender)
             payment_address = c.contract["buyer_order"]["order"]["payment"]["address"]
             chaincode = c.contract["buyer_order"]["order"]["payment"]["chaincode"]
             masterkey_b = c.contract["buyer_order"]["order"]["id"]["pubkeys"]["bitcoin"]
             buyer_key = derive_childkey(masterkey_b, chaincode)
             amount = c.contract["buyer_order"]["order"]["payment"]["amount"]
             listing_hash = c.contract["vendor_offer"]["listing"]["contract_id"]
             signature = self.signing_key.sign(
                 str(payment_address) + str(amount) + str(listing_hash) + str(buyer_key))[:64]
             c.await_funding(self.get_notification_listener(), self.multiplexer.blockchain, signature, False)
             return [signature]
         else:
             self.log.warning("received invalid order from %s reason %s" % (sender, v))
             return ["False"]
     except Exception, e:
         self.log.error("Exception (%s) occurred processing order from %s" % (e.message, sender))
         return ["False"]
开发者ID:inertia186,项目名称:OpenBazaar-Server,代码行数:26,代码来源:protocol.py


示例8: purchase_contract

    def purchase_contract(self, request):
        try:

            def handle_response(resp, contract):
                if resp:
                    contract.await_funding(
                        self.mserver.protocol.get_notification_listener(), self.protocol.blockchain, resp
                    )
                    request.write(
                        json.dumps(
                            {
                                "success": True,
                                "payment_address": payment[0],
                                "amount": payment[1],
                                "order_id": c.get_contract_id().encode("hex"),
                            },
                            indent=4,
                        )
                    )
                    request.finish()
                else:
                    request.write(json.dumps({"success": False, "reason": "seller rejected contract"}, indent=4))
                    request.finish()

            options = None
            if "options" in request.args:
                options = {}
                for option in request.args["options"]:
                    options[option] = request.args[option][0]
            c = Contract(self.db, hash_value=unhexlify(request.args["id"][0]), testnet=self.protocol.testnet)
            payment = c.add_purchase_info(
                int(request.args["quantity"][0]),
                request.args["ship_to"][0] if "ship_to" in request.args else None,
                request.args["address"][0] if "address" in request.args else None,
                request.args["city"][0] if "city" in request.args else None,
                request.args["state"][0] if "state" in request.args else None,
                request.args["postal_code"][0] if "postal_code" in request.args else None,
                request.args["country"][0] if "country" in request.args else None,
                request.args["moderator"][0] if "moderator" in request.args else None,
                options,
            )

            def get_node(node):
                if node is not None:
                    self.mserver.purchase(node, c).addCallback(handle_response, c)
                else:
                    request.write(json.dumps({"success": False, "reason": "unable to reach vendor"}, indent=4))
                    request.finish()

            seller_guid = unhexlify(c.contract["vendor_offer"]["listing"]["id"]["guid"])
            self.kserver.resolve(seller_guid).addCallback(get_node)
            return server.NOT_DONE_YET
        except Exception, e:
            request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
            request.finish()
            return server.NOT_DONE_YET
开发者ID:HiroIshikawa,项目名称:OpenBazaar-Server,代码行数:56,代码来源:restapi.py


示例9: set_contract

 def set_contract(self, request):
     try:
         if "options" in request.args:
             options = {}
             for option in request.args["options"]:
                 options[option] = request.args[option]
         c = Contract(self.db)
         c.create(
             str(request.args["expiration_date"][0]),
             request.args["metadata_category"][0],
             request.args["title"][0],
             request.args["description"][0],
             request.args["currency_code"][0],
             request.args["price"][0],
             request.args["process_time"][0],
             str_to_bool(request.args["nsfw"][0]),
             shipping_origin=request.args["shipping_origin"][0] if "shipping_origin" in request.args else None,
             shipping_regions=request.args["ships_to"] if "ships_to" in request.args else None,
             est_delivery_domestic=request.args["est_delivery_domestic"][0]
             if "est_delivery_domestic" in request.args
             else None,
             est_delivery_international=request.args["est_delivery_international"][0]
             if "est_delivery_international" in request.args
             else None,
             terms_conditions=request.args["terms_conditions"][0]
             if request.args["terms_conditions"][0] is not ""
             else None,
             returns=request.args["returns"][0] if request.args["returns"][0] is not "" else None,
             shipping_currency_code=request.args["shipping_currency_code"][0],
             shipping_domestic=request.args["shipping_domestic"][0],
             shipping_international=request.args["shipping_international"][0],
             keywords=request.args["keywords"] if "keywords" in request.args else None,
             category=request.args["category"][0] if request.args["category"][0] is not "" else None,
             condition=request.args["condition"][0] if request.args["condition"][0] is not "" else None,
             sku=request.args["sku"][0] if request.args["sku"][0] is not "" else None,
             images=request.args["images"],
             free_shipping=str_to_bool(request.args["free_shipping"][0]),
             options=options if "options" in request.args else None,
             moderators=request.args["moderators"] if "moderators" in request.args else None,
         )
         for keyword in request.args["keywords"]:
             self.kserver.set(
                 digest(keyword.lower()), c.get_contract_id(), self.kserver.node.getProto().SerializeToString()
             )
         request.write(json.dumps({"success": True, "id": c.get_contract_id().encode("hex")}))
         request.finish()
         return server.NOT_DONE_YET
     except Exception, e:
         request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
         request.finish()
         return server.NOT_DONE_YET
开发者ID:HiroIshikawa,项目名称:OpenBazaar-Server,代码行数:51,代码来源:restapi.py


示例10: rpc_refund

 def rpc_refund(self, sender, pubkey, encrypted):
     try:
         box = Box(self.signing_key.to_curve25519_private_key(), PublicKey(pubkey))
         refund = box.decrypt(encrypted)
         refund_json = json.loads(refund, object_pairs_hook=OrderedDict)
         c = Contract(self.db, hash_value=unhexlify(refund_json["refund"]["order_id"]),
                      testnet=self.multiplexer.testnet)
         c.process_refund(refund_json, self.multiplexer.blockchain, self.get_notification_listener())
         self.router.addContact(sender)
         self.log.info("order %s refunded by vendor" % refund_json["refund"]["order_id"])
         return ["True"]
     except Exception, e:
         self.log.error("unable to parse refund message from %s" % sender)
         return [e.message]
开发者ID:inertia186,项目名称:OpenBazaar-Server,代码行数:14,代码来源:protocol.py


示例11: rpc_complete_order

    def rpc_complete_order(self, sender, pubkey, encrypted):
        try:
            box = Box(PrivateKey(self.signing_key.encode(nacl.encoding.RawEncoder)), PublicKey(pubkey))
            order = box.decrypt(encrypted)
            c = Contract(self.db, contract=json.loads(order, object_pairs_hook=OrderedDict),
                         testnet=self.multiplexer.testnet)

            contract_id = c.accept_receipt(self.get_notification_listener(), self.multiplexer.blockchain)
            self.router.addContact(sender)
            self.log.info("received receipt for order %s" % contract_id)
            return ["True"]
        except Exception:
            self.log.error("unable to parse receipt from %s" % sender)
            return ["False"]
开发者ID:wmpedersen,项目名称:OpenBazaar-Server,代码行数:14,代码来源:protocol.py


示例12: delete_contract

 def delete_contract(self, request):
     try:
         if "id" in request.args:
             c = Contract(self.db, hash_value=unhexlify(request.args["id"][0]))
             for keyword in c.contract["vendor_offer"]["listing"]["item"]["keywords"]:
                 self.kserver.delete(keyword.lower(), c.get_contract_id(),
                                     self.keychain.signing_key.sign(c.get_contract_id())[:64])
             c.delete()
         request.write(json.dumps({"success": True}))
         request.finish()
         return server.NOT_DONE_YET
     except Exception, e:
         request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
         request.finish()
         return server.NOT_DONE_YET
开发者ID:jamesdwilson,项目名称:OpenBazaar-Server,代码行数:15,代码来源:restapi.py


示例13: rpc_order_confirmation

 def rpc_order_confirmation(self, sender, pubkey, encrypted):
     try:
         box = Box(self.signing_key.to_curve25519_private_key(), PublicKey(pubkey))
         order = box.decrypt(encrypted)
         c = Contract(self.db, contract=json.loads(order, object_pairs_hook=OrderedDict),
                      testnet=self.multiplexer.testnet)
         valid = c.accept_order_confirmation(self.get_notification_listener())
         if valid is True:
             self.router.addContact(sender)
             self.log.info("received confirmation for order %s" % c.get_order_id())
             return ["True"]
         else:
             self.log.warning("received invalid order confirmation from %s" % sender)
             return [valid]
     except Exception, e:
         self.log.error("unable to decrypt order confirmation from %s" % sender)
         return [str(e.message)]
开发者ID:inertia186,项目名称:OpenBazaar-Server,代码行数:17,代码来源:protocol.py


示例14: rpc_order_confirmation

 def rpc_order_confirmation(self, sender, pubkey, encrypted):
     try:
         box = Box(PrivateKey(self.signing_key.encode(nacl.encoding.RawEncoder)), PublicKey(pubkey))
         order = box.decrypt(encrypted)
         c = Contract(self.db, contract=json.loads(order, object_pairs_hook=OrderedDict),
                      testnet=self.multiplexer.testnet)
         contract_id = c.accept_order_confirmation(self.multiplexer.ws)
         if contract_id:
             self.router.addContact(sender)
             self.log.info("received confirmation for order %s" % contract_id)
             return ["True"]
         else:
             self.log.warning("received invalid order confirmation from %s" % sender)
             return ["False"]
     except Exception:
         self.log.error("unable to decrypt order confirmation from %s" % sender)
         return ["False"]
开发者ID:tasatko,项目名称:OpenBazaar-Server,代码行数:17,代码来源:protocol.py


示例15: delete_contract

 def delete_contract(self, request):
     try:
         if "id" in request.args:
             file_path = self.db.HashMap().get_file(request.args["id"][0])
             with open(file_path, "r") as filename:
                 contract = json.load(filename, object_pairs_hook=OrderedDict)
             c = Contract(self.db, contract=contract)
             if "keywords" in c.contract["vendor_offer"]["listing"]["item"]:
                 for keyword in c.contract["vendor_offer"]["listing"]["item"]["keywords"]:
                     self.kserver.delete(
                         keyword.lower(),
                         c.get_contract_id(),
                         self.keychain.signing_key.sign(c.get_contract_id())[:64],
                     )
             if "delete_images" in request.args:
                 c.delete(delete_images=True)
             else:
                 c.delete()
         request.write(json.dumps({"success": True}))
         request.finish()
         return server.NOT_DONE_YET
     except Exception, e:
         request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
         request.finish()
         return server.NOT_DONE_YET
开发者ID:HiroIshikawa,项目名称:OpenBazaar-Server,代码行数:25,代码来源:restapi.py


示例16: rpc_complete_order

    def rpc_complete_order(self, sender, pubkey, encrypted):
        try:
            box = Box(self.signing_key.to_curve25519_private_key(), PublicKey(pubkey))
            order = box.decrypt(encrypted)
            json.loads(order, object_pairs_hook=OrderedDict)
            temp = Contract(self.db, contract=json.loads(order, object_pairs_hook=OrderedDict),
                            testnet=self.multiplexer.testnet)
            c = Contract(self.db, hash_value=unhexlify(temp.get_order_id()),
                         testnet=self.multiplexer.testnet)

            contract_id = c.accept_receipt(self.get_notification_listener(),
                                           self.multiplexer.blockchain,
                                           receipt_json=json.dumps(temp.contract["buyer_receipt"], indent=4))
            self.router.addContact(sender)
            self.log.info("received receipt for order %s" % contract_id)
            return ["True"]
        except Exception, e:
            self.log.error("unable to parse receipt from %s" % sender)
            return [e.message]
开发者ID:inertia186,项目名称:OpenBazaar-Server,代码行数:19,代码来源:protocol.py


示例17: rpc_order

 def rpc_order(self, sender, pubkey, encrypted):
     try:
         box = Box(PrivateKey(self.signing_key.encode(nacl.encoding.RawEncoder)), PublicKey(pubkey))
         order = box.decrypt(encrypted)
         c = Contract(self.db, contract=json.loads(order, object_pairs_hook=OrderedDict),
                      testnet=self.multiplexer.testnet)
         if c.verify(sender.signed_pubkey[64:]):
             self.router.addContact(sender)
             self.log.info("Received an order from %s" % sender)
             payment_address = c.contract["buyer_order"]["order"]["payment"]["address"]
             signature = self.signing_key.sign(str(payment_address))[:64]
             c.await_funding(self.multiplexer.ws, self.multiplexer.blockchain, signature, False)
             return [signature]
         else:
             self.log.error("Received invalid order from %s" % sender)
             return ["False"]
     except Exception:
         self.log.error("Unable to decrypt order from %s" % sender)
         return ["False"]
开发者ID:JimmyMow,项目名称:OpenBazaar-Server,代码行数:19,代码来源:protocol.py


示例18: check_for_payment

    def check_for_payment(self, request):
        if not self.protocol.blockchain.connected:
            request.write(json.dumps({"success": False, "reason": "libbitcoin server offline"}, indent=4))
            request.finish()
            return server.NOT_DONE_YET
        try:
            file_path = DATA_FOLDER + "purchases/unfunded/" + request.args["order_id"][0] + ".json"
            with open(file_path, 'r') as filename:
                order = json.load(filename, object_pairs_hook=OrderedDict)
            c = Contract(self.db, contract=order, testnet=self.protocol.testnet)
            self.protocol.blockchain.refresh_connection()
            c.blockchain = self.protocol.blockchain
            c.notification_listener = self.mserver.protocol.get_notification_listener()
            c.is_purchase = True
            addr = c.contract["buyer_order"]["order"]["payment"]["address"]

            def history_fetched(ec, history):
                if not ec:
                    # pylint: disable=W0612
                    # pylint: disable=W0640
                    for objid, txhash, index, height, value in history:
                        def cb_txpool(ec, result):
                            if ec:
                                self.protocol.blockchain.fetch_transaction(txhash, cb_chain)
                            else:
                                c.on_tx_received(None, None, None, None, result)

                        def cb_chain(ec, result):
                            if not ec:
                                c.on_tx_received(None, None, None, None, result)

                        self.protocol.blockchain.fetch_txpool_transaction(txhash, cb_txpool)

            self.protocol.blockchain.fetch_history2(addr, history_fetched)

            request.write(json.dumps({"success": True}, indent=4))
            request.finish()
            return server.NOT_DONE_YET
        except Exception, e:
            request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
            request.finish()
            return server.NOT_DONE_YET
开发者ID:syntox,项目名称:OpenBazaar-Server,代码行数:42,代码来源:restapi.py


示例19: rpc_complete_order

    def rpc_complete_order(self, sender, pubkey, encrypted):
        try:
            box = Box(PrivateKey(self.signing_key.encode(nacl.encoding.RawEncoder)), PublicKey(pubkey))
            order = box.decrypt(encrypted)
            c = Contract(self.db, contract=json.loads(order, object_pairs_hook=OrderedDict),
                         testnet=self.multiplexer.testnet)

            def handle_result(contract_id):
                if contract_id:
                    self.router.addContact(sender)
                    self.log.info("Received receipt for order %s" % contract_id)
                    return ["True"]
                else:
                    self.log.error("Received invalid receipt from %s" % sender)
                    return ["False"]
            d = c.accept_receipt(self.multiplexer.ws, self.multiplexer.blockchain)
            d.addCallback(handle_result)
        except Exception:
            self.log.error("Unable to decrypt order receipt from %s" % sender)
            return ["False"]
开发者ID:pjam76,项目名称:OpenBazaar-Server,代码行数:20,代码来源:protocol.py


示例20: parse_messages

 def parse_messages(messages):
     if messages is not None:
         self.log.info("retrieved %s message(s) from the dht" % len(messages))
         for message in messages:
             try:
                 value = objects.Value()
                 value.ParseFromString(message)
                 try:
                     box = Box(self.signing_key.to_curve25519_private_key(), PublicKey(value.valueKey))
                     ciphertext = value.serializedData
                     plaintext = box.decrypt(ciphertext).decode("zlib")
                     p = objects.PlaintextMessage()
                     p.ParseFromString(plaintext)
                     signature = p.signature
                     p.ClearField("signature")
                     verify_key = nacl.signing.VerifyKey(p.pubkey)
                     verify_key.verify(p.SerializeToString(), signature)
                     h = nacl.hash.sha512(p.pubkey)
                     pow_hash = h[40:]
                     if int(pow_hash[:6], 16) >= 50 or p.sender_guid.encode("hex") != h[:40]:
                         raise Exception("Invalid guid")
                     if p.type == objects.PlaintextMessage.Type.Value("ORDER_CONFIRMATION"):
                         c = Contract(
                             self.db, hash_value=unhexlify(p.subject), testnet=self.protocol.multiplexer.testnet
                         )
                         c.accept_order_confirmation(
                             self.protocol.get_notification_listener(), confirmation_json=p.message
                         )
                     elif p.type == objects.PlaintextMessage.Type.Value("RECEIPT"):
                         c = Contract(
                             self.db, hash_value=unhexlify(p.subject), testnet=self.protocol.multiplexer.testnet
                         )
                         c.accept_receipt(
                             self.protocol.get_notification_listener(),
                             self.protocol.multiplexer.blockchain,
                             receipt_json=p.message,
                         )
                     elif p.type == objects.PlaintextMessage.Type.Value("DISPUTE_OPEN"):
                         process_dispute(
                             json.loads(p.message, object_pairs_hook=OrderedDict),
                             self.db,
                             self.protocol.get_message_listener(),
                             self.protocol.get_notification_listener(),
                             self.protocol.multiplexer.testnet,
                         )
                     else:
                         listener.notify(p, signature)
                 except Exception:
                     pass
                 signature = self.signing_key.sign(value.valueKey)[:64]
                 self.kserver.delete(self.kserver.node.id, value.valueKey, signature)
             except Exception:
                 pass
开发者ID:tcharding,项目名称:OpenBazaar-Server,代码行数:53,代码来源:network.py



注:本文中的market.contracts.Contract类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.AddonPremium类代码示例发布时间:2022-05-27
下一篇:
Python market.Market类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap