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


Python Bigchain.validate_transaction方法代码示例

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


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

示例1: print

# 需要导入模块: from bigchaindb import Bigchain [as 别名]
# 或者: from bigchaindb.Bigchain import validate_transaction [as 别名]
# create a second testuser
testuser2_priv, testuser2_pub = crypto.generate_key_pair()

# retrieve the transaction with condition id
tx_retrieved_id = b.get_owned_ids(testuser1_pub).pop()
print(json.dumps(tx_retrieved_id, sort_keys=True, indent=4, separators=(',', ':')))

# create a transfer transaction
tx_transfer = b.create_transaction(testuser1_pub, testuser2_pub, tx_retrieved_id, 'TRANSFER')

# sign the transaction
tx_transfer_signed = b.sign_transaction(tx_transfer, testuser1_priv)


b.validate_transaction(tx_transfer_signed)
# write the transaction
b.write_transaction(tx_transfer_signed)

sleep(8)

# check if the transaction is already in the bigchain
tx_transfer_retrieved = b.get_transaction(tx_transfer_signed['id'])
print(json.dumps(tx_transfer_retrieved, sort_keys=True, indent=4, separators=(',', ':')))

"""
Double Spends
"""

# create another transfer transaction with the same input
tx_transfer2 = b.create_transaction(testuser1_pub, testuser2_pub, tx_retrieved_id, 'TRANSFER')
开发者ID:dangerousbeans,项目名称:bigchaindb,代码行数:32,代码来源:run_doc_python_server_api_examples.py

示例2: Bigchain

# 需要导入模块: from bigchaindb import Bigchain [as 别名]
# 或者: from bigchaindb.Bigchain import validate_transaction [as 别名]
b = Bigchain()

govt_priv, govt_pub = writeout.importData("govt")

for x in range(1,8):
    priv, pub = writeout.importData("user"+str(x))
    tx_signed = writeout.importData("user"+str(x)+"vote")
    tx_retrieved = b.get_transaction(tx_signed['id'])
    print(tx_retrieved)


    # create a transfer transaction
    tx_transfer = b.create_transaction(pub, govt_pub, tx_retrieved['id'], 'TRANSFER')
    print(tx_transfer)

    # sign the transaction
    tx_transfer_signed = b.sign_transaction(tx_transfer, priv)
    print(tx_transfer_signed)

    # write the transaction
    b.write_transaction(tx_transfer_signed)

    # check if the transaction is already in the bigchain
    tx_transfer_retrieved = b.get_transaction(tx_transfer_signed['id'])

    print(tx_transfer_retrieved)

    data = b.validate_transaction(tx_transfer_signed)
    print(data)
开发者ID:ChesTaylor,项目名称:csci455,代码行数:31,代码来源:dummytransfer.py


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