Skip to content

Commit aee1f74

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 b03fca0 commit aee1f74

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
@@ -1388,6 +1388,19 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
13881388
self.inner.lock().unwrap().update_best_block(
13891389
header, height, broadcaster, fee_estimator, logger)
13901390
}
1391+
1392+
/// Returns the set of txids that should be monitored for their confirmation state.
1393+
pub fn get_relevant_txids(&self) -> Vec<Txid> {
1394+
let inner = self.inner.lock().unwrap();
1395+
let mut txids: Vec<Txid> = inner.onchain_events_waiting_threshold_conf
1396+
.iter()
1397+
.map(|entry| entry.txid)
1398+
.chain(inner.onchain_tx_handler.get_relevant_txids().into_iter())
1399+
.collect();
1400+
txids.sort_unstable();
1401+
txids.dedup();
1402+
txids
1403+
}
13911404
}
13921405

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