2019-05-15 01:48:48 +03: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 22:58:05 +03:00
|
|
|
exports.decryptKeystoreSync = keystore_1.decryptSync;
|
2019-05-15 01:48:48 +03: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 22:58:05 +03: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 15:03:56 +03:00
|
|
|
//# sourceMappingURL=index.js.map
|