Conversation
"+ Add Channel" wrote a row to `channels` but never to `channel_secrets`,
so pyMC_core had no key for the channel and every send failed with
"Channel 'bot' not in provided channels_config". Only #Public worked,
because its secret is seeded as a constant at first launch.
MeshCore derives a hashtag channel's key as sha256("#" + name)[:32]
(verified: sha256("#mesh")[:32] == 5b664cde0b08b220612113db980650f3,
matching the published value). Names are lowercased first, matching the
lowercase-alnum-and-hyphens convention the ecosystem uses; the key *is*
the shared secret, so "#Chicago" and "#chicago" must not diverge.
- ensure_channel() and send_message() now populate channel_secrets for
group channels, so both send and receive work without a reconnect
(GroupTextHandler queries the channel db live).
- A v6 -> v7 migration backfills channels created before this fix, so
existing installs repair themselves instead of needing a manual INSERT.
- #Public keeps its hardcoded constant; it is deliberately *not* the
derived sha256("#public")[:32], and backfilling it would break the
default channel.
Based on the patch contributed by @educationalpurposes in #81, with two
fixes on top:
- The backfill stored the lowercased name but left `channels.display_name`
mixed-case, and send_message passed display_name to pyMC_core's
case-sensitive matcher — so a backfilled "#Chicago" still failed to send.
Senders now resolve the name through channel_secrets rather than
trusting the display name.
- Removing a channel hard-deleted its secret, destroying secrets imported
with `radio_cli import-channel`, which cannot be recovered. Only derived
secrets are dropped now.
Closes #81
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #81.
Problem
+ Add Channelwrote a row tochannelsbut never tochannel_secrets, so pyMC_core had no key for the channel and every send failed withSend failed: Channel 'bot' not in provided channels_config. Only#Publicworked, because its secret is seeded as a constant at first launch.Fix
MeshCore derives a hashtag channel's key as
sha256("#" + name)[:32]. Verified independently of the issue report:sha256("#mesh")[:32] == 5b664cde0b08b220612113db980650f3, matching the published value. Names are lowercased first, matching the lowercase-alnum-and-hyphens convention the ecosystem uses — the key is the shared secret, so#Chicagoand#chicagomust not diverge.ensure_channel()andsend_message()now populatechannel_secretsfor group channels. Both send and receive work without a reconnect, sinceGroupTextHandlerqueries the channel db live.v6 -> v7migration backfills channels created before this fix, so existing installs repair themselves instead of needing the manualINSERTfrom the issue.#Publickeeps its hardcoded constant. It is deliberately not the derivedsha256("#public")[:32](8b4b705b…vs the real8b3387e9…), and backfilling it would break the default channel.Credit and changes on top
Based on the patch contributed by @educationalpurposes in #81, with two fixes:
channels.display_namemixed-case, andsend_messagepasseddisplay_namestraight to pyMC_core's case-sensitive matcher — so a backfilled#Chicagostill raisedChannel 'Chicago' not in provided channels_config. Senders now resolve the name throughchannel_secretsinstead of trusting the display name.radio_cli import-channelcannot be recovered; a derived hashtag secret always can. Only derived secrets are dropped now.Verification
uv run pytest: 115 passed, 1 skipped.ruff check/ruff format --checkclean.PacketBuilder.create_group_datagram: derived (#bot), imported-PSK (#MyPrivate), and constant (#Public) channels all build packets.tests/unit/test_channel_secrets.py.🤖 Generated with Claude Code