@@ -171,19 +171,25 @@ impl_writeable_tlv_based_enum_upgradable!(MonitorEvent,
171
171
) ;
172
172
173
173
/// Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on
174
- /// chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the
175
- /// preimage claim backward will lead to loss of funds.
174
+ /// chain, or when we failing an HTLC awaiting downstream confirmation to prevent a
175
+ /// backwards channel from going on-chain. Used to update the corresponding HTLC in the backward
176
+ /// channel. Failing to pass the preimage claim backward will lead to loss of funds.
176
177
#[ derive( Clone , PartialEq , Eq ) ]
177
178
pub struct HTLCUpdate {
178
179
pub ( crate ) payment_hash : PaymentHash ,
179
180
pub ( crate ) payment_preimage : Option < PaymentPreimage > ,
180
181
pub ( crate ) source : HTLCSource ,
181
182
pub ( crate ) htlc_value_satoshis : Option < u64 > ,
183
+ /// If this is an update to fail back the upstream HTLC, this signals whether we're failing
184
+ /// back this HTLC because we saw a downstream claim on-chain, or if we're close to the
185
+ /// upstream timeout and want to prevent the channel from going on-chain.
186
+ pub ( crate ) awaiting_downstream_confirmation : bool ,
182
187
}
183
188
impl_writeable_tlv_based ! ( HTLCUpdate , {
184
189
( 0 , payment_hash, required) ,
185
190
( 1 , htlc_value_satoshis, option) ,
186
191
( 2 , source, required) ,
192
+ ( 3 , awaiting_downstream_confirmation, ( default_value, false ) ) ,
187
193
( 4 , payment_preimage, option) ,
188
194
} ) ;
189
195
@@ -3560,6 +3566,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3560
3566
payment_preimage : None ,
3561
3567
source : source. clone ( ) ,
3562
3568
htlc_value_satoshis,
3569
+ awaiting_downstream_confirmation : false ,
3563
3570
} ) ) ;
3564
3571
self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC {
3565
3572
commitment_tx_output_idx,
@@ -3937,6 +3944,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3937
3944
payment_preimage : Some ( payment_preimage) ,
3938
3945
payment_hash,
3939
3946
htlc_value_satoshis : Some ( amount_msat / 1000 ) ,
3947
+ awaiting_downstream_confirmation : false ,
3940
3948
} ) ) ;
3941
3949
}
3942
3950
} else if offered_preimage_claim {
@@ -3960,6 +3968,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3960
3968
payment_preimage : Some ( payment_preimage) ,
3961
3969
payment_hash,
3962
3970
htlc_value_satoshis : Some ( amount_msat / 1000 ) ,
3971
+ awaiting_downstream_confirmation : false ,
3963
3972
} ) ) ;
3964
3973
}
3965
3974
} else {
0 commit comments