@@ -3035,6 +3035,7 @@ pub struct ReconnectArgs<'a, 'b, 'c, 'd> {
3035
3035
pub pending_htlc_fails : ( usize , usize ) ,
3036
3036
pub pending_cell_htlc_claims : ( usize , usize ) ,
3037
3037
pub pending_cell_htlc_fails : ( usize , usize ) ,
3038
+ pub pending_cell_htlc_malforms : ( usize , usize ) ,
3038
3039
pub pending_raa : ( bool , bool ) ,
3039
3040
}
3040
3041
@@ -3049,6 +3050,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
3049
3050
pending_htlc_fails : ( 0 , 0 ) ,
3050
3051
pending_cell_htlc_claims : ( 0 , 0 ) ,
3051
3052
pending_cell_htlc_fails : ( 0 , 0 ) ,
3053
+ pending_cell_htlc_malforms : ( 0 , 0 ) ,
3052
3054
pending_raa : ( false , false ) ,
3053
3055
}
3054
3056
}
@@ -3059,7 +3061,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
3059
3061
pub fn reconnect_nodes < ' a , ' b , ' c , ' d > ( args : ReconnectArgs < ' a , ' b , ' c , ' d > ) {
3060
3062
let ReconnectArgs {
3061
3063
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
3063
3065
} = args;
3064
3066
node_a. node . peer_connected ( & node_b. node . get_our_node_id ( ) , & msgs:: Init {
3065
3067
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>) {
3100
3102
node_b. node . handle_channel_reestablish ( & node_a. node . get_our_node_id ( ) , & msg) ;
3101
3103
resp_1. push ( handle_chan_reestablish_msgs ! ( node_b, node_a) ) ;
3102
3104
}
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
+ {
3104
3108
check_added_monitors ! ( node_b, 1 ) ;
3105
3109
} else {
3106
3110
check_added_monitors ! ( node_b, 0 ) ;
@@ -3111,17 +3115,21 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
3111
3115
node_a. node . handle_channel_reestablish ( & node_b. node . get_our_node_id ( ) , & msg) ;
3112
3116
resp_2. push ( handle_chan_reestablish_msgs ! ( node_a, node_b) ) ;
3113
3117
}
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
+ {
3115
3121
check_added_monitors ! ( node_a, 1 ) ;
3116
3122
} else {
3117
3123
check_added_monitors ! ( node_a, 0 ) ;
3118
3124
}
3119
3125
3120
3126
// We don't yet support both needing updates, as that would require a different commitment dance:
3121
3127
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 ) ||
3123
3130
( 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 ) ) ;
3125
3133
3126
3134
for chan_msgs in resp_1. drain ( ..) {
3127
3135
if send_channel_ready. 0 {
@@ -3144,7 +3152,10 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
3144
3152
} else {
3145
3153
assert ! ( chan_msgs. 1 . is_none( ) ) ;
3146
3154
}
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
+ {
3148
3159
let commitment_update = chan_msgs. 2 . unwrap ( ) ;
3149
3160
if pending_htlc_adds. 0 != -1 { // We use -1 to denote a response commitment_signed
3150
3161
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>) {
3153
3164
}
3154
3165
assert_eq ! ( commitment_update. update_fulfill_htlcs. len( ) , pending_htlc_claims. 0 + pending_cell_htlc_claims. 0 ) ;
3155
3166
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 ) ;
3157
3168
for update_add in commitment_update. update_add_htlcs {
3158
3169
node_a. node . handle_update_add_htlc ( & node_b. node . get_our_node_id ( ) , & update_add) ;
3159
3170
}
@@ -3163,6 +3174,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
3163
3174
for update_fail in commitment_update. update_fail_htlcs {
3164
3175
node_a. node . handle_update_fail_htlc ( & node_b. node . get_our_node_id ( ) , & update_fail) ;
3165
3176
}
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
+ }
3166
3180
3167
3181
if pending_htlc_adds. 0 != -1 { // We use -1 to denote a response commitment_signed
3168
3182
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>) {
3203
3217
} else {
3204
3218
assert ! ( chan_msgs. 1 . is_none( ) ) ;
3205
3219
}
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
+ {
3207
3224
let commitment_update = chan_msgs. 2 . unwrap ( ) ;
3208
3225
if pending_htlc_adds. 1 != -1 { // We use -1 to denote a response commitment_signed
3209
3226
assert_eq ! ( commitment_update. update_add_htlcs. len( ) , pending_htlc_adds. 1 as usize ) ;
3210
3227
}
3211
3228
assert_eq ! ( commitment_update. update_fulfill_htlcs. len( ) , pending_htlc_claims. 1 + pending_cell_htlc_claims. 1 ) ;
3212
3229
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 ) ;
3214
3231
for update_add in commitment_update. update_add_htlcs {
3215
3232
node_b. node . handle_update_add_htlc ( & node_a. node . get_our_node_id ( ) , & update_add) ;
3216
3233
}
@@ -3220,6 +3237,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
3220
3237
for update_fail in commitment_update. update_fail_htlcs {
3221
3238
node_b. node . handle_update_fail_htlc ( & node_a. node . get_our_node_id ( ) , & update_fail) ;
3222
3239
}
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
+ }
3223
3243
3224
3244
if pending_htlc_adds. 1 != -1 { // We use -1 to denote a response commitment_signed
3225
3245
commitment_signed_dance ! ( node_b, node_a, commitment_update. commitment_signed, false ) ;
0 commit comments