Skip to content

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

Description

@kasparsade

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 ✓

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions