From 387f4de3f27f1489c1c851d5becd369752e2147d Mon Sep 17 00:00:00 2001 From: OFF0 Date: Tue, 20 Dec 2022 21:28:32 +0100 Subject: [PATCH] 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 --- src/domutil.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/domutil.js b/src/domutil.js index fd76c12..26e2964 100644 --- a/src/domutil.js +++ b/src/domutil.js @@ -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; }