-
Notifications
You must be signed in to change notification settings - Fork 241
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
Message methods should accept more argument types #5
Comments
+1! |
+1 |
I'm working on this now. Would it be best to call a new constructor and let that handle the conversion? The constructor would also throw a TypeError for bad arguments. Message.prototype.sign = function sign(privateKey) {
privateKey = new PrivateKey(privateKey);
...
} |
I'd use Likewise, it may be better to only accept one type of private key, and have less automatic type handling, for similar reasons. Type handling can be done prior to that and will be more visible and flexible to implementation. There are multiple was that a private key can be represented as a string, and thus could be better handled prior via using: var privateKey = bitcore.PrivateKey.fromWIF(someWIF); //wif
// or
var privateKey = bitcore.PrivateKey.fromString(someString); //hexa |
For example,
sign
could check if privateKey is a String or Buffer and convert accordingly. I can add these, but I'll wait for #2 to be merged to avoid any conflicts.The text was updated successfully, but these errors were encountered: