@@ -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
@@ -74,14 +82,14 @@ impl InitFeatures {
74
82
#[ cfg( not( feature = "fuzztarget" ) ) ]
75
83
pub ( crate ) fn our_features ( ) -> InitFeatures {
76
84
InitFeatures {
77
- flags : vec ! [ 2 | 1 << 5 , 1 << ( 9 -8 ) ] ,
85
+ flags : vec ! [ 2 | 1 << 5 , 1 << ( 9 -8 ) | 1 << ( 15 - 8 ) , 1 << ( 17 - 8 * 2 ) ] ,
78
86
mark : PhantomData ,
79
87
}
80
88
}
81
89
#[ cfg( feature = "fuzztarget" ) ]
82
90
pub fn our_features ( ) -> InitFeatures {
83
91
InitFeatures {
84
- flags : vec ! [ 2 | 1 << 5 , 1 << ( 9 -8 ) ] ,
92
+ flags : vec ! [ 2 | 1 << 5 , 1 << ( 9 -8 ) | 1 << ( 15 - 8 ) , 1 << ( 17 - 8 * 2 ) ] ,
85
93
mark : PhantomData ,
86
94
}
87
95
}
@@ -143,14 +151,14 @@ impl NodeFeatures {
143
151
#[ cfg( not( feature = "fuzztarget" ) ) ]
144
152
pub ( crate ) fn our_features ( ) -> NodeFeatures {
145
153
NodeFeatures {
146
- flags : vec ! [ 2 | 1 << 5 , 1 << ( 9 -8 ) ] ,
154
+ flags : vec ! [ 2 | 1 << 5 , 1 << ( 9 -8 ) | 1 << ( 15 - 8 ) , 1 << ( 17 - 8 * 2 ) ] ,
147
155
mark : PhantomData ,
148
156
}
149
157
}
150
158
#[ cfg( feature = "fuzztarget" ) ]
151
159
pub 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
}
@@ -195,7 +203,8 @@ impl<T: sealed::Context> Features<T> {
195
203
self . flags . iter ( ) . enumerate ( ) . any ( |( idx, & byte) | {
196
204
( match idx {
197
205
0 => ( byte & 0b01000100 ) ,
198
- 1 => ( byte & 0b01010100 ) ,
206
+ 1 => ( byte & 0b00010100 ) ,
207
+ 2 => ( byte & 0b01010100 ) ,
199
208
_ => ( byte & 0b01010101 ) ,
200
209
} ) != 0
201
210
} )
@@ -205,7 +214,8 @@ impl<T: sealed::Context> Features<T> {
205
214
self . flags . iter ( ) . enumerate ( ) . any ( |( idx, & byte) | {
206
215
( match idx {
207
216
0 => ( byte & 0b11000100 ) ,
208
- 1 => ( byte & 0b11111100 ) ,
217
+ 1 => ( byte & 0b00111100 ) ,
218
+ 2 => ( byte & 0b11111100 ) ,
209
219
_ => byte,
210
220
} ) != 0
211
221
} )
@@ -219,16 +229,19 @@ impl<T: sealed::Context> Features<T> {
219
229
220
230
#[ cfg( test) ]
221
231
pub ( crate ) fn set_require_unknown_bits ( & mut self ) {
222
- let newlen = cmp:: max ( 2 , self . flags . len ( ) ) ;
232
+ let newlen = cmp:: max ( 3 , self . flags . len ( ) ) ;
223
233
self . flags . resize ( newlen, 0u8 ) ;
224
- self . flags [ 1 ] |= 0x40 ;
234
+ self . flags [ 2 ] |= 0x40 ;
225
235
}
226
236
227
237
#[ cfg( test) ]
228
238
pub ( crate ) fn clear_require_unknown_bits ( & mut self ) {
229
- let newlen = cmp:: max ( 2 , self . flags . len ( ) ) ;
239
+ let newlen = cmp:: max ( 3 , self . flags . len ( ) ) ;
230
240
self . flags . resize ( newlen, 0u8 ) ;
231
- self . flags [ 1 ] &= !0x40 ;
241
+ self . flags [ 2 ] &= !0x40 ;
242
+ if self . flags . len ( ) == 3 && self . flags [ 2 ] == 0 {
243
+ self . flags . resize ( 2 , 0u8 ) ;
244
+ }
232
245
if self . flags . len ( ) == 2 && self . flags [ 1 ] == 0 {
233
246
self . flags . resize ( 1 , 0u8 ) ;
234
247
}
@@ -270,6 +283,18 @@ impl<T: sealed::InitialRoutingSync> Features<T> {
270
283
}
271
284
}
272
285
286
+ impl < T : sealed:: PaymentSecret > Features < T > {
287
+ pub ( crate ) fn payment_secret ( & self ) -> bool {
288
+ self . flags . len ( ) > 1 && ( self . flags [ 1 ] & ( 3 << ( 12 -8 ) ) ) != 0
289
+ }
290
+ }
291
+
292
+ impl < T : sealed:: BasicMPP > Features < T > {
293
+ pub ( crate ) fn basic_mpp ( & self ) -> bool {
294
+ self . flags . len ( ) > 2 && ( self . flags [ 2 ] & ( 3 << ( 16 -8 * 2 ) ) ) != 0
295
+ }
296
+ }
297
+
273
298
impl < T : sealed:: Context > Writeable for Features < T > {
274
299
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
275
300
w. size_hint ( self . flags . len ( ) + 2 ) ;
0 commit comments