Code Monkey home page Code Monkey logo

Comments (8)

th0br0 avatar th0br0 commented on June 11, 2024

We can't repro. Could you please provide a test case?

from iota.js.

chrisdukakis avatar chrisdukakis commented on June 11, 2024

Make sure you pass total in options. If total is not passed to getNewAddress() it will call findTransactions() and increment the index until a new unused address is found.

from iota.js.

kgrsajid avatar kgrsajid commented on June 11, 2024

@chrisdukakis Are you sure about that? If I pass total along with index in options, it returns multiple addresses (ignores index). Please try it yourself.

@th0br0 Check the following codes. I have 13 used addresses. This code always returns the next unused address even if I set index as less than 13. For the index value >= 13 looks fine.

`var iota = new IOTA({
'host': 'http://service.iotasupport.com',
'port': 14265
});

	var seed = 'YOUR SEED';
	var options = { 
		checksum: true,
		security: 2,
		index: 3
	}
	iota.api.getNewAddress( seed, options, function( error, result ) {
	    console.log(result);
	    // Address:
	});`

from iota.js.

kgrsajid avatar kgrsajid commented on June 11, 2024

@th0br0 You didn't yet repro the issue?!

from iota.js.

th0br0 avatar th0br0 commented on June 11, 2024

I can't close, but:

 // Case 1: total
    //
    // If total number of addresses to generate is supplied, simply generate
    // and return the list of all addresses
 //  Case 2: no total provided
    //
    //  Continue calling findTransactions to see if address was already created
    //  if null, return list of addresses

Please read the documentation.
getNewAddress will return the next unused address.

This is no bug. If you think it is, please provide a repro case.

from iota.js.

kgrsajid avatar kgrsajid commented on June 11, 2024

@th0br0 OMG! Who wrote this library?!

I was talking about index, not total! Please read my posts carefully. I've already provided a case.

If you don't know, getNewAddress also returns specific address based on index, not just next unused address!

from iota.js.

th0br0 avatar th0br0 commented on June 11, 2024

You have not provided a test or repro case. You have provided a code snippet copied from the documentation. That is something quite different.

getNewAddress will only return either:

  • a set number of addresses from index to index+total
  • all addresses that are checked for past transactions starting at index
  • the first address after or at index without past transactions

If the address at index has been used, you will only see it returned if you either specify total or provide returnAll.

from iota.js.

kgrsajid avatar kgrsajid commented on June 11, 2024

Wow! I've lost my words!

It's really the most sophisticated function out there. Probably, we'll be able to transfer IOTA using this function in the future. (Because a function should do more than what it says in the documentation of course.)

I am closing this thread anyway. It seems like IOTA libraries are too perfect to have any bug in them.

from iota.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.