@@ -506,6 +506,9 @@ pub(crate) struct ChannelMonitorImpl<Signer: Sign> {
506
506
on_holder_tx_csv : u16 ,
507
507
508
508
commitment_secrets : CounterpartyCommitmentSecrets ,
509
+ /// The set of outpoints in each counterparty commitment transaction. We always need at least
510
+ /// the payment hash from `HTLCOutputInCommitment` to claim even a revoked commitment
511
+ /// transaction broadcast as we need to be able to construct the witness script in all cases.
509
512
counterparty_claimable_outpoints : HashMap < Txid , Vec < ( HTLCOutputInCommitment , Option < Box < HTLCSource > > ) > > ,
510
513
/// We cannot identify HTLC-Success or HTLC-Timeout transactions by themselves on the chain.
511
514
/// Nor can we figure out their commitment numbers without the commitment transaction they are
@@ -1200,6 +1203,18 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1200
1203
/// Compares a broadcasted commitment transaction's HTLCs with those in the latest state,
1201
1204
/// failing any HTLCs which didn't make it into the broadcasted commitment transaction back
1202
1205
/// after ANTI_REORG_DELAY blocks.
1206
+ ///
1207
+ /// We always compare against the set of HTLCs in counterparty commitment transactions, as those
1208
+ /// are the commitment transactions which are generated by us. The off-chain state machine in
1209
+ /// `Channel` will automatically resolve any HTLCs which were never included in a commitment
1210
+ /// transaction when it detects channel closure, but it is up to us to ensure any HTLCs which were
1211
+ /// included in a remote commitment transaction are failed back if they are not present in the
1212
+ /// broadcasted commitment transaction.
1213
+ ///
1214
+ /// Specifically, the removal process for HTLCs in `Channel` is always based on the counterparty
1215
+ /// sending a `revoke_and_ack`, which causes us to clear `prev_counterparty_commitment_txid`. Thus,
1216
+ /// as long as we examine both the current counterparty commitment transaction and, if it hasn't
1217
+ /// been revoked yet, the previous one, we we will never "forget" to resolve an HTLC.
1203
1218
macro_rules! fail_unbroadcast_htlcs {
1204
1219
( $self: expr, $commitment_tx_type: expr, $commitment_tx_conf_height: expr, $confirmed_htlcs_list: expr, $logger: expr) => { {
1205
1220
macro_rules! check_htlc_fails {
0 commit comments