hd: fix HD.from.
This commit is contained in:
parent
56e4bace42
commit
16f8fef00b
21
lib/hd/hd.js
21
lib/hd/hd.js
@ -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.');
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user