You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was testing the getZapInfo method with a profile that only has LUD06 and no LUD16, and it threw the following error:
Error getting NIP-57 zap spec Error: Unable to fetch zap endpoint https://undefined/.well-known/lnurlp/ : TypeError: Failed to fetch
Upon inspecting the code, I noticed that the method getNip57ZapSpecFromLud should not have fallen into the conditional case for LUD16 since the user I was trying to retrieve zap info from has an explicit LUD06 value (lud06 : "LNURL1DP68GURN8GHJ7ER9D4HJUMRWVF5HGUEWVDHK6TMVDE6HYMRS9A2K552DW9QS4J8WR2") and an empty string for lud16 (lud16 : " ").
if (lud16 && !lud16.startsWith("LNURL")) {
const [name, domain] = lud16.split("@");
zapEndpoint = `https://${domain}/.well-known/lnurlp/${name}`;
} else if (lud06) {
const { words } = bech32.decode(lud06, 1000);
const data = bech32.fromWords(words);
const utf8Decoder = new TextDecoder("utf-8");
zapEndpoint = utf8Decoder.decode(data);
}
This issue occurs because the profileFromEvent function is not parsing the payload correctly.
case "lud06":
profile.lud06 = payload.lud06;
break;
case "lud16":
profile.lud16 = payload.lud16;
break;
It might be helpful to add .trim() to detect falsy inputs.
The text was updated successfully, but these errors were encountered:
I was testing with more ill formed data and getZapInfo throws the same error. Would be nice to improve the robustness of the method
Ill formed data example:
I was testing the
getZapInfo
method with a profile that only hasLUD06
and noLUD16
, and it threw the following error:Upon inspecting the code, I noticed that the method
getNip57ZapSpecFromLud
should not have fallen into the conditional case forLUD16
since the user I was trying to retrieve zap info from has an explicitLUD06
value (lud06 : "LNURL1DP68GURN8GHJ7ER9D4HJUMRWVF5HGUEWVDHK6TMVDE6HYMRS9A2K552DW9QS4J8WR2"
) and an empty string forlud16
(lud16 : " "
).This issue occurs because the
profileFromEvent
function is not parsing the payload correctly.It might be helpful to add
.trim()
to detect falsy inputs.The text was updated successfully, but these errors were encountered: