fix: use hex encoding

This commit is contained in:
Alejandro Gomez 2023-02-27 19:58:37 +01:00
parent 74843f3a67
commit 328f34f8dc
No known key found for this signature in database
GPG Key ID: 4DF39E566658C817

View File

@ -37,7 +37,20 @@ export function encodeTLV(
author?: string, author?: string,
kind?: number kind?: number
) { ) {
if (
prefix !=== NostrPrefix.Address || typeof hex !== "string" ||
hex.length === 0 ||
hex.length % 2 !== 0
) {
return "";
}
const enc = new TextEncoder(); const enc = new TextEncoder();
let buf;
if (prefix === NostrPrefix.Address) {
buf = enc.encode(hex);
} else {
buf = secp.utils.hexToBytes(hex);
}
const buf = enc.encode(hex); const buf = enc.encode(hex);
const tl0 = [0, buf.length, ...buf]; const tl0 = [0, buf.length, ...buf];