diff --git a/lightning/src/util/mod.rs b/lightning/src/util/mod.rs index e86885a83db..9affed555c5 100644 --- a/lightning/src/util/mod.rs +++ b/lightning/src/util/mod.rs @@ -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)] @@ -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; diff --git a/lightning/src/util/scid_utils.rs b/lightning/src/util/scid_utils.rs index fbbcc69a133..e18f1e85a68 100644 --- a/lightning/src/util/scid_utils.rs +++ b/lightning/src/util/scid_utils.rs @@ -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; @@ -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, } @@ -65,7 +70,7 @@ pub fn scid_from_parts(block: u64, tx_index: u64, vout_index: u64) -> Result(&self, highest_seen_blockheight: u32, chain_hash: &ChainHash, fake_scid_rand_bytes: &[u8; 32], entropy_source: &ES) -> u64 + pub fn get_fake_scid(&self, highest_seen_blockheight: u32, chain_hash: &ChainHash, fake_scid_rand_bytes: &[u8; 32], entropy_source: &ES) -> u64 where ES::Target: EntropySource, { // Ensure we haven't created a namespace that doesn't fit into the 3 bits we've allocated for