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

Adding function to decide if HDNode is private #536

Merged
merged 3 commits into from
Feb 6, 2016
Merged

Adding function to decide if HDNode is private #536

merged 3 commits into from
Feb 6, 2016

Conversation

karelbilek
Copy link
Contributor

It's a very simple function that probably isn't that important, but can help someone.

If you like this idea, I will add some tests for that

@dcousens
Copy link
Contributor

dcousens commented Feb 5, 2016

Nice!

Maybe isNeutered? (aka, the inverse of isPrivate)
That way it is consistent with the neutered() interface?

That way a scenario could play out as:

if (!node.isNeutered()) node = node.neutered()

@dcousens
Copy link
Contributor

dcousens commented Feb 5, 2016

Also, are you up to add some tests? 👍

@dcousens dcousens self-assigned this Feb 5, 2016
@dcousens dcousens added this to the 2.3.0 milestone Feb 5, 2016
@karelbilek
Copy link
Contributor Author

Hm. On one hand, it makes sense, because it's consistent, on the other hand I just wouldn't guess from the name what it means.

I will look more into the travis failures (seems like style issue... that's what I get for editing code in github GUI :))

@@ -281,6 +281,10 @@ HDNode.prototype.deriveHardened = function (index) {
return this.derive(index + HDNode.HIGHEST_BIT)
}

HDNode.prototype.isPrivate = function () {
return !!(this.keyPair.d);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra semicolon

@dcousens
Copy link
Contributor

dcousens commented Feb 5, 2016

why not both?

I wouldn't be opposed to having both then I guess? Its just more to maintain and think about.
I'm just wanting to be consistent, especially since isPrivate is equally vague, at least the isNeutered introduces less context.

@fanatid thoughts?

@dcousens
Copy link
Contributor

dcousens commented Feb 5, 2016

In any case @Runn1ng, please add tests in lieu of the naming bike shed.

@fanatid
Copy link
Member

fanatid commented Feb 5, 2016

Since HDNode already has neutered, isNeutered is better.

@karelbilek
Copy link
Contributor Author

I have renamed the function and removed the semicolon. Now I am adding tests

Public === neutered. Private === not neutered
To test removing private information, it's probably better to start with them :)
@karelbilek
Copy link
Contributor Author

I have added some tests. Is it OK like this?

@karelbilek
Copy link
Contributor Author

...stupid semicolons! :D ok now?

@karelbilek
Copy link
Contributor Author

....the test failure is timeout failure and not related to my changes (I think).

@@ -240,7 +242,7 @@ describe('HDNode', function () {
var f = fixtures.valid[0]

it('strips all private information', function () {
var hd = HDNode.fromBase58(f.master.base58, NETWORKS_LIST)
var hd = HDNode.fromBase58(f.master.base58Priv, NETWORKS_LIST)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha. Good catch.

@dcousens
Copy link
Contributor

dcousens commented Feb 6, 2016

Sorry for the screw around @Runn1ng... 👍

@dcousens
Copy link
Contributor

dcousens commented Feb 6, 2016

Bugger it actually, thanks @Runn1ng 👍

If .isNeutered ends up being a bit too weird or confusing, we'll use isPrivate.

dcousens added a commit that referenced this pull request Feb 6, 2016
Adding function to decide if HDNode is private
@dcousens dcousens merged commit 75bd833 into bitcoinjs:master Feb 6, 2016
@dcousens
Copy link
Contributor

dcousens commented Feb 6, 2016

Won't publish for a little while yet, will be in 2.3.0

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

Successfully merging this pull request may close these issues.

3 participants