LNURL tipping

This commit is contained in:
2023-01-07 20:54:12 +00:00
parent 8c0b0ac986
commit 037f39e386
9 changed files with 236 additions and 32 deletions

View File

@ -33,6 +33,17 @@ export function bech32ToHex(str) {
return secp.utils.bytesToHex(Uint8Array.from(buff));
}
/**
* Decode bech32 to string UTF-8
* @param {string} str bech32 encoded string
* @returns
*/
export function bech32ToText(str) {
let decoded = bech32.decode(str, 1000);
let buf = bech32.fromWords(decoded.words);
return new TextDecoder().decode(Uint8Array.from(buf));
}
/**
* Convert hex note id to bech32 link url
* @param {string} hex