|
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());
|
@@ -559,4 +562,42 @@ fn do_test_splice_commitment_broadcast(splice_status: SpliceStatus, claim_htlcs:
|
559 | 562 | 2
|
560 | 563 | );
|
561 | 564 | }
|
| 565 | + |
| 566 | + // When the splice never confirms and we see a commitment transaction broadcast and confirm for |
| 567 | + // the current funding instead, we should expect to see an `Event::DiscardFunding` for the |
| 568 | + // splice transaction. |
| 569 | + if splice_status == SpliceStatus::Unconfirmed { |
| 570 | + // Remove the corresponding outputs and transactions the chain source is watching for the |
| 571 | + // splice as it is no longer being tracked. |
| 572 | + connect_blocks(&nodes[0], BREAKDOWN_TIMEOUT as u32); |
| 573 | + let (vout, txout) = splice_tx |
| 574 | + .output |
| 575 | + .iter() |
| 576 | + .enumerate() |
| 577 | + .find(|(_, output)| output.script_pubkey.is_p2wsh()) |
| 578 | + .unwrap(); |
| 579 | + let funding_outpoint = OutPoint { txid: splice_tx.compute_txid(), index: vout as u16 }; |
| 580 | + nodes[0] |
| 581 | + .chain_source |
| 582 | + .remove_watched_txn_and_outputs(funding_outpoint, txout.script_pubkey.clone()); |
| 583 | + nodes[1] |
| 584 | + .chain_source |
| 585 | + .remove_watched_txn_and_outputs(funding_outpoint, txout.script_pubkey.clone()); |
| 586 | + |
| 587 | + // `SpendableOutputs` events are also included here, but we don't care for them. |
| 588 | + let events = nodes[0].chain_monitor.chain_monitor.get_and_clear_pending_events(); |
| 589 | + assert_eq!(events.len(), if claim_htlcs { 2 } else { 4 }, "{events:?}"); |
| 590 | + if let Event::DiscardFunding { funding_info, .. } = &events[0] { |
| 591 | + assert_eq!(*funding_info, FundingInfo::OutPoint { outpoint: funding_outpoint }); |
| 592 | + } else { |
| 593 | + panic!(); |
| 594 | + } |
| 595 | + let events = nodes[1].chain_monitor.chain_monitor.get_and_clear_pending_events(); |
| 596 | + assert_eq!(events.len(), if claim_htlcs { 2 } else { 1 }, "{events:?}"); |
| 597 | + if let Event::DiscardFunding { funding_info, .. } = &events[0] { |
| 598 | + assert_eq!(*funding_info, FundingInfo::OutPoint { outpoint: funding_outpoint }); |
| 599 | + } else { |
| 600 | + panic!(); |
| 601 | + } |
| 602 | + } |
562 | 603 | }
|
0 commit comments