Skip to content

Commit 789348b

Browse files
committed
Change prevent-rebroadcast check to look at confirmed height; revert test
1 parent ee23649 commit 789348b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lightning/src/ln/channel.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5489,10 +5489,18 @@ impl<SP: Deref> Channel<SP> where
54895489
// Take the funding transaction, do not clear the field
54905490
self.context.funding_transaction.clone()
54915491
} else { None };
5492-
// That said, if the funding transaction is already confirmed (ie we're active with a
5493-
// minimum_depth over 0) don't bother re-broadcasting the confirmed funding tx.
5494-
if matches!(self.context.channel_state, ChannelState::ChannelReady(_)) && self.context.minimum_depth != Some(0) {
5495-
funding_broadcastable = None;
5492+
// That said, if the funding transaction is already confirmed,
5493+
// don't bother re-broadcasting the confirmed funding tx.
5494+
if funding_broadcastable.is_some() {
5495+
if let Some(height) = self.context.get_funding_tx_confirmation_height() {
5496+
if let Some(block) = self.context.get_funding_tx_confirmed_in() {
5497+
log_debug!(logger,
5498+
"Not rebroadcasting funding tx, as it's already confirmed, height: {} block: {} txid: {}",
5499+
height, block, funding_broadcastable.unwrap().txid()
5500+
);
5501+
funding_broadcastable = None;
5502+
}
5503+
}
54965504
}
54975505

54985506
// We will never broadcast the funding transaction when we're in MonitorUpdateInProgress

lightning/src/ln/payment_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ fn do_test_completed_payment_not_retryable_on_reload(use_dust: bool) {
891891
nodes[0].node.timer_tick_occurred();
892892
assert!(nodes[0].node.list_channels().is_empty());
893893
assert!(nodes[0].node.has_pending_payments());
894-
assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0).len(), 4);
894+
assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0).len(), 1);
895895
check_added_monitors!(nodes[0], 1);
896896

897897
nodes[0].node.peer_connected(nodes[1].node.get_our_node_id(), &msgs::Init {

0 commit comments

Comments
 (0)