當前位置: 首頁>>代碼示例>>Python>>正文


Python Transaction.get_transaction_id方法代碼示例

本文整理匯總了Python中src.transaction.Transaction.get_transaction_id方法的典型用法代碼示例。如果您正苦於以下問題:Python Transaction.get_transaction_id方法的具體用法?Python Transaction.get_transaction_id怎麽用?Python Transaction.get_transaction_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在src.transaction.Transaction的用法示例。


在下文中一共展示了Transaction.get_transaction_id方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: find_incoming_utxos

# 需要導入模塊: from src.transaction import Transaction [as 別名]
# 或者: from src.transaction.Transaction import get_transaction_id [as 別名]
def find_incoming_utxos(block_hash, transactions, isGenesis=False):
    """
    Iterates through all the outputs and looks for any directed to user's wallet.
    If found, save to the utxo pool
    :return:
    """
    myAddress = SHA256.new(get_public_key("string").encode()).hexdigest()
    conf = Configuration()
    for tnx_id, tnx_info in transactions.items():
        # deserialize transaction
        tnx_payload = tnx_info
        tnx_payload["transaction_id"] = tnx_id
        tnx = Transaction(payload=tnx_payload)

        for index in range(len(tnx.outputs)):
            if tnx.outputs[index]["address"] == myAddress and not isGenesis:
                save_utxo(tnx.get_transaction_id(), index, block_hash, tnx.outputs[index]["amount"])
                conf.add_balance(tnx.outputs[index]["amount"])
            elif tnx.outputs[index]["address"] == myAddress and isGenesis:
                save_utxo(tnx.get_transaction_id(), -1, block_hash, tnx.outputs[index]["amount"])
                conf.add_balance(tnx.outputs[index]["amount"])
開發者ID:Nurraku,項目名稱:ABC,代碼行數:23,代碼來源:api.py

示例2: create_transaction

# 需要導入模塊: from src.transaction import Transaction [as 別名]
# 或者: from src.transaction.Transaction import get_transaction_id [as 別名]
def create_transaction(recipient, amount):
    """
    creates a new transaction and add it to verified_transactions.json
    :param recipient: public address of the recipient
    :param amount: the amount of abc to be sent
    :return: None
    """
    # TODO: Send a success message to client
    conf = Configuration()
    try:
        tx = Transaction()
        tx.add_output(recipient, amount)
        tx.unlock_inputs(get_private_key(), get_public_key("string"))
        save_verified_transaction(tx.get_transaction_id(), tx.get_data())
        conf.subtract_balance(tx.sum_of_outputs())
    except ValueError as e:
        # Will raise if insufficient utxos are found
        raise ValueError("INSUFFICIENT FUNDS")
開發者ID:Nurraku,項目名稱:ABC,代碼行數:20,代碼來源:api.py


注:本文中的src.transaction.Transaction.get_transaction_id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。