本文整理汇总了Python中pycoin.tx.Tx.Tx.tx_from_hex方法的典型用法代码示例。如果您正苦于以下问题:Python Tx.tx_from_hex方法的具体用法?Python Tx.tx_from_hex怎么用?Python Tx.tx_from_hex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycoin.tx.Tx.Tx
的用法示例。
在下文中一共展示了Tx.tx_from_hex方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_tx_api
# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import tx_from_hex [as 别名]
def test_tx_api(self):
tx = Tx.tx_from_hex(TX_E1A18B843FC420734DEEB68FF6DF041A2585E1A0D7DBF3B82AAB98291A6D9952_HEX)
# this transaction is a pay-to-hash transaction
self.assertEqual(tx.id(), "e1a18b843fc420734deeb68ff6df041a2585e1a0d7dbf3b82aab98291a6d9952")
self.assertEqual(tx.txs_out[0].bitcoin_address(), "19LemzJ3XPdUxp113uynqCAivDbXZBdBy3")
# TODO: fix this when pay-to-hash properly parsed
self.assertEqual(tx.txs_out[1].bitcoin_address(), "3KmkA7hvqG2wKkWUGz1BySioUywvcmdPLR")
示例2: tx_to_b64
# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import tx_from_hex [as 别名]
def tx_to_b64(tx_hex):
# use this to dump raw transactions in the data above
import io
tx = Tx.tx_from_hex(tx_hex)
f = io.BytesIO()
tx.stream(f)
d = f.getvalue()
for idx in range(0, len(d), 45):
print('"%s"' % binascii.b2a_base64(d[idx:idx+45]).decode("utf8")[:-1])
示例3: test_blanked_hash
# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import tx_from_hex [as 别名]
def test_blanked_hash(self):
tx = Tx.tx_from_hex(TX_E1A18B843FC420734DEEB68FF6DF041A2585E1A0D7DBF3B82AAB98291A6D9952_HEX)
self.assertEqual(tx.id(), "e1a18b843fc420734deeb68ff6df041a2585e1a0d7dbf3b82aab98291a6d9952")
self.assertEqual(b2h(tx.blanked_hash()), "909579526c4c2c441687c7478d3f96249724d2ff071d2272b44500d6cf70d5d6")
tx.txs_in[0].script = b"foo"
self.assertEqual(b2h(tx.blanked_hash()), "909579526c4c2c441687c7478d3f96249724d2ff071d2272b44500d6cf70d5d6")
tx.txs_out[0].coin_value += 1
self.assertEqual(b2h(tx.blanked_hash()), "10d4e87f7bf35f2949e7693e7a4a84189aad8631f0b2b0999e88f7261066cbe5")
tx.txs_in[0].script = b"bar"
self.assertEqual(b2h(tx.blanked_hash()), "10d4e87f7bf35f2949e7693e7a4a84189aad8631f0b2b0999e88f7261066cbe5")
tx.txs_in[0].script = b""
self.assertEqual(b2h(tx.hash()), "10d4e87f7bf35f2949e7693e7a4a84189aad8631f0b2b0999e88f7261066cbe5")
tx.txs_in[0].script = b"foo"
self.assertEqual(b2h(tx.hash()), "c91910058722f1c0f52fc5c734939053c9b87882a9c72b609f21632e0bd13751")
示例4: test_is_invalid
# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import tx_from_hex [as 别名]
def test_is_invalid(self):
for (prevouts, tx_hex, flags) in txs_from_json(TX_INVALID_JSON):
try:
tx = Tx.tx_from_hex(tx_hex)
if not check_transaction(tx):
continue
unspents = [Spendable(coin_value=1000000,
script=compile_script(prevout[2]),
tx_hash=prevout[0], tx_out_index=prevout[1])
for prevout in prevouts]
tx.set_unspents(unspents)
bs = tx.bad_signature_count()
self.assertEqual(bs, 0)
except:
continue
self.fail("Invalid transaction: " + tx.id() +
" appears to be valid.")
示例5: test_is_valid
# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import tx_from_hex [as 别名]
def test_is_valid(self):
for (prevouts, tx_hex, flags) in txs_from_json(TX_VALID_JSON):
try:
tx = Tx.tx_from_hex(tx_hex)
except:
self.fail("Cannot parse tx_hex: " + tx_hex)
if not check_transaction(tx):
self.fail("check_transaction(tx) = False for valid tx: " +
tx_hex)
unspents = [Spendable(coin_value=1000000,
script=compile_script(prevout[2]),
tx_hash=prevout[0], tx_out_index=prevout[1])
for prevout in prevouts]
tx.set_unspents(unspents)
bs = tx.bad_signature_count()
if bs > 0:
msg = str(tx_hex) + " bad_signature_count() = " + str(bs)
self.fail(msg)
示例6: unsignedtx
# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import tx_from_hex [as 别名]
def unsignedtx(rawtx):
# FIXME validate tx is unsigned
return Tx.tx_from_hex(rawtx)
示例7: tx
# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import tx_from_hex [as 别名]
def tx(rawtx):
return Tx.tx_from_hex(rawtx)
示例8: test_issue_39
# 需要导入模块: from pycoin.tx.Tx import Tx [as 别名]
# 或者: from pycoin.tx.Tx.Tx import tx_from_hex [as 别名]
#.........这里部分代码省略.........
),
(
"AQAAAAEtUf3HWib/PGE4Ag4am7QPH6tuOc6W/q4yGMmuA14AqwEAAABrSDBF"
"AiEA5PGlIZB+UPxE0zEy7pjJcVpk350sKGDj4EdMUhq4U34CIDCvjTUGpTUu"
"KwVkRazYVaQtNycOlKYpp7KLIYcOxtdhASEDgIxJPwYZkNK+AB5A8EiuiHAy"
"C3SJXOLZZS88HHPNbyz/////AvCHSwAAAAAAGXapFPzJs204z1XX1bTuTd22"
"ssF2EvSMiKzwh0sAAAAAABl2qRQzzvYXSdEboq3wkaXgRWeBd/46bYisAAAA"
"AA=="
),
(
"AQAAAAJa+fLO2OCiRk98qhSvobvRyPsY3qrl0QEZa1jcIn70rgAAAABqRzBE"
"AiANKFITbLHEu93eBOx29YHRsyockZFIyF+8D9BWXTWK8wIgNvKqF87Ind6w"
"A3aigYv3KMRHmSgLnyBExWkad7Dc2WwDIQIQ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AADaAEgw"
"RQIhAIX1NZuYzrKUHFAxUNYI6yWMUuzCEapuZOUY6TdCspWaAiAchzgPP6if"
"WNh0cmVkyW1UpygM/eVa1XrtHepCMhvArAFHMEQCIGLJtKtbyJEaH6iQS+hK"
"xUlGrWwmqdJScz/JfSZ1Qln6AiBNRC+gswEEMjTNR5uVetqCGJkNL2m6fDfk"
"DyICU/otoQFHUiECzr9qtYCUjRRrfMdx2OZGl0NJ09exHz4DKH0Jl6R307kh"
"A3umUUhbeiyyIhketkpVkm5iu6v+m17SqUiKrVR7IEKCUq7/////Aux5CAAA"
"AAAAGXapFDIKbLrYWAn/2ZTB7ToisbIaZ5DoiKzL5TUPAAAAABepFNsSg3N8"
"2T68HrEpjWRKeEbFWm2WhwAAAAA="
)
]
TX_LIST = [Tx.tx_from_hex(b2h(binascii.a2b_base64(b64.encode("utf8")))) for b64 in TX_B64_LIST]
TX_DB = dict((tx.hash(), tx) for tx in TX_LIST)
for h in ["315ac7d4c26d69668129cc352851d9389b4a6868f1509c6c8b66bead11e2619f",
"dbf38261224ebff0c455c405e2435cfc69adb6b8a42d7b10674d9a4eb0464dca",
"de744408e4198c0a39310c8106d1830206e8d8a5392bcf715c9b5ec97d784edd",
"485716e53b422aca0fe5b1ded21360695ce5f49255d80e10db56458ed6962ff3"]:
tx = TX_DB.get(h2b_rev(h))
self.assertNotEqual(tx, None)
tx.unspents_from_db(TX_DB)
for idx, tx_in in enumerate(tx.txs_in):
self.assertTrue(tx.is_signature_ok(tx_in_idx=idx))