def checkAddresses(seed): # use IOTA api to get first n addresses of the seed api = Iota(iotaNode, seed) apiAdresses = api.get_new_addresses(count=numberOfAddresses) addresses = apiAdresses['addresses'] # check if one of the addresses matches the public known transaction address i = 0 while i < numberOfAddresses: address = str([addresses[i]][0]) if (publicTransactionAddress.startswith(address)): if (numberOfAddresses == 1): print( "\nAs we only checked one (i.e. the first) address of a seed, there can only be one result." ) print( "Please try to login with the following seed and check your balance:\n\n" + seed + "\n") printDonation() sys.exit() else: print("\nTry to login with this seed (others may follow): " + seed + "\n") seedCandidates.append(seed) i += 1
def addressGenerator(seed): api = Iota( iotaNode, seed ) # The iota nodes IP address must always be supplied, even if it actually isn't used in this case. gna_result = api.get_new_addresses( count=numberOfAddresses ) # This is the function to generate the address. addresses = gna_result['addresses'] i = 0 #int for number of addresses #print("Checking seed: " + seed) while i < numberOfAddresses: address = [addresses[i]] #print(" checking address : " + str(address[0])) i += 1 if address[ 0] == known_recieving_value: # If the address is equal to the recieving address then.. (Address without checksum) print("Bruteforcer Finished") print("The seed is: " + seed) file = open("seed.txt", "w") #Open file. file.write("Bingo. The seed is: " + seed) #print out bingo and the correct seed. file.close() #Close the file to save changes. #if it finds the correct address stop the program. increment( seed ) #increase counter by 1 and check if seed needs to be saved into log.
def add_txn_to_queue(request_data): request_command = json.loads(request_data) node_url = request_command['node_url'] address = request_command['address'] tag = request_command['tag'] messages = request_command['messages'] values = request_command['values'] bundle_hash = "" prepared_transferes = [] api = Iota(node_url, SEED) txn = \ ProposedTransaction( address = Address(address), message = TryteString.from_string(messages), tag = Tag(tag), value = int(values), ) prepared_transferes.append(txn) try: bundle_hash = api.send_transfer( depth = 7, transfers = prepared_transferes, min_weight_magnitude = 14 ) except Exception as e: print(e) return 0 print(bundle_hash['bundle'].hash) append_log(bundle_hash['bundle'].hash, LOG_HISTORY_TXN) return 0
def main(): api = Iota("http://localhost:14265") # For more information, see :py:meth:`Iota.send_transfer`. ti = time.time() a = api.send_transfer( depth=3, transfers=[ ProposedTransaction( # Recipient of the transfer. address=Address( "RECEIVINGWALLETADDRESSGOESHERE9WITHCHECKSUMANDSECURITYLEVELB999999999999999999999999999999" ), value=0, # Optional tag to attach to the transfer. tag=Tag(b'KITTEHS'), # Optional message to include with the transfer. message=TryteString.from_unicode('thx fur cheezburgers'), ), ], min_weight_magnitude=1) k = 0 for k in a["bundle"]: print(k)
class Wallet(object): __seed = "" __api = Iota('https://nodes.devnet.iota.org:443', __seed, testnet=True) __security_level = 2 __counter = 0 def __init__(self): # get the current working directory path = str(pathlib.Path(__file__).parent) # get init file data and build our parkingmeters container #home/ubuntu with open(path + "/init.txt") as json_file: data = json.load(json_file) self.__seed = data["SEED"] def get_seed(self): return self.__seed def set_seed(self, seed): self.__seed = seed def get_address(self): is_spent = 1 while is_spent == 1: address = self.__api.get_new_addresses( self.__counter, count=1, security_level=self.__security_level)['addresses'][0] is_spent = self.__api.were_addresses_spent_from([address ])['states'][0] self.__counter + 1 return address
def parse_argv(self, argv=None): # type: (Optional[tuple]) -> dict """ Parses arguments for the command. :param argv: Arguments to pass to the argument parser. If ``None``, defaults to ``sys.argv[1:]``. """ arguments = vars(self.create_argument_parser().parse_args(argv)) seed = None if self.requires_seed: seed_filepath = arguments.pop('seed_file') seed = (self.seed_from_filepath(seed_filepath) if seed_filepath else self.prompt_for_seed()) arguments['api'] =\ Iota( adapter = arguments.pop('uri'), seed = seed, testnet = arguments.pop('testnet'), ) return arguments
def test_backward_compatibility(self): """ Test that the local_pow feature is backward compatible. That is, if `local_pow` argument is omitted, it takes no effect and the pow extension package is not called. """ with patch('pow.ccurl_interface.attach_to_tangle', MagicMock(return_value=self.ccurl_bundle)) as mocked_ccurl: self.adapter = MockAdapter() self.adapter.seed_response('attachToTangle',{ 'trytes': self.bundle, }) # No `local_pow` argument is passed to the api! api = Iota(self.adapter) result = api.attach_to_tangle( self.trunk, self.branch, self.bundle, self.mwm) # Ccurl interface was not called self.assertFalse(mocked_ccurl.called) # Result is the one returned by MockAdapter self.assertEqual(result['trytes'], self.bundle) # And not by mocked pow pkg self.assertNotEqual(result['trytes'], self.ccurl_bundle)
def sendTX(msg): ''' PURPOSE: send transaction to the Tangle INPUT: address from a seed different than the one in this script OUTPUT: TX to devnet ''' seed = 'SEED99999999999999999999999999999999999999999999999999999999999999999999999999999' address = 'ADDRESS9FROM9DIFFERENT9SEED999999999999999999999999999999999999999999999999999999' api = Iota('https://nodes.devnet.iota.org:443', seed) tx = ProposedTransaction(address=Address(address), message=TryteString.from_unicode(msg), tag=Tag('YOURTAG'), value=0) try: tx = api.prepare_transfer(transfers=[tx]) except Exception as e: print("Check prepare_transfer ", e) raise try: result = api.send_trytes(tx['trytes'], depth=3, min_weight_magnitude=9) except: print("Check send_trytes")
def test_type_coercion(self): """ The result is coerced to the proper type. https://github.com/iotaledger/iota.py/issues/130 """ # noinspection SpellCheckingInspection self.adapter.seed_response( 'getTips', { 'duration': 42, 'hashes': [ 'TESTVALUE9DONTUSEINPRODUCTION99999ANSVWB' 'CZ9ABZYUK9YYXFRLROGMCMQHRARDQPNMHHZSZ9999', 'TESTVALUE9DONTUSEINPRODUCTION99999HCZURL' 'NFWEDRFCYHWTYGUEMJLJ9ZIJTFASAVSEAZJGA9999', ], }) gt_response = Iota(self.adapter).get_tips() self.assertEqual( list(map(type, gt_response['hashes'])), [TransactionHash] * 2, )
def transfer(address, tag, message, value): recipient_address = address sender_message = message sender_tag = tag prepared_transferes = [] api = Iota(URL_NODE, SEED) sender_tag = bytes(sender_tag) transfer_value = int(value) txn = \ ProposedTransaction( address = Address( recipient_address ), message = TryteString.from_string(sender_message), tag = Tag(sender_tag), value = transfer_value, ) prepared_transferes.append(txn) dict_raw_trytes_tx = api.prepare_transfer(prepared_transferes) len_tx = len(dict_raw_trytes_tx['trytes']) for index in range(len_tx): print str(dict_raw_trytes_tx['trytes'][index]) return True
def send_message(address, depth, message, tag, uri, value): # Ensure seed is not displayed in cleartext. seed = 'NO9SEED9REQUIRED999999999999999999999999999' # Create the API instance. api = Iota(uri, seed) print 'Starting transfer please wait...\n' # For more information, see :py:meth:`Iota.send_transfer`. bundle = api.send_transfer( depth=depth, # One or more :py:class:`ProposedTransaction` objects to add to the # bundle. transfers=[ ProposedTransaction( # Recipient of the transfer. address=Address(address), # Amount of IOTA to transfer. # By default this is a zero value transfer. value=value, # Optional tag to attach to the transfer. tag=Tag(tag), # Optional message to include with the transfer. message=TryteString.from_string(message), ), ], ) print 'Transfer complete. TX hash: ', bundle['bundle'].transactions[0].hash
def main(address, depth, message, tag, uri, value): # Ensure seed is not displayed in cleartext. seed = get_seed() # Create the API instance. api = Iota(uri, seed) if not seed: print('A random seed has been generated. Press return to see it.') output_seed(api.seed) print('Starting transfer.') # For more information, see :py:meth:`Iota.send_transfer`. api.send_transfer( depth=depth, # One or more :py:class:`ProposedTransaction` objects to add to the # bundle. transfers=[ ProposedTransaction( # Recipient of the transfer. address=Address(address), # Amount of IOTA to transfer. # By default this is a zero value transfer. value=value, # Optional tag to attach to the transfer. tag=Tag(tag), # Optional message to include with the transfer. message=TryteString.from_string(message), ), ], ) print('Transfer complete.')
def main(): # Ensure seed is not displayed in cleartext. #seed = get_seed() # Create the API instance. while(1): api = Iota("http://localhost:14265") #if not seed: # print('A random seed has been generated. Press return to see it.') # output_seed(api.seed) #print('Starting transfer.') # For more information, see :py:meth:`Iota.send_transfer`. api.send_transfer( depth=3, # One or more :py:class:`ProposedTransaction` objects to add to the # bundle. transfers=[ ProposedTransaction( # Recipient of the transfer. address=Address("RECEIVINGWALLETADDRESSGOESHERE9WITHCHECKSUMANDSECURITYLEVELB999999999999999999999999999999"), # Amount of IOTA to transfer. # By default this is a zero value transfer. value=0, # Optional tag to attach to the transfer. tag=Tag(b'KITTEHS'), # Optional message to include with the transfer. message=TryteString.from_unicode('thx fur cheezburgers'), ), ], min_weight_magnitude=1 )
def run(self): node_a_ip = self.node_a.ip node_b_ip = self.node_b.ip print_t(node_a_ip, "Starting thread...") print_t( node_a_ip, "Adding node {0} as a neighbour to {1}".format( node_b_ip, node_a_ip)) print_t( node_a_ip, "Attempting to connect to node: http://{0}:14265".format( node_a_ip)) try_again = True while try_again and self.retries > 0: try: api = Iota("http://{0}:14265".format(node_a_ip)) api.add_neighbors(["udp://{0}:14777".format(node_b_ip)]) self.node_a.connected_nodes.append(node_b_ip) print_t( node_a_ip, "Added node {0} as a neighbour to {1}".format( node_b_ip, node_a_ip)) try_again = False except: self.retries -= 1 print_t(node_a_ip, ERROR_MSG.format(node_a_ip, self.delay, self.retries)) try_again = True if self.retries != 0: time.sleep(self.delay) print_t(node_a_ip, "Exiting thread.")
def write_data_to_tangle(data): # Iota instance api = Iota(NODE_URL, SEED) # Txn description txn = ProposedTransaction( address=Address(receiver_address), message=TryteString.from_string(json.dumps(data)), tag=Tag(txn_tag), value=value, ) # Send transaction prepared_transferes = [] bundle = "" prepared_transferes.append(txn) try: bundle = api.send_transfer(depth=DEPTH, transfers=prepared_transferes, min_weight_magnitude=MIN_WEIGHT_MAGNITUDE) except Exception as e: print(e) return e print(bundle['bundle'].hash) return {"status": 200, "bundle": bundle['bundle'].hash}
def sendToAddress(self, message, address, depth, tag, value): api = Iota("http://iota.av.it.pt:14265") # Sample Data # address = b'RECEIVINGWALLETADDRESSGOESHERE9WITHCHECKSUMANDSECURITYLEVELB999999999999999999999RQXIUOZMD' # depth = 3 # tag = b'IOTAPASS' # value = 0 # For more information, see :py:meth:`Iota.send_transfer`. try: api.send_transfer( depth=depth, # One or more :py:class:`ProposedTransaction` objects to add to the # bundle. transfers=[ ProposedTransaction( # Recipient of the transfer. address=Address(address), # Amount of IOTA to transfer. # By default this is a zero value transfer. value=value, # Optional tag to attach to the transfer. tag=Tag(tag), # Optional message to include with the transfer. message=TryteString.from_string(message), ), ], ) return True except: return False
class IotaAdapter(Adapter): chain = Blockchain.IOTA client = Iota('https://nodes.devnet.thetangle.org:443', testnet=True) credentials = database.find_credentials(Blockchain.IOTA) address = credentials['address'] # There needs to be no key because zero-value transfers do not have a sender # https://iota.stackexchange.com/questions/1266/can-one-send-a-zero-value-transaction-from-any-address-to-any-address key = credentials['key'] # ---Store--- @classmethod def create_transaction(cls, text): tx = [ ProposedTransaction( # Recipient address=Address(cls.address), value=0, tag=Tag(b'TAG'), message=TryteString.from_string(text), ), ] return tx @staticmethod def sign_transaction(tx): # tx will be signed and sent in send_raw_transaction return tx @classmethod def send_raw_transaction(cls, tx): # "https://pyota.readthedocs.io/en/latest/api.html#send-transfer" bundle = cls.client.send_transfer(depth=4, transfers=tx) bundle = bundle["bundle"] bundle = Bundle.as_json_compatible(bundle) bundle = bundle[0] tx_hash = bundle["hash_"] tx_hash = str(tx_hash) return tx_hash @staticmethod def add_transaction_to_database(transaction_hash): database.add_transaction(transaction_hash, Blockchain.IOTA) # ---Retrieve--- @classmethod def get_transaction(cls, transaction_hash): bundle = cls.client.get_bundles(transaction_hash) return bundle["bundles"][0] @staticmethod def extract_data(bundle): json = Bundle.as_json_compatible(bundle) data = json[0]["signature_message_fragment"] return data @staticmethod def to_text(data): data = TryteString.decode(data) return str(data)
def test_wireup(self): """ Verifies that the command is wired up correctly. """ self.assertIsInstance( Iota(self.adapter).getBundles, GetBundlesCommand, )
def test_wireup(self): """ Verify that the command is wired up correctly. """ self.assertIsInstance( Iota(self.adapter).getTransactionsToApprove, GetTransactionsToApproveCommand, )
def test_wireup(self): """ Verify that the command is wired up correctly. """ self.assertIsInstance( Iota(self.adapter).getTransfers, GetTransfersCommand, )
def test_wireup(self): """ Verifies that the command is wired-up correctly. """ self.assertIsInstance( Iota(self.adapter).replayBundle, ReplayBundleCommand, )
def test_wireup(self): """ Verify that the command is wired up correctly. """ self.assertIsInstance( Iota(self.adapter).findTransactionObjects, FindTransactionObjectsCommand, )
def test_wireup(self): """ Verify that the command is wired up correctly. """ self.assertIsInstance( Iota(self.adapter).checkConsistency, CheckConsistencyCommand, )
def test_wireup(self): """ Verify that the command is wired up correctly. """ self.assertIsInstance( Iota(self.adapter).addNeighbors, AddNeighborsCommand, )
def test_wireup(self): """ Verify that the command is wired up correctly. """ self.assertIsInstance( Iota(self.adapter).wereAddressesSpentFrom, WereAddressesSpentFromCommand, )
def __init__(self): conf = ConfigParser() path = os.path.join(os.path.dirname(__file__), 'config/config.txt') conf.read(path) self.iota = Iota(conf.get('IOTA', 'node'), conf.get('IOTA', 'seed')) self.generator = AddressGenerator(self.iota.seed) self.match_making_addr = self.generator.get_addresses(1) self.memcached = base.Client(('127.0.0.1', 11211))
def test_wireup(self): """ Verify that the command is wired up correctly. """ self.assertIsInstance( Iota(self.adapter).attachToTangle, AttachToTangleCommand, )
def test_wireup(self): """ Verify that the command is wired up correctly. """ self.assertIsInstance( Iota(self.adapter).getNodeAPIConfiguration, GetNodeAPIConfigurationCommand, )
def test_wireup(self): """ Verify that the command is wired up correctly. """ self.assertIsInstance( Iota(self.adapter).getAccountData, GetAccountDataCommand, )
def test_wireup(self): """ Verify that the command is wired up correctly. """ self.assertIsInstance( Iota(self.adapter).broadcastAndStore, BroadcastAndStoreCommand, )