Exemple #1
0
        def send_tx(self):
            iroha = Iroha('admin@test')
            admin_private_key = 'f101537e319568c765b2cc89698325604991dca57b9716b58016b253506cab70'

            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)
Exemple #2
0
def add_keys_and_set_quorum():
    alice_iroha = Iroha('alice@test')
    alice_cmds = [
        alice_iroha.command('AddSignatory', account_id='alice@test',
                            public_key=ic.hex_key_to_bytes(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=ic.hex_key_to_bytes(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)
Exemple #3
0
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':
            del tx.signatures[:]  # we need do this temporarily, otherwise accept will not reach MST engine
        else:
            ic.sign_transaction(tx, *bob_private_keys)
    send_batch_and_print_status(*pending_transactions.transactions_response.transactions)
Exemple #4
0
def bob_declines_exchange_request():
    print("""
    
    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':
            del tx.signatures[:]  # we need do this temporarily, otherwise accept will not reach MST engine
        else:
            ic.sign_transaction(tx, *alice_private_keys)  # intentionally alice keys were used to fail bob's txs
            # zeroes as private keys are also acceptable
    send_batch_and_print_status(*pending_transactions.transactions_response.transactions)
Exemple #5
0
# Copyright Soramitsu Co., Ltd. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
#

print("""

PLEASE ENSURE THAT MST IS ENABLED IN IROHA CONFIG

""")

from irohalib import Iroha, IrohaGrpc
from irohalib import IrohaCrypto as ic

import binascii

iroha = Iroha('admin@test')
net = IrohaGrpc()

admin_private_key = open('../[email protected]').read()

alice_private_keys = [
    b'f101537e319568c765b2cc89698325604991dca57b9716b58016b253506caba1',
    b'f101537e319568c765b2cc89698325604991dca57b9716b58016b253506caba2'
]
alice_public_keys = [ic.derive_public_key(x) for x in alice_private_keys]

bob_private_keys = [
    b'f101537e319568c765b2cc89698325604991dca57b9716b58016b253506caba3',
    b'f101537e319568c765b2cc89698325604991dca57b9716b58016b253506caba4'
]
bob_public_keys = [ic.derive_public_key(x) for x in bob_private_keys]