当前位置: 首页>>代码示例>>Python>>正文


Python Contract.accept_order_confirmation方法代码示例

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


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

示例1: parse_messages

# 需要导入模块: from market.contracts import Contract [as 别名]
# 或者: from market.contracts.Contract import accept_order_confirmation [as 别名]
 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,代码行数:35,代码来源:network.py

示例2: parse_messages

# 需要导入模块: from market.contracts import Contract [as 别名]
# 或者: from market.contracts.Contract import accept_order_confirmation [as 别名]
 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,代码行数:55,代码来源:network.py

示例3: rpc_order_confirmation

# 需要导入模块: from market.contracts import Contract [as 别名]
# 或者: from market.contracts.Contract import accept_order_confirmation [as 别名]
 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.get_notification_listener())
         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:wmpedersen,项目名称:OpenBazaar-Server,代码行数:19,代码来源:protocol.py

示例4: rpc_order_confirmation

# 需要导入模块: from market.contracts import Contract [as 别名]
# 或者: from market.contracts.Contract import accept_order_confirmation [as 别名]
 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,代码行数:19,代码来源:protocol.py


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