use crate::util::byte_utils;
use crate::util::events::Event;
#[cfg(anchors)]
-use crate::util::events::{AnchorDescriptor, BumpTransactionEvent};
+use crate::util::events::{AnchorDescriptor, HTLCDescriptor, BumpTransactionEvent};
use crate::prelude::*;
use core::{cmp, mem};
log_trace!(logger, "Updating ChannelMonitor: channel force closed, should broadcast: {}", should_broadcast);
self.lockdown_from_offchain = true;
if *should_broadcast {
+ // There's no need to broadcast our commitment transaction if we've seen one
+ // confirmed (even with 1 confirmation) as it'll be rejected as
+ // duplicate/conflicting.
+ let detected_funding_spend = self.funding_spend_confirmed.is_some() ||
+ self.onchain_events_awaiting_threshold_conf.iter().find(|event| match event.event {
+ OnchainEvent::FundingSpendConfirmation { .. } => true,
+ _ => false,
+ }).is_some();
+ if detected_funding_spend {
+ continue;
+ }
self.broadcast_latest_holder_commitment_txn(broadcaster, logger);
// If the channel supports anchor outputs, we'll need to emit an external
// event to be consumed such that a child transaction is broadcast with a
pending_htlcs,
}));
},
+ ClaimEvent::BumpHTLC {
+ target_feerate_sat_per_1000_weight, htlcs,
+ } => {
+ let mut htlc_descriptors = Vec::with_capacity(htlcs.len());
+ for htlc in htlcs {
+ htlc_descriptors.push(HTLCDescriptor {
+ channel_keys_id: self.channel_keys_id,
+ channel_value_satoshis: self.channel_value_satoshis,
+ channel_parameters: self.onchain_tx_handler.channel_transaction_parameters.clone(),
+ commitment_txid: htlc.commitment_txid,
+ per_commitment_number: htlc.per_commitment_number,
+ htlc: htlc.htlc,
+ preimage: htlc.preimage,
+ counterparty_sig: htlc.counterparty_sig,
+ });
+ }
+ ret.push(Event::BumpTransaction(BumpTransactionEvent::HTLCResolution {
+ target_feerate_sat_per_1000_weight,
+ htlc_descriptors,
+ }));
+ }
}
}
ret
if let Some(new_outputs) = new_outputs_option {
watch_outputs.push(new_outputs);
}
- // Since there may be multiple HTLCs (all from the same commitment) being
- // claimed by the counterparty within the same transaction, and
- // `check_spend_counterparty_htlc` already checks for all of them, we can
- // safely break from our loop.
+ // Since there may be multiple HTLCs for this channel (all spending the
+ // same commitment tx) being claimed by the counterparty within the same
+ // transaction, and `check_spend_counterparty_htlc` already checks all the
+ // ones relevant to this channel, we can safely break from our loop.
break;
}
}