Compare commits

...

1 Commits

Author SHA1 Message Date
8f6ea4d8dd Add support for scanning nprofile QR codes
Changelog-Added: Added support for scanning nprofile QR codes

Closes: https://github.com/damus-io/damus/issues/2671
Signed-off-by: Terry Yiu <git@tyiu.xyz>
2025-08-18 08:36:58 -07:00

View File

@@ -440,21 +440,15 @@ fileprivate struct QRCameraView<Content: View>: View {
str.removeFirst("nostr:".count)
}
if let decoded = hex_decode(str),
str.count == 64
{
self.pubkey = Pubkey(Data(decoded))
return
let bech32 = Bech32Object.parse(str)
switch bech32 {
case .nprofile(let nprofile):
self.pubkey = nprofile.author
case .npub(let pubkey):
self.pubkey = pubkey
default:
return nil
}
if str.starts(with: "npub"),
let b32 = try? bech32_decode(str)
{
self.pubkey = Pubkey(b32.data)
return
}
return nil
}
}
}