@@ -3084,6 +3084,7 @@ pub struct ReconnectArgs<'a, 'b, 'c, 'd> {
3084
3084
pub pending_htlc_fails : ( usize , usize ) ,
3085
3085
pub pending_cell_htlc_claims : ( usize , usize ) ,
3086
3086
pub pending_cell_htlc_fails : ( usize , usize ) ,
3087
+ pub pending_cell_htlc_malforms : ( usize , usize ) ,
3087
3088
pub pending_raa : ( bool , bool ) ,
3088
3089
}
3089
3090
@@ -3098,6 +3099,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
3098
3099
pending_htlc_fails : ( 0 , 0 ) ,
3099
3100
pending_cell_htlc_claims : ( 0 , 0 ) ,
3100
3101
pending_cell_htlc_fails : ( 0 , 0 ) ,
3102
+ pending_cell_htlc_malforms : ( 0 , 0 ) ,
3101
3103
pending_raa : ( false , false ) ,
3102
3104
}
3103
3105
}
@@ -3108,7 +3110,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
3108
3110
pub fn reconnect_nodes < ' a , ' b , ' c , ' d > ( args : ReconnectArgs < ' a , ' b , ' c , ' d > ) {
3109
3111
let ReconnectArgs {
3110
3112
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
3112
3114
} = args;
3113
3115
node_a. node . peer_connected ( & node_b. node . get_our_node_id ( ) , & msgs:: Init {
3114
3116
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>) {
3149
3151
node_b. node . handle_channel_reestablish ( & node_a. node . get_our_node_id ( ) , & msg) ;
3150
3152
resp_1. push ( handle_chan_reestablish_msgs ! ( node_b, node_a) ) ;
3151
3153
}
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
+ {
3153
3157
check_added_monitors ! ( node_b, 1 ) ;
3154
3158
} else {
3155
3159
check_added_monitors ! ( node_b, 0 ) ;
@@ -3160,17 +3164,21 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
3160
3164
node_a. node . handle_channel_reestablish ( & node_b. node . get_our_node_id ( ) , & msg) ;
3161
3165
resp_2. push ( handle_chan_reestablish_msgs ! ( node_a, node_b) ) ;
3162
3166
}
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
+ {
3164
3170
check_added_monitors ! ( node_a, 1 ) ;
3165
3171
} else {
3166
3172
check_added_monitors ! ( node_a, 0 ) ;
3167
3173
}
3168
3174
3169
3175
// We don't yet support both needing updates, as that would require a different commitment dance:
3170
3176
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 ) ||
3172
3179
( 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 ) ) ;
3174
3182
3175
3183
for chan_msgs in resp_1. drain ( ..) {
3176
3184
if send_channel_ready. 0 {
@@ -3193,7 +3201,10 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
3193
3201
} else {
3194
3202
assert ! ( chan_msgs. 1 . is_none( ) ) ;
3195
3203
}
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
+ {
3197
3208
let commitment_update = chan_msgs. 2 . unwrap ( ) ;
3198
3209
if pending_htlc_adds. 0 != -1 { // We use -1 to denote a response commitment_signed
3199
3210
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>) {
3202
3213
}
3203
3214
assert_eq ! ( commitment_update. update_fulfill_htlcs. len( ) , pending_htlc_claims. 0 + pending_cell_htlc_claims. 0 ) ;
3204
3215
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 ) ;
3206
3217
for update_add in commitment_update. update_add_htlcs {
3207
3218
node_a. node . handle_update_add_htlc ( & node_b. node . get_our_node_id ( ) , & update_add) ;
3208
3219
}
@@ -3212,6 +3223,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
3212
3223
for update_fail in commitment_update. update_fail_htlcs {
3213
3224
node_a. node . handle_update_fail_htlc ( & node_b. node . get_our_node_id ( ) , & update_fail) ;
3214
3225
}
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
+ }
3215
3229
3216
3230
if pending_htlc_adds. 0 != -1 { // We use -1 to denote a response commitment_signed
3217
3231
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>) {
3252
3266
} else {
3253
3267
assert ! ( chan_msgs. 1 . is_none( ) ) ;
3254
3268
}
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
+ {
3256
3273
let commitment_update = chan_msgs. 2 . unwrap ( ) ;
3257
3274
if pending_htlc_adds. 1 != -1 { // We use -1 to denote a response commitment_signed
3258
3275
assert_eq ! ( commitment_update. update_add_htlcs. len( ) , pending_htlc_adds. 1 as usize ) ;
3259
3276
}
3260
3277
assert_eq ! ( commitment_update. update_fulfill_htlcs. len( ) , pending_htlc_claims. 1 + pending_cell_htlc_claims. 1 ) ;
3261
3278
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 ) ;
3263
3280
for update_add in commitment_update. update_add_htlcs {
3264
3281
node_b. node . handle_update_add_htlc ( & node_a. node . get_our_node_id ( ) , & update_add) ;
3265
3282
}
@@ -3269,6 +3286,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
3269
3286
for update_fail in commitment_update. update_fail_htlcs {
3270
3287
node_b. node . handle_update_fail_htlc ( & node_a. node . get_our_node_id ( ) , & update_fail) ;
3271
3288
}
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
+ }
3272
3292
3273
3293
if pending_htlc_adds. 1 != -1 { // We use -1 to denote a response commitment_signed
3274
3294
commitment_signed_dance ! ( node_b, node_a, commitment_update. commitment_signed, false ) ;
0 commit comments