From a64fd4540991f0eb7e4a25ff8759e9bb70a1b754 Mon Sep 17 00:00:00 2001 From: Vishal <64505169+vishalxl@users.noreply.github.com> Date: Mon, 26 Dec 2022 20:23:52 +0530 Subject: [PATCH] printed lnurl if it exists as qr code --- lib/console_ui.dart | 28 +++++++++++++++++++++------- lib/settings.dart | 3 +++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lib/console_ui.dart b/lib/console_ui.dart index 6316f8b..9b8e60f 100644 --- a/lib/console_ui.dart +++ b/lib/console_ui.dart @@ -307,6 +307,14 @@ void printProfile(Store node, String profilePubkey) { pronoun = "They"; } + 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 QR code print("The QR code for public key:\n\n"); try { @@ -315,13 +323,19 @@ void printProfile(Store node, String profilePubkey) { print("Could not generate qr code. \n"); } - 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 LNRUL if it exists + if( lud16.length > gMinLud16AddressLength) { + try { + List? typesAndModule = getTypeAndModule(lud16); + if( typesAndModule != null) { + print("The LNRUL in lud16 as QR:\n\n"); + print(getPubkeyAsQrString(lud16, typesAndModule[0], typesAndModule[1])); + } + } catch(e) { + print("Could not generate qr code for the lnurl given. \n"); + } + } + print("\nName : $authorName ( ${profilePubkey} )."); print("About : $about"); print("Picture : $picture"); diff --git a/lib/settings.dart b/lib/settings.dart index 21aad8a..70ee680 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -191,6 +191,9 @@ const int gMinEventIdLenInSearch = gEventLenPrinted; int gInvalidInputCount = 0; const int gMaxInValidInputAccepted = 40; +// LN settings +const int gMinLud16AddressLength = 10; // used in printProfile + // https://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html#8-colors // Color related settings const String defaultTextColor = "green";