Skip to content

Commit c57bf73

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 65e588f commit c57bf73

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
@@ -1385,6 +1385,19 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
13851385
self.inner.lock().unwrap().update_best_block(
13861386
header, height, broadcaster, fee_estimator, logger)
13871387
}
1388+
1389+
/// Returns the set of txids that should be monitored for re-organization out of the chain.
1390+
pub fn get_relevant_txids(&self) -> Vec<Txid> {
1391+
let inner = self.inner.lock().unwrap();
1392+
let mut txids: Vec<Txid> = inner.onchain_events_waiting_threshold_conf
1393+
.iter()
1394+
.map(|entry| entry.txid)
1395+
.chain(inner.onchain_tx_handler.get_relevant_txids().into_iter())
1396+
.collect();
1397+
txids.sort_unstable();
1398+
txids.dedup();
1399+
txids
1400+
}
13881401
}
13891402

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