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

public scid utils #2694

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lightning/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub mod ser;
pub mod message_signing;
pub mod invoice;
pub mod persist;
pub mod scid_utils;
pub mod string;
pub mod wakers;
#[cfg(fuzzing)]
Expand All @@ -34,7 +35,6 @@ pub(crate) mod chacha20;
pub(crate) mod poly1305;
pub(crate) mod chacha20poly1305rfc;
pub(crate) mod transaction_utils;
pub(crate) mod scid_utils;
pub(crate) mod time;

pub mod indexed_map;
Expand Down
8 changes: 8 additions & 0 deletions lightning/src/util/scid_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// You may not use this file except in accordance with one or both of these
// licenses.

//! Utilities for creating and parsing short channel ids.

/// Maximum block height that can be used in a `short_channel_id`. This
/// value is based on the 3-bytes available for block height.
pub const MAX_SCID_BLOCK: u64 = 0x00ffffff;
Expand All @@ -22,8 +24,11 @@ pub const MAX_SCID_VOUT_INDEX: u64 = 0xffff;
/// A `short_channel_id` construction error
#[derive(Debug, PartialEq, Eq)]
pub enum ShortChannelIdError {
/// Block height too high
BlockOverflow,
/// Tx index too high
TxIndexOverflow,
/// Vout index too high
VoutIndexOverflow,
}

Expand Down Expand Up @@ -91,8 +96,11 @@ pub(crate) mod fake_scid {
/// into the fake scid.
#[derive(Copy, Clone)]
pub(crate) enum Namespace {
/// Phantom nodes namespace
Phantom,
/// SCID aliases for outbound private channels
OutboundAlias,
/// Payment interception namespace
Intercept
}

Expand Down