Skip to content

Commit bfe1f39

Browse files
committed
Refactor funding pending check to return transaction if it exists
1 parent 6a546dd commit bfe1f39

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

lightning/src/ln/channel.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,10 +1306,6 @@ impl<Signer: Sign> Channel<Signer> {
13061306
self.channel_transaction_parameters.funding_outpoint.unwrap()
13071307
}
13081308

1309-
pub(crate) fn funding_transaction(&self) -> Option<Transaction> {
1310-
self.funding_transaction.clone()
1311-
}
1312-
13131309
#[inline]
13141310
/// Creates a set of keys for build_commitment_transaction to generate a transaction which our
13151311
/// counterparty will sign (ie DO NOT send signatures over a transaction created by this to
@@ -1905,10 +1901,14 @@ impl<Signer: Sign> Channel<Signer> {
19051901
Ok(())
19061902
}
19071903

1908-
/// Returns true if we have a pending funding transaction that is yet to broadcast
1909-
pub fn is_funding_pending(&self) -> bool {
1910-
self.funding_transaction.is_some() &&
1911-
self.channel_state & (ChannelState::FundingCreated as u32) != 0
1904+
/// Returns transaction if there is pending funding transaction that is yet to broadcast
1905+
pub fn has_funding_pending(&self) -> Option<Transaction> {
1906+
if self.funding_transaction.is_some() &&
1907+
self.channel_state & (ChannelState::FundingCreated as u32) != 0 {
1908+
self.funding_transaction.clone()
1909+
} else {
1910+
None
1911+
}
19121912
}
19131913

19141914
/// Returns a HTLCStats about inbound pending htlcs

lightning/src/ln/channelmanager.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,8 +1329,11 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
13291329
/// Helper function that issues the channel close events
13301330
fn issue_channel_close_events(&self, channel: &Channel<Signer>, closure_reason: ClosureReason) {
13311331
let mut pending_events_lock = self.pending_events.lock().unwrap();
1332-
if channel.is_funding_pending() {
1333-
pending_events_lock.push(events::Event::DiscardFunding { channel_id: channel.channel_id(), transaction: channel.funding_transaction() });
1332+
match channel.has_funding_pending() {
1333+
Some(transaction) => {
1334+
pending_events_lock.push(events::Event::DiscardFunding { channel_id: channel.channel_id(), transaction })
1335+
},
1336+
None => {},
13341337
}
13351338
pending_events_lock.push(events::Event::ChannelClosed { channel_id: channel.channel_id(), reason: closure_reason });
13361339
}

0 commit comments

Comments
 (0)