How to use the iotex-antenna/lib/account/wallet.decrypt function in iotex-antenna

To help you get started, we’ve selected a few iotex-antenna examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iotexproject / iotex-explorer / src / shared / wallet / unlock-by-keystore-file.tsx View on Github external
form.validateFields(async (err, values) => {
        if (err || !values || !values.password || !values.keystore) {
          this.setState({ isDecrypting: false });
          return;
        }
        const { password, keystore } = values;

        try {
          const keyObj = JSON.parse(keystore);
          const { privateKey } = decrypt(keyObj, password);
          const antenna = getAntenna(true);
          const account = await antenna.iotx.accounts.privateKeyToAccount(
            privateKey
          );
          this.props.dispatch(setAccount(account));
        } catch (e) {
          const msg = String(e);
          if (msg.indexOf("SyntaxError") !== -1) {
            notification.error({
              message: t("input.error.keystore.invalid"),
              duration: 5
            });
          } else if (msg.indexOf("derivation failed")) {
            notification.error({
              message: t("input.error.keystore.failed_to_derive"),
              duration: 5