| 
9 | 9 | 
 
  | 
10 | 10 | use crate::chain::chaininterface::FEERATE_FLOOR_SATS_PER_KW;  | 
11 | 11 | use crate::chain::channelmonitor::{ANTI_REORG_DELAY, LATENCY_GRACE_PERIOD_BLOCKS};  | 
 | 12 | +use crate::chain::transaction::OutPoint;  | 
12 | 13 | use crate::events::bump_transaction::sync::WalletSourceSync;  | 
13 |  | -use crate::events::{ClosureReason, Event, HTLCHandlingFailureType};  | 
 | 14 | +use crate::events::{ClosureReason, Event, FundingInfo, HTLCHandlingFailureType};  | 
14 | 15 | use crate::ln::chan_utils;  | 
 | 16 | +use crate::ln::channelmanager::BREAKDOWN_TIMEOUT;  | 
15 | 17 | use crate::ln::functional_test_utils::*;  | 
16 | 18 | use crate::ln::funding::{FundingTxInput, SpliceContribution};  | 
17 | 19 | use crate::ln::msgs::{self, BaseMessageHandler, ChannelMessageHandler, MessageSendEvent};  | 
@@ -305,7 +307,8 @@ fn lock_splice_after_blocks<'a, 'b, 'c, 'd>(  | 
305 | 307 | 		panic!();  | 
306 | 308 | 	}  | 
307 | 309 | 
 
  | 
308 |  | -	// Remove the corresponding outputs and transactions the chain source is watching.  | 
 | 310 | +	// Remove the corresponding outputs and transactions the chain source is watching for the  | 
 | 311 | +	// old funding as it is no longer being tracked.  | 
309 | 312 | 	node_a  | 
310 | 313 | 		.chain_source  | 
311 | 314 | 		.remove_watched_txn_and_outputs(prev_funding_outpoint, prev_funding_script.clone());  | 
@@ -560,4 +563,42 @@ fn do_test_splice_commitment_broadcast(splice_status: SpliceStatus, claim_htlcs:  | 
560 | 563 | 		);  | 
561 | 564 | 	}  | 
562 | 565 | 	check_added_monitors(&nodes[0], 2); // Two `ReleasePaymentComplete` monitor updates  | 
 | 566 | + | 
 | 567 | +	// When the splice never confirms and we see a commitment transaction broadcast and confirm for  | 
 | 568 | +	// the current funding instead, we should expect to see an `Event::DiscardFunding` for the  | 
 | 569 | +	// splice transaction.  | 
 | 570 | +	if splice_status == SpliceStatus::Unconfirmed {  | 
 | 571 | +		// Remove the corresponding outputs and transactions the chain source is watching for the  | 
 | 572 | +		// splice as it is no longer being tracked.  | 
 | 573 | +		connect_blocks(&nodes[0], BREAKDOWN_TIMEOUT as u32);  | 
 | 574 | +		let (vout, txout) = splice_tx  | 
 | 575 | +			.output  | 
 | 576 | +			.iter()  | 
 | 577 | +			.enumerate()  | 
 | 578 | +			.find(|(_, output)| output.script_pubkey.is_p2wsh())  | 
 | 579 | +			.unwrap();  | 
 | 580 | +		let funding_outpoint = OutPoint { txid: splice_tx.compute_txid(), index: vout as u16 };  | 
 | 581 | +		nodes[0]  | 
 | 582 | +			.chain_source  | 
 | 583 | +			.remove_watched_txn_and_outputs(funding_outpoint, txout.script_pubkey.clone());  | 
 | 584 | +		nodes[1]  | 
 | 585 | +			.chain_source  | 
 | 586 | +			.remove_watched_txn_and_outputs(funding_outpoint, txout.script_pubkey.clone());  | 
 | 587 | + | 
 | 588 | +		// `SpendableOutputs` events are also included here, but we don't care for them.  | 
 | 589 | +		let events = nodes[0].chain_monitor.chain_monitor.get_and_clear_pending_events();  | 
 | 590 | +		assert_eq!(events.len(), if claim_htlcs { 2 } else { 4 }, "{events:?}");  | 
 | 591 | +		if let Event::DiscardFunding { funding_info, .. } = &events[0] {  | 
 | 592 | +			assert_eq!(*funding_info, FundingInfo::OutPoint { outpoint: funding_outpoint });  | 
 | 593 | +		} else {  | 
 | 594 | +			panic!();  | 
 | 595 | +		}  | 
 | 596 | +		let events = nodes[1].chain_monitor.chain_monitor.get_and_clear_pending_events();  | 
 | 597 | +		assert_eq!(events.len(), if claim_htlcs { 2 } else { 1 }, "{events:?}");  | 
 | 598 | +		if let Event::DiscardFunding { funding_info, .. } = &events[0] {  | 
 | 599 | +			assert_eq!(*funding_info, FundingInfo::OutPoint { outpoint: funding_outpoint });  | 
 | 600 | +		} else {  | 
 | 601 | +			panic!();  | 
 | 602 | +		}  | 
 | 603 | +	}  | 
563 | 604 | }  | 
0 commit comments