diff --git a/src/Util.js b/src/Util.js index d3ba475f..85c80664 100644 --- a/src/Util.js +++ b/src/Util.js @@ -61,9 +61,14 @@ export function hexToBech32(hrp, hex) { if (typeof hex !== "string" || hex.length === 0 || hex.length % 2 != 0) { return ""; } - - let buf = secp.utils.hexToBytes(hex); - return bech32.encode(hrp, bech32.toWords(buf)); + + try { + let buf = secp.utils.hexToBytes(hex); + return bech32.encode(hrp, bech32.toWords(buf)); + } catch (e) { + console.warn("Invalid hex", hex, e); + return ""; + } } /**