Skip to content

Commit

Permalink
Preserve funding_transaction for the later lifecycle of the channel, …
Browse files Browse the repository at this point in the history
…simple solution
  • Loading branch information
optout21 committed Oct 23, 2024
1 parent e0838be commit ee23649
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5486,7 +5486,8 @@ impl<SP: Deref> Channel<SP> where
(matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if !flags.is_set(AwaitingChannelReadyFlags::WAITING_FOR_BATCH)) ||
matches!(self.context.channel_state, ChannelState::ChannelReady(_)))
{
self.context.funding_transaction.take()
// Take the funding transaction, do not clear the field
self.context.funding_transaction.clone()
} else { None };
// That said, if the funding transaction is already confirmed (ie we're active with a
// minimum_depth over 0) don't bother re-broadcasting the confirmed funding tx.
Expand Down Expand Up @@ -7893,6 +7894,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
self.context.minimum_depth = Some(COINBASE_MATURITY);
}

debug_assert!(self.context.funding_transaction.is_none());
self.context.funding_transaction = Some(funding_transaction);
self.context.is_batch_funding = Some(()).filter(|_| is_batch_funding);

Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/payment_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ fn do_test_completed_payment_not_retryable_on_reload(use_dust: bool) {
nodes[0].node.timer_tick_occurred();
assert!(nodes[0].node.list_channels().is_empty());
assert!(nodes[0].node.has_pending_payments());
assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0).len(), 1);
assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0).len(), 4);
check_added_monitors!(nodes[0], 1);

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

0 comments on commit ee23649

Please sign in to comment.