Skip to content

Commit 0bb8c5e

Browse files
committed
f remove unnecessary assignments & other unused ones
1 parent 7fc8a56 commit 0bb8c5e

File tree

4 files changed

+16
-23
lines changed

4 files changed

+16
-23
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,9 +704,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
704704
lock_fundings!(nodes);
705705

706706
let chan_a = nodes[0].list_usable_channels()[0].short_channel_id.unwrap();
707-
let chan_1_id = nodes[0].list_usable_channels()[0].channel_id;
708707
let chan_b = nodes[2].list_usable_channels()[0].short_channel_id.unwrap();
709-
let chan_2_id = nodes[2].list_usable_channels()[0].channel_id;
710708

711709
let mut payment_id: u8 = 0;
712710
let mut payment_idx: u64 = 0;

lightning/src/chain/channelmonitor.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2846,8 +2846,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
28462846
self.queue_latest_holder_commitment_txn_for_broadcast(broadcaster, &bounded_fee_estimator, logger);
28472847
} else if !self.holder_tx_signed {
28482848
log_error!(logger, "WARNING: You have a potentially-unsafe holder commitment transaction available to broadcast");
2849-
let channel_id = self.get_channel_id();
2850-
log_error!(logger, " in channel monitor for channel {}!", &channel_id);
2849+
log_error!(logger, " in channel monitor for channel {}!", &self.get_channel_id());
28512850
log_error!(logger, " Read the docs for ChannelMonitor::get_latest_holder_commitment_txn and take manual action!");
28522851
} else {
28532852
// If we generated a MonitorEvent::HolderForceClosed, the ChannelManager
@@ -5131,10 +5130,7 @@ mod tests {
51315130
&channel_parameters, ScriptBuf::new(), 46, 0, HolderCommitmentTransaction::dummy(&mut Vec::new()),
51325131
best_block, dummy_key, channel_id);
51335132

5134-
let chan_id = {
5135-
let monitor_impl = monitor.inner.lock().unwrap();
5136-
monitor_impl.get_channel_id()
5137-
};
5133+
let chan_id = monitor.inner.lock().unwrap().get_channel_id();
51385134
let context_logger = WithChannelMonitor::from(&logger, &monitor);
51395135
log_error!(context_logger, "This is an error");
51405136
log_warn!(context_logger, "This is an error");

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5575,8 +5575,7 @@ where
55755575
peer_state.monitor_update_blocked_actions.entry(chan_id).or_insert(Vec::new()).push(action);
55765576
}
55775577
if !during_init {
5578-
let prev_hop_channel_id = prev_hop.channel_id;
5579-
handle_new_monitor_update!(self, prev_hop.outpoint, prev_hop_channel_id, monitor_update, peer_state_lock,
5578+
handle_new_monitor_update!(self, prev_hop.outpoint, prev_hop.channel_id, monitor_update, peer_state_lock,
55805579
peer_state, per_peer_state, chan);
55815580
} else {
55825581
// If we're running during init we cannot update a monitor directly -

lightning/src/ln/shutdown_tests.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ fn test_upfront_shutdown_script() {
721721

722722
// We test that in case of peer committing upfront to a script, if it changes at closing, we refuse to sign
723723
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 2, 1000000, 1000000);
724-
nodes[0].node.close_channel(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: chan.3.txid(), index: 0 }), &nodes[2].node.get_our_node_id()).unwrap();
724+
nodes[0].node.close_channel(&chan.2, &nodes[2].node.get_our_node_id()).unwrap();
725725
let node_0_orig_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[2].node.get_our_node_id());
726726
let mut node_0_shutdown = node_0_orig_shutdown.clone();
727727
node_0_shutdown.scriptpubkey = Builder::new().push_opcode(opcodes::all::OP_RETURN).into_script().to_p2sh();
@@ -736,7 +736,7 @@ fn test_upfront_shutdown_script() {
736736

737737
// We test that in case of peer committing upfront to a script, if it doesn't change at closing, we sign
738738
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 2, 1000000, 1000000);
739-
nodes[0].node.close_channel(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: chan.3.txid(), index: 0 }), &nodes[2].node.get_our_node_id()).unwrap();
739+
nodes[0].node.close_channel(&chan.2, &nodes[2].node.get_our_node_id()).unwrap();
740740
let node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[2].node.get_our_node_id());
741741
// We test that in case of peer committing upfront to a script, if it oesn't change at closing, we sign
742742
nodes[2].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &node_0_shutdown);
@@ -750,7 +750,7 @@ fn test_upfront_shutdown_script() {
750750
// We test that if case of peer non-signaling we don't enforce committed script at channel opening
751751
*nodes[0].override_init_features.borrow_mut() = Some(nodes[0].node.init_features().clear_upfront_shutdown_script());
752752
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 1000000);
753-
nodes[0].node.close_channel(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: chan.3.txid(), index: 0 }), &nodes[1].node.get_our_node_id()).unwrap();
753+
nodes[0].node.close_channel(&chan.2, &nodes[1].node.get_our_node_id()).unwrap();
754754
let node_1_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
755755
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &node_1_shutdown);
756756
check_added_monitors!(nodes[1], 1);
@@ -765,7 +765,7 @@ fn test_upfront_shutdown_script() {
765765
// channel smoothly, opt-out is from channel initiator here
766766
*nodes[0].override_init_features.borrow_mut() = None;
767767
let chan = create_announced_chan_between_nodes_with_value(&nodes, 1, 0, 1000000, 1000000);
768-
nodes[1].node.close_channel(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: chan.3.txid(), index: 0 }), &nodes[0].node.get_our_node_id()).unwrap();
768+
nodes[1].node.close_channel(&chan.2, &nodes[0].node.get_our_node_id()).unwrap();
769769
check_added_monitors!(nodes[1], 1);
770770
let node_0_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
771771
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &node_0_shutdown);
@@ -779,7 +779,7 @@ fn test_upfront_shutdown_script() {
779779
//// We test that if user opt-out, we provide a zero-length script at channel opening and we are able to close
780780
//// channel smoothly
781781
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 1000000);
782-
nodes[1].node.close_channel(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: chan.3.txid(), index: 0 }), &nodes[0].node.get_our_node_id()).unwrap();
782+
nodes[1].node.close_channel(&chan.2, &nodes[0].node.get_our_node_id()).unwrap();
783783
check_added_monitors!(nodes[1], 1);
784784
let node_0_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
785785
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &node_0_shutdown);
@@ -894,7 +894,7 @@ fn test_segwit_v0_shutdown_script() {
894894
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
895895

896896
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
897-
nodes[1].node.close_channel(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: chan.3.txid(), index: 0 }), &nodes[0].node.get_our_node_id()).unwrap();
897+
nodes[1].node.close_channel(&chan.2, &nodes[0].node.get_our_node_id()).unwrap();
898898
check_added_monitors!(nodes[1], 1);
899899

900900
// Use a segwit v0 script supported even without option_shutdown_anysegwit
@@ -929,7 +929,7 @@ fn test_anysegwit_shutdown_script() {
929929
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
930930

931931
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
932-
nodes[1].node.close_channel(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: chan.3.txid(), index: 0 }), &nodes[0].node.get_our_node_id()).unwrap();
932+
nodes[1].node.close_channel(&chan.2, &nodes[0].node.get_our_node_id()).unwrap();
933933
check_added_monitors!(nodes[1], 1);
934934

935935
// Use a non-v0 segwit script supported by option_shutdown_anysegwit
@@ -975,14 +975,14 @@ fn test_unsupported_anysegwit_shutdown_script() {
975975
.expect(OnGetShutdownScriptpubkey { returns: supported_shutdown_script });
976976

977977
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
978-
match nodes[1].node.close_channel(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: chan.3.txid(), index: 0 }), &nodes[0].node.get_our_node_id()) {
978+
match nodes[1].node.close_channel(&chan.2, &nodes[0].node.get_our_node_id()) {
979979
Err(APIError::IncompatibleShutdownScript { script }) => {
980980
assert_eq!(script.into_inner(), unsupported_shutdown_script.clone().into_inner());
981981
},
982982
Err(e) => panic!("Unexpected error: {:?}", e),
983983
Ok(_) => panic!("Expected error"),
984984
}
985-
nodes[1].node.close_channel(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: chan.3.txid(), index: 0 }), &nodes[0].node.get_our_node_id()).unwrap();
985+
nodes[1].node.close_channel(&chan.2, &nodes[0].node.get_our_node_id()).unwrap();
986986
check_added_monitors!(nodes[1], 1);
987987

988988
// Use a non-v0 segwit script unsupported without option_shutdown_anysegwit
@@ -1007,7 +1007,7 @@ fn test_invalid_shutdown_script() {
10071007
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
10081008

10091009
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
1010-
nodes[1].node.close_channel(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: chan.3.txid(), index: 0 }), &nodes[0].node.get_our_node_id()).unwrap();
1010+
nodes[1].node.close_channel(&chan.2, &nodes[0].node.get_our_node_id()).unwrap();
10111011
check_added_monitors!(nodes[1], 1);
10121012

10131013
// Use a segwit v0 script with an unsupported witness program
@@ -1041,7 +1041,7 @@ fn test_user_shutdown_script() {
10411041
let shutdown_script = ShutdownScript::try_from(script.clone()).unwrap();
10421042

10431043
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
1044-
nodes[1].node.close_channel_with_feerate_and_script(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: chan.3.txid(), index: 0 }), &nodes[0].node.get_our_node_id(), None, Some(shutdown_script)).unwrap();
1044+
nodes[1].node.close_channel_with_feerate_and_script(&chan.2, &nodes[0].node.get_our_node_id(), None, Some(shutdown_script)).unwrap();
10451045
check_added_monitors!(nodes[1], 1);
10461046

10471047
let mut node_0_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
@@ -1068,7 +1068,7 @@ fn test_already_set_user_shutdown_script() {
10681068
let shutdown_script = ShutdownScript::try_from(script).unwrap();
10691069

10701070
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
1071-
let result = nodes[1].node.close_channel_with_feerate_and_script(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: chan.3.txid(), index: 0 }), &nodes[0].node.get_our_node_id(), None, Some(shutdown_script));
1071+
let result = nodes[1].node.close_channel_with_feerate_and_script(&chan.2, &nodes[0].node.get_our_node_id(), None, Some(shutdown_script));
10721072

10731073
assert_eq!(result, Err(APIError::APIMisuseError { err: "Cannot override shutdown script for a channel with one already set".to_string() }));
10741074
}
@@ -1200,7 +1200,7 @@ fn do_simple_legacy_shutdown_test(high_initiator_fee: bool) {
12001200
*feerate_lock *= 10;
12011201
}
12021202

1203-
nodes[0].node.close_channel(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: chan.3.txid(), index: 0 }), &nodes[1].node.get_our_node_id()).unwrap();
1203+
nodes[0].node.close_channel(&chan.2, &nodes[1].node.get_our_node_id()).unwrap();
12041204
let node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
12051205
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &node_0_shutdown);
12061206
let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());

0 commit comments

Comments
 (0)