Skip to content

Commit cc43f9c

Browse files
authored
Merge pull request #2864 from dunxen/2024-01-2797followups
Fix followups to PR2797
2 parents 5bf58f0 + 361079d commit cc43f9c

File tree

3 files changed

+14
-28
lines changed

3 files changed

+14
-28
lines changed

lightning/src/ln/channelmanager.rs

+13-17
Original file line numberDiff line numberDiff line change
@@ -1636,9 +1636,6 @@ pub struct ChannelDetails {
16361636
pub counterparty: ChannelCounterparty,
16371637
/// The Channel's funding transaction output, if we've negotiated the funding transaction with
16381638
/// our counterparty already.
1639-
///
1640-
/// Note that, if this has been set, `channel_id` for V1-established channels will be equivalent to
1641-
/// `ChannelId::v1_from_funding_outpoint(funding_txo.unwrap())`.
16421639
pub funding_txo: Option<OutPoint>,
16431640
/// The features which this channel operates with. See individual features for more info.
16441641
///
@@ -2296,7 +2293,7 @@ macro_rules! handle_new_monitor_update {
22962293
handle_new_monitor_update!($self, $update_res, $chan, _internal,
22972294
handle_monitor_update_completion!($self, $peer_state_lock, $peer_state, $per_peer_state_lock, $chan))
22982295
};
2299-
($self: ident, $funding_txo: expr, $channel_id: expr, $update: expr, $peer_state_lock: expr, $peer_state: expr, $per_peer_state_lock: expr, $chan: expr) => { {
2296+
($self: ident, $funding_txo: expr, $update: expr, $peer_state_lock: expr, $peer_state: expr, $per_peer_state_lock: expr, $chan: expr) => { {
23002297
let in_flight_updates = $peer_state.in_flight_monitor_updates.entry($funding_txo)
23012298
.or_insert_with(Vec::new);
23022299
// During startup, we push monitor updates as background events through to here in
@@ -2753,7 +2750,7 @@ where
27532750

27542751
// Update the monitor with the shutdown script if necessary.
27552752
if let Some(monitor_update) = monitor_update_opt.take() {
2756-
handle_new_monitor_update!(self, funding_txo_opt.unwrap(), *channel_id, monitor_update,
2753+
handle_new_monitor_update!(self, funding_txo_opt.unwrap(), monitor_update,
27572754
peer_state_lock, peer_state, per_peer_state, chan);
27582755
}
27592756
} else {
@@ -3414,7 +3411,7 @@ where
34143411
}, onion_packet, None, &self.fee_estimator, &&logger);
34153412
match break_chan_phase_entry!(self, send_res, chan_phase_entry) {
34163413
Some(monitor_update) => {
3417-
match handle_new_monitor_update!(self, funding_txo, channel_id, monitor_update, peer_state_lock, peer_state, per_peer_state, chan) {
3414+
match handle_new_monitor_update!(self, funding_txo, monitor_update, peer_state_lock, peer_state, per_peer_state, chan) {
34183415
false => {
34193416
// Note that MonitorUpdateInProgress here indicates (per function
34203417
// docs) that we will resend the commitment update once monitor
@@ -4770,7 +4767,7 @@ where
47704767
hash_map::Entry::Occupied(mut chan_phase) => {
47714768
if let ChannelPhase::Funded(chan) = chan_phase.get_mut() {
47724769
updated_chan = true;
4773-
handle_new_monitor_update!(self, funding_txo, channel_id, update.clone(),
4770+
handle_new_monitor_update!(self, funding_txo, update.clone(),
47744771
peer_state_lock, peer_state, per_peer_state, chan);
47754772
} else {
47764773
debug_assert!(false, "We shouldn't have an update for a non-funded channel");
@@ -5574,7 +5571,7 @@ where
55745571
peer_state.monitor_update_blocked_actions.entry(chan_id).or_insert(Vec::new()).push(action);
55755572
}
55765573
if !during_init {
5577-
handle_new_monitor_update!(self, prev_hop.outpoint, prev_hop.channel_id, monitor_update, peer_state_lock,
5574+
handle_new_monitor_update!(self, prev_hop.outpoint, monitor_update, peer_state_lock,
55785575
peer_state, per_peer_state, chan);
55795576
} else {
55805577
// If we're running during init we cannot update a monitor directly -
@@ -6570,7 +6567,7 @@ where
65706567
}
65716568
// Update the monitor with the shutdown script if necessary.
65726569
if let Some(monitor_update) = monitor_update_opt {
6573-
handle_new_monitor_update!(self, funding_txo_opt.unwrap(), chan.context.channel_id(), monitor_update,
6570+
handle_new_monitor_update!(self, funding_txo_opt.unwrap(), monitor_update,
65746571
peer_state_lock, peer_state, per_peer_state, chan);
65756572
}
65766573
},
@@ -6852,7 +6849,7 @@ where
68526849
let funding_txo = chan.context.get_funding_txo();
68536850
let monitor_update_opt = try_chan_phase_entry!(self, chan.commitment_signed(&msg, &&logger), chan_phase_entry);
68546851
if let Some(monitor_update) = monitor_update_opt {
6855-
handle_new_monitor_update!(self, funding_txo.unwrap(), chan.context.channel_id(), monitor_update, peer_state_lock,
6852+
handle_new_monitor_update!(self, funding_txo.unwrap(), monitor_update, peer_state_lock,
68566853
peer_state, per_peer_state, chan);
68576854
}
68586855
Ok(())
@@ -7031,7 +7028,7 @@ where
70317028
if let Some(monitor_update) = monitor_update_opt {
70327029
let funding_txo = funding_txo_opt
70337030
.expect("Funding outpoint must have been set for RAA handling to succeed");
7034-
handle_new_monitor_update!(self, funding_txo, chan.context.channel_id(), monitor_update,
7031+
handle_new_monitor_update!(self, funding_txo, monitor_update,
70357032
peer_state_lock, peer_state, per_peer_state, chan);
70367033
}
70377034
htlcs_to_fail
@@ -7372,7 +7369,7 @@ where
73727369
if let Some(monitor_update) = monitor_opt {
73737370
has_monitor_update = true;
73747371

7375-
handle_new_monitor_update!(self, funding_txo.unwrap(), chan.context.channel_id(), monitor_update,
7372+
handle_new_monitor_update!(self, funding_txo.unwrap(), monitor_update,
73767373
peer_state_lock, peer_state, per_peer_state, chan);
73777374
continue 'peer_loop;
73787375
}
@@ -8141,7 +8138,7 @@ where
81418138
if let Some((monitor_update, further_update_exists)) = chan.unblock_next_blocked_monitor_update() {
81428139
log_debug!(logger, "Unlocking monitor updating for channel {} and updating monitor",
81438140
channel_id);
8144-
handle_new_monitor_update!(self, channel_funding_outpoint, channel_id, monitor_update,
8141+
handle_new_monitor_update!(self, channel_funding_outpoint, monitor_update,
81458142
peer_state_lck, peer_state, per_peer_state, chan);
81468143
if further_update_exists {
81478144
// If there are more `ChannelMonitorUpdate`s to process, restart at the
@@ -9816,7 +9813,7 @@ impl_writeable_tlv_based!(PendingAddHTLCInfo, {
98169813
(2, prev_short_channel_id, required),
98179814
(4, prev_htlc_id, required),
98189815
(6, prev_funding_outpoint, required),
9819-
// Note that by the time we get past the required read for type 2 above, prev_funding_outpoint will be
9816+
// Note that by the time we get past the required read for type 6 above, prev_funding_outpoint will be
98209817
// filled in, so we can safely unwrap it here.
98219818
(7, prev_channel_id, (default_value, ChannelId::v1_from_funding_outpoint(prev_funding_outpoint.0.unwrap()))),
98229819
});
@@ -11079,12 +11076,11 @@ where
1107911076
Some((blocked_node_id, _blocked_channel_outpoint, blocked_channel_id, blocking_action)), ..
1108011077
} = action {
1108111078
if let Some(blocked_peer_state) = per_peer_state.get(&blocked_node_id) {
11082-
let channel_id = blocked_channel_id;
1108311079
log_trace!(logger,
1108411080
"Holding the next revoke_and_ack from {} until the preimage is durably persisted in the inbound edge's ChannelMonitor",
11085-
channel_id);
11081+
blocked_channel_id);
1108611082
blocked_peer_state.lock().unwrap().actions_blocking_raa_monitor_updates
11087-
.entry(*channel_id)
11083+
.entry(*blocked_channel_id)
1108811084
.or_insert_with(Vec::new).push(blocking_action.clone());
1108911085
} else {
1109011086
// If the channel we were blocking has closed, we don't need to

lightning/src/ln/peer_handler.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use crate::ln::ChannelId;
2424
use crate::ln::features::{InitFeatures, NodeFeatures};
2525
use crate::ln::msgs;
2626
use crate::ln::msgs::{ChannelMessageHandler, LightningError, SocketAddress, OnionMessageHandler, RoutingMessageHandler};
27-
use crate::util::macro_logger::DebugFundingChannelId;
2827
use crate::util::ser::{VecWriter, Writeable, Writer};
2928
use crate::ln::peer_channel_encryptor::{PeerChannelEncryptor, NextNoiseStep, MessageBuf, MSG_BUF_ALLOC_SIZE};
3029
use crate::ln::wire;
@@ -2007,7 +2006,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
20072006
log_debug!(WithContext::from(&self.logger, Some(*node_id), Some(msg.temporary_channel_id)), "Handling SendFundingCreated event in peer_handler for node {} for channel {} (which becomes {})",
20082007
log_pubkey!(node_id),
20092008
&msg.temporary_channel_id,
2010-
DebugFundingChannelId(&msg.funding_txid, msg.funding_output_index));
2009+
ChannelId::v1_from_funding_txid(msg.funding_txid.as_byte_array(), msg.funding_output_index));
20112010
// TODO: If the peer is gone we should generate a DiscardFunding event
20122011
// indicating to the wallet that they should just throw away this funding transaction
20132012
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);

lightning/src/util/macro_logger.rs

-9
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
// You may not use this file except in accordance with one or both of these
88
// licenses.
99

10-
use crate::chain::transaction::OutPoint;
1110
use crate::ln::ChannelId;
1211
use crate::sign::SpendableOutputDescriptor;
1312

14-
use bitcoin::hash_types::Txid;
1513
use bitcoin::blockdata::transaction::Transaction;
1614

1715
use crate::routing::router::Route;
@@ -39,13 +37,6 @@ macro_rules! log_bytes {
3937
}
4038
}
4139

42-
pub(crate) struct DebugFundingChannelId<'a>(pub &'a Txid, pub u16);
43-
impl<'a> core::fmt::Display for DebugFundingChannelId<'a> {
44-
fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
45-
ChannelId::v1_from_funding_outpoint(OutPoint { txid: self.0.clone(), index: self.1 }).fmt(f)
46-
}
47-
}
48-
4940
pub(crate) struct DebugFundingInfo<'a>(pub &'a ChannelId);
5041
impl<'a> core::fmt::Display for DebugFundingInfo<'a> {
5142
fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {

0 commit comments

Comments
 (0)