Skip to content

Commit 56842c2

Browse files
committed
Cleanups after #33, plus one unrelated bugfix spotted in #33 review
1 parent d0e9137 commit 56842c2

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/ln/channel.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,8 +1151,8 @@ impl Channel {
11511151
panic!("Should not have advanced channel commitment tx numbers prior to funding_created");
11521152
}
11531153

1154-
let funding_info = OutPoint::new(msg.funding_txid, msg.funding_output_index);
1155-
self.channel_monitor.set_funding_info(funding_info);
1154+
let funding_txo = OutPoint::new(msg.funding_txid, msg.funding_output_index);
1155+
self.channel_monitor.set_funding_info(funding_txo);
11561156

11571157
let (remote_initial_commitment_tx, our_signature) = match self.funding_created_signature(&msg.signature) {
11581158
Ok(res) => res,
@@ -1166,7 +1166,6 @@ impl Channel {
11661166

11671167
self.channel_monitor.provide_latest_remote_commitment_tx_info(&remote_initial_commitment_tx, Vec::new());
11681168
self.channel_state = ChannelState::FundingSent as u32;
1169-
let funding_txo = self.channel_monitor.get_funding_txo().unwrap();
11701169
self.channel_id = funding_txo.to_channel_id();
11711170
self.cur_remote_commitment_transaction_number -= 1;
11721171
self.cur_local_commitment_transaction_number -= 1;
@@ -1930,9 +1929,9 @@ impl Channel {
19301929
self.channel_update_count += 1;
19311930
} else {
19321931
self.funding_tx_confirmations = 1;
1933-
self.short_channel_id = Some(((height as u64) << (5*8)) |
1932+
self.short_channel_id = Some(((height as u64) << (5*8)) |
19341933
((*index_in_block as u64) << (2*8)) |
1935-
((self.channel_monitor.get_funding_txo().unwrap().index as u64) << (2*8)));
1934+
((txo_idx as u64) << (0*8)));
19361935
}
19371936
}
19381937
}
@@ -2071,7 +2070,6 @@ impl Channel {
20712070
// Now that we're past error-generating stuff, update our local state:
20722071
self.channel_monitor.provide_latest_remote_commitment_tx_info(&commitment_tx, Vec::new());
20732072
self.channel_state = ChannelState::FundingCreated as u32;
2074-
let funding_txo = self.channel_monitor.get_funding_txo().unwrap();
20752073
self.channel_id = funding_txo.to_channel_id();
20762074
self.cur_remote_commitment_transaction_number -= 1;
20772075

@@ -2332,7 +2330,7 @@ mod tests {
23322330
use ln::channel::{Channel,ChannelKeys,HTLCOutput,HTLCState,HTLCOutputInCommitment,TxCreationKeys};
23332331
use ln::chan_utils;
23342332
use chain::chaininterface::{FeeEstimator,ConfirmationTarget};
2335-
use chain::transaction::OutPoint;
2333+
use chain::transaction::OutPoint;
23362334
use secp256k1::{Secp256k1,Message,Signature};
23372335
use secp256k1::key::{SecretKey,PublicKey};
23382336
use crypto::sha2::Sha256;
@@ -2868,7 +2866,7 @@ mod tests {
28682866
let mut seed = [0; 32];
28692867
seed[0..32].clone_from_slice(&hex_bytes("0000000000000000000000000000000000000000000000000000000000000000").unwrap());
28702868
assert_eq!(chan_utils::build_commitment_secret(seed, 281474976710655),
2871-
hex_bytes("02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148").unwrap()[..]);
2869+
hex_bytes("02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148").unwrap()[..]);
28722870

28732871
seed[0..32].clone_from_slice(&hex_bytes("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF").unwrap());
28742872
assert_eq!(chan_utils::build_commitment_secret(seed, 281474976710655),

src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bitcoin::blockdata::block::BlockHeader;
1+
use bitcoin::blockdata::block::BlockHeader;
22
use bitcoin::blockdata::transaction::Transaction;
33
use bitcoin::blockdata::constants::genesis_block;
44
use bitcoin::network::constants::Network;

0 commit comments

Comments
 (0)