diff --git a/src/util/util.ts b/src/util/util.ts index f681f23..53fa6bb 100644 --- a/src/util/util.ts +++ b/src/util/util.ts @@ -168,7 +168,13 @@ export function getAddress(pk: string) { export function toMinHex(key: string | Buffer | number) { if (typeof key === 'number') key = toHex(key) + if (typeof key === 'string') { + key = key.trim() + + if(key.length<3 || key[0]!='0' || key[1]!='x') + throw new Error("Only Hex format is supported. Given value "+ key +" is not valid Hex ") + for (let i = 2; i < key.length; i++) { if (key[i] !== '0') return '0x' + key.substr(i)