How to use the iroha.IrohaCrypto.sign_transaction function in iroha

To help you get started, we’ve selected a few iroha examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger-archives / iroha / test / load / locustfile.py View on Github external
def send_tx(self):
            iroha = Iroha('admin@test')

            tx = iroha.transaction([iroha.command(
                'TransferAsset', src_account_id='admin@test', dest_account_id='test@test', asset_id='coin#test',
                amount='0.01', description=HOSTNAME
            )])
            ic.sign_transaction(tx, ADMIN_PRIVATE_KEY)

            self.client.send_tx(tx)
github hyperledger / iroha-python / examples / tx-example.py View on Github external
def set_age_to_userone():
    """
    Set age to userone@domain by admin@test
    """
    tx = iroha.transaction([
        iroha.command('SetAccountDetail',
                      account_id='userone@domain', key='age', value='18')
    ])
    IrohaCrypto.sign_transaction(tx, ADMIN_PRIVATE_KEY)
    send_transaction_and_print_status(tx)
github hyperledger / iroha-python / examples / tx-example.py View on Github external
def add_coin_to_admin():
    """
    Add 1000.00 units of 'coin#domain' to 'admin@test'
    """
    tx = iroha.transaction([
        iroha.command('AddAssetQuantity',
                      asset_id='coin#domain', amount='1000.00')
    ])
    IrohaCrypto.sign_transaction(tx, ADMIN_PRIVATE_KEY)
    send_transaction_and_print_status(tx)
github hyperledger / iroha-python / examples / batch-example.py View on Github external
def bob_accepts_exchange_request():
    global net
    q = ic.sign_query(
        Iroha('bob@test').query('GetPendingTransactions'),
        bob_private_keys[0]
    )
    pending_transactions = net.send_query(q)
    for tx in pending_transactions.transactions_response.transactions:
        if tx.payload.reduced_payload.creator_account_id == 'alice@test':
            # we need do this temporarily, otherwise accept will not reach MST engine
            del tx.signatures[:]
        else:
            ic.sign_transaction(tx, *bob_private_keys)
    send_batch_and_print_status(
        pending_transactions.transactions_response.transactions)
github hyperledger / iroha-python / examples / batch-example.py View on Github external
IT IS EXPECTED HERE THAT THE BATCH WILL FAIL STATEFUL VALIDATION
    
    """)
    global net
    q = ic.sign_query(
        Iroha('bob@test').query('GetPendingTransactions'),
        bob_private_keys[0]
    )
    pending_transactions = net.send_query(q)
    for tx in pending_transactions.transactions_response.transactions:
        if tx.payload.reduced_payload.creator_account_id == 'alice@test':
            # we need do this temporarily, otherwise accept will not reach MST engine
            del tx.signatures[:]
        else:
            # intentionally alice keys were used to fail bob's txs
            ic.sign_transaction(tx, *alice_private_keys)
            # zeroes as private keys are also acceptable
    send_batch_and_print_status(
        pending_transactions.transactions_response.transactions)
github hyperledger / iroha-python / examples / batch-example.py View on Github external
public_key=alice_public_keys[1]),
        alice_iroha.command('SetAccountQuorum',
                            account_id='alice@test', quorum=2)
    ]
    alice_tx = alice_iroha.transaction(alice_cmds)
    ic.sign_transaction(alice_tx, alice_private_keys[0])
    send_transaction_and_print_status(alice_tx)

    bob_iroha = Iroha('bob@test')
    bob_cmds = [
        bob_iroha.command('AddSignatory', account_id='bob@test',
                          public_key=bob_public_keys[1]),
        bob_iroha.command('SetAccountQuorum', account_id='bob@test', quorum=2)
    ]
    bob_tx = bob_iroha.transaction(bob_cmds)
    ic.sign_transaction(bob_tx, bob_private_keys[0])
    send_transaction_and_print_status(bob_tx)