@@ -3035,6 +3035,7 @@ pub struct ReconnectArgs<'a, 'b, 'c, 'd> {
30353035 pub pending_htlc_fails : ( usize , usize ) ,
30363036 pub pending_cell_htlc_claims : ( usize , usize ) ,
30373037 pub pending_cell_htlc_fails : ( usize , usize ) ,
3038+ pub pending_cell_htlc_malforms : ( usize , usize ) ,
30383039 pub pending_raa : ( bool , bool ) ,
30393040}
30403041
@@ -3049,6 +3050,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
30493050 pending_htlc_fails : ( 0 , 0 ) ,
30503051 pending_cell_htlc_claims : ( 0 , 0 ) ,
30513052 pending_cell_htlc_fails : ( 0 , 0 ) ,
3053+ pending_cell_htlc_malforms : ( 0 , 0 ) ,
30523054 pending_raa : ( false , false ) ,
30533055 }
30543056 }
@@ -3059,7 +3061,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
30593061pub fn reconnect_nodes < ' a , ' b , ' c , ' d > ( args : ReconnectArgs < ' a , ' b , ' c , ' d > ) {
30603062 let ReconnectArgs {
30613063 node_a, node_b, send_channel_ready, pending_htlc_adds, pending_htlc_claims, pending_htlc_fails,
3062- pending_cell_htlc_claims, pending_cell_htlc_fails, pending_raa
3064+ pending_cell_htlc_claims, pending_cell_htlc_fails, pending_cell_htlc_malforms , pending_raa
30633065 } = args;
30643066 node_a. node . peer_connected ( & node_b. node . get_our_node_id ( ) , & msgs:: Init {
30653067 features : node_b. node . init_features ( ) , networks : None , remote_network_address : None
@@ -3100,7 +3102,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
31003102 node_b. node . handle_channel_reestablish ( & node_a. node . get_our_node_id ( ) , & msg) ;
31013103 resp_1. push ( handle_chan_reestablish_msgs ! ( node_b, node_a) ) ;
31023104 }
3103- if pending_cell_htlc_claims. 0 != 0 || pending_cell_htlc_fails. 0 != 0 {
3105+ if pending_cell_htlc_claims. 0 != 0 || pending_cell_htlc_fails. 0 != 0 ||
3106+ pending_cell_htlc_malforms. 0 != 0
3107+ {
31043108 check_added_monitors ! ( node_b, 1 ) ;
31053109 } else {
31063110 check_added_monitors ! ( node_b, 0 ) ;
@@ -3111,17 +3115,21 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
31113115 node_a. node . handle_channel_reestablish ( & node_b. node . get_our_node_id ( ) , & msg) ;
31123116 resp_2. push ( handle_chan_reestablish_msgs ! ( node_a, node_b) ) ;
31133117 }
3114- if pending_cell_htlc_claims. 1 != 0 || pending_cell_htlc_fails. 1 != 0 {
3118+ if pending_cell_htlc_claims. 1 != 0 || pending_cell_htlc_fails. 1 != 0 ||
3119+ pending_cell_htlc_malforms. 1 != 0
3120+ {
31153121 check_added_monitors ! ( node_a, 1 ) ;
31163122 } else {
31173123 check_added_monitors ! ( node_a, 0 ) ;
31183124 }
31193125
31203126 // We don't yet support both needing updates, as that would require a different commitment dance:
31213127 assert ! ( ( pending_htlc_adds. 0 == 0 && pending_htlc_claims. 0 == 0 && pending_htlc_fails. 0 == 0 &&
3122- pending_cell_htlc_claims. 0 == 0 && pending_cell_htlc_fails. 0 == 0 ) ||
3128+ pending_cell_htlc_claims. 0 == 0 && pending_cell_htlc_fails. 0 == 0 &&
3129+ pending_cell_htlc_malforms. 0 == 0 ) ||
31233130 ( pending_htlc_adds. 1 == 0 && pending_htlc_claims. 1 == 0 && pending_htlc_fails. 1 == 0 &&
3124- pending_cell_htlc_claims. 1 == 0 && pending_cell_htlc_fails. 1 == 0 ) ) ;
3131+ pending_cell_htlc_claims. 1 == 0 && pending_cell_htlc_fails. 1 == 0 &&
3132+ pending_cell_htlc_malforms. 1 == 0 ) ) ;
31253133
31263134 for chan_msgs in resp_1. drain ( ..) {
31273135 if send_channel_ready. 0 {
@@ -3144,7 +3152,10 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
31443152 } else {
31453153 assert ! ( chan_msgs. 1 . is_none( ) ) ;
31463154 }
3147- 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 {
3155+ if pending_htlc_adds. 0 != 0 || pending_htlc_claims. 0 != 0 || pending_htlc_fails. 0 != 0 ||
3156+ pending_cell_htlc_claims. 0 != 0 || pending_cell_htlc_fails. 0 != 0 ||
3157+ pending_cell_htlc_malforms. 0 != 0
3158+ {
31483159 let commitment_update = chan_msgs. 2 . unwrap ( ) ;
31493160 if pending_htlc_adds. 0 != -1 { // We use -1 to denote a response commitment_signed
31503161 assert_eq ! ( commitment_update. update_add_htlcs. len( ) , pending_htlc_adds. 0 as usize ) ;
@@ -3153,7 +3164,7 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
31533164 }
31543165 assert_eq ! ( commitment_update. update_fulfill_htlcs. len( ) , pending_htlc_claims. 0 + pending_cell_htlc_claims. 0 ) ;
31553166 assert_eq ! ( commitment_update. update_fail_htlcs. len( ) , pending_htlc_fails. 0 + pending_cell_htlc_fails. 0 ) ;
3156- assert ! ( commitment_update. update_fail_malformed_htlcs. is_empty ( ) ) ;
3167+ assert_eq ! ( commitment_update. update_fail_malformed_htlcs. len ( ) , pending_cell_htlc_malforms . 0 ) ;
31573168 for update_add in commitment_update. update_add_htlcs {
31583169 node_a. node . handle_update_add_htlc ( & node_b. node . get_our_node_id ( ) , & update_add) ;
31593170 }
@@ -3163,6 +3174,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
31633174 for update_fail in commitment_update. update_fail_htlcs {
31643175 node_a. node . handle_update_fail_htlc ( & node_b. node . get_our_node_id ( ) , & update_fail) ;
31653176 }
3177+ for update_malformed in commitment_update. update_fail_malformed_htlcs {
3178+ node_a. node . handle_update_fail_malformed_htlc ( & node_b. node . get_our_node_id ( ) , & update_malformed) ;
3179+ }
31663180
31673181 if pending_htlc_adds. 0 != -1 { // We use -1 to denote a response commitment_signed
31683182 commitment_signed_dance ! ( node_a, node_b, commitment_update. commitment_signed, false ) ;
@@ -3203,14 +3217,17 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
32033217 } else {
32043218 assert ! ( chan_msgs. 1 . is_none( ) ) ;
32053219 }
3206- 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 {
3220+ if pending_htlc_adds. 1 != 0 || pending_htlc_claims. 1 != 0 || pending_htlc_fails. 1 != 0 ||
3221+ pending_cell_htlc_claims. 1 != 0 || pending_cell_htlc_fails. 1 != 0 ||
3222+ pending_cell_htlc_malforms. 1 != 0
3223+ {
32073224 let commitment_update = chan_msgs. 2 . unwrap ( ) ;
32083225 if pending_htlc_adds. 1 != -1 { // We use -1 to denote a response commitment_signed
32093226 assert_eq ! ( commitment_update. update_add_htlcs. len( ) , pending_htlc_adds. 1 as usize ) ;
32103227 }
32113228 assert_eq ! ( commitment_update. update_fulfill_htlcs. len( ) , pending_htlc_claims. 1 + pending_cell_htlc_claims. 1 ) ;
32123229 assert_eq ! ( commitment_update. update_fail_htlcs. len( ) , pending_htlc_fails. 1 + pending_cell_htlc_fails. 1 ) ;
3213- assert ! ( commitment_update. update_fail_malformed_htlcs. is_empty ( ) ) ;
3230+ assert_eq ! ( commitment_update. update_fail_malformed_htlcs. len ( ) , pending_cell_htlc_malforms . 1 ) ;
32143231 for update_add in commitment_update. update_add_htlcs {
32153232 node_b. node . handle_update_add_htlc ( & node_a. node . get_our_node_id ( ) , & update_add) ;
32163233 }
@@ -3220,6 +3237,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
32203237 for update_fail in commitment_update. update_fail_htlcs {
32213238 node_b. node . handle_update_fail_htlc ( & node_a. node . get_our_node_id ( ) , & update_fail) ;
32223239 }
3240+ for update_malformed in commitment_update. update_fail_malformed_htlcs {
3241+ node_b. node . handle_update_fail_malformed_htlc ( & node_a. node . get_our_node_id ( ) , & update_malformed) ;
3242+ }
32233243
32243244 if pending_htlc_adds. 1 != -1 { // We use -1 to denote a response commitment_signed
32253245 commitment_signed_dance ! ( node_b, node_a, commitment_update. commitment_signed, false ) ;
0 commit comments