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


Python Tx.parse方法代码示例

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


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

示例1: parse_tx

# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import parse [as 别名]
def parse_tx(arg, parser, tx_db, network):
    # hex transaction id
    tx = None

    if TX_ID_RE.match(arg):
        if tx_db is None:
            tx_db = create_tx_db(network)
        tx = tx_db.get(h2b_rev(arg))
        if not tx:
            parser.error("can't find Tx with id %s" % arg)
        return tx, tx_db

    # hex transaction data
    try:
        return Tx.from_hex(arg), tx_db
    except Exception:
        pass

    if os.path.exists(arg):
        try:
            with open(arg, "rb") as f:
                if f.name.endswith("hex"):
                    f = io.BytesIO(codecs.getreader("hex_codec")(f).read())
                tx = Tx.parse(f)
                tx.parse_unspents(f)
        except Exception:
            pass

    return tx, tx_db
开发者ID:onestarshang,项目名称:pycoin,代码行数:31,代码来源:tx.py

示例2: tx_for_tx_hash

# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import parse [as 别名]
 def tx_for_tx_hash(self, tx_hash):
     """
     returns the pycoin.tx object for tx_hash
     """
     try:
         url_append = "?token=%s&includeHex=true" % self.api_key
         url = self.base_url("txs/%s%s" % (b2h_rev(tx_hash), url_append))
         result = json.loads(urlopen(url).read().decode("utf8"))
         tx = Tx.parse(io.BytesIO(h2b(result.get("hex"))))
         return tx
     except:
         raise Exception
开发者ID:onestarshang,项目名称:pycoin,代码行数:14,代码来源:blockcypher.py

示例3: get

# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import parse [as 别名]
 def get(self, key):
     for path in self.paths_for_hash(key):
         try:
             tx = Tx.parse(open(path, "rb"))
             if tx and tx.hash() == key:
                 return tx
         except IOError:
             pass
     for method in self.lookup_methods:
         try:
             tx = method(key)
             if tx and tx.hash() == key:
                 self.put(tx)
                 return tx
         except Exception:
             pass
     return None
开发者ID:Bluejudy,项目名称:pycoin,代码行数:19,代码来源:tx_db.py

示例4: test_validate_multisig

# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import parse [as 别名]
 def test_validate_multisig(self):
     # this is a transaction in the block chain
     # the unspents are included too, so it can be validated
     f = io.BytesIO(h2b(
         "01000000025718fb915fb8b3a802bb699ddf04dd91261ef6715f5f2820a2b1b9b7e38b"
         "4f27000000004a004830450221008c2107ed4e026ab4319a591e8d9ec37719cdea0539"
         "51c660566e3a3399428af502202ecd823d5f74a77cc2159d8af2d3ea5d36a702fef9a7"
         "edaaf562aef22ac35da401ffffffff038f52231b994efb980382e4d804efeadaee13cf"
         "e01abe0d969038ccb45ec17000000000490047304402200487cd787fde9b337ab87f9f"
         "e54b9fd46d5d1692aa58e97147a4fe757f6f944202203cbcfb9c0fc4e3c453938bbea9"
         "e5ae64030cf7a97fafaf460ea2cb54ed5651b501ffffffff0100093d00000000001976"
         "a9144dc39248253538b93d3a0eb122d16882b998145888ac0000000002000000000000"
         "004751210351efb6e91a31221652105d032a2508275f374cea63939ad72f1b1e02f477"
         "da782100f2b7816db49d55d24df7bdffdbc1e203b424e8cd39f5651ab938e5e4a19356"
         "9e52ae404b4c00000000004751210351efb6e91a31221652105d032a2508275f374cea"
         "63939ad72f1b1e02f477da7821004f0331742bbc917ba2056a3b8a857ea47ec088dd10"
         "475ea311302112c9d24a7152ae"))
     tx = Tx.parse(f)
     tx.parse_unspents(f)
     self.assertEqual(tx.id(), "70c4e749f2b8b907875d1483ae43e8a6790b0c8397bbb33682e3602617f9a77a")
     self.assertEqual(tx.bad_signature_count(), 0)
开发者ID:onestarshang,项目名称:pycoin,代码行数:23,代码来源:pay_to_test.py

示例5: test_recognize_multisig

# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import parse [as 别名]
 def test_recognize_multisig(self):
     h = (
         "010000000139c92b102879eb95f14e7344e4dd7d481e1238b1bfb1fa0f735068d2927b"
         "231400000000910047304402208fc06d216ebb4b6a3a3e0f906e1512c372fa8a9c2a92"
         "505d04e9b451ea7acd0c0220764303bb7e514ddd77855949d941c934e9cbda8e3c3827"
         "bfdb5777477e73885b014730440220569ec6d2e81625dd18c73920e0079cdb4c1d67d3"
         "d7616759eb0c18cf566b3d3402201c60318f0a62e3ba85ca0f158d4dfe63c0779269eb"
         "6765b6fc939fc51e7a8ea901ffffffff0140787d01000000001976a914641ad5051edd"
         "97029a003fe9efb29359fcee409d88ac0000000040787d0100000000c952410496ec45"
         "f878b62c46c4be8e336dff7cc58df9b502178cc240eb3d31b1266f69f5767071aa3e01"
         "7d1b82a0bb28dab5e27d4d8e9725b3e68ed5f8a2d45c730621e34104cc71eb30d653c0"
         "c3163990c47b976f3fb3f37cccdcbedb169a1dfef58bbfbfaff7d8a473e7e2e6d317b8"
         "7bafe8bde97e3cf8f065dec022b51d11fcdd0d348ac4410461cbdcc5409fb4b4d42b51"
         "d33381354d80e550078cb532a34bfa2fcfdeb7d76519aecc62770f5b0e4ef8551946d8"
         "a540911abe3e7854a26f39f58b25c15342af53ae")
     f = io.BytesIO(h2b(h))
     tx = Tx.parse(f)
     tx.parse_unspents(f)
     self.assertEqual(tx.id(), "10c61e258e0a2b19b245a96a2d0a1538fe81cd4ecd547e0a3df7ed6fd3761ada")
     the_script = tx.unspents[0].script
     s = script_obj_from_script(tx.unspents[0].script)
     self.assertEqual(s.script(), the_script)
开发者ID:onestarshang,项目名称:pycoin,代码行数:24,代码来源:pay_to_test.py

示例6: deserialize

# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import parse [as 别名]
def deserialize(tx_data):
    return Tx.parse(BytesIO(tx_data))
开发者ID:uwecerron,项目名称:ngcccbase,代码行数:4,代码来源:pycoin_txcons.py

示例7: tx_from_b64

# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import parse [as 别名]
 def tx_from_b64(h):
     f = io.BytesIO(binascii.a2b_base64(h.encode("utf8")))
     return Tx.parse(f)
开发者ID:onestarshang,项目名称:pycoin,代码行数:5,代码来源:validate_tx_test.py

示例8: tx_for_tx_hash

# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import parse [as 别名]
 def tx_for_tx_hash(self, tx_hash):
     "Get a Tx by its hash."
     url = self.base_url("get_tx", b2h_rev(tx_hash))
     r = json.loads(urlopen(url).read().decode("utf8"))
     tx = Tx.parse(io.BytesIO(h2b(r.get("data").get("tx_hex"))))
     return tx
开发者ID:onestarshang,项目名称:pycoin,代码行数:8,代码来源:chain_so.py


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