|
|
@ -129,27 +129,28 @@ Credentials.prototype.exportCompressed = function() { |
|
|
|
return JSON.stringify(values); |
|
|
|
}; |
|
|
|
|
|
|
|
Credentials.prototype.importCompressed = function(compressed) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
Credentials.importCompressed = function(compressed) { |
|
|
|
var list; |
|
|
|
try { |
|
|
|
list = JSON.parse(compressed); |
|
|
|
} catch (ex) { |
|
|
|
throw new Error('Invalid string'); |
|
|
|
throw new Error('Invalid compressed format'); |
|
|
|
} |
|
|
|
|
|
|
|
var x = new Credentials(); |
|
|
|
|
|
|
|
// Remove version
|
|
|
|
var version = list[0]; |
|
|
|
list = _.rest(list); |
|
|
|
|
|
|
|
_.each(EXPORTABLE_FIELDS, function(field, i) { |
|
|
|
self[field] = list[i]; |
|
|
|
x[field] = list[i]; |
|
|
|
}); |
|
|
|
self._expand(); |
|
|
|
x._expand(); |
|
|
|
|
|
|
|
self.network = self.xPubKey.substr(0, 4) == 'tpub' ? 'testnet' : 'livenet'; |
|
|
|
self.publicKeyRing.push(self.xPubKey); |
|
|
|
x.network = x.xPubKey.substr(0, 4) == 'tpub' ? 'testnet' : 'livenet'; |
|
|
|
x.publicKeyRing.push(x.xPubKey); |
|
|
|
return x; |
|
|
|
}; |
|
|
|
|
|
|
|
module.exports = Credentials; |
|
|
|