本文整理汇总了Python中pycoin.tx.Tx.standard_tx方法的典型用法代码示例。如果您正苦于以下问题:Python Tx.standard_tx方法的具体用法?Python Tx.standard_tx怎么用?Python Tx.standard_tx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycoin.tx.Tx
的用法示例。
在下文中一共展示了Tx.standard_tx方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_build_spends
# 需要导入模块: from pycoin.tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx import standard_tx [as 别名]
def test_build_spends(self):
# create a coinbase Tx where we know the public & private key
exponent = wif_to_secret_exponent("5JMys7YfK72cRVTrbwkq5paxU7vgkMypB55KyXEtN5uSnjV7K8Y")
compressed = False
public_key_sec = public_pair_to_sec(ecdsa.public_pair_for_secret_exponent(ecdsa.generator_secp256k1, exponent), compressed=compressed)
the_coinbase_tx = Tx.coinbase_tx(public_key_sec, int(50 * 1e8), COINBASE_BYTES_FROM_80971)
# now create a Tx that spends the coinbase
compressed = False
exponent_2 = int("137f3276686959c82b454eea6eefc9ab1b9e45bd4636fb9320262e114e321da1", 16)
bitcoin_address_2 = public_pair_to_bitcoin_address(
ecdsa.public_pair_for_secret_exponent(ecdsa.generator_secp256k1, exponent_2),
compressed=compressed)
self.assertEqual("12WivmEn8AUth6x6U8HuJuXHaJzDw3gHNZ", bitcoin_address_2)
TX_DB = dict((tx.hash(), tx) for tx in [the_coinbase_tx])
coins_from = [(the_coinbase_tx.hash(), 0)]
coins_to = [(int(50 * 1e8), bitcoin_address_2)]
coinbase_spend_tx = Tx.standard_tx(coins_from, coins_to, TX_DB, [exponent])
coinbase_spend_tx.validate(TX_DB)
## now try to respend from priv_key_2 to priv_key_3
compressed = True
exponent_3 = int("f8d39b8ecd0e1b6fee5a340519f239097569d7a403a50bb14fb2f04eff8db0ff", 16)
bitcoin_address_3 = public_pair_to_bitcoin_address(
ecdsa.public_pair_for_secret_exponent(ecdsa.generator_secp256k1, exponent_3),
compressed=compressed)
self.assertEqual("13zzEHPCH2WUZJzANymow3ZrxcZ8iFBrY5", bitcoin_address_3)
TX_DB = dict((tx.hash(), tx) for tx in [coinbase_spend_tx])
spend_tx = Tx.standard_tx([(coinbase_spend_tx.hash(), 0)], [(int(50 * 1e8), bitcoin_address_3)], TX_DB, [exponent_2])
spend_tx.validate(TX_DB)
示例2: test_standard_tx_out
# 需要导入模块: from pycoin.tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx import standard_tx [as 别名]
def test_standard_tx_out(self):
coin_value = 10
recipient_bc_address = '1BcJRKjiwYQ3f37FQSpTYM7AfnXurMjezu'
tx_out = Tx.standard_tx([], [(coin_value, recipient_bc_address)]).txs_out[0]
s = str(tx_out)
self.assertEqual('TxOut<1E-7 "OP_DUP OP_HASH160 745e5b81fd30ca1e90311b012badabaa4411ae1a OP_EQUALVERIFY OP_CHECKSIG">', s)