2019-05-14 18:48:48 -04:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
var crowdsale_1 = require("./crowdsale");
|
|
|
|
exports.decryptCrowdsale = crowdsale_1.decrypt;
|
|
|
|
var inspect_1 = require("./inspect");
|
|
|
|
exports.getJsonWalletAddress = inspect_1.getJsonWalletAddress;
|
|
|
|
exports.isCrowdsaleWallet = inspect_1.isCrowdsaleWallet;
|
|
|
|
exports.isKeystoreWallet = inspect_1.isKeystoreWallet;
|
|
|
|
var keystore_1 = require("./keystore");
|
|
|
|
exports.decryptKeystore = keystore_1.decrypt;
|
2020-02-27 19:58:05 +00:00
|
|
|
exports.decryptKeystoreSync = keystore_1.decryptSync;
|
2019-05-14 18:48:48 -04:00
|
|
|
exports.encryptKeystore = keystore_1.encrypt;
|
|
|
|
function decryptJsonWallet(json, password, progressCallback) {
|
|
|
|
if (inspect_1.isCrowdsaleWallet(json)) {
|
|
|
|
if (progressCallback) {
|
|
|
|
progressCallback(0);
|
|
|
|
}
|
|
|
|
var account = crowdsale_1.decrypt(json, password);
|
|
|
|
if (progressCallback) {
|
|
|
|
progressCallback(1);
|
|
|
|
}
|
|
|
|
return Promise.resolve(account);
|
|
|
|
}
|
|
|
|
if (inspect_1.isKeystoreWallet(json)) {
|
|
|
|
return keystore_1.decrypt(json, password, progressCallback);
|
|
|
|
}
|
|
|
|
return Promise.reject(new Error("invalid JSON wallet"));
|
|
|
|
}
|
|
|
|
exports.decryptJsonWallet = decryptJsonWallet;
|
2020-02-27 19:58:05 +00:00
|
|
|
function decryptJsonWalletSync(json, password) {
|
|
|
|
if (inspect_1.isCrowdsaleWallet(json)) {
|
|
|
|
return crowdsale_1.decrypt(json, password);
|
|
|
|
}
|
|
|
|
if (inspect_1.isKeystoreWallet(json)) {
|
|
|
|
return keystore_1.decryptSync(json, password);
|
|
|
|
}
|
|
|
|
throw new Error("invalid JSON wallet");
|
|
|
|
}
|
|
|
|
exports.decryptJsonWalletSync = decryptJsonWalletSync;
|
2020-07-13 08:03:56 -04:00
|
|
|
//# sourceMappingURL=index.js.map
|