@@ -3026,6 +3026,7 @@ pub struct ReconnectArgs<'a, 'b, 'c, 'd> {
30263026 pub pending_htlc_fails : ( usize , usize ) ,
30273027 pub pending_cell_htlc_claims : ( usize , usize ) ,
30283028 pub pending_cell_htlc_fails : ( usize , usize ) ,
3029+ pub pending_cell_htlc_malforms : ( usize , usize ) ,
30293030 pub pending_raa : ( bool , bool ) ,
30303031}
30313032
@@ -3040,6 +3041,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
30403041 pending_htlc_fails : ( 0 , 0 ) ,
30413042 pending_cell_htlc_claims : ( 0 , 0 ) ,
30423043 pending_cell_htlc_fails : ( 0 , 0 ) ,
3044+ pending_cell_htlc_malforms : ( 0 , 0 ) ,
30433045 pending_raa : ( false , false ) ,
30443046 }
30453047 }
@@ -3050,7 +3052,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
30503052pub fn reconnect_nodes < ' a , ' b , ' c , ' d > ( args : ReconnectArgs < ' a , ' b , ' c , ' d > ) {
30513053 let ReconnectArgs {
30523054 node_a, node_b, send_channel_ready, pending_htlc_adds, pending_htlc_claims, pending_htlc_fails,
3053- pending_cell_htlc_claims, pending_cell_htlc_fails, pending_raa
3055+ pending_cell_htlc_claims, pending_cell_htlc_fails, pending_cell_htlc_malforms , pending_raa
30543056 } = args;
30553057 node_a. node . peer_connected ( & node_b. node . get_our_node_id ( ) , & msgs:: Init {
30563058 features : node_b. node . init_features ( ) , networks : None , remote_network_address : None
@@ -3091,7 +3093,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
30913093 node_b. node . handle_channel_reestablish ( & node_a. node . get_our_node_id ( ) , & msg) ;
30923094 resp_1. push ( handle_chan_reestablish_msgs ! ( node_b, node_a) ) ;
30933095 }
3094- if pending_cell_htlc_claims. 0 != 0 || pending_cell_htlc_fails. 0 != 0 {
3096+ if pending_cell_htlc_claims. 0 != 0 || pending_cell_htlc_fails. 0 != 0 ||
3097+ pending_cell_htlc_malforms. 0 != 0
3098+ {
30953099 check_added_monitors ! ( node_b, 1 ) ;
30963100 } else {
30973101 check_added_monitors ! ( node_b, 0 ) ;
@@ -3102,17 +3106,21 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
31023106 node_a. node . handle_channel_reestablish ( & node_b. node . get_our_node_id ( ) , & msg) ;
31033107 resp_2. push ( handle_chan_reestablish_msgs ! ( node_a, node_b) ) ;
31043108 }
3105- if pending_cell_htlc_claims. 1 != 0 || pending_cell_htlc_fails. 1 != 0 {
3109+ if pending_cell_htlc_claims. 1 != 0 || pending_cell_htlc_fails. 1 != 0 ||
3110+ pending_cell_htlc_malforms. 1 != 0
3111+ {
31063112 check_added_monitors ! ( node_a, 1 ) ;
31073113 } else {
31083114 check_added_monitors ! ( node_a, 0 ) ;
31093115 }
31103116
31113117 // We don't yet support both needing updates, as that would require a different commitment dance:
31123118 assert ! ( ( pending_htlc_adds. 0 == 0 && pending_htlc_claims. 0 == 0 && pending_htlc_fails. 0 == 0 &&
3113- pending_cell_htlc_claims. 0 == 0 && pending_cell_htlc_fails. 0 == 0 ) ||
3119+ pending_cell_htlc_claims. 0 == 0 && pending_cell_htlc_fails. 0 == 0 &&
3120+ pending_cell_htlc_malforms. 0 == 0 ) ||
31143121 ( pending_htlc_adds. 1 == 0 && pending_htlc_claims. 1 == 0 && pending_htlc_fails. 1 == 0 &&
3115- pending_cell_htlc_claims. 1 == 0 && pending_cell_htlc_fails. 1 == 0 ) ) ;
3122+ pending_cell_htlc_claims. 1 == 0 && pending_cell_htlc_fails. 1 == 0 &&
3123+ pending_cell_htlc_malforms. 1 == 0 ) ) ;
31163124
31173125 for chan_msgs in resp_1. drain ( ..) {
31183126 if send_channel_ready. 0 {
@@ -3135,7 +3143,10 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
31353143 } else {
31363144 assert ! ( chan_msgs. 1 . is_none( ) ) ;
31373145 }
3138- 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 {
3146+ if pending_htlc_adds. 0 != 0 || pending_htlc_claims. 0 != 0 || pending_htlc_fails. 0 != 0 ||
3147+ pending_cell_htlc_claims. 0 != 0 || pending_cell_htlc_fails. 0 != 0 ||
3148+ pending_cell_htlc_malforms. 0 != 0
3149+ {
31393150 let commitment_update = chan_msgs. 2 . unwrap ( ) ;
31403151 if pending_htlc_adds. 0 != -1 { // We use -1 to denote a response commitment_signed
31413152 assert_eq ! ( commitment_update. update_add_htlcs. len( ) , pending_htlc_adds. 0 as usize ) ;
@@ -3144,7 +3155,7 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
31443155 }
31453156 assert_eq ! ( commitment_update. update_fulfill_htlcs. len( ) , pending_htlc_claims. 0 + pending_cell_htlc_claims. 0 ) ;
31463157 assert_eq ! ( commitment_update. update_fail_htlcs. len( ) , pending_htlc_fails. 0 + pending_cell_htlc_fails. 0 ) ;
3147- assert ! ( commitment_update. update_fail_malformed_htlcs. is_empty ( ) ) ;
3158+ assert_eq ! ( commitment_update. update_fail_malformed_htlcs. len ( ) , pending_cell_htlc_malforms . 0 ) ;
31483159 for update_add in commitment_update. update_add_htlcs {
31493160 node_a. node . handle_update_add_htlc ( & node_b. node . get_our_node_id ( ) , & update_add) ;
31503161 }
@@ -3154,6 +3165,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
31543165 for update_fail in commitment_update. update_fail_htlcs {
31553166 node_a. node . handle_update_fail_htlc ( & node_b. node . get_our_node_id ( ) , & update_fail) ;
31563167 }
3168+ for update_malformed in commitment_update. update_fail_malformed_htlcs {
3169+ node_a. node . handle_update_fail_malformed_htlc ( & node_b. node . get_our_node_id ( ) , & update_malformed) ;
3170+ }
31573171
31583172 if pending_htlc_adds. 0 != -1 { // We use -1 to denote a response commitment_signed
31593173 commitment_signed_dance ! ( node_a, node_b, commitment_update. commitment_signed, false ) ;
@@ -3194,14 +3208,17 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
31943208 } else {
31953209 assert ! ( chan_msgs. 1 . is_none( ) ) ;
31963210 }
3197- 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 {
3211+ if pending_htlc_adds. 1 != 0 || pending_htlc_claims. 1 != 0 || pending_htlc_fails. 1 != 0 ||
3212+ pending_cell_htlc_claims. 1 != 0 || pending_cell_htlc_fails. 1 != 0 ||
3213+ pending_cell_htlc_malforms. 1 != 0
3214+ {
31983215 let commitment_update = chan_msgs. 2 . unwrap ( ) ;
31993216 if pending_htlc_adds. 1 != -1 { // We use -1 to denote a response commitment_signed
32003217 assert_eq ! ( commitment_update. update_add_htlcs. len( ) , pending_htlc_adds. 1 as usize ) ;
32013218 }
32023219 assert_eq ! ( commitment_update. update_fulfill_htlcs. len( ) , pending_htlc_claims. 1 + pending_cell_htlc_claims. 1 ) ;
32033220 assert_eq ! ( commitment_update. update_fail_htlcs. len( ) , pending_htlc_fails. 1 + pending_cell_htlc_fails. 1 ) ;
3204- assert ! ( commitment_update. update_fail_malformed_htlcs. is_empty ( ) ) ;
3221+ assert_eq ! ( commitment_update. update_fail_malformed_htlcs. len ( ) , pending_cell_htlc_malforms . 1 ) ;
32053222 for update_add in commitment_update. update_add_htlcs {
32063223 node_b. node . handle_update_add_htlc ( & node_a. node . get_our_node_id ( ) , & update_add) ;
32073224 }
@@ -3211,6 +3228,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
32113228 for update_fail in commitment_update. update_fail_htlcs {
32123229 node_b. node . handle_update_fail_htlc ( & node_a. node . get_our_node_id ( ) , & update_fail) ;
32133230 }
3231+ for update_malformed in commitment_update. update_fail_malformed_htlcs {
3232+ node_b. node . handle_update_fail_malformed_htlc ( & node_a. node . get_our_node_id ( ) , & update_malformed) ;
3233+ }
32143234
32153235 if pending_htlc_adds. 1 != -1 { // We use -1 to denote a response commitment_signed
32163236 commitment_signed_dance ! ( node_b, node_a, commitment_update. commitment_signed, false ) ;
0 commit comments