@@ -1164,13 +1164,16 @@ impl ChannelManager {
1164
1164
}
1165
1165
{
1166
1166
let mut res = Vec :: with_capacity ( 8 + 128 ) ;
1167
- if code == 0x1000 | 11 || code == 0x1000 | 12 {
1168
- res. extend_from_slice ( & byte_utils:: be64_to_array ( msg. amount_msat ) ) ;
1169
- }
1170
- else if code == 0x1000 | 13 {
1171
- res. extend_from_slice ( & byte_utils:: be32_to_array ( msg. cltv_expiry ) ) ;
1172
- }
1173
1167
if let Some ( chan_update) = chan_update {
1168
+ if code == 0x1000 | 11 || code == 0x1000 | 12 {
1169
+ res. extend_from_slice ( & byte_utils:: be64_to_array ( msg. amount_msat ) ) ;
1170
+ }
1171
+ else if code == 0x1000 | 13 {
1172
+ res. extend_from_slice ( & byte_utils:: be32_to_array ( msg. cltv_expiry ) ) ;
1173
+ }
1174
+ else if code == 0x1000 | 20 {
1175
+ res. extend_from_slice ( & byte_utils:: be16_to_array ( chan_update. contents . flags ) ) ;
1176
+ }
1174
1177
res. extend_from_slice ( & chan_update. encode_with_len ( ) [ ..] ) ;
1175
1178
}
1176
1179
return_err ! ( err, code, & res[ ..] ) ;
@@ -2084,7 +2087,12 @@ impl ChannelManager {
2084
2087
channel_id : msg. channel_id ,
2085
2088
htlc_id : msg. htlc_id ,
2086
2089
reason : if let Ok ( update) = chan_update {
2087
- ChannelManager :: build_first_hop_failure_packet ( & incoming_shared_secret, 0x1000 |20 , & update. encode_with_len ( ) [ ..] )
2090
+ ChannelManager :: build_first_hop_failure_packet ( & incoming_shared_secret, 0x1000 |20 , & {
2091
+ let mut res = Vec :: with_capacity ( 8 + 128 ) ;
2092
+ res. extend_from_slice ( & byte_utils:: be16_to_array ( update. contents . flags ) ) ;
2093
+ res. extend_from_slice ( & update. encode_with_len ( ) [ ..] ) ;
2094
+ res
2095
+ } [ ..] )
2088
2096
} else {
2089
2097
// This can only happen if the channel isn't in the fully-funded
2090
2098
// state yet, implying our counterparty is trying to route payments
@@ -5022,7 +5030,8 @@ mod tests {
5022
5030
_ => panic ! ( "Unexpected event" ) ,
5023
5031
} ;
5024
5032
match msg_events[ 1 ] {
5025
- MessageSendEvent :: PaymentFailureNetworkUpdate { .. } => {
5033
+ MessageSendEvent :: PaymentFailureNetworkUpdate { update : msgs:: HTLCFailChannelUpdate :: ChannelUpdateMessage { ref msg } } => {
5034
+ assert_eq ! ( msg. contents. short_channel_id, chan_1. 0 . contents. short_channel_id) ;
5026
5035
} ,
5027
5036
_ => panic ! ( "Unexpected event" ) ,
5028
5037
}
@@ -8135,7 +8144,7 @@ mod tests {
8135
8144
// Tests handling of a monitor update failure when processing an incoming RAA
8136
8145
let mut nodes = create_network ( 3 ) ;
8137
8146
create_announced_chan_between_nodes ( & nodes, 0 , 1 ) ;
8138
- create_announced_chan_between_nodes ( & nodes, 1 , 2 ) ;
8147
+ let chan_2 = create_announced_chan_between_nodes ( & nodes, 1 , 2 ) ;
8139
8148
8140
8149
// Rebalance a bit so that we can send backwards from 2 to 1.
8141
8150
send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , 5000000 ) ;
@@ -8221,7 +8230,9 @@ mod tests {
8221
8230
let msg_events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
8222
8231
assert_eq ! ( msg_events. len( ) , 1 ) ;
8223
8232
match msg_events[ 0 ] {
8224
- MessageSendEvent :: PaymentFailureNetworkUpdate { .. } => {
8233
+ MessageSendEvent :: PaymentFailureNetworkUpdate { update : msgs:: HTLCFailChannelUpdate :: ChannelUpdateMessage { ref msg } } => {
8234
+ assert_eq ! ( msg. contents. short_channel_id, chan_2. 0 . contents. short_channel_id) ;
8235
+ assert_eq ! ( msg. contents. flags & 2 , 2 ) ; // temp disabled
8225
8236
} ,
8226
8237
_ => panic ! ( "Unexpected event" ) ,
8227
8238
}
0 commit comments