Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
({ wif }: WifLoginProps) => async (): Promise => {
if (!wallet.isWIF(wif) && !wallet.isPrivateKey(wif)) {
throw new Error('Invalid private key entered')
}
const account = new wallet.Account(wif)
const hasInternetConnectivity = await checkForInternetConnectivity()
return {
wif: account.WIF,
publicKey: account.publicKey,
address: account.address,
isHardwareLogin: false,
hasInternetConnectivity,
}
},
)
const wifAuthenticate = (wif) => {
if (!wallet.isWIF(wif) && !wallet.isPrivateKey(wif)) {
throw new Error('That is not a valid private key.');
}
const account = new wallet.Account(wif);
return { wif: account.WIF, address: account.address };
};
renderDescription = () => {
const { encryptedWIF } = this.props;
if (isEmpty(encryptedWIF)) {
return null;
}
if (wallet.isPrivateKey(encryptedWIF)) {
return 'Private key detected.';
} else {
return 'Encrypted key detected, please type passphrase.';
}
};
isValid = () => {
const { encryptedWIF, passphrase } = this.props;
return !(isEmpty(encryptedWIF) || (!wallet.isPrivateKey(encryptedWIF) && isEmpty(passphrase)));
};
renderPassphraseInput = () => {
const { encryptedWIF, passphrase, disabled } = this.props;
if (isEmpty(encryptedWIF) || wallet.isPrivateKey(encryptedWIF)) {
return null;
}
return (
);
};