nip19: add bech32 TLV url parsing
Create shortened URLs for bech32 with TLV data strings. Additionally, upon clicking on an nevent URL the user is directed to the note. Lightning-url: LNURL1DP68GURN8GHJ7EM9W3SKCCNE9E3K7MF0D3H82UNVWQHKWUN9V4HXGCTHDC6RZVGR8SW3G Signed-off-by: kernelkind <kernelkind@gmail.com> Reviewed-by: William Casarin <jb55@jb55.com> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
William Casarin
parent
af75eed83a
commit
d07ad67778
@@ -121,7 +121,8 @@ enum RefId: TagConvertible, TagKeys, Equatable, Hashable {
|
||||
case quote(QuoteId)
|
||||
case hashtag(TagElem)
|
||||
case param(TagElem)
|
||||
|
||||
case naddr(NAddr)
|
||||
|
||||
var key: RefKey {
|
||||
switch self {
|
||||
case .event: return .e
|
||||
@@ -129,11 +130,12 @@ enum RefId: TagConvertible, TagKeys, Equatable, Hashable {
|
||||
case .quote: return .q
|
||||
case .hashtag: return .t
|
||||
case .param: return .d
|
||||
case .naddr: return .a
|
||||
}
|
||||
}
|
||||
|
||||
enum RefKey: AsciiCharacter, TagKey, CustomStringConvertible {
|
||||
case e, p, t, d, q
|
||||
case e, p, t, d, q, a
|
||||
|
||||
var keychar: AsciiCharacter {
|
||||
self.rawValue
|
||||
@@ -155,6 +157,8 @@ enum RefId: TagConvertible, TagKeys, Equatable, Hashable {
|
||||
case .quote(let quote): return quote.hex()
|
||||
case .hashtag(let string): return string.string()
|
||||
case .param(let string): return string.string()
|
||||
case .naddr(let naddr):
|
||||
return naddr.kind.description + ":" + naddr.author.hex() + ":" + naddr.identifier
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,6 +178,7 @@ enum RefId: TagConvertible, TagKeys, Equatable, Hashable {
|
||||
case .q: return t1.id().map({ .quote(QuoteId($0)) })
|
||||
case .t: return .hashtag(t1)
|
||||
case .d: return .param(t1)
|
||||
case .a: return .naddr(NAddr(identifier: "", author: Pubkey(Data()), relays: [], kind: 0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user