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

Python serialize.b2h_rev函数代码示例

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

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



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

示例1: check_bip143_tx

 def check_bip143_tx(self, tx_u_hex, tx_s_hex, txs_out_value_scripthex_pair, tx_in_count, tx_out_count, version, lock_time):
     tx_u = Tx.from_hex(tx_u_hex)
     tx_s = Tx.from_hex(tx_s_hex)
     txs_out = [
         TxOut(int(coin_value * 1e8), h2b(script_hex)) for coin_value, script_hex in txs_out_value_scripthex_pair
     ]
     for tx in (tx_u, tx_s):
         self.assertEqual(len(tx.txs_in), tx_in_count)
         self.assertEqual(len(tx.txs_out), tx_out_count)
         self.assertEqual(tx.version, version)
         self.assertEqual(tx.lock_time, lock_time)
         tx.set_unspents(txs_out)
     self.check_unsigned(tx_u)
     self.check_signed(tx_s)
     tx_hex = tx_u.as_hex()
     self.assertEqual(tx_hex, tx_u_hex)
     tx_hex = tx_s.as_hex()
     self.assertEqual(tx_hex, tx_s_hex)
     tx_u_prime = self.unsigned_copy(tx_s)
     tx_hex = tx_u_prime.as_hex()
     self.assertEqual(tx_hex, tx_u_hex)
     self.assertEqual(b2h_rev(double_sha256(h2b(tx_s_hex))), tx_s.w_id())
     self.assertEqual(b2h_rev(double_sha256(h2b(tx_u_hex))), tx_u.w_id())
     self.assertEqual(b2h_rev(double_sha256(h2b(tx_u_hex))), tx_u.id())
     return tx_u, tx_s
开发者ID:Stevengu999,项目名称:pycoin,代码行数:25,代码来源:segwit_test.py


示例2: test_h2b

 def test_h2b(self):
     h = "000102"
     b = b"\x00\x01\x02"
     self.assertEqual(h2b(h), b)
     self.assertEqual(b2h(b), h)
     self.assertEqual(h2b_rev(h), b[::-1])
     self.assertEqual(b2h_rev(b), "020100")
开发者ID:E-LLP,项目名称:pycoin,代码行数:7,代码来源:test_serialize.py


示例3: save_spendable

 def save_spendable(self, spendable):
     tx_hash = b2h_rev(spendable.tx_hash)
     script = b2h(spendable.script)
     c = self._exec_sql("insert or replace into Spendable values (?, ?, ?, ?, ?, ?, ?)", tx_hash,
                         spendable.tx_out_index, spendable.coin_value, script,
                         spendable.block_index_available, spendable.does_seem_spent,
                         spendable.block_index_spent)
开发者ID:DOGEtools,项目名称:doge-millionaire,代码行数:7,代码来源:SQLite3Persistence.py


示例4: query_links

 def query_links (self, proxy):
     if self.previous_hash != 0:
         tx = ProxyTx.from_txhash(proxy, b2h_rev(self.previous_hash), do_query_links=False)
         txout = tx.txs_out[self.previous_index]
         self._address = txout.address(addrversion=proxy.addrversion)
         self.coin_value = txout.coin_value
         self.is_shallow = False
开发者ID:nelisky,项目名称:pycoin,代码行数:7,代码来源:proxy.py


示例5: tx_for_tx_hash

 def tx_for_tx_hash(self, tx_hash):
     URL = "%s/api/tx/%s" % (self.base_url, b2h_rev(tx_hash))
     r = json.loads(urlopen(URL).read().decode("utf8"))
     tx = tx_from_json_dict(r)
     if tx.hash() == tx_hash:
         return tx
     return None
开发者ID:Stevengu999,项目名称:pycoin,代码行数:7,代码来源:insight.py


示例6: get_tx

 def get_tx(self, tx_hash):
     url = "%s/rawtx/%s" % (self.base_url, b2h_rev(tx_hash))
     result = json.loads(urlopen(url).read().decode("utf8"))
     tx = Tx.from_hex(result["rawtx"])
     if tx.hash() == tx_hash:
         return tx
     return None
开发者ID:StorjOld,项目名称:btctxstore,代码行数:7,代码来源:blockexplorer.py


示例7: get_tx

 def get_tx(self, tx_hash):
     URL = "%s/api/rawtx/%s" % (self.base_url, b2h_rev(tx_hash))
     r = json.loads(urlopen(URL).read().decode("utf8"))
     tx = Tx.tx_from_hex(r['rawtx'])
     if tx.hash() == tx_hash:
         return tx
     return None
开发者ID:NinjaDevelper,项目名称:btctxstore,代码行数:7,代码来源:insight.py


示例8: reformat

 def reformat(spendable):
     return {
         "txid": b2h_rev(spendable.tx_hash),
         "index": spendable.tx_out_index,
         "value": spendable.coin_value,
         "script": b2h(spendable.script),
     }
开发者ID:hfeeki,项目名称:btctxstore,代码行数:7,代码来源:serialize.py


示例9: dump_inputs

def dump_inputs(tx, netcode, verbose_signature, address_prefix, traceback_f, disassembly_level):

    def signature_for_hash_type_f(hash_type, script):
        return tx.signature_hash(script, idx, hash_type)

    for idx, tx_in in enumerate(tx.txs_in):
        if tx.is_coinbase():
            print("%4d: COINBASE  %12.5f mBTC" % (idx, satoshi_to_mbtc(tx.total_in())))
            continue
        suffix = ""
        if tx.missing_unspent(idx):
            tx_out = None
            address = tx_in.bitcoin_address(address_prefix=address_prefix)
        else:
            tx_out = tx.unspents[idx]
            sig_result = " sig ok" if tx.is_signature_ok(idx, traceback_f=traceback_f) else " BAD SIG"
            suffix = " %12.5f mBTC %s" % (satoshi_to_mbtc(tx_out.coin_value), sig_result)
            address = tx_out.bitcoin_address(netcode=netcode)
        t = "%4d: %34s from %s:%-4d%s" % (idx, address, b2h_rev(tx_in.previous_hash),
                                          tx_in.previous_index, suffix)
        print(t.rstrip())
        if disassembly_level > 0:
            dump_disassembly(tx_in, tx_out, tx.lock_time, signature_for_hash_type_f)

        if verbose_signature:
            dump_signatures(tx, tx_in, tx_out, idx, netcode, address_prefix, traceback_f, disassembly_level)
开发者ID:onestarshang,项目名称:pycoin,代码行数:26,代码来源:tx.py


示例10: get_tx

def get_tx(tx_hash):
    """
    Get a Tx by its hash.
    """
    URL = "%s/tx/raw/%s" % (blockrendpoint.url, b2h_rev(tx_hash))
    r = json.loads(urlopen(URL).read().decode("utf8"))
    tx = Tx.parse(io.BytesIO(h2b(r.get("data").get("tx").get("hex"))))
    return tx
开发者ID:newexo,项目名称:pycoin,代码行数:8,代码来源:blockr_io.py


示例11: get_tx

def get_tx(tx_hash):
    """
    Get a Tx by its hash.
    """
    URL = "http://btc.blockr.io/api/v1/tx/raw/%s" % b2h_rev(tx_hash)
    r = json.loads(urlopen(URL).read().decode("utf8"))
    tx = Tx.parse(io.BytesIO(h2b(r.get("data").get("tx").get("hex"))))
    return tx
开发者ID:Bluejudy,项目名称:pycoin,代码行数:8,代码来源:blockr_io.py


示例12: tx_for_tx_hash

def tx_for_tx_hash(tx_hash):
    URL = "https://api.biteasy.com/blockchain/v1/transactions/%s" % b2h_rev(tx_hash)
    r = Request(URL,
                headers={"content-type": "application/json", "accept": "*/*", "User-Agent": "curl/7.29.0" })
    d = urlopen(r).read()
    tx = json_to_tx(d.decode("utf8"))
    if tx.hash() == tx_hash:
        return tx
    return None
开发者ID:Bluejudy,项目名称:pycoin,代码行数:9,代码来源:biteasy.py


示例13: put

 def put(self, tx):
     name = b2h_rev(tx.hash())
     if self.writable_cache_path:
         try:
             path = os.path.join(self.writable_cache_path, "%s_tx.bin" % name)
             with open(path, "wb") as f:
                 tx.stream(f)
         except IOError:
             pass
开发者ID:Bluejudy,项目名称:pycoin,代码行数:9,代码来源:tx_db.py


示例14: tx_for_tx_hash

 def tx_for_tx_hash(self, tx_hash):
     """
     Get a Tx by its hash.
     """
     url = "%s/rawtx/%s" % (self.url, b2h_rev(tx_hash))
     d = urlopen(url).read()
     j = json.loads(d.decode("utf8"))
     tx = Tx.from_hex(j.get("rawtx", ""))
     if tx.hash() == tx_hash:
         return tx
开发者ID:onestarshang,项目名称:pycoin,代码行数:10,代码来源:blockexplorer.py


示例15: confirms

 def confirms(self, txid):
     try:
         url = "%s/tx/%s" % (self.base_url, b2h_rev(txid))
         result = json.loads(urlopen(url).read().decode("utf8"))
         return result.get("confirmations", 0)
     except HTTPError as ex:
         if ex.code == 404:  # unpublished tx
             return None
         else:
             raise ex
开发者ID:F483,项目名称:btctxstore,代码行数:10,代码来源:insight.py


示例16: tx_for_tx_hash

 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:Stevengu999,项目名称:pycoin,代码行数:12,代码来源:blockcypher.py


示例17: spendable_for_hash_index

 def spendable_for_hash_index(self, tx_hash, tx_out_index):
     tx_hash_hex = b2h_rev(tx_hash)
     SQL = ("select coin_value, script, block_index_available, "
            "does_seem_spent, block_index_spent from Spendable where "
            "tx_hash = ? and tx_out_index = ?")
     c = self._exec_sql(SQL, tx_hash_hex, tx_out_index)
     r = c.fetchone()
     if r is None:
         return r
     return Spendable(coin_value=r[0], script=h2b(r[1]), tx_hash=tx_hash,
                      tx_out_index=tx_out_index, block_index_available=r[2],
                      does_seem_spent=r[3], block_index_spent=r[4])
开发者ID:DOGEtools,项目名称:doge-millionaire,代码行数:12,代码来源:SQLite3Persistence.py


示例18: dump_block

def dump_block(block, network):
    blob = stream_to_bytes(block.stream)
    print("%d bytes   block hash %s" % (len(blob), block.id()))
    print("version %d" % block.version)
    print("prior block hash %s" % b2h_rev(block.previous_block_hash))
    print("merkle root %s" % binascii.hexlify(block.merkle_root).decode("utf8"))
    print("timestamp %s" % datetime.datetime.utcfromtimestamp(block.timestamp).isoformat())
    print("difficulty %d" % block.difficulty)
    print("nonce %s" % block.nonce)
    print("%d transaction%s" % (len(block.txs), "s" if len(block.txs) != 1 else ""))
    for idx, tx in enumerate(block.txs):
        print("Tx #%d:" % idx)
        dump_tx(tx, netcode=network)
开发者ID:Meebleforp79,项目名称:pycoin,代码行数:13,代码来源:block.py


示例19: _fetch_loop

 def _fetch_loop(self, next_message, getdata_loop_future):
     try:
         while True:
             name, data = yield from next_message()
             ITEM_LOOKUP = dict(tx="tx", block="block", merkleblock="header")
             if name in ITEM_LOOKUP:
                 item = data[ITEM_LOOKUP[name]]
                 the_hash = item.hash()
                 TYPE_DB = {"tx": ITEM_TYPE_TX,
                            "block": ITEM_TYPE_BLOCK,
                            "merkleblock": ITEM_TYPE_MERKLEBLOCK}
                 the_type = TYPE_DB[name]
                 inv_item = InvItem(the_type, the_hash)
                 future = self.futures.get(inv_item)
                 if name == "merkleblock":
                     txs = []
                     for h in data["tx_hashes"]:
                         name, data = yield from next_message()
                         if name != "tx":
                             logging.error(
                                 "insufficient tx messages after merkleblock message: missing %s",
                                 b2h_rev(h))
                             del self.futures[inv_item]
                             future.set_result(None)
                             break
                         tx = data["tx"]
                         if tx.hash() != h:
                             logging.error(
                                 "missing tx message after merkleblock message: missing %s", b2h_rev(h))
                             del self.futures[inv_item]
                             future.set_result(None)
                             break
                         txs.append(tx)
                     item.txs = txs
                 if future is not None:
                     del self.futures[inv_item]
                     if not future.done():
                         future.set_result(item)
                     else:
                         logging.info("got %s unsolicited", item.id())
             if name == "notfound":
                 for inv_item in data["items"]:
                     the_hash = inv_item.data
                     future = self.futures.get(inv_item)
                     if future:
                         del self.futures[inv_item]
                         future.set_result(None)
     except EOFError:
         getdata_loop_future.cancel()
开发者ID:E-LLP,项目名称:pycoinnet,代码行数:49,代码来源:Fetcher.py


示例20: dump_block

def dump_block(block, netcode=None):
    if netcode is None:
        netcode = get_current_netcode()
    blob = stream_to_bytes(block.stream)
    print("%d bytes   block hash %s" % (len(blob), block.id()))
    print("version %d" % block.version)
    print("prior block hash %s" % b2h_rev(block.previous_block_hash))
    print("merkle root %s" % b2h(block.merkle_root))
    print("timestamp %s" % datetime.datetime.utcfromtimestamp(block.timestamp).isoformat())
    print("difficulty %d" % block.difficulty)
    print("nonce %s" % block.nonce)
    print("%d transaction%s" % (len(block.txs), "s" if len(block.txs) != 1 else ""))
    for idx, tx in enumerate(block.txs):
        print("Tx #%d:" % idx)
        dump_tx(tx, netcode=netcode, verbose_signature=False, disassembly_level=0, do_trace=False, use_pdb=False)
开发者ID:onestarshang,项目名称:pycoin,代码行数:15,代码来源:block.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python serialize.h2b函数代码示例发布时间:2022-05-25
下一篇:
Python serialize.b2h函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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