本文整理汇总了Python中transaction.Transaction.unserialize方法的典型用法代码示例。如果您正苦于以下问题:Python Transaction.unserialize方法的具体用法?Python Transaction.unserialize怎么用?Python Transaction.unserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类transaction.Transaction
的用法示例。
在下文中一共展示了Transaction.unserialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import unserialize [as 别名]
def main():
cb = Callbacks()
# Handle some simple command-line arguments
# -w Key : watch an RC4-encrypted channel
# -p : watch the Public unencrypted channel
# -t tx : try decoding and processing transaction 'tx' (hex)
i = 1
done = False
while i < len(sys.argv):
c = sys.argv[i]
if c == '-w':
i += 1
cb.watch_rc4(sys.argv[i].encode('utf8'))
elif c == '-a':
i += 1
cb.watch_aes128(sys.argv[i].encode('utf8'))
elif c == '-b':
i += 1
cb.watch_aes256(sys.argv[i].encode('utf8'))
elif c == '-p':
cb.watch_public()
elif c == '-r':
i += 1
private_key = load_private_key(open(sys.argv[i], 'rb').read().decode('ascii'))
cb.watch_rsa(private_key)
elif c == '-t':
i += 1
cb.got_transaction(Transaction.unserialize(Bitcoin.hexstring_to_bytes(sys.argv[i], reverse=False))[0])
done = True
else:
print('invalid command line argument: {}'.format(c))
return
i += 1
if done:
return
# start network thread
bitcoin_network = BitcoinNetwork(cb)
bitcoin_network.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
bitcoin_network.stop()
bitcoin_network.join()
raise
示例2: handle_tx
# 需要导入模块: from transaction import Transaction [as 别名]
# 或者: from transaction.Transaction import unserialize [as 别名]
def handle_tx(self, payload):
tx, _ = Transaction.unserialize(payload)
txhash = tx.hash()
if txhash in self.transaction_requests_in_progress:
self.bitcoin_network.got_transaction(tx)
self.transaction_requests_in_progress.pop(txhash)