content: parse lightning addresses and render as links

LN addresses use too much screen real estate, render as link seems
more useful.

lightning links are words starting with the following prefix:
lnbc for Bitcoin mainnet, lntb for testnet, lntbs for signet, and
lnbcrt for regtest

https://github.com/lightning/bolts/blob/master/11-payment-encoding.md#human-readable-part
OFF0 2022-12-20 21:28:32 +01:00
parent d7f75f92e0
commit 387f4de3f2
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA
1 changed files with 5 additions and 0 deletions

View File

@ -59,6 +59,11 @@ export function parseTextContent(string) {
.map(line => {
const words = line.split(' ');
return words.map(word => {
if (word.match(/^ln(tbs?|bcr?t?)[a-z0-9]+$/g)) {
return elem('a', {
href: `lightning:${word}`
}, `lightning:${word.slice(0, 24)}`);
}
if (!word.match(/(https?:\/\/|www\.)\S*/)) {
return word;
}