Skip to content

Instantly share code, notes, and snippets.

@Blazing-Mike
Created November 7, 2022 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Blazing-Mike/0840ce5c2e54363cdc3f8d5049da324d to your computer and use it in GitHub Desktop.
Save Blazing-Mike/0840ce5c2e54363cdc3f8d5049da324d to your computer and use it in GitHub Desktop.
function constructEndpoint(lnRequest) {
if (lnRequest.includes("@")) {
return DECODE_LN_ADDRESS;
}
if (lnRequest.startsWith("lnurl") && lnRequest.includes("lnurl")) {
return DECODE_LNURL;
}
if (lnRequest.startsWith("ln")) {
return DECODE_PAYMENT_REQUEST;
}
}
function requestDetails(lnRequest) {
if (lnRequest.includes("@")) {
return { lnAddress: lnRequest };
}
if (lnRequest.startsWith("lnurl") && lnRequest.includes("lnurl")) {
return { encodedLnUrl: lnRequest };
}
if (lnRequest.startsWith("ln")) {
return { request: lnRequest };
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment