Skip to content

Commit 025e938

Browse files
committed
Expose ClaimId for each claim bump in BumpTransactionEvent
1 parent 3f9e3d9 commit 025e938

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 3 additions & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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.into_iter().collect()
482482
}
483483

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

lightning/src/events/bump_transaction.rs

Lines changed: 21 additions & 0 deletions
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,15 @@ 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+
/// Any future instances of `ChannelClose` bump events that share the same `claim_id` must
180+
/// be considered the same claim. Therefore, the idenfier serves as a "UTXO lock" for users,
181+
/// as they can assign the additional inputs required for the claim to this identifier to
182+
/// ensure their claims don't double spend and conflict with each other. However, note that
183+
/// in some cases, it may be required to double spend the UTXOs assigned to previous claims
184+
/// in new claims if there aren't any unassigned UTXOs available to use.
185+
claim_id: ClaimId,
176186
/// The target feerate that the transaction package, which consists of the commitment
177187
/// transaction and the to-be-crafted child anchor transaction, must meet.
178188
package_target_feerate_sat_per_1000_weight: u32,
@@ -222,6 +232,17 @@ pub enum BumpTransactionEvent {
222232
/// [`EcdsaChannelSigner::sign_holder_htlc_transaction`]: crate::sign::EcdsaChannelSigner::sign_holder_htlc_transaction
223233
/// [`HTLCDescriptor::tx_input_witness`]: HTLCDescriptor::tx_input_witness
224234
HTLCResolution {
235+
/// The unique identifier for the claim of the HTLCs in the confirmed commitment
236+
/// transaction.
237+
///
238+
/// Any future instances of `HTLCResolution` bump events that share the same `claim_id` must
239+
/// be considered the same claim, even if the set of HTLCs to claim has changed. Therefore,
240+
/// the identifier serves as a "UTXO lock" for users, as they can assign the additional
241+
/// inputs required for the claim to this identifier to ensure their claims don't double
242+
/// spend and conflict with each other. However, note that in some cases, it may be required
243+
/// to double spend the UTXOs assigned to previous claims in new claims if there aren't any
244+
/// unassigned UTXOs available to use.
245+
claim_id: ClaimId,
225246
/// The target feerate that the resulting HTLC transaction must meet.
226247
target_feerate_sat_per_1000_weight: u32,
227248
/// The set of pending HTLCs on the confirmed commitment that need to be claimed, preferably

lightning/src/ln/monitor_tests.rs

Lines changed: 1 addition & 1 deletion
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)