Exemplo n.º 1
0
def test2():
    config = configparser.ConfigParser()
    config.read('config.cfg')
    seed = config['IOTA']['seed']

    api = Iota('https://iotanode.us:443', seed)
    original = now = len(api.get_transfers()['bundles'])
    while original == now:
        try:
            now = len(api.get_transfers()['bundles'])
        except Exception as e:
            print('Fehler: ', e)
        sleep(0.5)
    print('Transaktion empfangen.')
Exemplo n.º 2
0
    def test_wireup(self):
        """
    Verify that the command is wired up correctly.

    The API method indeed calls the appropiate command.
    """
        with patch(
                'iota.commands.extended.get_transfers.GetTransfersCommand.__call__',
                MagicMock(return_value='You found me!')) as mocked_command:

            api = Iota(self.adapter)

            # Don't need to call with proper args here.
            response = api.get_transfers()

            self.assertTrue(mocked_command.called)

            self.assertEqual(response, 'You found me!')
Exemplo n.º 3
0
#Import library for Iota
from iota import Iota

#define API - para realizar as comunicações
Eliabel0 = Iota('https://nodes.thetangle.org:443', b'SEEDS9GOES9HERE')
Eliabel1 = Iota('https://nodes.thetangle.org:443', b'SEEDS9GOES9HERE')

#Lê todas as informações da rede TANGLE referente aquela SEED
print("Collecting info from Tangle. Wait please...")
now = datetime.now()
print("Start collecting at:  ", now.strftime("%Y/%m/%d - %H:%M:%S"))

while True:
    while True:
        try:
            bundles_info = Eliabel0.get_transfers()
            now = datetime.now()
            print("Last info updated at: ",
                  now.strftime("%Y/%m/%d - %H:%M:%S"))
            break
        except:
            print(
                '  Conection error on Tangle/Node. Trying again, please wait...'
            )
            now = datetime.now()
            print("  Errot at: ", now.strftime("%Y/%m/%d - %H:%M:%S"))

    #Reading bundle transactions
    num_bundle = 0
    list_test = list()
    list_db = list()
Exemplo n.º 4
0
# Imports of the PyOTA library
import sys, os
from iota import (__version__, Address, Iota)

# Create an IOTA object
api = Iota('https://nodes.thetangle.org:443',
           '<TYPE_THE_IOTA_HOTSPOT_SEED_HERE>')
# IOTA hotspot addresses
iota_addr = Address(b'<TYPE_THE_IOTA_HOTSPOT_ADDRESS_HERE>')
# IOTA message received from the user transfer
iota_msg = ''
# Amount of data requested in MBytes
mbytes_requested = 0

# Get a list of bundles from the IOTA hotspot address
response = api.get_transfers()
bundles = response['bundles']
# Get a list of transactions from the most resent transfer (last bundle)
latest_bundle = bundles[len(bundles) - 1]
transactions = latest_bundle.transactions

# Decode the signature message framgment for each transation
for transaction in transactions:
    # Find the transation that contains the optional string message
    if transaction.value > 0:
        message = str(transaction.signature_message_fragment.decode())
        if message != '':
            value = transaction.value
            iota_msg = message
            # Convert from i to Mi tokens
            Mi = (value / 1000000)