本文整理汇总了Python中pycoin.tx.Tx.Tx.hash方法的典型用法代码示例。如果您正苦于以下问题:Python Tx.hash方法的具体用法?Python Tx.hash怎么用?Python Tx.hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycoin.tx.Tx.Tx
的用法示例。
在下文中一共展示了Tx.hash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: store_nulldata
# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import hash [as 别名]
def store_nulldata(service, testnet, nulldatatxout, keys,
changeaddress=None, txouts=None, fee=10000,
locktime=0, publish=True):
# get required satoshis
txouts = txouts if txouts else []
required = sum(list(map(lambda txout: txout.coin_value, txouts))) + fee
# get txins
addresses = list(map(lambda key: key.address(), keys))
txins, total = find_txins(service, addresses, required)
if total < required:
raise exceptions.InsufficientFunds(required, total)
# setup txouts
changeaddress = changeaddress if changeaddress else addresses[0]
changeout = deserialize.txout(testnet, changeaddress, total - required)
txouts = txouts + [nulldatatxout, changeout]
# create, sign and publish tx
tx = Tx(1, txins, txouts, locktime)
tx = sign_tx(service, testnet, tx, keys)
if publish:
service.send_tx(tx)
return tx.hash()
示例2: get_tx
# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import hash [as 别名]
def get_tx(tx_hash):
"""
Get a Tx by its hash.
"""
# TODO: fix this
j = get_json_for_hash(tx_hash)
txs_in = []
for j_in in j.get("in"):
if j_in.get("coinbase"):
txs_in.append(TxIn.coinbase_tx_in(binascii.unhexlify(j_in["coinbase"])))
else:
txs_in.append(TxIn(
h2b_rev(j_in["prev_out"]["hash"]),
int(j_in["prev_out"]["n"]),
tools.compile(j_in["scriptSig"])))
txs_out = []
for j_out in j.get("out"):
txs_out.append(TxOut(int(btc_to_satoshi(j_out["value"])), tools.compile(j_out["scriptPubKey"])))
tx = Tx(int(j["ver"]), txs_in, txs_out, int(j["lock_time"]))
assert tx.hash() == tx_hash
return tx