Skip to content

Commit bd5f608

Browse files
committed
Check all FundingScopes in get_relevant_txids
Pending funding transactions for splices should be monitored for appearance on chain. Include these in ChannelManager::get_relevant_txids so that they can be watched.
1 parent 886c7f1 commit bd5f608

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

lightning/src/ln/channel.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9034,6 +9034,25 @@ impl<SP: Deref> FundedChannel<SP> where
90349034
Ok((None, timed_out_htlcs, announcement_sigs))
90359035
}
90369036

9037+
pub fn get_relevant_txids(&self) -> impl Iterator<Item=(Txid, u32, Option<BlockHash>)> + '_ {
9038+
core::iter::once(&self.funding)
9039+
.chain(self.pending_funding.iter())
9040+
.map(|funding|
9041+
(
9042+
funding.get_funding_txid(),
9043+
funding.get_funding_tx_confirmation_height(),
9044+
funding.funding_tx_confirmed_in,
9045+
)
9046+
)
9047+
.filter_map(|(txid_opt, height_opt, hash_opt)|
9048+
if let (Some(funding_txid), Some(conf_height), Some(block_hash)) = (txid_opt, height_opt, hash_opt) {
9049+
Some((funding_txid, conf_height, Some(block_hash)))
9050+
} else {
9051+
None
9052+
}
9053+
)
9054+
}
9055+
90379056
/// Checks if any funding transaction is no longer confirmed in the main chain. This may
90389057
/// force-close the channel, but may also indicate a harmless reorganization of a block or two
90399058
/// before the channel has reached channel_ready or splice_locked, and we can just wait for more
@@ -10194,11 +10213,6 @@ impl<SP: Deref> FundedChannel<SP> where
1019410213
}
1019510214
}
1019610215

10197-
/// Returns the block hash in which our funding transaction was confirmed.
10198-
pub fn get_funding_tx_confirmed_in(&self) -> Option<BlockHash> {
10199-
self.funding.funding_tx_confirmed_in
10200-
}
10201-
1020210216
pub fn has_pending_splice(&self) -> bool {
1020310217
self.pending_splice.is_some()
1020410218
}

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11940,11 +11940,8 @@ where
1194011940
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
1194111941
let peer_state = &mut *peer_state_lock;
1194211942
for chan in peer_state.channel_by_id.values().filter_map(Channel::as_funded) {
11943-
let txid_opt = chan.funding.get_funding_txo();
11944-
let height_opt = chan.funding.get_funding_tx_confirmation_height();
11945-
let hash_opt = chan.get_funding_tx_confirmed_in();
11946-
if let (Some(funding_txo), Some(conf_height), Some(block_hash)) = (txid_opt, height_opt, hash_opt) {
11947-
res.push((funding_txo.txid, conf_height, Some(block_hash)));
11943+
for (funding_txid, conf_height, block_hash) in chan.get_relevant_txids() {
11944+
res.push((funding_txid, conf_height, block_hash));
1194811945
}
1194911946
}
1195011947
}

0 commit comments

Comments
 (0)