@@ -2061,7 +2061,6 @@ impl FundingScope {
2061
2061
self.channel_transaction_parameters.funding_outpoint
2062
2062
}
2063
2063
2064
- #[cfg(splicing)]
2065
2064
fn get_funding_txid(&self) -> Option<Txid> {
2066
2065
self.channel_transaction_parameters.funding_outpoint.map(|txo| txo.txid)
2067
2066
}
@@ -9267,7 +9266,7 @@ where
9267
9266
9268
9267
#[cfg(splicing)]
9269
9268
if let Some(confirmed_funding_index) = confirmed_funding_index {
9270
- let pending_splice = match self.pending_splice.as_ref () {
9269
+ let pending_splice = match self.pending_splice.as_mut () {
9271
9270
Some(pending_splice) => pending_splice,
9272
9271
None => {
9273
9272
// TODO: Move pending_funding into pending_splice
@@ -9276,8 +9275,26 @@ where
9276
9275
return Err(ClosureReason::ProcessingError { err });
9277
9276
},
9278
9277
};
9279
- let funding = self.pending_funding.get(confirmed_funding_index).unwrap();
9278
+ let funding = self.pending_funding.get_mut(confirmed_funding_index).unwrap();
9279
+
9280
+ // Check if the splice funding transaction was unconfirmed
9281
+ if funding.get_funding_tx_confirmations(height) == 0 {
9282
+ funding.funding_tx_confirmation_height = 0;
9283
+ if let Some(sent_funding_txid) = pending_splice.sent_funding_txid {
9284
+ if Some(sent_funding_txid) == funding.get_funding_txid() {
9285
+ log_warn!(
9286
+ logger,
9287
+ "Unconfirming sent splice_locked txid {} for channel {}",
9288
+ sent_funding_txid,
9289
+ &self.context.channel_id,
9290
+ );
9291
+ pending_splice.sent_funding_txid = None;
9292
+ }
9293
+ }
9294
+ }
9280
9295
9296
+ let pending_splice = self.pending_splice.as_ref().unwrap();
9297
+ let funding = self.pending_funding.get(confirmed_funding_index).unwrap();
9281
9298
if let Some(splice_locked) = self.check_get_splice_locked(pending_splice, funding, height) {
9282
9299
log_info!(logger, "Sending a splice_locked to our peer for channel {}", &self.context.channel_id);
9283
9300
@@ -9300,31 +9317,45 @@ where
9300
9317
Ok((None, timed_out_htlcs, announcement_sigs))
9301
9318
}
9302
9319
9303
- /// Indicates the funding transaction is no longer confirmed in the main chain. This may
9320
+ /// Checks if any funding transaction is no longer confirmed in the main chain. This may
9304
9321
/// force-close the channel, but may also indicate a harmless reorganization of a block or two
9305
- /// before the channel has reached channel_ready and we can just wait for more blocks.
9306
- #[rustfmt::skip]
9307
- pub fn funding_transaction_unconfirmed<L: Deref>(&mut self, logger: &L) -> Result<(), ClosureReason> where L::Target: Logger {
9308
- if self.funding.funding_tx_confirmation_height != 0 {
9309
- // We handle the funding disconnection by calling best_block_updated with a height one
9310
- // below where our funding was connected, implying a reorg back to conf_height - 1.
9311
- let reorg_height = self.funding.funding_tx_confirmation_height - 1;
9312
- // We use the time field to bump the current time we set on channel updates if its
9313
- // larger. If we don't know that time has moved forward, we can just set it to the last
9314
- // time we saw and it will be ignored.
9315
- let best_time = self.context.update_time_counter;
9316
-
9317
- match self.do_best_block_updated(reorg_height, best_time, None::<(ChainHash, &&dyn NodeSigner, &UserConfig)>, logger) {
9318
- Ok((channel_ready, timed_out_htlcs, announcement_sigs)) => {
9319
- assert!(channel_ready.is_none(), "We can't generate a funding with 0 confirmations?");
9320
- assert!(timed_out_htlcs.is_empty(), "We can't have accepted HTLCs with a timeout before our funding confirmation?");
9321
- assert!(announcement_sigs.is_none(), "We can't generate an announcement_sigs with 0 confirmations?");
9322
- Ok(())
9323
- },
9324
- Err(e) => Err(e)
9322
+ /// before the channel has reached channel_ready or splice_locked, and we can just wait for more
9323
+ /// blocks.
9324
+ #[rustfmt::skip]
9325
+ pub fn transaction_unconfirmed<L: Deref>(
9326
+ &mut self, txid: &Txid, logger: &L,
9327
+ ) -> Result<(), ClosureReason>
9328
+ where
9329
+ L::Target: Logger,
9330
+ {
9331
+ let unconfirmed_funding = core::iter::once(&mut self.funding)
9332
+ .chain(self.pending_funding.iter_mut())
9333
+ .find(|funding| funding.get_funding_txid() == Some(*txid));
9334
+
9335
+ if let Some(funding) = unconfirmed_funding {
9336
+ if funding.funding_tx_confirmation_height != 0 {
9337
+ // We handle the funding disconnection by calling best_block_updated with a height one
9338
+ // below where our funding was connected, implying a reorg back to conf_height - 1.
9339
+ let reorg_height = funding.funding_tx_confirmation_height - 1;
9340
+ // We use the time field to bump the current time we set on channel updates if its
9341
+ // larger. If we don't know that time has moved forward, we can just set it to the last
9342
+ // time we saw and it will be ignored.
9343
+ let best_time = self.context.update_time_counter;
9344
+
9345
+ match self.do_best_block_updated(reorg_height, best_time, None::<(ChainHash, &&dyn NodeSigner, &UserConfig)>, logger) {
9346
+ Ok((channel_ready, timed_out_htlcs, announcement_sigs)) => {
9347
+ assert!(channel_ready.is_none(), "We can't generate a funding with 0 confirmations?");
9348
+ assert!(timed_out_htlcs.is_empty(), "We can't have accepted HTLCs with a timeout before our funding confirmation?");
9349
+ assert!(announcement_sigs.is_none(), "We can't generate an announcement_sigs with 0 confirmations?");
9350
+ Ok(())
9351
+ },
9352
+ Err(e) => Err(e),
9353
+ }
9354
+ } else {
9355
+ // We never learned about the funding confirmation anyway, just ignore
9356
+ Ok(())
9325
9357
}
9326
9358
} else {
9327
- // We never learned about the funding confirmation anyway, just ignore
9328
9359
Ok(())
9329
9360
}
9330
9361
}
0 commit comments