vishalxl / nostr_console

Nostr console is an open-source twitter-like social network, direct chat app and group chat all bundled into one program. Built on the decentralized Nostr protocol.
GNU Affero General Public License v3.0
441 stars 33 forks source link

New install just passing in private and public key as parameters #17

Closed eldraquereal closed 1 year ago

eldraquereal commented 2 years ago

dart run bin/nostr_console.dart -p thekey -k theprivkey

Going to use the provided private key Going to use default file to read from and store events: all_nostr_events.txt Reading events from default file.......read 0 posts from file all_nostr_events.txt Waiting for user posts to come in........done Waiting for feed to come in..............done Unhandled exception: RangeError (end): Invalid value: Not in inclusive range 0..3: -1

0 RangeError.checkValidRange (dart:core/errors.dart:363:9)

1 _StringBase.substring (dart:core-patch/string_patch.dart:400:27)

2 EventData.decryptDirectMessage (package:nostr_console/event_ds.dart:296:27)

3 EventData.translateAndExpandMentions (package:nostr_console/event_ds.dart:253:27)

4 Store.handleDirectMessages (package:nostr_console/tree_ds.dart:783:24)

5 new Store.fromEvents. (package:nostr_console/tree_ds.dart:845:9)

6 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:617:13)

7 new Store.fromEvents (package:nostr_console/tree_ds.dart:829:24)

8 getTree (package:nostr_console/tree_ds.dart:2105:24)

9 main.. (file:///D:/Apps/nostr_console/bin/nostr_console.dart:312:26)

10 new Future.delayed. (dart:async/future.dart:424:39)

11 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15)

12 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)

13 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

eldraquereal commented 2 years ago

Seems to run without the keys - also tested with compiled version

vishalxl commented 2 years ago

It's basically crashing when trying to decrypt direct message. So either the code is buggy related to key, or its buggy related to event format ( can't handle event format).

By any chance your private or public key start with 0? There is a known issue where Nostr Console can't seem to handle public keys that start with 0.

eldraquereal commented 2 years ago

No, a 5 (pub) and an f (priv) - private key is one generated by Alby if any use?

Interestingly, if I just have the public key on the command line I can read and enter public channels fine - as soon as I add the private key it errors.

vishalxl commented 2 years ago

can you check if any of these keys is not 64 bytes? It may happen, so just checking.

NorrinRadd commented 2 years ago

No, a 5 (pub) and an f (priv) - private key is one generated by Alby if any use?

Interestingly, if I just have the public key on the command line I can read and enter public channels fine - as soon as I add the private key it errors.

have you tried using the priv key and only the priv key?

vishalxl commented 2 years ago

Just for the record, there are two formats of keys: 1 is the hex format that nostr_console takes, and another is the npub format that's used by Damus. Both can be used to represent the same key.

vishalxl commented 1 year ago

Issue b: Seems to be same issue: Almost exact same error is seen with private key 1 with argument --prikey=0000000000000000000000000000000000000000000000000000000000000001

Waiting for user posts to come in........done
Waiting for feed to come in..............done
Unhandled exception:
RangeError (end): Invalid value: Not in inclusive range 0..3: -1
#0      RangeError.checkValidRange (dart:core/errors.dart:363:9)
#1      _StringBase.substring (dart:core-patch/string_patch.dart:400:27)
#2      EventData.decryptDirectMessage (package:nostr_console/event_ds.dart:426:27)
#3      EventData.translateAndExpandMentions (package:nostr_console/event_ds.dart:383:27)
#4      Store.handleDirectMessages (package:nostr_console/tree_ds.dart:784:24)
#5      new Store.fromEvents.<anonymous closure> (package:nostr_console/tree_ds.dart:843:9)
#6      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:617:13)
#7      new Store.fromEvents (package:nostr_console/tree_ds.dart:830:24)
#8      getTree (package:nostr_console/tree_ds.dart:2143:24)
#9      main.<anonymous closure>.<anonymous closure> (file:///C:/Users/Vishal/Documents/GitHub/nostr_console/bin/nostr_console.dart:333:26)
#10     new Future.delayed.<anonymous closure> (dart:async/future.dart:424:39)
#11     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
#12     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
#13     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
vishalxl commented 1 year ago

hi eldraquereal, can you try running the same keys with the latest release here, version 0.1.5-beta.

I have fixed some such crashes with it, wondering if yours too may get fixed.

vishalxl commented 1 year ago

No further details known, closing.