public scid utils

This commit is contained in:
Evan Feenstra 2023-10-28 08:38:17 -07:00
parent d2242f604d
commit 9a665ca0b8
2 changed files with 9 additions and 1 deletions

View file

@ -20,6 +20,7 @@ pub mod ser;
pub mod message_signing; pub mod message_signing;
pub mod invoice; pub mod invoice;
pub mod persist; pub mod persist;
pub mod scid_utils;
pub mod string; pub mod string;
pub mod wakers; pub mod wakers;
#[cfg(fuzzing)] #[cfg(fuzzing)]
@ -34,7 +35,6 @@ pub(crate) mod chacha20;
pub(crate) mod poly1305; pub(crate) mod poly1305;
pub(crate) mod chacha20poly1305rfc; pub(crate) mod chacha20poly1305rfc;
pub(crate) mod transaction_utils; pub(crate) mod transaction_utils;
pub(crate) mod scid_utils;
pub(crate) mod time; pub(crate) mod time;
pub mod indexed_map; pub mod indexed_map;

View file

@ -7,6 +7,8 @@
// You may not use this file except in accordance with one or both of these // You may not use this file except in accordance with one or both of these
// licenses. // licenses.
//! Utilities for creating and parsing short channel ids.
/// Maximum block height that can be used in a `short_channel_id`. This /// Maximum block height that can be used in a `short_channel_id`. This
/// value is based on the 3-bytes available for block height. /// value is based on the 3-bytes available for block height.
pub const MAX_SCID_BLOCK: u64 = 0x00ffffff; pub const MAX_SCID_BLOCK: u64 = 0x00ffffff;
@ -22,8 +24,11 @@ pub const MAX_SCID_VOUT_INDEX: u64 = 0xffff;
/// A `short_channel_id` construction error /// A `short_channel_id` construction error
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub enum ShortChannelIdError { pub enum ShortChannelIdError {
/// Block height too high
BlockOverflow, BlockOverflow,
/// Tx index too high
TxIndexOverflow, TxIndexOverflow,
/// Vout index too high
VoutIndexOverflow, VoutIndexOverflow,
} }
@ -91,8 +96,11 @@ pub(crate) mod fake_scid {
/// into the fake scid. /// into the fake scid.
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub(crate) enum Namespace { pub(crate) enum Namespace {
/// Phantom nodes namespace
Phantom, Phantom,
/// SCID aliases for outbound private channels
OutboundAlias, OutboundAlias,
/// Payment interception namespace
Intercept Intercept
} }