How to use the @cityofzion/neon-js.wallet.decryptAsync function in @cityofzion/neon-js

To help you get started, we’ve selected a few @cityofzion/neon-js 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 CityOfZion / neon-wallet / app / components / CreateImportSplitWalletForm / CreateImportSplitWalletForm.jsx View on Github external
existingPassphrase,
      selectedAccount,
    } = this.state
    const {
      generateNewWalletAccount,
      authenticated,
      history,
      accounts,
    } = this.props

    if (selectedAccount) {
      const accountInStorage = accounts.find(
        account => account.label === selectedAccount.value,
      )

      const key = await wallet.decryptAsync(
        accountInStorage.key,
        existingPassphrase,
      )
      generateNewWalletAccount(
        passphrase,
        passphrase2,
        key,
        keypart2,
        'SPLIT',
        history,
        walletName,
        authenticated,
        () => this.setState({ submitButtonDisabled: false }),
      )
    }
  }
github CityOfZion / neon-wallet / app / components / CreateImportSplitWalletForm / CreateImportSplitWalletForm.jsx View on Github external
toggleStep = (e: SyntheticMouseEvent<*>) => {
    if (this.state.step === 1) {
      const { existingPassphrase, selectedAccount, keypart2 } = this.state
      const { showErrorNotification } = this.props

      if (selectedAccount) {
        const accountInStorage = this.props.accounts.find(
          account => account.label === selectedAccount.value,
        )

        this.setState({ submitButtonDisabled: true })
        e.preventDefault()

        wallet
          .decryptAsync(accountInStorage.key, existingPassphrase)
          .then(() => {
            if (keypart2 && !wallet.isWIF(keypart2)) {
              showErrorNotification({
                message: 'Invalid secondary private key WIF',
              })
            } else {
              this.setState({ step: 2 })
            }
          })
          .catch(err => showErrorNotification({ message: err.message }))
          .finally(() => this.setState({ submitButtonDisabled: false }))
      }
    } else {
      this.setState({ step: 1 })
    }
github nos / client / src / renderer / login / actions / authActions.js View on Github external
const nep2Authenticate = async (passphrase, encryptedWIF) => {
  if (!wallet.isNEP2(encryptedWIF)) {
    throw new Error('That is not a valid encrypted key.');
  }

  const wif = await wallet.decryptAsync(encryptedWIF, passphrase);
  const account = new wallet.Account(wif);

  return { wif: account.WIF, address: account.address };
};
github CityOfZion / neon-wallet / app / actions / authActions.js View on Github external
({ passphrase, encryptedWIF }: Nep2LoginProps) => async (): Promise<
    AccountType,
  > => {
    if (!validatePassphraseLength(passphrase)) {
      throw new Error('Passphrase too short')
    }

    if (!wallet.isNEP2(encryptedWIF)) {
      throw new Error('Invalid encrypted key entered')
    }

    const wif = await wallet.decryptAsync(encryptedWIF, passphrase)
    const account = new wallet.Account(wif)

    await upgradeNEP6AddAddresses(encryptedWIF, wif)

    const hasInternetConnectivity = await checkForInternetConnectivity()

    return {
      wif: account.WIF,
      publicKey: account.publicKey,
      address: account.address,
      isHardwareLogin: false,
      hasInternetConnectivity,
    }
  },
)
github nos / client / src / renderer / shared / components / NewWallet / Import / ExistingImport / ExistingImport.js View on Github external
submit = async () => {
    const {
      account,
      passphrase,
      accounts,
      setPassphrase,
      addAccount,
      showErrorToast,
      legacyPassphrase,
      currentAccount
    } = this.props;

    const walletLabel = accounts.filter((acc) => acc.encryptedKey === currentAccount)[0].walletName;

    try {
      const wif = await wallet.decryptAsync(currentAccount, legacyPassphrase);
      const { privateKey } = new wallet.Account(wif);

      const options = {
        walletLabel,
        coinType: NEO,
        isHardware: account.isHardware,
        isImport: true,
        privateKey
      };

      addAccount({ account, passphrase, options });
      setPassphrase('');
    } catch (e) {
      showErrorToast(`Incorrect legacy passphrase for account ${walletLabel}`);
    }
  };