@@ -84,8 +84,8 @@ static struct amount_msat our_msat;
84
84
/* Needed for anchor outputs */
85
85
static struct pubkey funding_pubkey [NUM_SIDES ];
86
86
87
- /* Does option_static_remotekey apply to this commitment tx ? */
88
- static bool option_static_remotekey ;
87
+ /* At what commit number does option_static_remotekey apply ? */
88
+ static u64 static_remotekey_start [ NUM_SIDES ] ;
89
89
90
90
/* Does option_anchor_outputs apply to this commitment tx? */
91
91
static bool option_anchor_outputs ;
@@ -2615,7 +2615,7 @@ static void handle_our_unilateral(const struct tx_parts *tx,
2615
2615
if (!derive_keyset (& local_per_commitment_point ,
2616
2616
& basepoints [LOCAL ],
2617
2617
& basepoints [REMOTE ],
2618
- option_static_remotekey ,
2618
+ commit_num >= static_remotekey_start [ LOCAL ] ,
2619
2619
ks ))
2620
2620
status_failed (STATUS_FAIL_INTERNAL_ERROR ,
2621
2621
"Deriving keyset for %" PRIu64 , commit_num );
@@ -3050,7 +3050,7 @@ static void handle_their_cheat(const struct tx_parts *tx,
3050
3050
if (!derive_keyset (remote_per_commitment_point ,
3051
3051
& basepoints [REMOTE ],
3052
3052
& basepoints [LOCAL ],
3053
- option_static_remotekey ,
3053
+ commit_num >= static_remotekey_start [ REMOTE ] ,
3054
3054
ks ))
3055
3055
status_failed (STATUS_FAIL_INTERNAL_ERROR ,
3056
3056
"Deriving keyset for %" PRIu64 , commit_num );
@@ -3063,7 +3063,7 @@ static void handle_their_cheat(const struct tx_parts *tx,
3063
3063
" other_payment_key: %s"
3064
3064
" self_htlc_key: %s"
3065
3065
" other_htlc_key: %s"
3066
- " (option_static_remotekey = %i )" ,
3066
+ " (static_remotekey = %" PRIu64 "/%" PRIu64 " )" ,
3067
3067
commit_num ,
3068
3068
type_to_string (tmpctx , struct pubkey ,
3069
3069
& keyset -> self_revocation_key ),
@@ -3077,7 +3077,8 @@ static void handle_their_cheat(const struct tx_parts *tx,
3077
3077
& keyset -> self_htlc_key ),
3078
3078
type_to_string (tmpctx , struct pubkey ,
3079
3079
& keyset -> other_htlc_key ),
3080
- option_static_remotekey );
3080
+ static_remotekey_start [LOCAL ],
3081
+ static_remotekey_start [REMOTE ]);
3081
3082
3082
3083
remote_wscript = to_self_wscript (tmpctx , to_self_delay [REMOTE ], keyset );
3083
3084
@@ -3154,7 +3155,7 @@ static void handle_their_cheat(const struct tx_parts *tx,
3154
3155
tx_blockheight ,
3155
3156
script [LOCAL ],
3156
3157
remote_per_commitment_point ,
3157
- option_static_remotekey );
3158
+ commit_num >= static_remotekey_start [ REMOTE ] );
3158
3159
script [LOCAL ] = NULL ;
3159
3160
add_amt (& total_outs , amt );
3160
3161
continue ;
@@ -3334,7 +3335,7 @@ static void handle_their_unilateral(const struct tx_parts *tx,
3334
3335
if (!derive_keyset (remote_per_commitment_point ,
3335
3336
& basepoints [REMOTE ],
3336
3337
& basepoints [LOCAL ],
3337
- option_static_remotekey ,
3338
+ commit_num >= static_remotekey_start [ REMOTE ] ,
3338
3339
ks ))
3339
3340
status_failed (STATUS_FAIL_INTERNAL_ERROR ,
3340
3341
"Deriving keyset for %" PRIu64 , commit_num );
@@ -3434,7 +3435,7 @@ static void handle_their_unilateral(const struct tx_parts *tx,
3434
3435
tx_blockheight ,
3435
3436
script [LOCAL ],
3436
3437
remote_per_commitment_point ,
3437
- option_static_remotekey );
3438
+ commit_num >= static_remotekey_start [ REMOTE ] );
3438
3439
script [LOCAL ] = NULL ;
3439
3440
add_amt (& our_outs , amt );
3440
3441
continue ;
@@ -3634,10 +3635,13 @@ static void handle_unknown_commitment(const struct tx_parts *tx,
3634
3635
assert (amount_asset_is_main (& asset ));
3635
3636
amt = amount_asset_to_sat (& asset );
3636
3637
3637
- if (wally_tx_output_scripteq (tx -> outputs [i ], local_scripts [0 ]))
3638
+ /* Elements can have empty output scripts it seems. */
3639
+ if (local_scripts [0 ]
3640
+ && wally_tx_output_scripteq (tx -> outputs [i ], local_scripts [0 ]))
3638
3641
which_script = 0 ;
3639
- else if (wally_tx_output_scripteq (tx -> outputs [i ],
3640
- local_scripts [1 ]))
3642
+ else if (local_scripts [1 ]
3643
+ && wally_tx_output_scripteq (tx -> outputs [i ],
3644
+ local_scripts [1 ]))
3641
3645
which_script = 1 ;
3642
3646
else
3643
3647
continue ;
@@ -3666,8 +3670,8 @@ static void handle_unknown_commitment(const struct tx_parts *tx,
3666
3670
local_scripts [which_script ],
3667
3671
possible_remote_per_commitment_point ,
3668
3672
which_script == 1 );
3669
- local_scripts [0 ] = local_scripts [1 ] = NULL ;
3670
3673
to_us_output = i ;
3674
+ break ;
3671
3675
}
3672
3676
3673
3677
if (to_us_output == -1 ) {
@@ -3772,7 +3776,8 @@ int main(int argc, char *argv[])
3772
3776
& possible_remote_per_commitment_point ,
3773
3777
& funding_pubkey [LOCAL ],
3774
3778
& funding_pubkey [REMOTE ],
3775
- & option_static_remotekey ,
3779
+ & static_remotekey_start [LOCAL ],
3780
+ & static_remotekey_start [REMOTE ],
3776
3781
& option_anchor_outputs ,
3777
3782
& open_is_replay ,
3778
3783
& min_relay_feerate )) {
0 commit comments