@@ -826,6 +826,13 @@ pub(crate) struct ChannelMonitorImpl<Signer: Sign> {
826
826
/// spending CSV for revocable outputs).
827
827
htlcs_resolved_on_chain : Vec < IrrevocablyResolvedHTLC > ,
828
828
829
+ /// The set of `SpendableOutput` events which we have already passed upstream to be claimed.
830
+ /// These are tracked explicitly to ensure that we don't generate the same events redundantly
831
+ /// if users duplicatively confirm old transactions. Specifically for transactions claiming a
832
+ /// revoked remote outpoint we otherwise have no tracking at all once they've reached
833
+ /// [`ANTI_REORG_DELAY`], so we have to track them here.
834
+ spendable_txids_confirmed : Vec < Txid > ,
835
+
829
836
// We simply modify best_block in Channel's block_connected so that serialization is
830
837
// consistent but hopefully the users' copy handles block_connected in a consistent way.
831
838
// (we do *not*, however, update them in update_monitor to ensure any local user copies keep
@@ -1071,6 +1078,7 @@ impl<Signer: Sign> Writeable for ChannelMonitorImpl<Signer> {
1071
1078
( 7 , self . funding_spend_seen, required) ,
1072
1079
( 9 , self . counterparty_node_id, option) ,
1073
1080
( 11 , self . confirmed_commitment_tx_counterparty_output, option) ,
1081
+ ( 13 , self . spendable_txids_confirmed, vec_type) ,
1074
1082
} ) ;
1075
1083
1076
1084
Ok ( ( ) )
@@ -1179,6 +1187,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1179
1187
funding_spend_confirmed : None ,
1180
1188
confirmed_commitment_tx_counterparty_output : None ,
1181
1189
htlcs_resolved_on_chain : Vec :: new ( ) ,
1190
+ spendable_txids_confirmed : Vec :: new ( ) ,
1182
1191
1183
1192
best_block,
1184
1193
counterparty_node_id : Some ( counterparty_node_id) ,
@@ -3042,6 +3051,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
3042
3051
self . pending_events . push ( Event :: SpendableOutputs {
3043
3052
outputs : vec ! [ descriptor]
3044
3053
} ) ;
3054
+ self . spendable_txids_confirmed . push ( entry. txid ) ;
3045
3055
} ,
3046
3056
OnchainEvent :: HTLCSpendConfirmation { commitment_tx_output_idx, preimage, .. } => {
3047
3057
self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC {
@@ -3777,13 +3787,15 @@ impl<'a, K: KeysInterface> ReadableArgs<&'a K>
3777
3787
let mut funding_spend_seen = Some ( false ) ;
3778
3788
let mut counterparty_node_id = None ;
3779
3789
let mut confirmed_commitment_tx_counterparty_output = None ;
3790
+ let mut spendable_txids_confirmed = Some ( Vec :: new ( ) ) ;
3780
3791
read_tlv_fields ! ( reader, {
3781
3792
( 1 , funding_spend_confirmed, option) ,
3782
3793
( 3 , htlcs_resolved_on_chain, vec_type) ,
3783
3794
( 5 , pending_monitor_events, vec_type) ,
3784
3795
( 7 , funding_spend_seen, option) ,
3785
3796
( 9 , counterparty_node_id, option) ,
3786
3797
( 11 , confirmed_commitment_tx_counterparty_output, option) ,
3798
+ ( 13 , spendable_txids_confirmed, vec_type) ,
3787
3799
} ) ;
3788
3800
3789
3801
let mut secp_ctx = Secp256k1 :: new ( ) ;
@@ -3836,6 +3848,7 @@ impl<'a, K: KeysInterface> ReadableArgs<&'a K>
3836
3848
funding_spend_confirmed,
3837
3849
confirmed_commitment_tx_counterparty_output,
3838
3850
htlcs_resolved_on_chain : htlcs_resolved_on_chain. unwrap ( ) ,
3851
+ spendable_txids_confirmed : spendable_txids_confirmed. unwrap ( ) ,
3839
3852
3840
3853
best_block,
3841
3854
counterparty_node_id,
0 commit comments