@@ -3026,6 +3026,7 @@ pub struct ReconnectArgs<'a, 'b, 'c, 'd> {
3026
3026
pub pending_htlc_fails : ( usize , usize ) ,
3027
3027
pub pending_cell_htlc_claims : ( usize , usize ) ,
3028
3028
pub pending_cell_htlc_fails : ( usize , usize ) ,
3029
+ pub pending_cell_htlc_malforms : ( usize , usize ) ,
3029
3030
pub pending_raa : ( bool , bool ) ,
3030
3031
}
3031
3032
@@ -3040,6 +3041,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
3040
3041
pending_htlc_fails : ( 0 , 0 ) ,
3041
3042
pending_cell_htlc_claims : ( 0 , 0 ) ,
3042
3043
pending_cell_htlc_fails : ( 0 , 0 ) ,
3044
+ pending_cell_htlc_malforms : ( 0 , 0 ) ,
3043
3045
pending_raa : ( false , false ) ,
3044
3046
}
3045
3047
}
@@ -3050,7 +3052,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
3050
3052
pub fn reconnect_nodes < ' a , ' b , ' c , ' d > ( args : ReconnectArgs < ' a , ' b , ' c , ' d > ) {
3051
3053
let ReconnectArgs {
3052
3054
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
3054
3056
} = args;
3055
3057
node_a. node . peer_connected ( & node_b. node . get_our_node_id ( ) , & msgs:: Init {
3056
3058
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>) {
3091
3093
node_b. node . handle_channel_reestablish ( & node_a. node . get_our_node_id ( ) , & msg) ;
3092
3094
resp_1. push ( handle_chan_reestablish_msgs ! ( node_b, node_a) ) ;
3093
3095
}
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
+ {
3095
3099
check_added_monitors ! ( node_b, 1 ) ;
3096
3100
} else {
3097
3101
check_added_monitors ! ( node_b, 0 ) ;
@@ -3102,17 +3106,21 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
3102
3106
node_a. node . handle_channel_reestablish ( & node_b. node . get_our_node_id ( ) , & msg) ;
3103
3107
resp_2. push ( handle_chan_reestablish_msgs ! ( node_a, node_b) ) ;
3104
3108
}
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
+ {
3106
3112
check_added_monitors ! ( node_a, 1 ) ;
3107
3113
} else {
3108
3114
check_added_monitors ! ( node_a, 0 ) ;
3109
3115
}
3110
3116
3111
3117
// We don't yet support both needing updates, as that would require a different commitment dance:
3112
3118
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 ) ||
3114
3121
( 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 ) ) ;
3116
3124
3117
3125
for chan_msgs in resp_1. drain ( ..) {
3118
3126
if send_channel_ready. 0 {
@@ -3135,7 +3143,10 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
3135
3143
} else {
3136
3144
assert ! ( chan_msgs. 1 . is_none( ) ) ;
3137
3145
}
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
+ {
3139
3150
let commitment_update = chan_msgs. 2 . unwrap ( ) ;
3140
3151
if pending_htlc_adds. 0 != -1 { // We use -1 to denote a response commitment_signed
3141
3152
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>) {
3144
3155
}
3145
3156
assert_eq ! ( commitment_update. update_fulfill_htlcs. len( ) , pending_htlc_claims. 0 + pending_cell_htlc_claims. 0 ) ;
3146
3157
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 ) ;
3148
3159
for update_add in commitment_update. update_add_htlcs {
3149
3160
node_a. node . handle_update_add_htlc ( & node_b. node . get_our_node_id ( ) , & update_add) ;
3150
3161
}
@@ -3154,6 +3165,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
3154
3165
for update_fail in commitment_update. update_fail_htlcs {
3155
3166
node_a. node . handle_update_fail_htlc ( & node_b. node . get_our_node_id ( ) , & update_fail) ;
3156
3167
}
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
+ }
3157
3171
3158
3172
if pending_htlc_adds. 0 != -1 { // We use -1 to denote a response commitment_signed
3159
3173
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>) {
3194
3208
} else {
3195
3209
assert ! ( chan_msgs. 1 . is_none( ) ) ;
3196
3210
}
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
+ {
3198
3215
let commitment_update = chan_msgs. 2 . unwrap ( ) ;
3199
3216
if pending_htlc_adds. 1 != -1 { // We use -1 to denote a response commitment_signed
3200
3217
assert_eq ! ( commitment_update. update_add_htlcs. len( ) , pending_htlc_adds. 1 as usize ) ;
3201
3218
}
3202
3219
assert_eq ! ( commitment_update. update_fulfill_htlcs. len( ) , pending_htlc_claims. 1 + pending_cell_htlc_claims. 1 ) ;
3203
3220
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 ) ;
3205
3222
for update_add in commitment_update. update_add_htlcs {
3206
3223
node_b. node . handle_update_add_htlc ( & node_a. node . get_our_node_id ( ) , & update_add) ;
3207
3224
}
@@ -3211,6 +3228,9 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
3211
3228
for update_fail in commitment_update. update_fail_htlcs {
3212
3229
node_b. node . handle_update_fail_htlc ( & node_a. node . get_our_node_id ( ) , & update_fail) ;
3213
3230
}
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
+ }
3214
3234
3215
3235
if pending_htlc_adds. 1 != -1 { // We use -1 to denote a response commitment_signed
3216
3236
commitment_signed_dance ! ( node_b, node_a, commitment_update. commitment_signed, false ) ;
0 commit comments