7
7
// You may not use this file except in accordance with one or both of these
8
8
// licenses.
9
9
10
+ //! Utilities for creating and parsing short channel ids.
11
+
10
12
/// Maximum block height that can be used in a `short_channel_id`. This
11
13
/// value is based on the 3-bytes available for block height.
12
14
pub const MAX_SCID_BLOCK : u64 = 0x00ffffff ;
@@ -22,8 +24,11 @@ pub const MAX_SCID_VOUT_INDEX: u64 = 0xffff;
22
24
/// A `short_channel_id` construction error
23
25
#[ derive( Debug , PartialEq , Eq ) ]
24
26
pub enum ShortChannelIdError {
27
+ /// Block height too high
25
28
BlockOverflow ,
29
+ /// Tx index too high
26
30
TxIndexOverflow ,
31
+ /// Vout index too high
27
32
VoutIndexOverflow ,
28
33
}
29
34
@@ -65,7 +70,7 @@ pub fn scid_from_parts(block: u64, tx_index: u64, vout_index: u64) -> Result<u64
65
70
/// 2) phantom node payments, to get an scid for the phantom node's phantom channel
66
71
/// 3) payments intended to be intercepted will route using a fake scid (this is typically used so
67
72
/// the forwarding node can open a JIT channel to the next hop)
68
- pub ( crate ) mod fake_scid {
73
+ pub mod fake_scid {
69
74
use bitcoin:: blockdata:: constants:: ChainHash ;
70
75
use bitcoin:: network:: constants:: Network ;
71
76
use crate :: sign:: EntropySource ;
@@ -90,9 +95,12 @@ pub(crate) mod fake_scid {
90
95
/// receipt, and handle the HTLC accordingly. The namespace identifier is encrypted when encoded
91
96
/// into the fake scid.
92
97
#[ derive( Copy , Clone ) ]
93
- pub ( crate ) enum Namespace {
98
+ pub enum Namespace {
99
+ /// Phantom nodes namespace
94
100
Phantom ,
101
+ /// SCID aliases for outbound private channels
95
102
OutboundAlias ,
103
+ /// Payment interception namespace
96
104
Intercept
97
105
}
98
106
@@ -101,7 +109,7 @@ pub(crate) mod fake_scid {
101
109
/// between segwit activation and the current best known height, and the tx index and output
102
110
/// index are also selected from a "reasonable" range. We add this logic because it makes it
103
111
/// non-obvious at a glance that the scid is fake, e.g. if it appears in invoice route hints.
104
- pub ( crate ) fn get_fake_scid < ES : Deref > ( & self , highest_seen_blockheight : u32 , chain_hash : & ChainHash , fake_scid_rand_bytes : & [ u8 ; 32 ] , entropy_source : & ES ) -> u64
112
+ pub fn get_fake_scid < ES : Deref > ( & self , highest_seen_blockheight : u32 , chain_hash : & ChainHash , fake_scid_rand_bytes : & [ u8 ; 32 ] , entropy_source : & ES ) -> u64
105
113
where ES :: Target : EntropySource ,
106
114
{
107
115
// Ensure we haven't created a namespace that doesn't fit into the 3 bits we've allocated for
0 commit comments