@@ -267,8 +267,26 @@ where
267267 latest_seen_timestamp
268268 ) ;
269269
270+ let mut funding_sats: Option < u64 > = None ;
271+
272+ if version >= 2 && has_additional_data {
273+ // forwards compatibility
274+ let additional_data: Vec < u8 > = Readable :: read ( read_cursor) ?;
275+ let mut cursor = & additional_data[ ..] ;
276+ let funding_sats_read: BigSize = Readable :: read ( & mut cursor) ?;
277+ funding_sats = Some ( funding_sats_read. 0 ) ;
278+ if !cursor. is_empty ( ) {
279+ log_gossip ! (
280+ self . logger,
281+ "Ignoring {} bytes of additional data in channel announcement" ,
282+ cursor. len( )
283+ ) ;
284+ }
285+ }
286+
270287 let announcement_result = network_graph. add_channel_from_partial_announcement (
271288 short_channel_id,
289+ funding_sats,
272290 backdated_timestamp as u64 ,
273291 features,
274292 node_id_1,
@@ -286,16 +304,6 @@ where
286304 return Err ( lightning_error. into ( ) ) ;
287305 }
288306 }
289-
290- if version >= 2 && has_additional_data {
291- // forwards compatibility
292- let additional_data: Vec < u8 > = Readable :: read ( read_cursor) ?;
293- log_gossip ! (
294- self . logger,
295- "Ignoring {} bytes of additional data in channel announcement" ,
296- additional_data. len( )
297- ) ;
298- }
299307 }
300308
301309 for modification in node_modifications {
@@ -664,7 +672,7 @@ mod tests {
664672 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
665673 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
666674 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
667- 0 , 0 , 0 , 1 , 0 , 0 , 1 , 0 , 255 , 128 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 147 , 23 , 23 , 23 , 23 , 23 , 23 ,
675+ 0 , 0 , 0 , 1 , 0 , 0 , 1 , 0 , 255 , 128 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 147 , 42 , 23 , 23 , 23 , 23 , 23 ,
668676 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 ,
669677 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 ,
670678 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 , 23 ,
@@ -685,9 +693,11 @@ mod tests {
685693 "Ignoring 255 bytes of additional data in node announcement" ,
686694 3 ,
687695 ) ;
696+ // Note that our extra data is 147 bytes long, but the first byte (42) is read as the
697+ // channel's funding amount (as a BigSize).
688698 logger. assert_log_contains (
689699 "lightning_rapid_gossip_sync::processing" ,
690- "Ignoring 147 bytes of additional data in channel announcement" ,
700+ "Ignoring 146 bytes of additional data in channel announcement" ,
691701 1 ,
692702 ) ;
693703 logger. assert_log_contains (
0 commit comments