Skip to content

smite-ir: add LoadShortChannelId operation#96

Open
devvaansh wants to merge 2 commits into
morehouse:masterfrom
devvaansh:load-short-channel-id
Open

smite-ir: add LoadShortChannelId operation#96
devvaansh wants to merge 2 commits into
morehouse:masterfrom
devvaansh:load-short-channel-id

Conversation

@devvaansh
Copy link
Copy Markdown
Contributor

Short channel IDs are needed for BOLT 7 gossip messages such as
channel_announcement and channel_update.

A short channel ID encodes the block height, transaction index, and
output index of the funding transaction as a packed u64.

Part of #71.

Adds wire codecs for the BOLT 7 short_channel_id packed type and the
channel_update gossip message (type 258), including sign/verify helpers
backed by secp256k1 ECDSA, and wires ChannelUpdate into the central
Message enum so it can be dispatched off the wire.

short_channel_id:

  * Packed u64 representation per BOLT 7 (3 bytes block || 3 bytes tx ||
    2 bytes output). new() panics on out-of-range components (24-bit
    block / tx index), which would be a programmer error in every
    realistic caller. from_u64 is the infallible inverse of as_u64.

channel_update:

  * Preserves any trailing unknown bytes via a pub extra: Vec<u8> field
    so that re-encoding is byte-identical and the signature still
    verifies. Per BOLT 7 the signature covers everything after the
    leading signature field, including unknown fields following
    fee_proportional_millionths.
  * sign(&mut self, sk) writes the body via write_body (which includes
    extra) and stores the resulting ECDSA signature.
  * verify(&self, pk) -> bool recomputes the digest and returns whether
    the stored signature matches the supplied pubkey. Unlike
    node_announcement, channel_update does not embed node_id on the
    wire, so the receiver must look the key up from the previously-seen
    channel_announcement for short_channel_id and pass it explicitly.
  * The decoder is intentionally lenient about flag bits (it preserves
    message_flags / channel_flags verbatim) and leaves policy decisions
    such as enforcement of must_be_one to the caller -- this matches
    how we want to fuzz divergent BOLT 7 implementations.
@devvaansh devvaansh changed the title smite-ir: add LoadShortChannelId operation smite-ir: add LoadShortChannelId operation May 24, 2026
@devvaansh devvaansh force-pushed the load-short-channel-id branch 2 times, most recently from 87513b8 to 259fe5e Compare May 24, 2026 20:19
Short channel IDs are needed for BOLT 7 gossip messages such as channel_announcement and channel_update.
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

Successfully merging this pull request may close these issues.

1 participant