Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterize network information detection #402

Closed
dcousens opened this issue Apr 28, 2015 · 9 comments
Closed

Parameterize network information detection #402

dcousens opened this issue Apr 28, 2015 · 9 comments
Assignees
Milestone

Comments

@dcousens
Copy link
Contributor

Remaining aspects of #325

We should add network to all parts of the API that need it~~, with no defaulting~~.

That means ECPair.fromWIF would require a target network, with an Error thrown if the wrong network is given.
Same with HDNode.fromBase58.

@dcousens
Copy link
Contributor Author

This part of #325 was probably the most controversial, and likely demands more discussion.
I know as a user of this library, in any cases where I alternate between testnet and mainnet for testing anyway, my code is littered with the network information anyway, so this just enforces that behaviour for me.

But it does make the examples a little more verbose.

@dcousens dcousens added this to the 2.0.0 milestone Apr 28, 2015
@jprichardson
Copy link
Member

Disagree with not having a default network. Maybe it's just a matter of taste for me. But it seems that it should always default to the bitcoin network. I understand that it may add more clarity, but at the cost of verbosity, that's for sure.

@dcousens
Copy link
Contributor Author

@jprichardson its an interesting problem to be sure. Defaults are powerful. But in this case they can also be a source of error.

I know for a fact that removing them would be useful in avoiding little frustrating errors that pop up often, but keeping them doesn't appear to be too harmful either as the error is usually immediately obvious.

@dcousens
Copy link
Contributor Author

dcousens commented May 7, 2015

Ping @weilu, @rubensayshi for any further discussion and thoughts? Yay or nay on this?

@dcousens dcousens removed the feature label May 7, 2015
@rubensayshi
Copy link
Contributor

I like having a default network,

but I have to admit, I've personally build everything I did so far to support both testnet and mainnet and thus specify the network all the time.
So my regular argument of 'if 90+% of the use cases are X then it should be the default' doesn't seem to apply as much.

regardless I think a default doesn't hurt and makes life easier for a group of users, including most likely people who try out the library for the first time

@weilu
Copy link
Contributor

weilu commented May 11, 2015

Provide a consistent default network when possible. In case of detection of a network, require a list of possible networks passed in.

@dcousens
Copy link
Contributor Author

In case of detection of a network, require a list of possible networks passed in.

That is an interesting approach.
I guess that would absolve the use of the global networks object entirely making extending the library to alt coins quite simple to explain.

@dcousens
Copy link
Contributor Author

Unless there is further discussion, I'm actually thinking the best approach for the auto-detected networks will be as @weilu outlined above:

Provide a consistent default network when possible. In case of detection of a network, require a list of possible networks passed in.

And for the default network, maintain the behaviour as it currently stands.

@dcousens dcousens changed the title Remove defaulted network information Remove network information pass-through Jul 7, 2015
@dcousens dcousens changed the title Remove network information pass-through Parameterize network information detection Jul 7, 2015
@dcousens
Copy link
Contributor Author

Resolved in #425

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants