hd: fix HD.from.

This commit is contained in:
Christopher Jeffrey 2016-10-03 14:50:19 -07:00
parent 56e4bace42
commit 16f8fef00b
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -112,26 +112,21 @@ HD.fromExtended = function fromExtended(data) {
*/
HD.from = function from(options, network) {
var xkey;
assert(options, 'Options required.');
if (options.xkey)
xkey = options.xkey;
else if (options.xpubkey)
xkey = options.xpubkey;
else if (options.xprivkey)
xkey = options.xprivkey;
else
xkey = options;
if (HD.isHD(options))
return options;
if (HD.isExtended(xkey))
return HD.fromBase58(xkey);
if (HD.isExtended(options))
return HD.fromBase58(options);
if (HD.hasPrefix(options))
return HD.fromRaw(options);
return HD.fromMnemonic(options, network);
if (options && typeof options === 'object')
return HD.fromMnemonic(options, network);
throw new Error('Cannot create HD key from bad options.');
};
/**