Merge branch 'master' into add-wallet-modal
This commit is contained in:
@@ -57,13 +57,25 @@ struct Profile: Codable {
|
|||||||
set(s) { value["lud16"] = s }
|
set(s) { value["lud16"] = s }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lnurl: String? {
|
||||||
|
guard let addr = lud06 ?? lud16 else {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
if addr.contains("@") {
|
||||||
|
return lnaddress_to_lnurl(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
var nip05: String? {
|
var nip05: String? {
|
||||||
get { return value["nip05"]; }
|
get { return value["nip05"]; }
|
||||||
set(s) { value["nip05"] = s }
|
set(s) { value["nip05"] = s }
|
||||||
}
|
}
|
||||||
|
|
||||||
var lightning_uri: URL? {
|
var lightning_uri: URL? {
|
||||||
return make_ln_url(self.lud06) ?? make_ln_url(self.lud16)
|
return make_ln_url(self.lnurl)
|
||||||
}
|
}
|
||||||
|
|
||||||
init(from decoder: Decoder) throws {
|
init(from decoder: Decoder) throws {
|
||||||
@@ -110,3 +122,17 @@ struct NostrSubscription {
|
|||||||
let sub_id: String
|
let sub_id: String
|
||||||
let filter: NostrFilter
|
let filter: NostrFilter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func lnaddress_to_lnurl(_ lnaddr: String) -> String? {
|
||||||
|
let parts = lnaddr.split(separator: "@")
|
||||||
|
guard parts.count == 2 else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = "https://\(parts[1])/.well-known/lnurlp/\(parts[0])";
|
||||||
|
guard let dat = url.data(using: .utf8) else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return bech32_encode(hrp: "lnurl", Array(dat))
|
||||||
|
}
|
||||||
|
|||||||
@@ -133,7 +133,8 @@ func get_saved_pubkey() -> String? {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func get_saved_privkey() -> String? {
|
func get_saved_privkey() -> String? {
|
||||||
try? Vault.getPrivateKey(keychainConfiguration: DamusKeychainConfiguration())
|
let mkey = try? Vault.getPrivateKey(keychainConfiguration: DamusKeychainConfiguration());
|
||||||
|
return mkey.map { $0.trimmingCharacters(in: .whitespaces) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func removePrivateKeyFromUserDefaults() throws {
|
fileprivate func removePrivateKeyFromUserDefaults() throws {
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ struct EditMetadataView: View {
|
|||||||
website: website,
|
website: website,
|
||||||
nip05: nip05.isEmpty ? nil : nip05,
|
nip05: nip05.isEmpty ? nil : nip05,
|
||||||
picture: picture.isEmpty ? nil : picture,
|
picture: picture.isEmpty ? nil : picture,
|
||||||
lud06: ln.contains("@") ? ln : nil,
|
lud06: ln.contains("@") ? nil : ln,
|
||||||
lud16: ln.contains("@") ? nil : ln
|
lud16: ln.contains("@") ? ln : nil
|
||||||
);
|
);
|
||||||
|
|
||||||
let m_metadata_ev = make_metadata_event(keypair: damus_state.keypair, metadata: metadata)
|
let m_metadata_ev = make_metadata_event(keypair: damus_state.keypair, metadata: metadata)
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ struct ProfileView: View {
|
|||||||
|
|
||||||
//@EnvironmentObject var profile: ProfileModel
|
//@EnvironmentObject var profile: ProfileModel
|
||||||
|
|
||||||
func LNButton(lud06: String?, lud16: String?) -> some View {
|
func LNButton(lud06: String?, lud16: String?, profile: Profile) -> some View {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
if let l = lud06 {
|
if let l = lud06 {
|
||||||
inv = l
|
inv = l
|
||||||
@@ -139,6 +139,12 @@ struct ProfileView: View {
|
|||||||
.symbolRenderingMode(.palette)
|
.symbolRenderingMode(.palette)
|
||||||
.font(.system(size: 34).weight(.thin))
|
.font(.system(size: 34).weight(.thin))
|
||||||
.foregroundStyle(colorScheme == .light ? .black : .white, colorScheme == .light ? .black.opacity(0.1) : .white.opacity(0.2))
|
.foregroundStyle(colorScheme == .light ? .black : .white, colorScheme == .light ? .black.opacity(0.1) : .white.opacity(0.2))
|
||||||
|
}.contextMenu {
|
||||||
|
Button {
|
||||||
|
UIPasteboard.general.string = profile.lnurl ?? ""
|
||||||
|
} label: {
|
||||||
|
Label("Copy LNUrl", systemImage: "doc.on.doc")
|
||||||
|
}
|
||||||
}.sheet(isPresented: $showingSelectWallet, onDismiss: {showingSelectWallet = false}) {
|
}.sheet(isPresented: $showingSelectWallet, onDismiss: {showingSelectWallet = false}) {
|
||||||
SelectWalletView(showingSelectWallet: $showingSelectWallet, invoice: $inv)
|
SelectWalletView(showingSelectWallet: $showingSelectWallet, invoice: $inv)
|
||||||
}
|
}
|
||||||
@@ -164,9 +170,11 @@ struct ProfileView: View {
|
|||||||
ProfilePicView(pubkey: profile.pubkey, size: PFP_SIZE, highlight: .custom(Color.black, 2), profiles: damus_state.profiles)
|
ProfilePicView(pubkey: profile.pubkey, size: PFP_SIZE, highlight: .custom(Color.black, 2), profiles: damus_state.profiles)
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
if (data != nil) && (data?.lud06 != nil || data?.lud16 != nil) {
|
if let profile = data {
|
||||||
LNButton(lud06: data?.lud06, lud16: data?.lud16)
|
if (profile?.lud06 != nil || profile?.lud16 != nil) {
|
||||||
|
LNButton(lud06: data?.lud06, lud16: data?.lud16,, profile: profile)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DMButton
|
DMButton
|
||||||
|
|||||||
Reference in New Issue
Block a user