diff --git a/.yarn/versions/570cf76a.yml b/.yarn/versions/570cf76a.yml new file mode 100644 index 00000000..c01d3ca3 --- /dev/null +++ b/.yarn/versions/570cf76a.yml @@ -0,0 +1,19 @@ +releases: + "@fluent-wallet/account": patch + "@fluent-wallet/wallet_add-vault": patch + "@fluent-wallet/wallet_create-account": patch + "@fluent-wallet/wallet_create-address": patch + "@fluent-wallet/wallet_generate-address": patch + "@fluent-wallet/wallet_generate-private-key": patch + "@fluent-wallet/wallet_validate-private-key": patch + +declined: + - helios + - "@fluent-wallet/addr-by-network" + - helios-background + - "@fluent-wallet/base32-address" + - "@fluent-wallet/contract-method-name" + - helios-popup + - "@fluent-wallet/spec" + - "@fluent-wallet/shorten-address" + - "@fluent-wallet/utils" diff --git a/packages/account/index.js b/packages/account/index.js index a5e60700..36593809 100644 --- a/packages/account/index.js +++ b/packages/account/index.js @@ -1,7 +1,7 @@ import {getAddress as toChecksumAddress} from '@ethersproject/address' import {computeAddress} from '@ethersproject/transactions' import {Wallet} from '@ethersproject/wallet' -import {randomInt, addHexPrefix} from '@fluent-wallet/utils' +import {randomInt, addHexPrefix, isHexString} from '@fluent-wallet/utils' import { NULL_HEX_ADDRESS, INTERNAL_CONTRACTS_HEX_ADDRESS, @@ -121,6 +121,9 @@ export const randomPrivateKey = () => { export const validatePrivateKey = privateKey => { let valid = false try { + // If the string is not a 64-character hex string, then it is an invalid private key. + if (!isHexString(addHexPrefix(privateKey), 32)) return false + const rst = fromPrivate(privateKey) valid = Boolean(rst.address) } catch (err) {