def get_dicts(UID): print("Connexion to the iota devnet...") ##for the return find = 0 api = Iota('https://nodes.devnet.iota.org:443', testnet=True) #Import public key for authentification pub_jey = import_public_key(f'keys/car_{UID}_pub.pem') print("Get all the transaction from the concessionaire address..") test = import_file('seed_adress/address_concess_store.txt') address = [test] ## get all transaction done to the adress transactions = api.find_transaction_objects(addresses=address) #UID='AA9999999999999999999999999' print("Parcours des transaction") for transaction in transactions['transactions']: # Ignore input transactions; these have cryptographic signatures, # not human-readable messages. if transaction.value < 0: continue message = transaction.signature_message_fragment date = transaction.timestamp Tag_t = transaction.tag if message is None: print('(None)') else: if Tag_t[0:2] == UID: code = message.decode().split('?')[0] if code == 'km': km[transaction.timestamp] = get_value(message) find = get_verify_IOTA(message, pub_jey) elif code == 'conso': conso[transaction.timestamp] = get_value(message) find = get_verify_IOTA(message, pub_jey) elif code == 'usure': usure[transaction.timestamp] = get_value(message) find = get_verify_IOTA(message, pub_jey) else: print('Code introuvable') if find == 0: return "error" response["km"] = dict(sorted(km.items())) response["conso"] = dict(sorted(conso.items())) response["usure"] = dict(sorted(usure.items())) return response
def test_wireup(self): """ Verify that the command is wired up correctly. (sync) The API method indeed calls the appropiate command. """ with patch( 'iota.commands.extended.find_transaction_objects.FindTransactionObjectsCommand.__call__', MagicMock(return_value=async_return( 'You found me!'))) as mocked_command: api = Iota(self.adapter) # Don't need to call with proper args here. response = api.find_transaction_objects('bundle') self.assertTrue(mocked_command.called) self.assertEqual(response, 'You found me!')
from iota import Iota, Address from iota.codecs import TrytesDecodeError # Declare an API object api = Iota('https://nodes.devnet.iota.org:443', devnet=True) # Address to fetch data from # Replace with your random generated address from Tutorial 2. to fetch the data # that you uploaded. addy = Address( b'WWO9DRAUDDSDSTTUPKJRNPSYLWAVQBBXISLKLTNDPVKOPMUERDUELLUPHNT9L9YWBDKOLYVWRAFRKIBLP' ) print('Fetching data from the Tangle...') # Fetch the transaction objects of the address from the Tangle response = api.find_transaction_objects(addresses=[addy]) if not response['transactions']: print('Couldn\'t find data for the given address.') else: print('Found:') # Iterate over the fetched transaction objects for tx in response['transactions']: # data is in the signature_message_fragment attribute as trytes, we need # to decode it into a unicode string data = tx.signature_message_fragment.decode(errors='ignore') print(data)