Skip to content

Commit 98e7e35

Browse files
committed
Expose ClaimId for each claim bump in BumpTransactionEvent
1 parent 95b74ab commit 98e7e35

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

lightning/src/chain/channelmonitor.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2502,7 +2502,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
25022502
let mut ret = Vec::new();
25032503
mem::swap(&mut ret, &mut self.pending_events);
25042504
#[cfg(anchors)]
2505-
for claim_event in self.onchain_tx_handler.get_and_clear_pending_claim_events().drain(..) {
2505+
for (claim_id, claim_event) in self.onchain_tx_handler.get_and_clear_pending_claim_events().drain(..) {
25062506
match claim_event {
25072507
ClaimEvent::BumpCommitment {
25082508
package_target_feerate_sat_per_1000_weight, commitment_tx, anchor_output_idx,
@@ -2513,6 +2513,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
25132513
let commitment_tx_fee_satoshis = self.channel_value_satoshis -
25142514
commitment_tx.output.iter().fold(0u64, |sum, output| sum + output.value);
25152515
ret.push(Event::BumpTransaction(BumpTransactionEvent::ChannelClose {
2516+
claim_id,
25162517
package_target_feerate_sat_per_1000_weight,
25172518
commitment_tx,
25182519
commitment_tx_fee_satoshis,
@@ -2544,6 +2545,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
25442545
});
25452546
}
25462547
ret.push(Event::BumpTransaction(BumpTransactionEvent::HTLCResolution {
2548+
claim_id,
25472549
target_feerate_sat_per_1000_weight,
25482550
htlc_descriptors,
25492551
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.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

+21
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 idenfier serves as a "UTXO lock" for users, as they can assign the additional inputs
241+
/// required for the claim to this identifier to ensure their claims don't double spend and
242+
/// conflict with each other. However, note that in some cases, it may be required to double
243+
/// spend the UTXOs assigned to previous claims in new claims if there aren't any unassigned
244+
/// 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

+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)