Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got an error stack after a successful follow, cannot repro #7

Open
mazz opened this issue Nov 10, 2023 · 3 comments
Open

Got an error stack after a successful follow, cannot repro #7

mazz opened this issue Nov 10, 2023 · 3 comments

Comments

@mazz
Copy link

mazz commented Nov 10, 2023

Got this error stack once, but restarted iex and it didn't happen the second time.

I'm pretty sure this is a legit npub:

iex(4)> NostrApp.follow("npub15tmnw5709va4pgrzpn2kqnnuc2ejssm9a599262jwdpmvmwn9rmqawlkv7")
:ok
iex(5)>
11:11:34.204 [info] sent an follow command for npub15tmnw5709va4pgrzpn2kqnnuc2ejssm9a599262jwdpmvmwn9rmqawlkv7

11:11:34.479 [info] wss://relay.nostr.bg sent 2484cad4a61410b8ed3129b25fe050f13c7e5eb60fef1e99ea3c8160fa0218d0: true

11:11:34.585 [error] GenServer #PID<0.297.0> terminating
** (FunctionClauseError) no function clause matching in Nostr.Client.Workflows.Follow.handle_info/2
    (nostr 0.2.0) lib/nostr/client/workflows/follow.ex:50: Nostr.Client.Workflows.Follow.handle_info({"wss://relay.nostr.bg", "ea82e1640c5bbef5bb650dea2d48d245", %NostrBasics.Event{id: "2484cad4a61410b8ed3129b25fe050f13c7e5eb60fef1e99ea3c8160fa0218d0", pubkey: <<0x74c2d39896c2223815f8aea29793a007a0b2f02620aa9cd01a2fb0b5cc319f44::256>>, created_at: ~U[2023-11-10 16:11:34Z], kind: 3, tags: [["p", "a2f73753cf2b3b50a0620cd5604e7cc2b3284365ed0a5569527343b66dd328f6", ""]], content: "", sig: <<0xce610924b895dce172a20a0bcd8232f420df925c4b96b754b68a9c3cf96390e0b138e6bce862db333e0250f895025cefd315290ea5173f88b598d0dabe7d331b::512>>}}, %{follow_pubkey: <<162, 247, 55, 83, 207, 43, 59, 80, 160, 98, 12, 213, 96, 78, 124, 194, 179, 40, 67, 101, 237, 10, 85, 105, 82, 115, 67, 182, 109, 211, 40, 246>>, got_contact_list: true, owner_pid: #PID<0.272.0>, privkey: <<60, 162, 188, 98, 30, 233, 134, 172, 116, 214, 205, 239, 204, 102, 87, 222, 4, 145, 64, 51, 140, 170, 75, 144, 192, 149, 99, 26, 31, 8, 202, 74>>, relay_pids: [#PID<0.277.0>], subscriptions: [{#PID<0.277.0>, :ea82e1640c5bbef5bb650dea2d48d245}]})
    (stdlib 4.2) gen_server.erl:1123: :gen_server.try_dispatch/4
    (stdlib 4.2) gen_server.erl:1200: :gen_server.handle_msg/6
    (stdlib 4.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: {"wss://relay.nostr.bg", "ea82e1640c5bbef5bb650dea2d48d245", %NostrBasics.Event{id: "2484cad4a61410b8ed3129b25fe050f13c7e5eb60fef1e99ea3c8160fa0218d0", pubkey: <<0x74c2d39896c2223815f8aea29793a007a0b2f02620aa9cd01a2fb0b5cc319f44::256>>, created_at: ~U[2023-11-10 16:11:34Z], kind: 3, tags: [["p", "a2f73753cf2b3b50a0620cd5604e7cc2b3284365ed0a5569527343b66dd328f6", ""]], content: "", sig: <<0xce610924b895dce172a20a0bcd8232f420df925c4b96b754b68a9c3cf96390e0b138e6bce862db333e0250f895025cefd315290ea5173f88b598d0dabe7d331b::512>>}}
State: %{follow_pubkey: <<162, 247, 55, 83, 207, 43, 59, 80, 160, 98, 12, 213, 96, 78, 124, 194, 179, 40, 67, 101, 237, 10, 85, 105, 82, 115, 67, 182, 109, 211, 40, 246>>, got_contact_list: true, owner_pid: #PID<0.272.0>, privkey: <<60, 162, 188, 98, 30, 233, 134, 172, 116, 214, 205, 239, 204, 102, 87, 222, 4, 145, 64, 51, 140, 170, 75, 144, 192, 149, 99, 26, 31, 8, 202, 74>>, relay_pids: [#PID<0.277.0>], subscriptions: [{#PID<0.277.0>, :ea82e1640c5bbef5bb650dea2d48d245}]}

Here's how I initialized my iex:

.iex.local.exs:

relays = [
  "wss://relay.nostr.bg",
  "wss://relay.nostr.pro"
]

nsec = "nsec...lg"
{:ok, pkey} = NostrBasics.Keys.PrivateKey.from_nsec(nsec)
NostrApp.start_link(relays, pkey)

{:ok, pubkey} = NostrBasics.Keys.PublicKey.from_private_key(pkey)
NostrApp.timeline(pubkey)

from mix.lock:

  "nostr_basics": {:hex, :nostr_basics, "0.1.6", "dbbbef1a16645f6edb1102286d2576907785ef320115ebfd525da18e2c5f596d", [:mix], [{:bech32, "~> 1.0", [hex: :bech32, repo: "hexpm", optional: false]}, {:binary, "~> 0.0.5", [hex: :binary, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:k256, "~> 0.0.7", [hex: :k256, repo: "hexpm", optional: false]}], "hexpm", "ac8a4ac54c8956a5f435ddf9a2fe220c2f5e7167cbdca024986eeba0ab3b5377"},

Elixir:

Erlang/OTP 25 [erts-13.1.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Elixir 1.14.2 (compiled with Erlang/OTP 25)
@mazz mazz changed the title Got an error stack after a successful follow Got an error stack after a successful follow, cannot repro Nov 10, 2023
@RooSoft
Copy link
Owner

RooSoft commented Nov 15, 2023

In the 4th line of iex, it is attempted to follow using an npub...

The solution probably is

{:ok, pubkey} = PublicKey.from_npub("npub15tmnw5709va4pgrzpn2kqnnuc2ejssm9a599262jwdpmvmwn9rmqawlkv7")
NostrApp.follow(pubkey)

This probably is under documented as we speak. Also, an improvement might be that the lib converts npubs automatically, so that 4th line you made might start to make sense.

To be honest, as a user, I'd expect what you did to work. Unfortunately, as we speak, most functions expect a binary version of most stuff, especially keys.

@RooSoft
Copy link
Owner

RooSoft commented Nov 15, 2023

Also, the fact that that specific line returns a :ok is pretty odd, as I'm pretty sure it can't work.

Been a while I haven't tinkered with that lib, so, might be that in the past I made some improvements to make it work, but on the top of my head, that's not the case.

@mazz
Copy link
Author

mazz commented Nov 16, 2023

Got the same error with a binary pubkey:

ok,
 <<116, 194, 211, 152, 150, 194, 34, 56, 21, 248, 174, 162, 151, 147, 160, 7,
   160, 178, 240, 38, 32, 170, 156, 208, 26, 47, 176, 181, 204, 49, 159, 68>>}
iex(4)> {:ok, follow_pubkey} = NostrBasics.Keys.PublicKey.from_npub("npub1wnpd8xykcg3rs90c463f0yaqq7st9upxyz4fe5q697cttnp3nazq8fehvc")
{:ok,
 <<116, 194, 211, 152, 150, 194, 34, 56, 21, 248, 174, 162, 151, 147, 160, 7,
   160, 178, 240, 38, 32, 170, 156, 208, 26, 47, 176, 181, 204, 49, 159, 68>>}
iex(5)> NostrApp.follow(follow_pubkey)
:ok
iex(6)> 
21:41:08.241 [info] sent an follow command for t�Ә��"8^U������^G���& ���^Z/���1�D
 
21:41:08.513 [info] wss://relay.nostr.bg sent b5b9ec7f000ee824236aa29d694e5352631edfdb1471931bf8b3838175df0ae2: true
 
21:41:08.619 [error] GenServer #PID<0.336.0> terminating
** (FunctionClauseError) no function clause matching in Nostr.Client.Workflows.Follow.handle_info/2
    (nostr 0.2.0) lib/nostr/client/workflows/follow.ex:50: Nostr.Client.Workflows.Follow.handle_info({"wss://relay.nostr.bg", "d397fe85a7d8cc6985e0d710b7b65fc7", %NostrBasics.Event{id: "b5b9ec7f000ee824236aa29d694e5352631edfdb1471931bf8b3838175df0ae2", pubkey: <<0x9a05d2993271174302cb92df1ef71afce4203267fc2db6243d1a09d3db431dbb::256>>, created_at: ~U[2023-11-16 02:41:08Z], kind: 3, tags: [["p", "74c2d39896c2223815f8aea29793a007a0b2f02620aa9cd01a2fb0b5cc319f44", ""]], content: "", sig: <<0xa6f9c16c8fa31f6f076dc0b044c266b9a431e8fe37a9108e4833056c4ef2080f5f2552b639e10d6b2dca6edbd0679d89a6a07bd26b73733290f392556ad27998::512>>}}, %{follow_pubkey: <<116, 194, 211, 152, 150, 194, 34, 56, 21, 248, 174, 162, 151, 147, 160, 7, 160, 178, 240, 38, 32, 170, 156, 208, 26, 47, 176, 181, 204, 49, 159, 68>>, got_contact_list: true, owner_pid: #PID<0.272.0>, privkey: <<124, 187, 169, 145, 23, 210, 137, 123, 153, 79, 239, 55, 5, 232, 169, 157, 23, 252, 191, 233, 38, 230, 187, 204, 84, 125, 189, 58, 149, 181, 186, 189>>, relay_pids: [#PID<0.277.0>], subscriptions: [{#PID<0.277.0>, :d397fe85a7d8cc6985e0d710b7b65fc7}]})
    (stdlib 4.2) gen_server.erl:1123: :gen_server.try_dispatch/4
    (stdlib 4.2) gen_server.erl:1200: :gen_server.handle_msg/6
    (stdlib 4.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: {"wss://relay.nostr.bg", "d397fe85a7d8cc6985e0d710b7b65fc7", %NostrBasics.Event{id: "b5b9ec7f000ee824236aa29d694e5352631edfdb1471931bf8b3838175df0ae2", pubkey: <<0x9a05d2993271174302cb92df1ef71afce4203267fc2db6243d1a09d3db431dbb::256>>, created_at: ~U[2023-11-16 02:41:08Z], kind: 3, tags: [["p", "74c2d39896c2223815f8aea29793a007a0b2f02620aa9cd01a2fb0b5cc319f44", ""]], content: "", sig: <<0xa6f9c16c8fa31f6f076dc0b044c266b9a431e8fe37a9108e4833056c4ef2080f5f2552b639e10d6b2dca6edbd0679d89a6a07bd26b73733290f392556ad27998::512>>}}
State: %{follow_pubkey: <<116, 194, 211, 152, 150, 194, 34, 56, 21, 248, 174, 162, 151, 147, 160, 7, 160, 178, 240, 38, 32, 170, 156, 208, 26, 47, 176, 181, 204, 49, 159, 68>>, got_contact_list: true, owner_pid: #PID<0.272.0>, privkey: <<124, 187, 169, 145, 23, 210, 137, 123, 153, 79, 239, 55, 5, 232, 169, 157, 23, 252, 191, 233, 38, 230, 187, 204, 84, 125, 189, 58, 149, 181, 186, 189>>, relay_pids: [#PID<0.277.0>], subscriptions: [{#PID<0.277.0>, :d397fe85a7d8cc6985e0d710b7b65fc7}]}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants