Skip to content

Commit b5079f6

Browse files
authored
feat: add lud-20 to LnurlPayMetaData (#52)
* feat: add lud-20 to LnurlPayMetaData
1 parent e82ff66 commit b5079f6

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Check out the LUDS repository: [luds](https://github.com/lnurl/luds/)
3636
- [ ] LUD-17
3737
- [ ] LUD-18
3838
- [ ] LUD-19
39-
- [ ] LUD-20
39+
- [x] LUD-20
4040
- [ ] LUD-21
4141

4242

lnurl/types.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ def __get_url__(cls, address: str) -> Union[OnionUrl, ClearnetUrl, DebugUrl]:
240240

241241

242242
class LnurlPayMetadata(ReprMixin, str):
243-
valid_metadata_mime_types = {"text/plain", "image/png;base64", "image/jpeg;base64"}
243+
# LUD-20: Long payment description for pay protocol. "text/long-desc"
244+
valid_metadata_mime_types = {"text/plain", "image/png;base64", "image/jpeg;base64", "text/long-desc"}
244245

245246
__slots__ = ("_list",)
246247

@@ -263,7 +264,11 @@ def __validate_metadata__(cls, json_str: str) -> List[Tuple[str, str]]:
263264
mime_types = [x[0] for x in clean_data]
264265
counts = {x: mime_types.count(x) for x in mime_types}
265266

266-
if not clean_data or "text/plain" not in mime_types or counts["text/plain"] > 1:
267+
if (
268+
not clean_data
269+
or ("text/plain" not in mime_types and "text/long-desc" not in mime_types)
270+
or counts["text/plain"] > 1
271+
):
267272
raise InvalidLnurlPayMetadata
268273

269274
return clean_data

0 commit comments

Comments
 (0)