This commit is contained in:
Kieran 2023-01-10 11:19:52 +00:00
parent 77ad8a3052
commit ccbf041b2a
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941

View File

@ -58,6 +58,10 @@ export function eventLink(hex) {
* @param {string} hex
*/
export function hexToBech32(hrp, hex) {
if (typeof hex !== "string" || hex.length === 0 || hex.length % 2 != 0) {
return null;
}
let buf = secp.utils.hexToBytes(hex);
return bech32.encode(hrp, bech32.toWords(buf));
}