@@ -33,6 +33,14 @@ mod sealed { // You should just use the type aliases instead.
33
33
pub trait VariableLengthOnion : Context { }
34
34
impl VariableLengthOnion for InitContext { }
35
35
impl VariableLengthOnion for NodeContext { }
36
+
37
+ pub trait PaymentSecret : Context { }
38
+ impl PaymentSecret for InitContext { }
39
+ impl PaymentSecret for NodeContext { }
40
+
41
+ pub trait BasicMPP : Context { }
42
+ impl BasicMPP for InitContext { }
43
+ impl BasicMPP for NodeContext { }
36
44
}
37
45
38
46
/// Tracks the set of features which a node implements, templated by the context in which it
@@ -82,14 +90,14 @@ impl InitFeatures {
82
90
#[ cfg( not( feature = "fuzztarget" ) ) ]
83
91
pub ( crate ) fn our_features ( ) -> InitFeatures {
84
92
InitFeatures {
85
- flags : vec ! [ 2 | 1 << 5 , 1 << ( 9 -8 ) ] ,
93
+ flags : vec ! [ 2 | 1 << 5 , 1 << ( 9 -8 ) | 1 << ( 15 - 8 ) , 1 << ( 17 - 8 * 2 ) ] ,
86
94
mark : PhantomData ,
87
95
}
88
96
}
89
97
#[ cfg( feature = "fuzztarget" ) ]
90
98
pub fn our_features ( ) -> InitFeatures {
91
99
InitFeatures {
92
- flags : vec ! [ 2 | 1 << 5 , 1 << ( 9 -8 ) ] ,
100
+ flags : vec ! [ 2 | 1 << 5 , 1 << ( 9 -8 ) | 1 << ( 15 - 8 ) , 1 << ( 17 - 8 * 2 ) ] ,
93
101
mark : PhantomData ,
94
102
}
95
103
}
@@ -150,14 +158,14 @@ impl NodeFeatures {
150
158
#[ cfg( not( feature = "fuzztarget" ) ) ]
151
159
pub ( crate ) fn our_features ( ) -> NodeFeatures {
152
160
NodeFeatures {
153
- flags : vec ! [ 2 | 1 << 5 , 1 << ( 9 -8 ) ] ,
161
+ flags : vec ! [ 2 | 1 << 5 , 1 << ( 9 -8 ) | 1 << ( 15 - 8 ) , 1 << ( 17 - 8 * 2 ) ] ,
154
162
mark : PhantomData ,
155
163
}
156
164
}
157
165
#[ cfg( feature = "fuzztarget" ) ]
158
166
pub fn our_features ( ) -> NodeFeatures {
159
167
NodeFeatures {
160
- flags : vec ! [ 2 | 1 << 5 , 1 << ( 9 -8 ) ] ,
168
+ flags : vec ! [ 2 | 1 << 5 , 1 << ( 9 -8 ) | 1 << ( 15 - 8 ) , 1 << ( 17 - 8 * 2 ) ] ,
161
169
mark : PhantomData ,
162
170
}
163
171
}
@@ -187,7 +195,8 @@ impl<T: sealed::Context> Features<T> {
187
195
self . flags . iter ( ) . enumerate ( ) . any ( |( idx, & byte) | {
188
196
( match idx {
189
197
0 => ( byte & 0b01000100 ) ,
190
- 1 => ( byte & 0b01010100 ) ,
198
+ 1 => ( byte & 0b00010100 ) ,
199
+ 2 => ( byte & 0b01010100 ) ,
191
200
_ => ( byte & 0b01010101 ) ,
192
201
} ) != 0
193
202
} )
@@ -197,7 +206,8 @@ impl<T: sealed::Context> Features<T> {
197
206
self . flags . iter ( ) . enumerate ( ) . any ( |( idx, & byte) | {
198
207
( match idx {
199
208
0 => ( byte & 0b11000100 ) ,
200
- 1 => ( byte & 0b11111100 ) ,
209
+ 1 => ( byte & 0b00111100 ) ,
210
+ 2 => ( byte & 0b11111100 ) ,
201
211
_ => byte,
202
212
} ) != 0
203
213
} )
@@ -211,16 +221,19 @@ impl<T: sealed::Context> Features<T> {
211
221
212
222
#[ cfg( test) ]
213
223
pub ( crate ) fn set_require_unknown_bits ( & mut self ) {
214
- let newlen = cmp:: max ( 2 , self . flags . len ( ) ) ;
224
+ let newlen = cmp:: max ( 3 , self . flags . len ( ) ) ;
215
225
self . flags . resize ( newlen, 0u8 ) ;
216
- self . flags [ 1 ] |= 0x40 ;
226
+ self . flags [ 2 ] |= 0x40 ;
217
227
}
218
228
219
229
#[ cfg( test) ]
220
230
pub ( crate ) fn clear_require_unknown_bits ( & mut self ) {
221
- let newlen = cmp:: max ( 2 , self . flags . len ( ) ) ;
231
+ let newlen = cmp:: max ( 3 , self . flags . len ( ) ) ;
222
232
self . flags . resize ( newlen, 0u8 ) ;
223
- self . flags [ 1 ] &= !0x40 ;
233
+ self . flags [ 2 ] &= !0x40 ;
234
+ if self . flags . len ( ) == 3 && self . flags [ 2 ] == 0 {
235
+ self . flags . resize ( 2 , 0u8 ) ;
236
+ }
224
237
if self . flags . len ( ) == 2 && self . flags [ 1 ] == 0 {
225
238
self . flags . resize ( 1 , 0u8 ) ;
226
239
}
@@ -262,6 +275,18 @@ impl<T: sealed::InitialRoutingSync> Features<T> {
262
275
}
263
276
}
264
277
278
+ impl < T : sealed:: PaymentSecret > Features < T > {
279
+ pub ( crate ) fn payment_secret ( & self ) -> bool {
280
+ self . flags . len ( ) > 1 && ( self . flags [ 1 ] & ( 3 << ( 12 -8 ) ) ) != 0
281
+ }
282
+ }
283
+
284
+ impl < T : sealed:: BasicMPP > Features < T > {
285
+ pub ( crate ) fn basic_mpp ( & self ) -> bool {
286
+ self . flags . len ( ) > 2 && ( self . flags [ 2 ] & ( 3 << ( 16 -8 * 2 ) ) ) != 0
287
+ }
288
+ }
289
+
265
290
impl < T : sealed:: Context > Writeable for Features < T > {
266
291
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
267
292
w. size_hint ( self . flags . len ( ) + 2 ) ;
0 commit comments