Expose ClaimId for each claim bump in BumpTransactionEvent
authorWilmer Paulino <wilmer@wilmerpaulino.com>
Thu, 11 May 2023 20:50:46 +0000 (13:50 -0700)
committerWilmer Paulino <wilmer@wilmerpaulino.com>
Mon, 19 Jun 2023 21:05:45 +0000 (14:05 -0700)
lightning/src/chain/channelmonitor.rs
lightning/src/chain/onchaintx.rs
lightning/src/events/bump_transaction.rs
lightning/src/ln/monitor_tests.rs

index a48f169a4d5e605b330f49896bc191779dd389d7..f0a2e80def635ea52589e99fa56b789b118754b7 100644 (file)
@@ -2505,7 +2505,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
                let mut ret = Vec::new();
                mem::swap(&mut ret, &mut self.pending_events);
                #[cfg(anchors)]
-               for claim_event in self.onchain_tx_handler.get_and_clear_pending_claim_events().drain(..) {
+               for (claim_id, claim_event) in self.onchain_tx_handler.get_and_clear_pending_claim_events().drain(..) {
                        match claim_event {
                                ClaimEvent::BumpCommitment {
                                        package_target_feerate_sat_per_1000_weight, commitment_tx, anchor_output_idx,
@@ -2516,6 +2516,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
                                        let commitment_tx_fee_satoshis = self.channel_value_satoshis -
                                                commitment_tx.output.iter().fold(0u64, |sum, output| sum + output.value);
                                        ret.push(Event::BumpTransaction(BumpTransactionEvent::ChannelClose {
+                                               claim_id,
                                                package_target_feerate_sat_per_1000_weight,
                                                commitment_tx,
                                                commitment_tx_fee_satoshis,
@@ -2547,6 +2548,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
                                                });
                                        }
                                        ret.push(Event::BumpTransaction(BumpTransactionEvent::HTLCResolution {
+                                               claim_id,
                                                target_feerate_sat_per_1000_weight,
                                                htlc_descriptors,
                                                tx_lock_time,
index f7d781a35deed19f49665638bff7363ab2169fcf..58ad449334b98db717880ea915c1b571087c6726 100644 (file)
@@ -475,10 +475,10 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
        }
 
        #[cfg(anchors)]
-       pub(crate) fn get_and_clear_pending_claim_events(&mut self) -> Vec<ClaimEvent> {
+       pub(crate) fn get_and_clear_pending_claim_events(&mut self) -> Vec<(ClaimId, ClaimEvent)> {
                let mut events = Vec::new();
                swap(&mut events, &mut self.pending_claim_events);
-               events.into_iter().map(|(_, event)| event).collect()
+               events
        }
 
        /// Triggers rebroadcasts/fee-bumps of pending claims from a force-closed channel. This is
index 950a31af37d8480a6eb080fc6d874360c19798cd..d627132eaced34606f35b55062b4159d7670d6c5 100644 (file)
@@ -9,6 +9,7 @@
 
 //! Utitilies for bumping transactions originating from [`super::Event`]s.
 
+use crate::chain::ClaimId;
 use crate::ln::PaymentPreimage;
 use crate::ln::chan_utils;
 use crate::ln::chan_utils::{ChannelTransactionParameters, HTLCOutputInCommitment};
@@ -173,6 +174,12 @@ pub enum BumpTransactionEvent {
        /// [`EcdsaChannelSigner::sign_holder_anchor_input`]: crate::sign::EcdsaChannelSigner::sign_holder_anchor_input
        /// [`build_anchor_input_witness`]: crate::ln::chan_utils::build_anchor_input_witness
        ChannelClose {
+               /// The unique identifier for the claim of the anchor output in the commitment transaction.
+               ///
+               /// The identifier must map to the set of external UTXOs assigned to the claim, such that
+               /// they can be reused when a new claim with the same identifier needs to be made, resulting
+               /// in a fee-bumping attempt.
+               claim_id: ClaimId,
                /// The target feerate that the transaction package, which consists of the commitment
                /// transaction and the to-be-crafted child anchor transaction, must meet.
                package_target_feerate_sat_per_1000_weight: u32,
@@ -222,6 +229,13 @@ pub enum BumpTransactionEvent {
        /// [`EcdsaChannelSigner::sign_holder_htlc_transaction`]: crate::sign::EcdsaChannelSigner::sign_holder_htlc_transaction
        /// [`HTLCDescriptor::tx_input_witness`]: HTLCDescriptor::tx_input_witness
        HTLCResolution {
+               /// The unique identifier for the claim of the HTLCs in the confirmed commitment
+               /// transaction.
+               ///
+               /// The identifier must map to the set of external UTXOs assigned to the claim, such that
+               /// they can be reused when a new claim with the same identifier needs to be made, resulting
+               /// in a fee-bumping attempt.
+               claim_id: ClaimId,
                /// The target feerate that the resulting HTLC transaction must meet.
                target_feerate_sat_per_1000_weight: u32,
                /// The set of pending HTLCs on the confirmed commitment that need to be claimed, preferably
index 5fa39137cf4577f41f85a57b95aedf067ea43e5b..c6b3f39d2f9bcc74e3dd20633a88b01f64795e32 100644 (file)
@@ -1785,7 +1785,7 @@ fn do_test_monitor_rebroadcast_pending_claims(anchors: bool) {
                        let mut feerate = 0;
                        #[cfg(anchors)] {
                                feerate = if let Event::BumpTransaction(BumpTransactionEvent::HTLCResolution {
-                                       target_feerate_sat_per_1000_weight, mut htlc_descriptors, tx_lock_time,
+                                       target_feerate_sat_per_1000_weight, mut htlc_descriptors, tx_lock_time, ..
                                }) = events.pop().unwrap() {
                                        let secp = Secp256k1::new();
                                        assert_eq!(htlc_descriptors.len(), 1);