diff --git a/lightning/src/ln/interactivetxs.rs b/lightning/src/ln/interactivetxs.rs index deec638f7f1..15e911cbb4c 100644 --- a/lightning/src/ln/interactivetxs.rs +++ b/lightning/src/ln/interactivetxs.rs @@ -1328,7 +1328,7 @@ mod tests { impl EntropySource for TestEntropySource { fn get_secure_random_bytes(&self) -> [u8; 32] { let mut res = [0u8; 32]; - let increment = self.0.get_increment(); + let increment = self.0.next(); for (i, byte) in res.iter_mut().enumerate() { // Rotate the increment value by 'i' bits to the right, to avoid clashes // when `generate_local_serial_id` does a parity flip on consecutive calls for the diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 51695bba09a..ca6d709410f 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -1053,7 +1053,7 @@ impl SecretKey { let mut ephemeral_hash = self.ephemeral_key_midstate.clone(); - let counter = self.peer_counter.get_increment(); + let counter = self.peer_counter.next(); ephemeral_hash.input(&counter.to_le_bytes()); SecretKey::from_slice(&Sha256::from_engine(ephemeral_hash).to_byte_array()).expect("You broke SHA-256!") } diff --git a/lightning/src/sign/mod.rs b/lightning/src/sign/mod.rs index 1a84caf3639..4b8a9e0255a 100644 --- a/lightning/src/sign/mod.rs +++ b/lightning/src/sign/mod.rs @@ -2504,7 +2504,7 @@ impl RandomBytes { impl EntropySource for RandomBytes { fn get_secure_random_bytes(&self) -> [u8; 32] { - let index = self.index.get_increment(); + let index = self.index.next(); let mut nonce = [0u8; 16]; nonce[..8].copy_from_slice(&index.to_be_bytes()); ChaCha20::get_single_block(&self.seed, &nonce) diff --git a/lightning/src/util/atomic_counter.rs b/lightning/src/util/atomic_counter.rs index 7b5d177c701..3627ccf8a6b 100644 --- a/lightning/src/util/atomic_counter.rs +++ b/lightning/src/util/atomic_counter.rs @@ -21,7 +21,7 @@ impl AtomicCounter { counter: Mutex::new(0), } } - pub(crate) fn get_increment(&self) -> u64 { + pub(crate) fn next(&self) -> u64 { #[cfg(target_has_atomic = "64")] { self.counter.fetch_add(1, Ordering::AcqRel) }