Esempio n. 1
0
def add_asset_tx():
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .addAssetQuantity('coin#test', '5000.99') \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 2
0
def transfer_asset_tx():
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .transferAsset(alice['id'], bob['id'], 'coin#test', 'transfer to Bob', '60.00') \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 3
0
def set_account_detail_tx():
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .setAccountDetail(admin['id'], 'fav_color', 'red') \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 4
0
def remove_signatory_tx():
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .removeSignatory(alice['id'], alice['key'].publicKey()) \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 5
0
def create_account_tx():
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .createAccount('bob', 'test', bob['key'].publicKey()) \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 6
0
def grant_can_remove_my_signatory_tx():
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .grantPermission(bob['id'], iroha.Grantable_kRemoveMySignatory) \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 7
0
def create_asset_tx():
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .createAsset('coin', 'test', 2) \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 8
0
def detach_role_tx():
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .detachRole(admin['id'], 'test_role') \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
def revoke_can_set_my_account_detail_tx():
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .revokePermission(bob['id'], iroha.Grantable_kSetMyAccountDetail) \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 10
0
def set_quorum_tx():
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(bob['id']) \
        .setAccountQuorum(alice['id'], 2) \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(bob['key']).finish()
Esempio n. 11
0
def create_domain_tx():
    # 'test_role' was created in genesis transaction
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .createDomain('another-domain', 'test_role') \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 12
0
def add_signatory_tx():
    extra_key = iroha.ModelCrypto().generateKeypair()
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .addSignatory(alice['id'], extra_key.publicKey()) \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 13
0
def set_quorum_tx():
    # Quourum cannot be greater than amount of keys linked to an account
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .setAccountQuorum(alice['id'], 2) \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 14
0
def add_peer_tx():
    peer_key = iroha.ModelCrypto().generateKeypair()
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .addPeer('192.168.10.10:50541', peer_key.publicKey()) \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 15
0
def grant_can_remove_my_signatory_tx():
    extra_key = iroha.ModelCrypto().generateKeypair()
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .grantPermission(bob['id'], iroha.Grantable_kRemoveMySignatory) \
        .addSignatory(alice['id'], extra_key.publicKey()) \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 16
0
def admin_action_2_tx():
    global admin_tx2_hash_blob
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(admin['id']) \
        .setAccountDetail(admin['id'], 'hyperledger', 'iroha') \
        .build()
    admin_tx2_hash_blob = tx.hash().blob()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(admin['key']).finish()
Esempio n. 17
0
def alice_action_2_tx():
    global alice_tx2_hash_blob
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .addAssetQuantity('coin#first', '600.30') \
        .build()
    alice_tx2_hash_blob = tx.hash().blob()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 18
0
def alice_action_1_tx():
    global alice_tx1_hash
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .createAsset('coin', 'first', 2) \
        .build()
    alice_tx1_hash = tx.hash()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 19
0
def append_role_tx():
    # Note that you can append only that role that has
    # lesser or the same set of permissions as transaction creator.
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .appendRole(bob['id'], 'second_role') \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 20
0
def create_role_tx():
    # You can pick only those permissions that
    # already belong to account of transaction creator.
    role_permissions = iroha.RolePermissionSet([iroha.Role_kCreateDomain])
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(alice['id']) \
        .createRole('newrole', role_permissions) \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(alice['key']).finish()
Esempio n. 21
0
def genesis_tx():
    test_permissions = iroha.RolePermissionSet([iroha.Role_kGetMyAccount])
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(admin['id']) \
        .addPeer('0.0.0.0:50541', admin['key'].publicKey()) \
        .createRole('admin_role', commons.all_permissions()) \
        .createRole('test_role', test_permissions) \
        .createDomain('test', 'test_role') \
        .createAccount('admin', 'test', admin['key'].publicKey()) \
        .createAccount('alice', 'test', alice['key'].publicKey()) \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(admin['key']).finish()
Esempio n. 22
0
def genesis_tx():
    test_permissions = iroha.RolePermissionSet([iroha.Role_kGetDomainAccAstTxs])
    tx = iroha.ModelTransactionBuilder() \
        .createdTime(commons.now()) \
        .creatorAccountId(admin['id']) \
        .addPeer('0.0.0.0:50541', admin['key'].publicKey()) \
        .createRole('admin_role', commons.all_permissions()) \
        .createRole('test_role', test_permissions) \
        .createDomain('test', 'test_role') \
        .createAccount('admin', 'test', admin['key'].publicKey()) \
        .createAccount('alice', 'test', alice['key'].publicKey()) \
        .createAsset('coin', 'test', 2) \
        .addAssetQuantity('coin#test', '500.69') \
        .transferAsset(admin['id'], alice['id'], 'coin#test', 'top up', '10.00') \
        .build()
    return iroha.ModelProtoTransaction(tx) \
        .signAndAddSignature(admin['key']).finish()
Esempio n. 23
0
 def test_empty_tx(self):
   with self.assertRaises(ValueError):
     iroha.ModelTransactionBuilder().build()
Esempio n. 24
0
 def base(self):
   return iroha.ModelTransactionBuilder()\
     .createdTime(int(time.time() * 1000))\
     .creatorAccountId("admin@test")
Esempio n. 25
0
 def generate_base(self):
     return iroha.ModelTransactionBuilder().txCounter(123)\
                                .createdTime(int(time.time() * 1000))\
                                .creatorAccountId("admin@test")\
Esempio n. 26
0
import sys
sys.path.insert(0, 'build/shared_model/bindings')
import iroha

import transaction_pb2
import endpoint_pb2
import endpoint_pb2_grpc
import queries_pb2
import grpc
import time

tx_builder = iroha.ModelTransactionBuilder()
query_builder = iroha.ModelQueryBuilder()
crypto = iroha.ModelCrypto()

admin_priv = open("../[email protected]", "r").read()
admin_pub = open("../[email protected]", "r").read()
key_pair = crypto.convertFromExisting(admin_pub, admin_priv)

user1_kp = crypto.generateKeypair()


def current_time():
    return int(round(time.time() * 1000))


creator = "admin@test"

query_counter = 1