handle lightning tip addresses and LNURL better

This commit is contained in:
hzrd149 2023-02-15 11:21:51 -06:00
parent 21a49d7aa8
commit 8368da0e43
2 changed files with 23 additions and 8 deletions

View File

@ -52,10 +52,10 @@
## TODO
- Create a "event posting" service that can show modals (for qr code scanning), warnings (signed by wrong pubkey), and results (what relays responded) when posting events.
- Create notifications service that keeps track of read notifications. (show unread count in sidenav)
- Rebuild relays view to show relay info and settings NIP-11
- add button for creating lightning invoice via WebLN
- allow user to select relay or following list when fetching replies (default to my relays + following?)
- massive thread note1dapvuu8fl09yjtg2gyr2h6nypaffl2sq0aj5raz86463qk5kpyzqlxvtc3
- use `nostr-tools` to allow user to generate and use nsec keys for login.
- filter list of followers by users the user has blocked/reported (stops bots/spammers from showing up at followers)
- Add note embeds
- Add "repost" button that mentions the note
@ -66,6 +66,8 @@
- make app a valid web share target https://developer.chrome.com/articles/web-share-target/
- implement NIP-56 and blocking
- block notes based on content
- allow user to select relay or following list when fetching replies (default to my relays + following?)
- massive thread note1dapvuu8fl09yjtg2gyr2h6nypaffl2sq0aj5raz86463qk5kpyzqlxvtc3
## Setup

View File

@ -10,10 +10,17 @@ export const UserTipButton = ({ pubkey, ...props }: { pubkey: string } & Omit<Ic
const toast = useToast();
if (!metadata) return null;
let lnurl = metadata.lud06;
if (metadata.lud16 && !lnurl) {
const parts = metadata.lud16.split("@");
lnurl = encodeText("lnurl", `https://${parts[1]}/.well-known/lnurlp/${parts[0]}`);
// use lud06 and lud16 fields interchangeably
let lnurl = metadata.lud06 || metadata.lud16;
if (lnurl && lnurl.includes("@")) {
//if its a lightning address convert it to a lnurl
const parts = lnurl.split("@");
if (parts[0] && parts[1]) {
lnurl = encodeText("lnurl", `https://${parts[1]}/.well-known/lnurlp/${parts[0]}`);
} else {
// failed to parse it. something is wrong...
lnurl = undefined;
}
}
if (!lnurl) return null;
@ -32,7 +39,13 @@ export const UserTipButton = ({ pubkey, ...props }: { pubkey: string } & Omit<Ic
status: "success",
duration: 1000,
});
} catch (e) {}
} catch (e: any) {
toast({
status: "error",
description: e?.message,
isClosable: true,
});
}
} else {
window.open(`lnurl:${lnurl}`);
}