Skip to content

Commit 32f0f6b

Browse files
committed
Reset FundingScope::funding_tx_confirmation_height
FundingScope::funding_tx_confirmation_height is reset as part of calling ChannelContext::check_funding_meets_minimum_depth via FundedChannel::check_get_channel_ready. This side effect requires using mutable references to self when otherwise it would not be needed. Instead of reseting funding_tx_confirmation_height there, do so when unconfirming the funding transaction.
1 parent 44671ae commit 32f0f6b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lightning/src/ln/channel.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4974,7 +4974,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
49744974
self.get_initial_counterparty_commitment_signature(funding, logger)
49754975
}
49764976

4977-
fn check_funding_meets_minimum_depth(&self, funding: &mut FundingScope, height: u32) -> bool {
4977+
fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
49784978
let is_coinbase = funding
49794979
.funding_transaction
49804980
.as_ref()
@@ -4997,10 +4997,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
49974997
}
49984998

49994999
let funding_tx_confirmations = height as i64 - funding.funding_tx_confirmation_height as i64 + 1;
5000-
if funding_tx_confirmations <= 0 {
5001-
funding.funding_tx_confirmation_height = 0;
5002-
}
5003-
50045000
if funding_tx_confirmations < minimum_depth.unwrap_or(0) as i64 {
50055001
return false;
50065002
}
@@ -8221,7 +8217,7 @@ impl<SP: Deref> FundedChannel<SP> where
82218217
// Called:
82228218
// * always when a new block/transactions are confirmed with the new height
82238219
// * when funding is signed with a height of 0
8224-
if !self.context.check_funding_meets_minimum_depth(&mut self.funding, height) {
8220+
if !self.context.check_funding_meets_minimum_depth(&self.funding, height) {
82258221
return None;
82268222
}
82278223

@@ -8480,6 +8476,9 @@ impl<SP: Deref> FundedChannel<SP> where
84808476
// larger. If we don't know that time has moved forward, we can just set it to the last
84818477
// time we saw and it will be ignored.
84828478
let best_time = self.context.update_time_counter;
8479+
8480+
self.funding.funding_tx_confirmation_height = 0;
8481+
84838482
match self.do_best_block_updated(reorg_height, best_time, None::<(ChainHash, &&dyn NodeSigner, &UserConfig)>, logger) {
84848483
Ok((channel_ready, timed_out_htlcs, announcement_sigs)) => {
84858484
assert!(channel_ready.is_none(), "We can't generate a funding with 0 confirmations?");

0 commit comments

Comments
 (0)