From 27ce32bd1bfe0a8dc6b2843fb360b37bb2134f7f Mon Sep 17 00:00:00 2001 From: Vishal <64505169+vishalxl@users.noreply.github.com> Date: Mon, 26 Dec 2022 20:09:55 +0530 Subject: [PATCH] displayed lud16 if people have it in their profile page --- bin/nostr_console.dart | 1 + lib/console_ui.dart | 2 ++ lib/event_ds.dart | 17 ++++++++++------- lib/tree_ds.dart | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/bin/nostr_console.dart b/bin/nostr_console.dart index f036758..039ab23 100644 --- a/bin/nostr_console.dart +++ b/bin/nostr_console.dart @@ -119,6 +119,7 @@ Future main(List arguments) async { if( userPublicKey == gDefaultPublicKey) { print("You should ideally create your own private key and use it with ${gWarningColor}--prikey$gColorEndMarker program argument. "); print("Create a private key from ${gWarningColor}astral.ninja, @damusapp, or even from command line using `openssl rand -hex 32`.$gColorEndMarker.\n"); + print("npub/nsec keys can be converted to hex key format using https://damus.io/key"); } // handle relay related argument diff --git a/lib/console_ui.dart b/lib/console_ui.dart index 8cd3637..6316f8b 100644 --- a/lib/console_ui.dart +++ b/lib/console_ui.dart @@ -318,12 +318,14 @@ void printProfile(Store node, String profilePubkey) { print(""); String about = gKindONames[profilePubkey]?.about??""; String picture = gKindONames[profilePubkey]?.picture??""; + String lud16 = gKindONames[profilePubkey]?.lud16??""; int dateLastUpdated = gKindONames[profilePubkey]?.createdAt??0; bool verified = gKindONames[profilePubkey]?.nip05Verified??false; String nip05Id = gKindONames[profilePubkey]?.nip05Id??""; print("\nName : $authorName ( ${profilePubkey} )."); print("About : $about"); print("Picture : $picture"); + print("Lud16 : $lud16"); print("Nip 05 : ${verified?"yes. ${nip05Id}":"no"}"); print("\nLast Updated: ${getPrintableDate(dateLastUpdated)}\n"); diff --git a/lib/event_ds.dart b/lib/event_ds.dart index 290891d..0da6940 100644 --- a/lib/event_ds.dart +++ b/lib/event_ds.dart @@ -31,12 +31,12 @@ List nip08PlaceHolders = ["#[0]", "#[1]", "#[2]", "#[3]", "#[4]", "#[5]" // kind 0 event and/or kind 3 event, both with their own time stamps. class UserNameInfo { int? createdAt; - String? name, about, picture; + String? name, about, picture, lud16; int? createdAtKind3; Event ?latestContactEvent; bool nip05Verified; String? nip05Id; - UserNameInfo(this.createdAt, this.name, this.about, this.picture, this.nip05Id , this.latestContactEvent, [this.createdAtKind3 = null, this.nip05Verified = false]); + UserNameInfo(this.createdAt, this.name, this.about, this.picture, this.lud16, this.nip05Id , this.latestContactEvent, [this.createdAtKind3 = null, this.nip05Verified = false]); } /* @@ -1064,6 +1064,7 @@ bool processKind0Event(Event e) { String name = ""; String about = ""; String picture = ""; + String lud16 = ""; String nip05 = ""; try { @@ -1071,6 +1072,7 @@ bool processKind0Event(Event e) { name = json["name"]??""; about = json["about"]??""; picture = json["picture"]??""; + lud16 = json["lud16"]??""; nip05 = json['nip05']??""; //String twitterId = json['twitter']??""; //String githubId = json['github']??""; @@ -1080,12 +1082,12 @@ bool processKind0Event(Event e) { bool newEntry = false, entryModified = false; if( !gKindONames.containsKey(e.eventData.pubkey)) { - gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, nip05, null); + gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, lud16, nip05, null); newEntry = true;; } else { int oldTime = gKindONames[e.eventData.pubkey]?.createdAt??0; if( oldTime < e.eventData.createdAt) { - gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, nip05, null); + gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, lud16, nip05, null); entryModified = true; } } @@ -1121,7 +1123,7 @@ bool processKind0Event(Event e) { int oldTime = 0; if( !gKindONames.containsKey(e.eventData.pubkey)) { //printWarning("in response handing. creating user info"); - gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, null, null); + gKindONames[e.eventData.pubkey] = UserNameInfo(e.eventData.createdAt, name, about, picture, lud16, null, null); } else { oldTime = gKindONames[e.eventData.pubkey]?.createdAt??0; //print("in response handing. user info exists with old time = $oldTime and this event time = ${e.eventData.createdAt}"); @@ -1157,7 +1159,7 @@ bool processKind3Event(Event newContactEvent) { bool newEntry = false, entryModified = false; if( !gKindONames.containsKey(newContactEvent.eventData.pubkey)) { - gKindONames[newContactEvent.eventData.pubkey] = UserNameInfo(null, null, null, null, null, newContactEvent, newContactEvent.eventData.createdAt); + gKindONames[newContactEvent.eventData.pubkey] = UserNameInfo(null, null, null, null, null, null, newContactEvent, newContactEvent.eventData.createdAt); newEntry = true;; } else { // if entry already exists, then check its old time and update only if we have a newer entry now @@ -1167,9 +1169,10 @@ bool processKind3Event(Event newContactEvent) { String? name = gKindONames[newContactEvent.eventData.pubkey]?.name, about = gKindONames[newContactEvent.eventData.pubkey]?.about, picture = gKindONames[newContactEvent.eventData.pubkey]?.picture, + lud16 = gKindONames[newContactEvent.eventData.pubkey]?.lud16, nip05id = gKindONames[newContactEvent.eventData.pubkey]?.nip05Id??""; - gKindONames[newContactEvent.eventData.pubkey] = UserNameInfo(createdAt, name, about, picture, nip05id, newContactEvent, newContactEvent.eventData.createdAt ); + gKindONames[newContactEvent.eventData.pubkey] = UserNameInfo(createdAt, name, about, picture, lud16, nip05id, newContactEvent, newContactEvent.eventData.createdAt ); entryModified = true;; } } diff --git a/lib/tree_ds.dart b/lib/tree_ds.dart index 7482bb4..2164f20 100644 --- a/lib/tree_ds.dart +++ b/lib/tree_ds.dart @@ -1258,7 +1258,7 @@ class Store { // for pubkeys that don't have any kind 0 events ( but have other events), add then to global kind0 store so they can still be accessed tempChildEventsMap.forEach((key, value) { if( !gKindONames.containsKey(value.event.eventData.pubkey)) { - gKindONames[value.event.eventData.pubkey] = UserNameInfo(null, null, null, null, null, null ); + gKindONames[value.event.eventData.pubkey] = UserNameInfo(null, null, null, null, null, null, null ); } });