Skip to content

Commit d5cbc6c

Browse files
committed
Expose ClaimId for each claim bump in BumpTransactionEvent
1 parent 537c34b commit d5cbc6c

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

lightning/src/chain/channelmonitor.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2505,7 +2505,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
25052505
let mut ret = Vec::new();
25062506
mem::swap(&mut ret, &mut self.pending_events);
25072507
#[cfg(anchors)]
2508-
for claim_event in self.onchain_tx_handler.get_and_clear_pending_claim_events().drain(..) {
2508+
for (claim_id, claim_event) in self.onchain_tx_handler.get_and_clear_pending_claim_events().drain(..) {
25092509
match claim_event {
25102510
ClaimEvent::BumpCommitment {
25112511
package_target_feerate_sat_per_1000_weight, commitment_tx, anchor_output_idx,
@@ -2516,6 +2516,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
25162516
let commitment_tx_fee_satoshis = self.channel_value_satoshis -
25172517
commitment_tx.output.iter().fold(0u64, |sum, output| sum + output.value);
25182518
ret.push(Event::BumpTransaction(BumpTransactionEvent::ChannelClose {
2519+
claim_id,
25192520
package_target_feerate_sat_per_1000_weight,
25202521
commitment_tx,
25212522
commitment_tx_fee_satoshis,
@@ -2547,6 +2548,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
25472548
});
25482549
}
25492550
ret.push(Event::BumpTransaction(BumpTransactionEvent::HTLCResolution {
2551+
claim_id,
25502552
target_feerate_sat_per_1000_weight,
25512553
htlc_descriptors,
25522554
tx_lock_time,

lightning/src/chain/onchaintx.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -475,10 +475,10 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
475475
}
476476

477477
#[cfg(anchors)]
478-
pub(crate) fn get_and_clear_pending_claim_events(&mut self) -> Vec<ClaimEvent> {
478+
pub(crate) fn get_and_clear_pending_claim_events(&mut self) -> Vec<(ClaimId, ClaimEvent)> {
479479
let mut events = Vec::new();
480480
swap(&mut events, &mut self.pending_claim_events);
481-
events.into_iter().map(|(_, event)| event).collect()
481+
events
482482
}
483483

484484
/// Triggers rebroadcasts/fee-bumps of pending claims from a force-closed channel. This is

lightning/src/events/bump_transaction.rs

+14
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
//! Utitilies for bumping transactions originating from [`super::Event`]s.
1111
12+
use crate::chain::ClaimId;
1213
use crate::ln::PaymentPreimage;
1314
use crate::ln::chan_utils;
1415
use crate::ln::chan_utils::{ChannelTransactionParameters, HTLCOutputInCommitment};
@@ -173,6 +174,12 @@ pub enum BumpTransactionEvent {
173174
/// [`EcdsaChannelSigner::sign_holder_anchor_input`]: crate::sign::EcdsaChannelSigner::sign_holder_anchor_input
174175
/// [`build_anchor_input_witness`]: crate::ln::chan_utils::build_anchor_input_witness
175176
ChannelClose {
177+
/// The unique identifier for the claim of the anchor output in the commitment transaction.
178+
///
179+
/// The identifier must map to the set of external UTXOs assigned to the claim, such that
180+
/// they can be reused when a new claim with the same identifier needs to be made, resulting
181+
/// in a fee-bumping attempt.
182+
claim_id: ClaimId,
176183
/// The target feerate that the transaction package, which consists of the commitment
177184
/// transaction and the to-be-crafted child anchor transaction, must meet.
178185
package_target_feerate_sat_per_1000_weight: u32,
@@ -222,6 +229,13 @@ pub enum BumpTransactionEvent {
222229
/// [`EcdsaChannelSigner::sign_holder_htlc_transaction`]: crate::sign::EcdsaChannelSigner::sign_holder_htlc_transaction
223230
/// [`HTLCDescriptor::tx_input_witness`]: HTLCDescriptor::tx_input_witness
224231
HTLCResolution {
232+
/// The unique identifier for the claim of the HTLCs in the confirmed commitment
233+
/// transaction.
234+
///
235+
/// The identifier must map to the set of external UTXOs assigned to the claim, such that
236+
/// they can be reused when a new claim with the same identifier needs to be made, resulting
237+
/// in a fee-bumping attempt.
238+
claim_id: ClaimId,
225239
/// The target feerate that the resulting HTLC transaction must meet.
226240
target_feerate_sat_per_1000_weight: u32,
227241
/// The set of pending HTLCs on the confirmed commitment that need to be claimed, preferably

lightning/src/ln/monitor_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1785,7 +1785,7 @@ fn do_test_monitor_rebroadcast_pending_claims(anchors: bool) {
17851785
let mut feerate = 0;
17861786
#[cfg(anchors)] {
17871787
feerate = if let Event::BumpTransaction(BumpTransactionEvent::HTLCResolution {
1788-
target_feerate_sat_per_1000_weight, mut htlc_descriptors, tx_lock_time,
1788+
target_feerate_sat_per_1000_weight, mut htlc_descriptors, tx_lock_time, ..
17891789
}) = events.pop().unwrap() {
17901790
let secp = Secp256k1::new();
17911791
assert_eq!(htlc_descriptors.len(), 1);

0 commit comments

Comments
 (0)