Skip to content

Commit 476bb09

Browse files
committed
Add ChannelMonitor::get_relevant_txids
Define an Electrum-friendly interface for ChannelMonitor where txids of relevant transactions can be obtained. For any of these transactions that are re-orged out of the chain, users must call transaction_unconfirmed.
1 parent 2d4a34e commit 476bb09

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,19 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
13861386
self.inner.lock().unwrap().update_best_block(
13871387
header, height, broadcaster, fee_estimator, logger)
13881388
}
1389+
1390+
/// Returns the set of txids that should be monitored for their confirmation state.
1391+
pub fn get_relevant_txids(&self) -> Vec<Txid> {
1392+
let inner = self.inner.lock().unwrap();
1393+
let mut txids: Vec<Txid> = inner.onchain_events_waiting_threshold_conf
1394+
.iter()
1395+
.map(|entry| entry.txid)
1396+
.chain(inner.onchain_tx_handler.get_relevant_txids().into_iter())
1397+
.collect();
1398+
txids.sort_unstable();
1399+
txids.dedup();
1400+
txids
1401+
}
13891402
}
13901403

13911404
impl<Signer: Sign> ChannelMonitorImpl<Signer> {

lightning/src/ln/onchaintx.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,16 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
945945
}
946946
}
947947

948+
pub(crate) fn get_relevant_txids(&self) -> Vec<Txid> {
949+
let mut txids: Vec<Txid> = self.onchain_events_waiting_threshold_conf
950+
.iter()
951+
.map(|entry| entry.txid)
952+
.collect();
953+
txids.sort_unstable();
954+
txids.dedup();
955+
txids
956+
}
957+
948958
pub(crate) fn provide_latest_holder_tx(&mut self, tx: HolderCommitmentTransaction) {
949959
self.prev_holder_commitment = Some(replace(&mut self.holder_commitment, tx));
950960
self.holder_htlc_sigs = None;

0 commit comments

Comments
 (0)