Catch exceptions
This commit is contained in:
parent
b43f01ff4a
commit
4aeea82bc2
11
src/Util.js
11
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 "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user