|
|
@ -7,6 +7,7 @@ var networks = require('./networks'); |
|
|
|
var base58check = require('./encoding/base58check'); |
|
|
|
var Address = require('./address'); |
|
|
|
var PublicKey = require('./publickey'); |
|
|
|
var jsUtil = require('./util/js'); |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
@ -51,7 +52,11 @@ var PrivateKey = function PrivateKey(data, network, compressed) { |
|
|
|
} else if (data instanceof Buffer || data instanceof Uint8Array) { |
|
|
|
info = PrivateKey._transformBuffer(data, network, compressed); |
|
|
|
} else if (typeof(data) === 'string'){ |
|
|
|
info = PrivateKey._transformWIF(data, network, compressed); |
|
|
|
if (jsUtil.isHexa(data)) { |
|
|
|
info.bn = BN(new Buffer(data, 'hex')); |
|
|
|
} else { |
|
|
|
info = PrivateKey._transformWIF(data, network, compressed); |
|
|
|
} |
|
|
|
} else { |
|
|
|
throw new TypeError('First argument is an unrecognized data type.'); |
|
|
|
} |
|
|
|