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


Python Transaction.deserialize方法代码示例

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


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

示例1: signtransaction

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import deserialize [as 别名]
 def signtransaction(self, tx, privkey=None):
     """Sign a transaction. The wallet keys will be used unless a private key is provided."""
     t = Transaction(tx)
     t.deserialize()
     if privkey:
         pubkey = bitcoin.public_key_from_private_key(privkey)
         t.sign({pubkey:privkey})
     else:
         self.wallet.sign_transaction(t, self.password)
     return t
开发者ID:mnaamani,项目名称:electrum,代码行数:12,代码来源:commands.py

示例2: gettransaction

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import deserialize [as 别名]
 def gettransaction(self, txid, deserialized=False):
     """Retrieve a transaction. """
     tx = self.wallet.transactions.get(txid) if self.wallet else None
     if tx is None and self.network:
         raw = self.network.synchronous_get(('blockchain.transaction.get', [txid]))
         if raw:
             tx = Transaction(raw)
         else:
             raise BaseException("Unknown transaction")
     return tx.deserialize() if deserialized else tx
开发者ID:mnaamani,项目名称:electrum,代码行数:12,代码来源:commands.py

示例3: tx_response

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import deserialize [as 别名]
 def tx_response(self, response):
     params, result = self.parse_response(response)
     if not params:
         return
     tx_hash, tx_height = params
     assert tx_hash == hash_encode(sha256(result.decode('hex')))
     tx = Transaction(result)
     try:
         tx.deserialize()
     except Exception:
         self.print_msg("cannot deserialize transaction, skipping", tx_hash)
         return
     self.wallet.receive_tx_callback(tx_hash, tx, tx_height)
     self.requested_tx.remove((tx_hash, tx_height))
     self.print_error("received tx:", tx_hash, len(tx.raw))
     # callbacks
     self.network.trigger_callback('new_transaction', (tx,))
     if not self.requested_tx:
         self.network.trigger_callback('updated')
开发者ID:mazaclub,项目名称:electrum-grs,代码行数:21,代码来源:synchronizer.py

示例4: getrawtransaction

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import deserialize [as 别名]
    def getrawtransaction(self, tx_hash):
        if self.wallet:
            tx = self.wallet.transactions.get(tx_hash)
            if tx:
                return tx

        raw = self.network.synchronous_get([ ('blockchain.transaction.get',[tx_hash]) ])[0]
        if raw:
            return Transaction.deserialize(raw)
        else:
            return "unknown transaction"
开发者ID:9cat,项目名称:electrum-tpc,代码行数:13,代码来源:commands.py

示例5: tx_response

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import deserialize [as 别名]
    def tx_response(self, response):
        params, result = self.parse_response(response)
        if not params:
            return
        tx_hash, tx_height = params
        assert tx_hash == hash_encode(Hash(result.decode('hex')))
        tx = Transaction(result)
        try:
            tx.deserialize()
        except Exception:
            self.print_msg("cannot deserialize transaction, skipping", tx_hash)
            return

        self.wallet.receive_tx_callback(tx_hash, tx, tx_height)
        self.requested_tx.remove((tx_hash, tx_height))
        self.print_error("received tx:", tx_hash, len(tx.raw))
        if not self.requested_tx:
            self.network.trigger_callback('updated')
            # Updated gets called too many times from other places as
            # well; if we used that signal we get the notification
            # three times
            self.network.trigger_callback("new_transaction")
开发者ID:Frankie-666,项目名称:electrum-dash,代码行数:24,代码来源:synchronizer.py

示例6: sendrawtransaction

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import deserialize [as 别名]
 def sendrawtransaction(self, raw):
     tx = Transaction.deserialize(raw)
     return self.network.synchronous_get([('blockchain.transaction.broadcast', [str(tx)])])[0]
开发者ID:9cat,项目名称:electrum-tpc,代码行数:5,代码来源:commands.py

示例7: decoderawtransaction

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import deserialize [as 别名]
 def decoderawtransaction(self, raw):
     tx = Transaction.deserialize(raw)
     return {'inputs':tx.inputs, 'outputs':tx.outputs}
开发者ID:9cat,项目名称:electrum-tpc,代码行数:5,代码来源:commands.py

示例8: signrawtransaction

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import deserialize [as 别名]
 def signrawtransaction(self, raw_tx, private_keys):
     tx = Transaction.deserialize(raw_tx)
     self.wallet.signrawtransaction(tx, private_keys, self.password)
     return tx
开发者ID:9cat,项目名称:electrum-tpc,代码行数:6,代码来源:commands.py

示例9: deserialize

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import deserialize [as 别名]
 def deserialize(self, tx):
     """Deserialize a serialized transaction"""
     t = Transaction(tx)
     return t.deserialize()
开发者ID:mnaamani,项目名称:electrum,代码行数:6,代码来源:commands.py

示例10: decoderawtransaction

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import deserialize [as 别名]
 def decoderawtransaction(self, raw):
     tx = Transaction(raw)
     return tx.deserialize()
开发者ID:ROIV,项目名称:ViorCoin-ElectrumWallet,代码行数:5,代码来源:commands.py

示例11: signtxwithwallet

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import deserialize [as 别名]
 def signtxwithwallet(self, raw_tx):
     tx = Transaction(raw_tx)
     tx.deserialize()
     self.wallet.sign_transaction(tx, self.password)
     return tx
开发者ID:vergecurrency,项目名称:electrum-xvg-tor,代码行数:7,代码来源:commands.py

示例12: run_interface

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import deserialize [as 别名]

#.........这里部分代码省略.........
                except Queue.Empty:
                    break
                new_addresses.append(addr)
            if new_addresses:
                self.subscribe_to_addresses(new_addresses)

            # request missing transactions
            for tx_hash, tx_height in missing_tx:
                if (tx_hash, tx_height) not in requested_tx:
                    self.network.send([ ('blockchain.transaction.get',[tx_hash, tx_height]) ], self.queue.put)
                    requested_tx.append( (tx_hash, tx_height) )
            missing_tx = []

            # detect if situation has changed
            if self.network.is_up_to_date() and self.queue.empty():
                if not self.wallet.is_up_to_date():
                    self.wallet.set_up_to_date(True)
                    self.was_updated = True
            else:
                if self.wallet.is_up_to_date():
                    self.wallet.set_up_to_date(False)
                    self.was_updated = True

            if self.was_updated:
                self.network.trigger_callback('updated')
                self.was_updated = False

            # 2. get a response
            try:
                r = self.queue.get(timeout=0.1)
            except Queue.Empty:
                continue

            # 3. process response
            method = r['method']
            params = r['params']
            result = r.get('result')
            error = r.get('error')
            if error:
                print_error("error", r)
                continue

            if method == 'blockchain.address.subscribe':
                addr = params[0]
                if self.wallet.get_status(self.wallet.get_history(addr)) != result:
                    if requested_histories.get(addr) is None:
                        self.network.send([('blockchain.address.get_history', [addr])], self.queue.put)
                        requested_histories[addr] = result

            elif method == 'blockchain.address.get_history':
                addr = params[0]
                print_error("receiving history", addr, result)
                if result == ['*']:
                    assert requested_histories.pop(addr) == '*'
                    self.wallet.receive_history_callback(addr, result)
                else:
                    hist = []
                    # check that txids are unique
                    txids = []
                    for item in result:
                        tx_hash = item['tx_hash']
                        if tx_hash not in txids:
                            txids.append(tx_hash)
                            hist.append( (tx_hash, item['height']) )

                    if len(hist) != len(result):
                        raise Exception("error: server sent history with non-unique txid", result)

                    # check that the status corresponds to what was announced
                    rs = requested_histories.pop(addr)
                    if self.wallet.get_status(hist) != rs:
                        raise Exception("error: status mismatch: %s"%addr)

                    # store received history
                    self.wallet.receive_history_callback(addr, hist)

                    # request transactions that we don't have
                    for tx_hash, tx_height in hist:
                        if self.wallet.transactions.get(tx_hash) is None:
                            if (tx_hash, tx_height) not in requested_tx and (tx_hash, tx_height) not in missing_tx:
                                missing_tx.append( (tx_hash, tx_height) )

            elif method == 'blockchain.transaction.get':
                tx_hash = params[0]
                tx_height = params[1]
                assert tx_hash == bitcoin.hash_encode(bitcoin.Hash(result.decode('hex')))
                tx = Transaction.deserialize(result)
                self.wallet.receive_tx_callback(tx_hash, tx, tx_height)
                self.was_updated = True
                requested_tx.remove( (tx_hash, tx_height) )
                print_error("received tx:", tx_hash, len(tx.raw))

            else:
                print_error("Error: Unknown message:" + method + ", " + repr(params) + ", " + repr(result) )

            if self.was_updated and not requested_tx:
                self.network.trigger_callback('updated')
                # Updated gets called too many times from other places as well; if we use that signal we get the notification three times
                self.network.trigger_callback("new_transaction")
                self.was_updated = False
开发者ID:1gabo,项目名称:electrum,代码行数:104,代码来源:synchronizer.py

示例13: signtxwithkey

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import deserialize [as 别名]
 def signtxwithkey(self, raw_tx, sec):
     tx = Transaction.deserialize(raw_tx)
     pubkey = bitcoin.public_key_from_private_key(sec)
     tx.sign({ pubkey:sec })
     return tx
开发者ID:FrictionlessCoin,项目名称:electrum-ixc,代码行数:7,代码来源:commands.py

示例14: broadcast

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import deserialize [as 别名]
 def broadcast(self, tx):
     """Broadcast a transaction to the network. """
     t = Transaction.deserialize(tx)
     return self.network.synchronous_get([('blockchain.transaction.broadcast', [str(t)])])[0]
开发者ID:martexcoin,项目名称:encompass,代码行数:6,代码来源:commands.py

示例15: decoderawtransaction

# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import deserialize [as 别名]
 def decoderawtransaction(self, raw):
     tx = Transaction(raw)
     tx.deserialize()
     return {"inputs": tx.inputs, "outputs": tx.outputs}
开发者ID:creditbit,项目名称:electrum-creditbit,代码行数:6,代码来源:commands.py


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