How to use the @cityofzion/neon-js.wallet.isNEP2 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 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 nos / client / src / renderer / login / actions / previousAuthActions.js View on Github external
export const writePreviousAuthActions = createActions(ID, ({ encryptedWIF }) => async () => {
  if (!wallet.isNEP2(encryptedWIF)) {
    throw new Error('Invalid encrypted WIF');
  }

  const data = { encryptedWIF };
  await setStorage(ID, data);
  return data;
});
github be-neo / neoblog / packages / sdk / src / helpers / neo.js View on Github external
export const determineKey = key => {
  if (wallet.isNEP2(key)) return "NEP2";
  if (wallet.isWIF(key)) return "WIF";
  return false;
};
github snowypowers / ansy / src / components / Form.js View on Github external
genWallet () {
    if (this.private.value === '') {
      this.setState({ error: 'Empty Field!' })
      return
    }
    if (!wallet.isNEP2(this.private.value) && !wallet.isWIF(this.private.value) && !wallet.isPrivateKey(this.private.value)) {
      this.setState({ error: 'Wrong Private Key Length!' })
      return
    }

    let newWallet = {}
    try {
      const acct = new wallet.Account(this.private.value)
      if (wallet.isNEP2(this.private.value)) {
        if (this.conPassword.value.length > 0) {
          newWallet.nep2 = acct.encrypted
          acct.decrypt(this.conPassword.value)
        } else {
          this.setState({error: "Encrypted key provided without password!"})
        }
      }
      newWallet.private = acct.privateKey
      newWallet.public = acct.publicKey
      newWallet.address = acct.address
    } catch (e) {
      this.setState({ error: "Invalid Private key!" })
      return
    }

    const done = this.props.addWallet(newWallet)
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,