Skip to content

Commit 369faca

Browse files
committed
Track block hash, return via get_relevant_txids
Previously, `Confirm::get_relevant_txids()` only returned a list of transactions that have to be monitored for reorganization out of the chain. This interface however required double bookkeeping: while we internally keep track of the best block, height, etc, it would also require the user to keep track which transaction was previously confirmed in which block and to take actions based on any change, e.g, to reconfirm them when the block would be reorged-out and the transactions had been reconfirmed in another block. Here, we track the confirmation block hash internally and return it via `Confirm::get_relevant_txids()` to the user, which alleviates the requirement for double bookkeeping: the user can now simply check whether the given transaction is still confirmed and in the given block, and take action if not.
1 parent e55e0d5 commit 369faca

File tree

7 files changed

+85
-43
lines changed

7 files changed

+85
-43
lines changed

lightning/src/chain/chainmonitor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
//! servicing [`ChannelMonitor`] updates from the client.
2525
2626
use bitcoin::blockdata::block::BlockHeader;
27-
use bitcoin::hash_types::Txid;
27+
use bitcoin::hash_types::{Txid, BlockHash};
2828

2929
use crate::chain;
3030
use crate::chain::{ChannelMonitorUpdateStatus, Filter, WatchedOutput};
@@ -544,7 +544,7 @@ where
544544
});
545545
}
546546

547-
fn get_relevant_txids(&self) -> Vec<Txid> {
547+
fn get_relevant_txids(&self) -> Vec<(Txid, Option<BlockHash>)> {
548548
let mut txids = Vec::new();
549549
let monitor_states = self.monitors.read().unwrap();
550550
for monitor_state in monitor_states.values() {

lightning/src/chain/channelmonitor.rs

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,15 @@ impl Readable for CounterpartyCommitmentParameters {
332332
}
333333
}
334334

335-
/// An entry for an [`OnchainEvent`], stating the block height when the event was observed and the
336-
/// transaction causing it.
335+
/// An entry for an [`OnchainEvent`], stating the block height and hash when the event was
336+
/// observed, as well as the transaction causing it.
337337
///
338338
/// Used to determine when the on-chain event can be considered safe from a chain reorganization.
339339
#[derive(PartialEq, Eq)]
340340
struct OnchainEventEntry {
341341
txid: Txid,
342342
height: u32,
343+
block_hash: Option<BlockHash>, // Added as optional, will be filled in for any entry generated on 0.0.113 or after
343344
event: OnchainEvent,
344345
transaction: Option<Transaction>, // Added as optional, but always filled in, in LDK 0.0.110
345346
}
@@ -440,6 +441,7 @@ impl Writeable for OnchainEventEntry {
440441
(0, self.txid, required),
441442
(1, self.transaction, option),
442443
(2, self.height, required),
444+
(3, self.block_hash, option),
443445
(4, self.event, required),
444446
});
445447
Ok(())
@@ -450,16 +452,18 @@ impl MaybeReadable for OnchainEventEntry {
450452
fn read<R: io::Read>(reader: &mut R) -> Result<Option<Self>, DecodeError> {
451453
let mut txid = Txid::all_zeros();
452454
let mut transaction = None;
455+
let mut block_hash = None;
453456
let mut height = 0;
454457
let mut event = None;
455458
read_tlv_fields!(reader, {
456459
(0, txid, required),
457460
(1, transaction, option),
458461
(2, height, required),
462+
(3, block_hash, option),
459463
(4, event, ignorable),
460464
});
461465
if let Some(ev) = event {
462-
Ok(Some(Self { txid, transaction, height, event: ev }))
466+
Ok(Some(Self { txid, transaction, height, block_hash, event: ev }))
463467
} else {
464468
Ok(None)
465469
}
@@ -1482,11 +1486,11 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
14821486
}
14831487

14841488
/// Returns the set of txids that should be monitored for re-organization out of the chain.
1485-
pub fn get_relevant_txids(&self) -> Vec<Txid> {
1489+
pub fn get_relevant_txids(&self) -> Vec<(Txid, Option<BlockHash>)> {
14861490
let inner = self.inner.lock().unwrap();
1487-
let mut txids: Vec<Txid> = inner.onchain_events_awaiting_threshold_conf
1491+
let mut txids: Vec<(Txid, Option<BlockHash>)> = inner.onchain_events_awaiting_threshold_conf
14881492
.iter()
1489-
.map(|entry| entry.txid)
1493+
.map(|entry| (entry.txid, entry.block_hash))
14901494
.chain(inner.onchain_tx_handler.get_relevant_txids().into_iter())
14911495
.collect();
14921496
txids.sort_unstable();
@@ -1939,7 +1943,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
19391943
/// been revoked yet, the previous one, we we will never "forget" to resolve an HTLC.
19401944
macro_rules! fail_unbroadcast_htlcs {
19411945
($self: expr, $commitment_tx_type: expr, $commitment_txid_confirmed: expr, $commitment_tx_confirmed: expr,
1942-
$commitment_tx_conf_height: expr, $confirmed_htlcs_list: expr, $logger: expr) => { {
1946+
$commitment_tx_conf_height: expr, $commitment_tx_conf_hash: expr, $confirmed_htlcs_list: expr, $logger: expr) => { {
19431947
debug_assert_eq!($commitment_tx_confirmed.txid(), $commitment_txid_confirmed);
19441948

19451949
macro_rules! check_htlc_fails {
@@ -1983,6 +1987,7 @@ macro_rules! fail_unbroadcast_htlcs {
19831987
txid: $commitment_txid_confirmed,
19841988
transaction: Some($commitment_tx_confirmed.clone()),
19851989
height: $commitment_tx_conf_height,
1990+
block_hash: Some(*$commitment_tx_conf_hash),
19861991
event: OnchainEvent::HTLCUpdate {
19871992
source: (**source).clone(),
19881993
payment_hash: htlc.payment_hash.clone(),
@@ -2401,7 +2406,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
24012406
/// Returns packages to claim the revoked output(s), as well as additional outputs to watch and
24022407
/// general information about the output that is to the counterparty in the commitment
24032408
/// transaction.
2404-
fn check_spend_counterparty_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L)
2409+
fn check_spend_counterparty_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, block_hash: &BlockHash, logger: &L)
24052410
-> (Vec<PackageTemplate>, TransactionOutputs, CommitmentTxCounterpartyOutputInfo)
24062411
where L::Target: Logger {
24072412
// Most secp and related errors trying to create keys means we have no hope of constructing
@@ -2472,13 +2477,13 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
24722477

24732478
if let Some(per_commitment_data) = per_commitment_option {
24742479
fail_unbroadcast_htlcs!(self, "revoked_counterparty", commitment_txid, tx, height,
2475-
per_commitment_data.iter().map(|(htlc, htlc_source)|
2480+
block_hash, per_commitment_data.iter().map(|(htlc, htlc_source)|
24762481
(htlc, htlc_source.as_ref().map(|htlc_source| htlc_source.as_ref()))
24772482
), logger);
24782483
} else {
24792484
debug_assert!(false, "We should have per-commitment option for any recognized old commitment txn");
24802485
fail_unbroadcast_htlcs!(self, "revoked counterparty", commitment_txid, tx, height,
2481-
[].iter().map(|reference| *reference), logger);
2486+
block_hash, [].iter().map(|reference| *reference), logger);
24822487
}
24832488
}
24842489
} else if let Some(per_commitment_data) = per_commitment_option {
@@ -2495,7 +2500,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
24952500
self.counterparty_commitment_txn_on_chain.insert(commitment_txid, commitment_number);
24962501

24972502
log_info!(logger, "Got broadcast of non-revoked counterparty commitment transaction {}", commitment_txid);
2498-
fail_unbroadcast_htlcs!(self, "counterparty", commitment_txid, tx, height,
2503+
fail_unbroadcast_htlcs!(self, "counterparty", commitment_txid, tx, height, block_hash,
24992504
per_commitment_data.iter().map(|(htlc, htlc_source)|
25002505
(htlc, htlc_source.as_ref().map(|htlc_source| htlc_source.as_ref()))
25012506
), logger);
@@ -2631,7 +2636,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
26312636
(claimable_outpoints, Some((htlc_txid, outputs)))
26322637
}
26332638

2634-
// Returns (1) `PackageTemplate`s that can be given to the OnChainTxHandler, so that the handler can
2639+
// Returns (1) `PackageTemplate`s that can be given to the OnchainTxHandler, so that the handler can
26352640
// broadcast transactions claiming holder HTLC commitment outputs and (2) a holder revokable
26362641
// script so we can detect whether a holder transaction has been seen on-chain.
26372642
fn get_broadcasted_holder_claims(&self, holder_tx: &HolderSignedTx, conf_height: u32) -> (Vec<PackageTemplate>, Option<(Script, PublicKey, PublicKey)>) {
@@ -2676,7 +2681,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
26762681
/// revoked using data in holder_claimable_outpoints.
26772682
/// Should not be used if check_spend_revoked_transaction succeeds.
26782683
/// Returns None unless the transaction is definitely one of our commitment transactions.
2679-
fn check_spend_holder_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L) -> Option<(Vec<PackageTemplate>, TransactionOutputs)> where L::Target: Logger {
2684+
fn check_spend_holder_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, block_hash: &BlockHash, logger: &L) -> Option<(Vec<PackageTemplate>, TransactionOutputs)> where L::Target: Logger {
26802685
let commitment_txid = tx.txid();
26812686
let mut claim_requests = Vec::new();
26822687
let mut watch_outputs = Vec::new();
@@ -2699,7 +2704,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
26992704
let mut to_watch = self.get_broadcasted_holder_watch_outputs(&self.current_holder_commitment_tx, tx);
27002705
append_onchain_update!(res, to_watch);
27012706
fail_unbroadcast_htlcs!(self, "latest holder", commitment_txid, tx, height,
2702-
self.current_holder_commitment_tx.htlc_outputs.iter()
2707+
block_hash, self.current_holder_commitment_tx.htlc_outputs.iter()
27032708
.map(|(htlc, _, htlc_source)| (htlc, htlc_source.as_ref())), logger);
27042709
} else if let &Some(ref holder_tx) = &self.prev_holder_signed_commitment_tx {
27052710
if holder_tx.txid == commitment_txid {
@@ -2708,7 +2713,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
27082713
let res = self.get_broadcasted_holder_claims(holder_tx, height);
27092714
let mut to_watch = self.get_broadcasted_holder_watch_outputs(holder_tx, tx);
27102715
append_onchain_update!(res, to_watch);
2711-
fail_unbroadcast_htlcs!(self, "previous holder", commitment_txid, tx, height,
2716+
fail_unbroadcast_htlcs!(self, "previous holder", commitment_txid, tx, height, block_hash,
27122717
holder_tx.htlc_outputs.iter().map(|(htlc, _, htlc_source)| (htlc, htlc_source.as_ref())),
27132718
logger);
27142719
}
@@ -2816,7 +2821,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
28162821

28172822
if height > self.best_block.height() {
28182823
self.best_block = BestBlock::new(block_hash, height);
2819-
self.block_confirmed(height, vec![], vec![], vec![], &broadcaster, &fee_estimator, &logger)
2824+
self.block_confirmed(height, block_hash, vec![], vec![], vec![], &broadcaster, &fee_estimator, &logger)
28202825
} else if block_hash != self.best_block.block_hash() {
28212826
self.best_block = BestBlock::new(block_hash, height);
28222827
self.onchain_events_awaiting_threshold_conf.retain(|ref entry| entry.height <= height);
@@ -2868,14 +2873,14 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
28682873
let mut commitment_tx_to_counterparty_output = None;
28692874
if (tx.input[0].sequence.0 >> 8*3) as u8 == 0x80 && (tx.lock_time.0 >> 8*3) as u8 == 0x20 {
28702875
let (mut new_outpoints, new_outputs, counterparty_output_idx_sats) =
2871-
self.check_spend_counterparty_transaction(&tx, height, &logger);
2876+
self.check_spend_counterparty_transaction(&tx, height, &block_hash, &logger);
28722877
commitment_tx_to_counterparty_output = counterparty_output_idx_sats;
28732878
if !new_outputs.1.is_empty() {
28742879
watch_outputs.push(new_outputs);
28752880
}
28762881
claimable_outpoints.append(&mut new_outpoints);
28772882
if new_outpoints.is_empty() {
2878-
if let Some((mut new_outpoints, new_outputs)) = self.check_spend_holder_transaction(&tx, height, &logger) {
2883+
if let Some((mut new_outpoints, new_outputs)) = self.check_spend_holder_transaction(&tx, height, &block_hash, &logger) {
28792884
debug_assert!(commitment_tx_to_counterparty_output.is_none(),
28802885
"A commitment transaction matched as both a counterparty and local commitment tx?");
28812886
if !new_outputs.1.is_empty() {
@@ -2891,6 +2896,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
28912896
txid,
28922897
transaction: Some((*tx).clone()),
28932898
height,
2899+
block_hash: Some(block_hash),
28942900
event: OnchainEvent::FundingSpendConfirmation {
28952901
on_local_output_csv: balance_spendable_csv,
28962902
commitment_tx_to_counterparty_output,
@@ -2909,16 +2915,16 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
29092915
// While all commitment/HTLC-Success/HTLC-Timeout transactions have one input, HTLCs
29102916
// can also be resolved in a few other ways which can have more than one output. Thus,
29112917
// we call is_resolving_htlc_output here outside of the tx.input.len() == 1 check.
2912-
self.is_resolving_htlc_output(&tx, height, &logger);
2918+
self.is_resolving_htlc_output(&tx, height, &block_hash, &logger);
29132919

2914-
self.is_paying_spendable_output(&tx, height, &logger);
2920+
self.is_paying_spendable_output(&tx, height, &block_hash, &logger);
29152921
}
29162922

29172923
if height > self.best_block.height() {
29182924
self.best_block = BestBlock::new(block_hash, height);
29192925
}
29202926

2921-
self.block_confirmed(height, txn_matched, watch_outputs, claimable_outpoints, &broadcaster, &fee_estimator, &logger)
2927+
self.block_confirmed(height, block_hash, txn_matched, watch_outputs, claimable_outpoints, &broadcaster, &fee_estimator, &logger)
29222928
}
29232929

29242930
/// Update state for new block(s)/transaction(s) confirmed. Note that the caller must update
@@ -2931,6 +2937,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
29312937
fn block_confirmed<B: Deref, F: Deref, L: Deref>(
29322938
&mut self,
29332939
conf_height: u32,
2940+
conf_hash: BlockHash,
29342941
txn_matched: Vec<&Transaction>,
29352942
mut watch_outputs: Vec<TransactionOutputs>,
29362943
mut claimable_outpoints: Vec<PackageTemplate>,
@@ -3235,7 +3242,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
32353242

32363243
/// Check if any transaction broadcasted is resolving HTLC output by a success or timeout on a holder
32373244
/// or counterparty commitment tx, if so send back the source, preimage if found and payment_hash of resolved HTLC
3238-
fn is_resolving_htlc_output<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L) where L::Target: Logger {
3245+
fn is_resolving_htlc_output<L: Deref>(&mut self, tx: &Transaction, height: u32, block_hash: &BlockHash, logger: &L) where L::Target: Logger {
32393246
'outer_loop: for input in &tx.input {
32403247
let mut payment_data = None;
32413248
let htlc_claim = HTLCClaim::from_witness(&input.witness);
@@ -3320,7 +3327,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
33203327
log_claim!($tx_info, $holder_tx, htlc_output, false);
33213328
let outbound_htlc = $holder_tx == htlc_output.offered;
33223329
self.onchain_events_awaiting_threshold_conf.push(OnchainEventEntry {
3323-
txid: tx.txid(), height, transaction: Some(tx.clone()),
3330+
txid: tx.txid(), height, block_hash: Some(*block_hash), transaction: Some(tx.clone()),
33243331
event: OnchainEvent::HTLCSpendConfirmation {
33253332
commitment_tx_output_idx: input.previous_output.vout,
33263333
preimage: if accepted_preimage_claim || offered_preimage_claim {
@@ -3364,6 +3371,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
33643371
self.onchain_events_awaiting_threshold_conf.push(OnchainEventEntry {
33653372
txid: tx.txid(),
33663373
height,
3374+
block_hash: Some(*block_hash),
33673375
transaction: Some(tx.clone()),
33683376
event: OnchainEvent::HTLCSpendConfirmation {
33693377
commitment_tx_output_idx: input.previous_output.vout,
@@ -3387,6 +3395,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
33873395
txid: tx.txid(),
33883396
transaction: Some(tx.clone()),
33893397
height,
3398+
block_hash: Some(*block_hash),
33903399
event: OnchainEvent::HTLCSpendConfirmation {
33913400
commitment_tx_output_idx: input.previous_output.vout,
33923401
preimage: Some(payment_preimage),
@@ -3414,6 +3423,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
34143423
txid: tx.txid(),
34153424
transaction: Some(tx.clone()),
34163425
height,
3426+
block_hash: Some(*block_hash),
34173427
event: OnchainEvent::HTLCUpdate {
34183428
source, payment_hash,
34193429
htlc_value_satoshis: Some(amount_msat / 1000),
@@ -3428,7 +3438,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
34283438
}
34293439

34303440
/// Check if any transaction broadcasted is paying fund back to some address we can assume to own
3431-
fn is_paying_spendable_output<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L) where L::Target: Logger {
3441+
fn is_paying_spendable_output<L: Deref>(&mut self, tx: &Transaction, height: u32, block_hash: &BlockHash, logger: &L) where L::Target: Logger {
34323442
let mut spendable_output = None;
34333443
for (i, outp) in tx.output.iter().enumerate() { // There is max one spendable output for any channel tx, including ones generated by us
34343444
if i > ::core::u16::MAX as usize {
@@ -3488,6 +3498,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
34883498
txid: tx.txid(),
34893499
transaction: Some(tx.clone()),
34903500
height,
3501+
block_hash: Some(*block_hash),
34913502
event: OnchainEvent::MaturingOutput { descriptor: spendable_output.clone() },
34923503
};
34933504
log_info!(logger, "Received spendable output {}, spendable at height {}", log_spendable!(spendable_output), entry.confirmation_threshold());
@@ -3529,7 +3540,7 @@ where
35293540
self.0.best_block_updated(header, height, &*self.1, &*self.2, &*self.3);
35303541
}
35313542

3532-
fn get_relevant_txids(&self) -> Vec<Txid> {
3543+
fn get_relevant_txids(&self) -> Vec<(Txid, Option<BlockHash>)> {
35333544
self.0.get_relevant_txids()
35343545
}
35353546
}

lightning/src/chain/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ pub trait Confirm {
171171
/// if they become available at the same time.
172172
fn best_block_updated(&self, header: &BlockHeader, height: u32);
173173

174-
/// Returns transactions that should be monitored for reorganization out of the chain.
174+
/// Returns transactions that should be monitored for reorganization out of the chain along
175+
/// with the hash of the block as part of which had been previously confirmed.
175176
///
176177
/// Will include any transactions passed to [`transactions_confirmed`] that have insufficient
177178
/// confirmations to be safe from a chain reorganization. Will not include any transactions
@@ -180,11 +181,13 @@ pub trait Confirm {
180181
/// May be called to determine the subset of transactions that must still be monitored for
181182
/// reorganization. Will be idempotent between calls but may change as a result of calls to the
182183
/// other interface methods. Thus, this is useful to determine which transactions may need to be
183-
/// given to [`transaction_unconfirmed`].
184+
/// given to [`transaction_unconfirmed`]. If any of the returned transactions are confirmed in
185+
/// a block other than the one with the given hash, they need to be unconfirmed and reconfirmed
186+
/// via [`transaction_unconfirmed`] and [`transactions_confirmed`], respectively.
184187
///
185188
/// [`transactions_confirmed`]: Self::transactions_confirmed
186189
/// [`transaction_unconfirmed`]: Self::transaction_unconfirmed
187-
fn get_relevant_txids(&self) -> Vec<Txid>;
190+
fn get_relevant_txids(&self) -> Vec<(Txid, Option<BlockHash>)>;
188191
}
189192

190193
/// An enum representing the status of a channel monitor update persistence.

lightning/src/chain/onchaintx.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use bitcoin::blockdata::transaction::Transaction;
1616
use bitcoin::blockdata::transaction::OutPoint as BitcoinOutPoint;
1717
use bitcoin::blockdata::script::Script;
1818

19-
use bitcoin::hash_types::Txid;
19+
use bitcoin::hash_types::{Txid, BlockHash};
2020

2121
use bitcoin::secp256k1::{Secp256k1, ecdsa::Signature};
2222
use bitcoin::secp256k1;
@@ -58,6 +58,7 @@ const MAX_ALLOC_SIZE: usize = 64*1024;
5858
struct OnchainEventEntry {
5959
txid: Txid,
6060
height: u32,
61+
block_hash: Option<BlockHash>, // Added as optional, will be filled in for any entry generated on 0.0.113 or after
6162
event: OnchainEvent,
6263
}
6364

@@ -92,6 +93,7 @@ impl Writeable for OnchainEventEntry {
9293
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
9394
write_tlv_fields!(writer, {
9495
(0, self.txid, required),
96+
(1, self.block_hash, option),
9597
(2, self.height, required),
9698
(4, self.event, required),
9799
});
@@ -103,14 +105,16 @@ impl MaybeReadable for OnchainEventEntry {
103105
fn read<R: io::Read>(reader: &mut R) -> Result<Option<Self>, DecodeError> {
104106
let mut txid = Txid::all_zeros();
105107
let mut height = 0;
108+
let mut block_hash = None;
106109
let mut event = None;
107110
read_tlv_fields!(reader, {
108111
(0, txid, required),
112+
(1, block_hash, option),
109113
(2, height, required),
110114
(4, event, ignorable),
111115
});
112116
if let Some(ev) = event {
113-
Ok(Some(Self { txid, height, event: ev }))
117+
Ok(Some(Self { txid, height, block_hash, event: ev }))
114118
} else {
115119
Ok(None)
116120
}
@@ -860,12 +864,12 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
860864
self.claimable_outpoints.get(outpoint).is_some()
861865
}
862866

863-
pub(crate) fn get_relevant_txids(&self) -> Vec<Txid> {
864-
let mut txids: Vec<Txid> = self.onchain_events_awaiting_threshold_conf
867+
pub(crate) fn get_relevant_txids(&self) -> Vec<(Txid, Option<BlockHash>)> {
868+
let mut txids: Vec<(Txid, Option<BlockHash>)> = self.onchain_events_awaiting_threshold_conf
865869
.iter()
866-
.map(|entry| entry.txid)
870+
.map(|entry| (entry.txid, entry.block_hash))
867871
.collect();
868-
txids.sort_unstable();
872+
txids.sort_unstable_by_key(|(txid, _)| *txid);
869873
txids.dedup();
870874
txids
871875
}

lightning/src/ln/channel.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4520,6 +4520,11 @@ impl<Signer: Sign> Channel<Signer> {
45204520
self.channel_transaction_parameters.funding_outpoint
45214521
}
45224522

4523+
/// Returns the block hash in which our funding transaction was confirmed.
4524+
pub fn get_funding_tx_confirmed_in(&self) -> Option<BlockHash> {
4525+
self.funding_tx_confirmed_in
4526+
}
4527+
45234528
fn get_holder_selected_contest_delay(&self) -> u16 {
45244529
self.channel_transaction_parameters.holder_selected_contest_delay
45254530
}

0 commit comments

Comments
 (0)