+ /// Gets the set of txids which should be monitored for their confirmation state.
+ ///
+ /// If you're providing information about reorganizations via [`transaction_unconfirmed`], this
+ /// is the set of transactions which you may need to call [`transaction_unconfirmed`] for.
+ ///
+ /// This may be useful to poll to determine the set of transactions which must be registered
+ /// with an Electrum server or for which an Electrum server needs to be polled to determine
+ /// transaction confirmation state.
+ ///
+ /// This may update after any [`transactions_confirmed`] or [`block_connected`] call.
+ ///
+ /// Note that this is NOT the set of transactions which must be included in calls to
+ /// [`transactions_confirmed`] if they are confirmed, but a small subset of it.
+ ///
+ /// [`transactions_confirmed`]: Self::transactions_confirmed
+ /// [`transaction_unconfirmed`]: Self::transaction_unconfirmed
+ /// [`block_connected`]: chain::Listen::block_connected
+ pub fn get_relevant_txids(&self) -> Vec<Txid> {
+ let channel_state = self.channel_state.lock().unwrap();
+ let mut res = Vec::with_capacity(channel_state.short_to_id.len());
+ for chan in channel_state.by_id.values() {
+ if let Some(funding_txo) = chan.get_funding_txo() {
+ res.push(funding_txo.txid);
+ }
+ }
+ res
+ }
+
+ /// Marks a transaction as having been reorganized out of the blockchain.
+ ///
+ /// If a transaction is included in [`get_relevant_txids`], and is no longer in the main branch
+ /// of the blockchain, this function should be called to indicate that the transaction should
+ /// be considered reorganized out.
+ ///
+ /// Once this is called, the given transaction will no longer appear on [`get_relevant_txids`],
+ /// though this may be called repeatedly for a given transaction without issue.
+ ///
+ /// Note that if the transaction is confirmed on the main chain in a different block (indicated
+ /// via a call to [`transactions_confirmed`]), it may re-appear in [`get_relevant_txids`], thus
+ /// be very wary of race-conditions wherein the final state of a transaction indicated via
+ /// these APIs is not the same as its state on the blockchain.
+ ///
+ /// [`transactions_confirmed`]: Self::transactions_confirmed
+ /// [`get_relevant_txids`]: Self::get_relevant_txids
+ pub fn transaction_unconfirmed(&self, txid: &Txid) {
+ let _persistence_guard = PersistenceNotifierGuard::new(&self.total_consistency_lock, &self.persistence_notifier);
+ self.do_chain_event(None, |channel| {
+ if let Some(funding_txo) = channel.get_funding_txo() {
+ if funding_txo.txid == *txid {
+ channel.funding_transaction_unconfirmed().map(|_| (None, Vec::new()))
+ } else { Ok((None, Vec::new())) }
+ } else { Ok((None, Vec::new())) }
+ });
+ }
+