X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Fchannel.rs;h=d4b30f0c456a8636665d5bff1c212194f186cd1f;hb=b2bd64d2ebce897743dbd4912bc7a70c3361d147;hp=e8ec23d9451e837a3e2acde52d0de194ed283f91;hpb=c0c139cdc2daff65ad0cf95417853a8a917f68f2;p=rust-lightning diff --git a/src/ln/channel.rs b/src/ln/channel.rs index e8ec23d9..d4b30f0c 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -438,7 +438,7 @@ impl Channel { let secp_ctx = Secp256k1::new(); let channel_monitor = ChannelMonitor::new(&chan_keys.revocation_base_key, &chan_keys.delayed_payment_base_key, &chan_keys.htlc_base_key, BREAKDOWN_TIMEOUT, - keys_provider.get_destination_script()); + keys_provider.get_destination_script(), logger.clone()); Ok(Channel { user_id: user_id, @@ -600,7 +600,7 @@ impl Channel { let secp_ctx = Secp256k1::new(); let mut channel_monitor = ChannelMonitor::new(&chan_keys.revocation_base_key, &chan_keys.delayed_payment_base_key, &chan_keys.htlc_base_key, BREAKDOWN_TIMEOUT, - keys_provider.get_destination_script()); + keys_provider.get_destination_script(), logger.clone()); channel_monitor.set_their_base_keys(&msg.htlc_basepoint, &msg.delayed_payment_basepoint); channel_monitor.set_their_to_self_delay(msg.to_self_delay); @@ -2560,6 +2560,18 @@ impl Channel { self.feerate_per_kw } + pub fn get_cur_local_commitment_transaction_number(&self) -> u64 { + self.cur_local_commitment_transaction_number + 1 + } + + pub fn get_cur_remote_commitment_transaction_number(&self) -> u64 { + self.cur_remote_commitment_transaction_number + 1 - if self.channel_state & (ChannelState::AwaitingRemoteRevoke as u32) != 0 { 1 } else { 0 } + } + + pub fn get_revoked_remote_commitment_transaction_number(&self) -> u64 { + self.cur_remote_commitment_transaction_number + 2 + } + //TODO: Testing purpose only, should be changed in another way after #81 #[cfg(test)] pub fn get_local_keys(&self) -> &ChannelKeys { @@ -2674,6 +2686,7 @@ impl Channel { if self.funding_tx_confirmations > 0 { if header.bitcoin_hash() != self.last_block_connected { self.last_block_connected = header.bitcoin_hash(); + self.channel_monitor.last_block_hash = self.last_block_connected; self.funding_tx_confirmations += 1; if self.funding_tx_confirmations == Channel::derive_minimum_depth(self.channel_value_satoshis*1000, self.value_to_self_msat) as u64 { let need_commitment_update = if non_shutdown_state == ChannelState::FundingSent as u32 {