-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 some checks on deriving indexes #539
Conversation
if (index >= highestIndex) { | ||
throw new Error('Could not derive with too high index') | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to say I don't understand typeforce that much, but it seems it's actually pretty easy to do that in there. How do you want to name the types... UnsignedInt31 and UnsignedInt32? :) (can typeforce right now to check if the number is integer by the way?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also would you want these types to be added into typeforce source directly, or rather somewhere in bitcoin.js?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...oh, it seems you actually do have the types already in bitcoinjs (well not the 31 bit one, but that can be added). OK, will use that instead
As a consequence, it will not allow accidentally double-hardened indexes. It also won't allow strings or forgotten parameters.
yep you were right, it's easier with typeforce types |
Adding some checks on deriving indexes
Nice @Runn1ng 👍 |
I have added some checks on hardening indexes.
You don't want to accidentally put in twice hardened index, or a negative number to harden (which produces non-hardened index), etc.