Beispiel #1
0
    def load_wallet(self, wallet):
        config = configparser.ConfigParser()
        config.read(wallet)
        iota_seed_e = config['wallet']['iotaSeed']
        iota_seed = self.key_f.decrypt(
            iota_seed_e.encode('utf-8')).decode('utf-8')

        api = Iota(self.node, iota_seed)
        inputs = api.get_inputs()

        addresses = inputs['inputs']
        config['wallet']['index'] = str(len(addresses))

        if len(addresses) == 0:
            print("No address found. Generating...")
            gna_result = api.get_new_addresses(count=1)
            addresses = gna_result['addresses']

        config['wallet']['activeAddress'] = str(addresses[-1])
        config['wallet']['totalBalance'] = str(inputs['totalBalance'])

        for i, address in enumerate(addresses):
            config['addresses']['Address ' + str(i)] = str(address)

        with open(wallet, 'w') as configfile:
            config.write(configfile)

        return api, inputs
Beispiel #2
0
class FSend:
    def __init__(self, config, index, jspath):
        self.index = index
        self.api = Iota(config.getNodeUrl(), config.getSeed())
        self.secLvl = config.getSecLvl()
        self.checksum = config.getChecksum()
        self.jspath = jspath
        self.owner = config.getOwner()

    # search for addresses with inputs
    def get_value_addresses(self):
        response = self.api.get_inputs(start=0, stop=self.index, security_level=self.secLvl)
        self.value_addresses = response['inputs']
        self.summary = response['totalBalance']
        if self.summary == 0:
            pass
        else:
            self.send_funds()

    # prepare tx and send funds
    def send_funds(self):
        tx = ProposedTransaction(
            address=Address(self.owner),
            message=TryteString.from_unicode('IOTAPay Device V1'),
            tag=Tag('IOTAPAYTRANSACTION'),
            value=self.summary
        )
        tx = self.api.prepare_transfer(transfers=[tx], inputs=self.value_addresses, change_address=self.owner)
        result = self.api.send_trytes(tx['trytes'], depth=3, min_weight_magnitude=14)
        print('Transaction with:', self.summary, 'iota sent to the tangle!')
Beispiel #3
0
    def update_balance(self, wallet, index):
        config = configparser.ConfigParser()
        config.read(wallet)
        iota_seed_e = config['wallet']['iotaSeed']
        iota_seed = self.key_f.decrypt(
            iota_seed_e.encode('utf-8')).decode('utf-8')

        api = Iota(self.node, iota_seed)
        inputs = api.get_inputs(start=index - 1, stop=index)
        balance = inputs['totalBalance']
        config['wallet']['activeBalance'] = str(balance)
        active_address = inputs['inputs'][0]

        with open(wallet, 'w') as configfile:
            config.write(configfile)

        return balance, active_address
Beispiel #4
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_inputs.GetInputsCommand.__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_inputs()

            self.assertTrue(mocked_command.called)

            self.assertEqual(response, 'You found me!')
Beispiel #5
0
def main():
    i=1
    print "I start playing the IOTA lottery. Good luck."

    ##Infinite look how checks the randomly created seeds.

    while i>0:
        semilla = crea_seed() 

        ## CHANGE THIS - Here you need to include a Full IOTA Node instead localhost
        ## If you want to try quickly maybe It can be a good idea to install your own 
        ## Full Node  
        api = Iota('http://*****:*****@gmail.com", "PASSWORD")
            text = msg.as_string()
            server.sendmail(fromaddr, toaddr, text)
            server.quit()

        else:
            print semilla+ ": " + str(saldo)
Beispiel #6
0
def batch_transfer(filename,
                   node_uri,
                   seed,
                   amount_of_seeds=100,
                   amount_per_seed=10000,
                   batch_size=25,
                   depth=3,
                   tag='GIFT',
                   message='',
                   pow_node_uri=None):
    needed_funds = amount_of_seeds * amount_per_seed
    print('You are about to spend %s iota spread out over %s addresses.' %
          (needed_funds, amount_of_seeds))
    print('Checking your seeds balance...')

    if pow_node_uri:
        router = RoutingWrapper(node_uri)
        router.add_route('attachToTangle', pow_node_uri)
        api = Iota(router, seed)
    else:
        api = Iota(node_uri, seed)

    inputs = api.get_inputs()
    balance = inputs['totalBalance']

    if balance < needed_funds:
        print(
            "You don't have enough funds available on your SEED, please make sure your seed has at least %si available!"
            % needed_funds)
        return

    print(
        'You have enough available to transfer the %si, Generating %d seeds and addresses now...'
        % (needed_funds, amount_of_seeds))

    seedlist = []
    for i in range(amount_of_seeds):
        random_seed = ''.join(
            [choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ9') for x in range(81)])
        gen = AddressGenerator(random_seed)
        new_addr = gen.get_addresses(0, 1, 2)[0]
        seedlist.append((random_seed, new_addr))
        print('.', sep='', end='', flush=True)

    print('\n')

    with open(filename, 'w') as fh:
        writer = csv.writer(fh)
        writer.writerow(['Seed', 'Address', 'Iota'])

        for gseed, gaddr in seedlist:
            writer.writerow([gseed, gaddr, amount_per_seed])

    print('All seeds and addresses are now available in %s!' % filename)

    amount_of_bundles = (amount_of_seeds // batch_size) + 1

    if amount_of_seeds % batch_size == 0:
        amount_of_bundles -= 1

    print(
        'We will generate and send %d bundles containing %d transactions per bundle max, this can take a while...'
        % (amount_of_bundles, batch_size))

    from_addr = None
    for i in range(amount_of_bundles):
        sliced = seedlist[i * batch_size:(i + 1) * batch_size]
        print('Starting transfer of bundle %d containing %d seeds...' %
              (i + 1, len(sliced)))

        transfers = []
        for gseed, gaddr in sliced:
            transfers.append(
                ProposedTransaction(
                    address=gaddr,
                    value=amount_per_seed,
                    tag=Tag(tag),
                    message=TryteString.from_string(message),
                ))

        bundle = api.send_transfer(depth=depth, transfers=transfers)

        for tx in bundle['bundle'].transactions:
            if tx.current_index == tx.last_index:
                print('Remainder:', tx.current_index, tx.address, tx.value)
                from_addr = tx.address

                if amount_per_seed == 0:
                    continue

                print(
                    'Waiting for the TX to confirm and the remainder address (%s) to fill...'
                    % tx.address)
                while True:
                    balances = api.get_balances([tx.address], 100)
                    if balances['balances'][0] > 0:
                        break
                    else:
                        print('...', sep='', end='', flush=True)

                    sleep(5)

                print('\n')

        print('Transfer complete.')

    print('All done!')
Beispiel #7
0
from iota.crypto.types import Seed
from iota import Iota
import json, sys

with open('config.json', 'r') as f:
    data = json.load(f)
    url = data['url']

my_seed = 'YGCOACXP9SCGRWZBXLMIINVDFSDHKKIFCPNWYQGX9VRMM99VCHXFTNLELCHNJQTLTFTXRZBGEKUUGOPM9'

if len(sys.argv) == 2:
    my_seed = sys.argv[1]

api = Iota(adapter=url, seed=my_seed)

input = api.get_inputs(start=0, stop=10)
print(input)