X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Fscid_utils.rs;h=676c303bfa8dc1384b404cfe355aa77d99990242;hb=bbb590b5518eb6e76ddd642187163c487c67dd5c;hp=11b8d0c95e098761ad6cfdd86e9ad717a48fcd27;hpb=99073c74ddce0d7b7a09eca1a4d938704309eb19;p=rust-lightning diff --git a/lightning/src/util/scid_utils.rs b/lightning/src/util/scid_utils.rs index 11b8d0c9..676c303b 100644 --- a/lightning/src/util/scid_utils.rs +++ b/lightning/src/util/scid_utils.rs @@ -61,7 +61,7 @@ pub fn scid_from_parts(block: u64, tx_index: u64, vout_index: u64) -> Result(&self, highest_seen_blockheight: u32, genesis_hash: &BlockHash, fake_scid_rand_bytes: &[u8; 32], keys_manager: &K) -> u64 + pub(crate) fn get_fake_scid(&self, highest_seen_blockheight: u32, genesis_hash: &BlockHash, fake_scid_rand_bytes: &[u8; 32], keys_manager: &K) -> u64 where K::Target: KeysInterface, { // Ensure we haven't created a namespace that doesn't fit into the 3 bits we've allocated for // namespaces. assert!((*self as u8) < MAX_NAMESPACES); - const BLOCKS_PER_MONTH: u32 = 144 /* blocks per day */ * 30 /* days per month */; let rand_bytes = keys_manager.get_secure_random_bytes(); let segwit_activation_height = segwit_activation_height(genesis_hash); @@ -109,7 +112,7 @@ pub(crate) mod fake_scid { // We want to ensure that this fake channel won't conflict with any transactions we haven't // seen yet, in case `highest_seen_blockheight` is updated before we get full information // about transactions confirmed in the given block. - blocks_since_segwit_activation = blocks_since_segwit_activation.saturating_sub(BLOCKS_PER_MONTH); + blocks_since_segwit_activation = blocks_since_segwit_activation.saturating_sub(MAX_SCID_BLOCKS_FROM_NOW); let rand_for_height = u32::from_be_bytes(rand_bytes[..4].try_into().unwrap()); let fake_scid_height = segwit_activation_height + rand_for_height % (blocks_since_segwit_activation + 1); @@ -138,13 +141,6 @@ pub(crate) mod fake_scid { } } - pub fn get_phantom_scid(fake_scid_rand_bytes: &[u8; 32], highest_seen_blockheight: u32, genesis_hash: &BlockHash, keys_manager: &K) -> u64 - where K::Target: KeysInterface, - { - let namespace = Namespace::Phantom; - namespace.get_fake_scid(highest_seen_blockheight, genesis_hash, fake_scid_rand_bytes, keys_manager) - } - fn segwit_activation_height(genesis: &BlockHash) -> u32 { const MAINNET_GENESIS_STR: &'static str = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"; if BlockHash::from_hex(MAINNET_GENESIS_STR).unwrap() == *genesis {