@@ -3084,6 +3084,7 @@ pub struct ReconnectArgs<'a, 'b, 'c, 'd> {
30843084 pub pending_htlc_fails : ( usize , usize ) ,
30853085 pub pending_cell_htlc_claims : ( usize , usize ) ,
30863086 pub pending_cell_htlc_fails : ( usize , usize ) ,
3087+ pub pending_cell_htlc_malforms : ( usize , usize ) ,
30873088 pub pending_raa : ( bool , bool ) ,
30883089}
30893090
@@ -3098,6 +3099,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
30983099 pending_htlc_fails : ( 0 , 0 ) ,
30993100 pending_cell_htlc_claims : ( 0 , 0 ) ,
31003101 pending_cell_htlc_fails : ( 0 , 0 ) ,
3102+ pending_cell_htlc_malforms : ( 0 , 0 ) ,
31013103 pending_raa : ( false , false ) ,
31023104 }
31033105 }
@@ -3108,7 +3110,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
31083110pub fn reconnect_nodes < ' a , ' b , ' c , ' d > ( args : ReconnectArgs < ' a , ' b , ' c , ' d > ) {
31093111 let ReconnectArgs {
31103112 node_a, node_b, send_channel_ready, pending_htlc_adds, pending_htlc_claims, pending_htlc_fails,
3111- pending_cell_htlc_claims, pending_cell_htlc_fails, pending_raa
3113+ pending_cell_htlc_claims, pending_cell_htlc_fails, pending_cell_htlc_malforms , pending_raa
31123114 } = args;
31133115 node_a. node . peer_connected ( & node_b. node . get_our_node_id ( ) , & msgs:: Init {
31143116 features : node_b. node . init_features ( ) , networks : None , remote_network_address : None
@@ -3149,7 +3151,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
31493151 node_b. node . handle_channel_reestablish ( & node_a. node . get_our_node_id ( ) , & msg) ;
31503152 resp_1. push ( handle_chan_reestablish_msgs ! ( node_b, node_a) ) ;
31513153 }
3152- if pending_cell_htlc_claims. 0 != 0 || pending_cell_htlc_fails. 0 != 0 {
3154+ if pending_cell_htlc_claims. 0 != 0 || pending_cell_htlc_fails. 0 != 0 ||
3155+ pending_cell_htlc_malforms. 0 != 0
3156+ {
31533157 check_added_monitors ! ( node_b, 1 ) ;
31543158 } else {
31553159 check_added_monitors ! ( node_b, 0 ) ;
@@ -3160,17 +3164,21 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
31603164 node_a. node . handle_channel_reestablish ( & node_b. node . get_our_node_id ( ) , & msg) ;
31613165 resp_2. push ( handle_chan_reestablish_msgs ! ( node_a, node_b) ) ;
31623166 }
3163- if pending_cell_htlc_claims. 1 != 0 || pending_cell_htlc_fails. 1 != 0 {
3167+ if pending_cell_htlc_claims. 1 != 0 || pending_cell_htlc_fails. 1 != 0 ||
3168+ pending_cell_htlc_malforms. 1 != 0
3169+ {
31643170 check_added_monitors ! ( node_a, 1 ) ;
31653171 } else {
31663172 check_added_monitors ! ( node_a, 0 ) ;
31673173 }
31683174
31693175 // We don't yet support both needing updates, as that would require a different commitment dance:
31703176 assert ! ( ( pending_htlc_adds. 0 == 0 && pending_htlc_claims. 0 == 0 && pending_htlc_fails. 0 == 0 &&
3171- pending_cell_htlc_claims. 0 == 0 && pending_cell_htlc_fails. 0 == 0 ) ||
3177+ pending_cell_htlc_claims. 0 == 0 && pending_cell_htlc_fails. 0 == 0 &&
3178+ pending_cell_htlc_malforms. 0 == 0 ) ||
31723179 ( pending_htlc_adds. 1 == 0 && pending_htlc_claims. 1 == 0 && pending_htlc_fails. 1 == 0 &&
3173- pending_cell_htlc_claims. 1 == 0 && pending_cell_htlc_fails. 1 == 0 ) ) ;
3180+ pending_cell_htlc_claims. 1 == 0 && pending_cell_htlc_fails. 1 == 0 &&
3181+ pending_cell_htlc_malforms. 1 == 0 ) ) ;
31743182
31753183 for chan_msgs in resp_1. drain ( ..) {
31763184 if send_channel_ready. 0 {
@@ -3193,7 +3201,10 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
31933201 } else {
31943202 assert ! ( chan_msgs. 1 . is_none( ) ) ;
31953203 }
3196- if pending_htlc_adds. 0 != 0 || pending_htlc_claims. 0 != 0 || pending_htlc_fails. 0 != 0 || pending_cell_htlc_claims. 0 != 0 || pending_cell_htlc_fails. 0 != 0 {
3204+ if pending_htlc_adds. 0 != 0 || pending_htlc_claims. 0 != 0 || pending_htlc_fails. 0 != 0 ||
3205+ pending_cell_htlc_claims. 0 != 0 || pending_cell_htlc_fails. 0 != 0 ||
3206+ pending_cell_htlc_malforms. 0 != 0
3207+ {
31973208 let commitment_update = chan_msgs. 2 . unwrap ( ) ;
31983209 if pending_htlc_adds. 0 != -1 { // We use -1 to denote a response commitment_signed
31993210 assert_eq ! ( commitment_update. update_add_htlcs. len( ) , pending_htlc_adds. 0 as usize ) ;
@@ -3202,7 +3213,7 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
32023213 }
32033214 assert_eq ! ( commitment_update. update_fulfill_htlcs. len( ) , pending_htlc_claims. 0 + pending_cell_htlc_claims. 0 ) ;
32043215 assert_eq ! ( commitment_update. update_fail_htlcs. len( ) , pending_htlc_fails. 0 + pending_cell_htlc_fails. 0 ) ;
3205- assert ! ( commitment_update. update_fail_malformed_htlcs. is_empty ( ) ) ;
3216+ assert_eq ! ( commitment_update. update_fail_malformed_htlcs. len ( ) , pending_cell_htlc_malforms . 0 ) ;
32063217 for update_add in commitment_update. update_add_htlcs {
32073218 node_a. node . handle_update_add_htlc ( & node_b. node . get_our_node_id ( ) , & update_add) ;
32083219 }
@@ -3212,6 +3223,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
32123223 for update_fail in commitment_update. update_fail_htlcs {
32133224 node_a. node . handle_update_fail_htlc ( & node_b. node . get_our_node_id ( ) , & update_fail) ;
32143225 }
3226+ for update_malformed in commitment_update. update_fail_malformed_htlcs {
3227+ node_a. node . handle_update_fail_malformed_htlc ( & node_b. node . get_our_node_id ( ) , & update_malformed) ;
3228+ }
32153229
32163230 if pending_htlc_adds. 0 != -1 { // We use -1 to denote a response commitment_signed
32173231 commitment_signed_dance ! ( node_a, node_b, commitment_update. commitment_signed, false ) ;
@@ -3252,14 +3266,17 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
32523266 } else {
32533267 assert ! ( chan_msgs. 1 . is_none( ) ) ;
32543268 }
3255- if pending_htlc_adds. 1 != 0 || pending_htlc_claims. 1 != 0 || pending_htlc_fails. 1 != 0 || pending_cell_htlc_claims. 1 != 0 || pending_cell_htlc_fails. 1 != 0 {
3269+ if pending_htlc_adds. 1 != 0 || pending_htlc_claims. 1 != 0 || pending_htlc_fails. 1 != 0 ||
3270+ pending_cell_htlc_claims. 1 != 0 || pending_cell_htlc_fails. 1 != 0 ||
3271+ pending_cell_htlc_malforms. 1 != 0
3272+ {
32563273 let commitment_update = chan_msgs. 2 . unwrap ( ) ;
32573274 if pending_htlc_adds. 1 != -1 { // We use -1 to denote a response commitment_signed
32583275 assert_eq ! ( commitment_update. update_add_htlcs. len( ) , pending_htlc_adds. 1 as usize ) ;
32593276 }
32603277 assert_eq ! ( commitment_update. update_fulfill_htlcs. len( ) , pending_htlc_claims. 1 + pending_cell_htlc_claims. 1 ) ;
32613278 assert_eq ! ( commitment_update. update_fail_htlcs. len( ) , pending_htlc_fails. 1 + pending_cell_htlc_fails. 1 ) ;
3262- assert ! ( commitment_update. update_fail_malformed_htlcs. is_empty ( ) ) ;
3279+ assert_eq ! ( commitment_update. update_fail_malformed_htlcs. len ( ) , pending_cell_htlc_malforms . 1 ) ;
32633280 for update_add in commitment_update. update_add_htlcs {
32643281 node_b. node . handle_update_add_htlc ( & node_a. node . get_our_node_id ( ) , & update_add) ;
32653282 }
@@ -3269,6 +3286,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
32693286 for update_fail in commitment_update. update_fail_htlcs {
32703287 node_b. node . handle_update_fail_htlc ( & node_a. node . get_our_node_id ( ) , & update_fail) ;
32713288 }
3289+ for update_malformed in commitment_update. update_fail_malformed_htlcs {
3290+ node_b. node . handle_update_fail_malformed_htlc ( & node_a. node . get_our_node_id ( ) , & update_malformed) ;
3291+ }
32723292
32733293 if pending_htlc_adds. 1 != -1 { // We use -1 to denote a response commitment_signed
32743294 commitment_signed_dance ! ( node_b, node_a, commitment_update. commitment_signed, false ) ;
0 commit comments