meshcore-uconsole icon indicating copy to clipboard operation
meshcore-uconsole copied to clipboard

Add Channel does not derive or store channel secret, causing send to fail

Open kasparsade opened this issue 5 months ago • 3 comments

Bug

When adding a hashtag channel via the + Add Channel button, the app writes a row to the channels table but does not insert a corresponding row into channel_secrets. This causes any send attempt on the new channel to fail with:

Send failed: Channel 'bot' not in provided channels_config

Steps to reproduce

  1. Launch the app and connect to the radio.
  2. Click + Add Channel and add a hashtag channel (e.g. #bot).
  3. Type a message and click Send.
  4. Observe the error above.

Root cause

Hashtag channel secrets are deterministically derived as: sha256('#' + channel_name)[:32] (first 32 hex chars of SHA-256).

The + Add Channel handler writes to channels but skips channel_secrets, so pyMC_core cannot find the encryption key at send time.

The #Public channel works because it has a hardcoded secret already present in the DB from initial setup.

Workaround

Manually insert the derived secret:

import hashlib
name = "bot"
secret = hashlib.sha256(f"#{name}".encode()).hexdigest()[:32]
# INSERT INTO channel_secrets VALUES('bot', secret)

Fix

In the + Add Channel handler, after writing to channels, also insert into channel_secrets:

secret = hashlib.sha256(f"#{channel_name}".encode()).hexdigest()[:32]
# INSERT OR IGNORE INTO channel_secrets (name, secret) VALUES (?, ?)

Environment

  • meshcore-uconsole on ClockworkPi uConsole CM5 (HackerGadgets AIO v2)
  • Verified algorithm against known value: sha256("#chicago")[:32] == c1c289b131e5222370cbc2048445844b ✓

kasparsade avatar Jun 03 '26 23:06 kasparsade

When working on this issue, is it a good time to add the Private Channels (with a psk) feature?

desultorylogic avatar Jun 09 '26 04:06 desultorylogic

Hi everyone,

first of all: thanks to the author for creating this amazing software for uConsole / AIOv2.

I was following this thread, as I had the same challenge with hashtag channels and also GPS device (see https://github.com/cwill747/meshcore-uconsole/issues/82). As I did not see any recent commits for this repo (despite the proposed fix by kasparsade), I asked Claude to have a look at this and propose a solution. Please don't be offended by the vibe coding approach, as this is only intended to be a temporary fix for frequent uConsole MeshCore users until a more capable coder than me commits a proper solution to the branch. Feel free to test, improve, modify (or completely ignore) the attached patch. No guarantees of course and a fair warning, because this is 100% AI produced, however for me it fixed the channels issue and the GPS issue (at least after previous GPS use on /dev/ttyAMA0).

INSTALL-uconsole-cm5-en.md meshcore-fixes-81-82.patch

educationalpurposes avatar Jul 13 '26 08:07 educationalpurposes

Thanks all and sorry for missing this - reviewing now

cwill747 avatar Aug 09 '26 17:08 cwill747