X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=lightning%2Fsrc%2Fln%2Fchannel.rs;h=5ce39592fabdc59fcdfad91e43e153b7bbb2b806;hb=367834ca9039eb64d6f85b6bd4432c735e776b81;hp=e00d34895c2e30b54c84dab6945dc6344238c97d;hpb=6133498ca1a455c09724ad8e78286e330ea6e9d0;p=rust-lightning diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index e00d3489..5ce39592 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -262,6 +262,9 @@ enum UpdateStatus { // has been completed, and then turn into a Channel to get compiler-time enforcement of things like // calling channel_id() before we're set up or things like get_outbound_funding_signed on an // inbound channel. +// +// Holder designates channel data owned for the benefice of the user client. +// Counterparty designates channel data owned by the another channel participant entity. pub(super) struct Channel { config: ChannelConfig, @@ -3122,6 +3125,7 @@ impl Channel { } /// Allowed in any state (including after shutdown) + #[cfg(test)] pub fn get_holder_htlc_minimum_msat(&self) -> u64 { self.holder_htlc_minimum_msat } @@ -3140,7 +3144,7 @@ impl Channel { /// Allowed in any state (including after shutdown) pub fn get_counterparty_htlc_minimum_msat(&self) -> u64 { - self.holder_htlc_minimum_msat + self.counterparty_htlc_minimum_msat } pub fn get_value_satoshis(&self) -> u64 { @@ -3311,7 +3315,7 @@ impl Channel { /// /// May return some HTLCs (and their payment_hash) which have timed out and should be failed /// back. - pub fn block_connected(&mut self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], indexes_of_txn_matched: &[usize]) -> Result<(Option, Vec<(HTLCSource, PaymentHash)>), msgs::ErrorMessage> { + pub fn block_connected(&mut self, header: &BlockHeader, txdata: &[(usize, &Transaction)], height: u32) -> Result<(Option, Vec<(HTLCSource, PaymentHash)>), msgs::ErrorMessage> { let mut timed_out_htlcs = Vec::new(); self.holding_cell_htlc_updates.retain(|htlc_update| { match htlc_update { @@ -3331,7 +3335,7 @@ impl Channel { } } if non_shutdown_state & !(ChannelState::TheirFundingLocked as u32) == ChannelState::FundingSent as u32 { - for (ref tx, index_in_block) in txn_matched.iter().zip(indexes_of_txn_matched) { + for &(index_in_block, tx) in txdata.iter() { if tx.txid() == self.funding_txo.unwrap().txid { let txo_idx = self.funding_txo.unwrap().index as usize; if txo_idx >= tx.output.len() || tx.output[txo_idx].script_pubkey != self.get_funding_redeemscript().to_v0_p2wsh() || @@ -3362,14 +3366,14 @@ impl Channel { } } } - if height > 0xff_ff_ff || (*index_in_block) > 0xff_ff_ff { + if height > 0xff_ff_ff || (index_in_block) > 0xff_ff_ff { panic!("Block was bogus - either height 16 million or had > 16 million transactions"); } assert!(txo_idx <= 0xffff); // txo_idx is a (u16 as usize), so this is just listed here for completeness self.funding_tx_confirmations = 1; - self.short_channel_id = Some(((height as u64) << (5*8)) | - ((*index_in_block as u64) << (2*8)) | - ((txo_idx as u64) << (0*8))); + self.short_channel_id = Some(((height as u64) << (5*8)) | + ((index_in_block as u64) << (2*8)) | + ((txo_idx as u64) << (0*8))); } } }