X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Fchannel.rs;h=43f913eb2f569d37169ce91eb8609f78e030371a;hb=2470812077dfa09b77c7ff881208a9dcb6174d7a;hp=188af477dded2049771aa6d800ffe3cc3421407e;hpb=830343f12980dd3dddc960721e67acc8885436f0;p=rust-lightning diff --git a/src/ln/channel.rs b/src/ln/channel.rs index 188af477..43f913eb 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -271,7 +271,7 @@ pub struct Channel { /// to detect unconfirmation after a serialize-unserialize roudtrip where we may not see a full /// series of block_connected/block_disconnected calls. Obviously this is not a guarantee as we /// could miss the funding_tx_confirmed_in block as well, but it serves as a useful fallback. - funding_tx_confirmed_in: Sha256dHash, + funding_tx_confirmed_in: Option, short_channel_id: Option, /// Used to deduplicate block_connected callbacks last_block_connected: Sha256dHash, @@ -401,7 +401,7 @@ impl Channel { last_sent_closing_fee: None, - funding_tx_confirmed_in: Default::default(), + funding_tx_confirmed_in: None, short_channel_id: None, last_block_connected: Default::default(), funding_tx_confirmations: 0, @@ -519,7 +519,7 @@ impl Channel { last_sent_closing_fee: None, - funding_tx_confirmed_in: Default::default(), + funding_tx_confirmed_in: None, short_channel_id: None, last_block_connected: Default::default(), funding_tx_confirmations: 0, @@ -1827,6 +1827,7 @@ impl Channel { self.user_id } + /// May only be called after funding has been initiated (ie is_funding_initiated() is true) pub fn channel_monitor(&self) -> ChannelMonitor { if self.channel_state < ChannelState::FundingCreated as u32 { panic!("Can't get a channel monitor until funding has been created"); @@ -1904,6 +1905,11 @@ impl Channel { self.is_usable() } + /// Returns true if funding_created was sent/received. + pub fn is_funding_initiated(&self) -> bool { + self.channel_state >= ChannelState::FundingCreated as u32 + } + /// Returns true if this channel is fully shut down. True here implies that no further actions /// may/will be taken on this channel, and thus this object should be freed. Any future changes /// will be handled appropriately by the chain monitor. @@ -1936,7 +1942,7 @@ impl Channel { } else if self.channel_state < ChannelState::ChannelFunded as u32 { panic!("Started confirming a channel in a state pre-FundingSent?"); } - self.funding_tx_confirmed_in = header.bitcoin_hash(); + self.funding_tx_confirmed_in = Some(header.bitcoin_hash()); //TODO: Note that this must be a duplicate of the previous commitment point they sent us, //as otherwise we will have a commitment transaction that they can't revoke (well, kinda, @@ -1982,7 +1988,7 @@ impl Channel { return true; } } - if header.bitcoin_hash() == self.funding_tx_confirmed_in { + if Some(header.bitcoin_hash()) == self.funding_tx_confirmed_in { self.funding_tx_confirmations = CONF_TARGET as u64 - 1; } false