@@ -4,29 +4,6 @@ use lightning::sign::EntropySource;
4
4
use crate :: lsps0:: ser:: RequestId ;
5
5
use crate :: prelude:: String ;
6
6
7
- /// Maximum transaction index that can be used in a `short_channel_id`.
8
- /// This value is based on the 3-bytes available for tx index.
9
- pub const MAX_SCID_TX_INDEX : u64 = 0x00ffffff ;
10
-
11
- /// Maximum vout index that can be used in a `short_channel_id`. This
12
- /// value is based on the 2-bytes available for the vout index.
13
- pub const MAX_SCID_VOUT_INDEX : u64 = 0xffff ;
14
-
15
- /// Extracts the block height (most significant 3-bytes) from the `short_channel_id`.
16
- pub fn block_from_scid ( short_channel_id : & u64 ) -> u32 {
17
- ( short_channel_id >> 40 ) as u32
18
- }
19
-
20
- /// Extracts the tx index (bytes [2..4]) from the `short_channel_id`.
21
- pub fn tx_index_from_scid ( short_channel_id : & u64 ) -> u32 {
22
- ( ( short_channel_id >> 16 ) & MAX_SCID_TX_INDEX ) as u32
23
- }
24
-
25
- /// Extracts the vout (bytes [0..2]) from the `short_channel_id`.
26
- pub fn vout_from_scid ( short_channel_id : & u64 ) -> u16 {
27
- ( ( short_channel_id) & MAX_SCID_VOUT_INDEX ) as u16
28
- }
29
-
30
7
pub fn scid_from_human_readable_string ( human_readable_scid : & str ) -> Result < u64 , ( ) > {
31
8
let mut parts = human_readable_scid. split ( 'x' ) ;
32
9
@@ -57,6 +34,7 @@ pub fn hex_str(value: &[u8]) -> String {
57
34
#[ cfg( test) ]
58
35
mod tests {
59
36
use super :: * ;
37
+ use lightning:: util:: scid_utils:: { block_from_scid, tx_index_from_scid, vout_from_scid} ;
60
38
61
39
#[ test]
62
40
fn parses_human_readable_scid_correctly ( ) {
@@ -68,8 +46,8 @@ mod tests {
68
46
69
47
let scid = scid_from_human_readable_string ( & human_readable_scid) . unwrap ( ) ;
70
48
71
- assert_eq ! ( block_from_scid( & scid) , block) ;
72
- assert_eq ! ( tx_index_from_scid( & scid) , tx_index) ;
73
- assert_eq ! ( vout_from_scid( & scid) , vout) ;
49
+ assert_eq ! ( block_from_scid( scid) , block) ;
50
+ assert_eq ! ( tx_index_from_scid( scid) , tx_index) ;
51
+ assert_eq ! ( vout_from_scid( scid) , vout) ;
74
52
}
75
53
}
0 commit comments