@@ -33,17 +33,17 @@ pub enum ShortChannelIdError {
33
33
}
34
34
35
35
/// Extracts the block height (most significant 3-bytes) from the `short_channel_id`
36
- pub fn block_from_scid ( short_channel_id : & u64 ) -> u32 {
36
+ pub fn block_from_scid ( short_channel_id : u64 ) -> u32 {
37
37
return ( short_channel_id >> 40 ) as u32 ;
38
38
}
39
39
40
40
/// Extracts the tx index (bytes [2..4]) from the `short_channel_id`
41
- pub fn tx_index_from_scid ( short_channel_id : & u64 ) -> u32 {
41
+ pub fn tx_index_from_scid ( short_channel_id : u64 ) -> u32 {
42
42
return ( ( short_channel_id >> 16 ) & MAX_SCID_TX_INDEX ) as u32 ;
43
43
}
44
44
45
45
/// Extracts the vout (bytes [0..2]) from the `short_channel_id`
46
- pub fn vout_from_scid ( short_channel_id : & u64 ) -> u16 {
46
+ pub fn vout_from_scid ( short_channel_id : u64 ) -> u16 {
47
47
return ( ( short_channel_id) & MAX_SCID_VOUT_INDEX ) as u16 ;
48
48
}
49
49
@@ -162,22 +162,22 @@ pub(crate) mod fake_scid {
162
162
163
163
/// Returns whether the given fake scid falls into the phantom namespace.
164
164
pub fn is_valid_phantom ( fake_scid_rand_bytes : & [ u8 ; 32 ] , scid : u64 , chain_hash : & ChainHash ) -> bool {
165
- let block_height = scid_utils:: block_from_scid ( & scid) ;
166
- let tx_index = scid_utils:: tx_index_from_scid ( & scid) ;
165
+ let block_height = scid_utils:: block_from_scid ( scid) ;
166
+ let tx_index = scid_utils:: tx_index_from_scid ( scid) ;
167
167
let namespace = Namespace :: Phantom ;
168
168
let valid_vout = namespace. get_encrypted_vout ( block_height, tx_index, fake_scid_rand_bytes) ;
169
169
block_height >= segwit_activation_height ( chain_hash)
170
- && valid_vout == scid_utils:: vout_from_scid ( & scid) as u8
170
+ && valid_vout == scid_utils:: vout_from_scid ( scid) as u8
171
171
}
172
172
173
173
/// Returns whether the given fake scid falls into the intercept namespace.
174
174
pub fn is_valid_intercept ( fake_scid_rand_bytes : & [ u8 ; 32 ] , scid : u64 , chain_hash : & ChainHash ) -> bool {
175
- let block_height = scid_utils:: block_from_scid ( & scid) ;
176
- let tx_index = scid_utils:: tx_index_from_scid ( & scid) ;
175
+ let block_height = scid_utils:: block_from_scid ( scid) ;
176
+ let tx_index = scid_utils:: tx_index_from_scid ( scid) ;
177
177
let namespace = Namespace :: Intercept ;
178
178
let valid_vout = namespace. get_encrypted_vout ( block_height, tx_index, fake_scid_rand_bytes) ;
179
179
block_height >= segwit_activation_height ( chain_hash)
180
- && valid_vout == scid_utils:: vout_from_scid ( & scid) as u8
180
+ && valid_vout == scid_utils:: vout_from_scid ( scid) as u8
181
181
}
182
182
183
183
#[ cfg( test) ]
@@ -248,14 +248,14 @@ pub(crate) mod fake_scid {
248
248
let namespace = Namespace :: Phantom ;
249
249
let fake_scid = namespace. get_fake_scid ( 500_000 , & mainnet_genesis, & fake_scid_rand_bytes, & keys_manager) ;
250
250
251
- let fake_height = scid_utils:: block_from_scid ( & fake_scid) ;
251
+ let fake_height = scid_utils:: block_from_scid ( fake_scid) ;
252
252
assert ! ( fake_height >= MAINNET_SEGWIT_ACTIVATION_HEIGHT ) ;
253
253
assert ! ( fake_height <= 500_000 ) ;
254
254
255
- let fake_tx_index = scid_utils:: tx_index_from_scid ( & fake_scid) ;
255
+ let fake_tx_index = scid_utils:: tx_index_from_scid ( fake_scid) ;
256
256
assert ! ( fake_tx_index <= MAX_TX_INDEX ) ;
257
257
258
- let fake_vout = scid_utils:: vout_from_scid ( & fake_scid) ;
258
+ let fake_vout = scid_utils:: vout_from_scid ( fake_scid) ;
259
259
assert ! ( fake_vout < MAX_NAMESPACES as u16 ) ;
260
260
}
261
261
}
@@ -267,29 +267,29 @@ mod tests {
267
267
268
268
#[ test]
269
269
fn test_block_from_scid ( ) {
270
- assert_eq ! ( block_from_scid( & 0x000000_000000_0000 ) , 0 ) ;
271
- assert_eq ! ( block_from_scid( & 0x000001_000000_0000 ) , 1 ) ;
272
- assert_eq ! ( block_from_scid( & 0x000001_ffffff_ffff ) , 1 ) ;
273
- assert_eq ! ( block_from_scid( & 0x800000_ffffff_ffff ) , 0x800000 ) ;
274
- assert_eq ! ( block_from_scid( & 0xffffff_ffffff_ffff ) , 0xffffff ) ;
270
+ assert_eq ! ( block_from_scid( 0x000000_000000_0000 ) , 0 ) ;
271
+ assert_eq ! ( block_from_scid( 0x000001_000000_0000 ) , 1 ) ;
272
+ assert_eq ! ( block_from_scid( 0x000001_ffffff_ffff ) , 1 ) ;
273
+ assert_eq ! ( block_from_scid( 0x800000_ffffff_ffff ) , 0x800000 ) ;
274
+ assert_eq ! ( block_from_scid( 0xffffff_ffffff_ffff ) , 0xffffff ) ;
275
275
}
276
276
277
277
#[ test]
278
278
fn test_tx_index_from_scid ( ) {
279
- assert_eq ! ( tx_index_from_scid( & 0x000000_000000_0000 ) , 0 ) ;
280
- assert_eq ! ( tx_index_from_scid( & 0x000000_000001_0000 ) , 1 ) ;
281
- assert_eq ! ( tx_index_from_scid( & 0xffffff_000001_ffff ) , 1 ) ;
282
- assert_eq ! ( tx_index_from_scid( & 0xffffff_800000_ffff ) , 0x800000 ) ;
283
- assert_eq ! ( tx_index_from_scid( & 0xffffff_ffffff_ffff ) , 0xffffff ) ;
279
+ assert_eq ! ( tx_index_from_scid( 0x000000_000000_0000 ) , 0 ) ;
280
+ assert_eq ! ( tx_index_from_scid( 0x000000_000001_0000 ) , 1 ) ;
281
+ assert_eq ! ( tx_index_from_scid( 0xffffff_000001_ffff ) , 1 ) ;
282
+ assert_eq ! ( tx_index_from_scid( 0xffffff_800000_ffff ) , 0x800000 ) ;
283
+ assert_eq ! ( tx_index_from_scid( 0xffffff_ffffff_ffff ) , 0xffffff ) ;
284
284
}
285
285
286
286
#[ test]
287
287
fn test_vout_from_scid ( ) {
288
- assert_eq ! ( vout_from_scid( & 0x000000_000000_0000 ) , 0 ) ;
289
- assert_eq ! ( vout_from_scid( & 0x000000_000000_0001 ) , 1 ) ;
290
- assert_eq ! ( vout_from_scid( & 0xffffff_ffffff_0001 ) , 1 ) ;
291
- assert_eq ! ( vout_from_scid( & 0xffffff_ffffff_8000 ) , 0x8000 ) ;
292
- assert_eq ! ( vout_from_scid( & 0xffffff_ffffff_ffff ) , 0xffff ) ;
288
+ assert_eq ! ( vout_from_scid( 0x000000_000000_0000 ) , 0 ) ;
289
+ assert_eq ! ( vout_from_scid( 0x000000_000000_0001 ) , 1 ) ;
290
+ assert_eq ! ( vout_from_scid( 0xffffff_ffffff_0001 ) , 1 ) ;
291
+ assert_eq ! ( vout_from_scid( 0xffffff_ffffff_8000 ) , 0x8000 ) ;
292
+ assert_eq ! ( vout_from_scid( 0xffffff_ffffff_ffff ) , 0xffff ) ;
293
293
}
294
294
295
295
#[ test]
0 commit comments