Skip to content

Commit d850e12

Browse files
authored
Merge pull request #535 from TheBlueMatt/2020-03-462-nits
A few minor nits on #462
2 parents 48549de + 6abce81 commit d850e12

File tree

5 files changed

+139
-163
lines changed

5 files changed

+139
-163
lines changed

lightning/src/ln/channelmonitor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,7 +2010,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
20102010
watch_outputs.push(new_outputs);
20112011
}
20122012
}
2013-
claimable_outpoints.push(new_outpoints);
2013+
claimable_outpoints.append(&mut new_outpoints);
20142014
}
20152015
if !funding_txo.is_none() && claimable_outpoints.is_empty() {
20162016
if let Some(spendable_output) = self.check_spend_closing_transaction(&tx) {
@@ -2020,7 +2020,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
20202020
} else {
20212021
if let Some(&(commitment_number, _)) = self.remote_commitment_txn_on_chain.get(&prevout.txid) {
20222022
let mut new_outpoints = self.check_spend_remote_htlc(&tx, commitment_number, height);
2023-
claimable_outpoints.push(new_outpoints);
2023+
claimable_outpoints.append(&mut new_outpoints);
20242024
}
20252025
}
20262026
}

lightning/src/ln/functional_test_utils.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -403,14 +403,15 @@ pub fn create_announced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &'a
403403
}
404404

405405
macro_rules! check_spends {
406-
($tx: expr, $spends_tx: expr) => {
406+
($tx: expr, $($spends_txn: expr),*) => {
407407
{
408408
$tx.verify(|out_point| {
409-
if out_point.txid == $spends_tx.txid() {
410-
$spends_tx.output.get(out_point.vout as usize).cloned()
411-
} else {
412-
None
413-
}
409+
$(
410+
if out_point.txid == $spends_txn.txid() {
411+
return $spends_txn.output.get(out_point.vout as usize).cloned()
412+
}
413+
)*
414+
None
414415
}).unwrap();
415416
}
416417
}
@@ -1033,7 +1034,7 @@ pub fn test_txn_broadcast<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, chan: &(msgs::Cha
10331034
let mut res = Vec::with_capacity(2);
10341035
node_txn.retain(|tx| {
10351036
if tx.input.len() == 1 && tx.input[0].previous_output.txid == chan.3.txid() {
1036-
check_spends!(tx, chan.3.clone());
1037+
check_spends!(tx, chan.3);
10371038
if commitment_tx.is_none() {
10381039
res.push(tx.clone());
10391040
}
@@ -1049,7 +1050,7 @@ pub fn test_txn_broadcast<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, chan: &(msgs::Cha
10491050
if has_htlc_tx != HTLCType::NONE {
10501051
node_txn.retain(|tx| {
10511052
if tx.input.len() == 1 && tx.input[0].previous_output.txid == res[0].txid() {
1052-
check_spends!(tx, res[0].clone());
1053+
check_spends!(tx, res[0]);
10531054
if has_htlc_tx == HTLCType::TIMEOUT {
10541055
assert!(tx.lock_time != 0);
10551056
} else {
@@ -1098,7 +1099,7 @@ pub fn check_preimage_claim<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, prev_txn: &Vec<
10981099

10991100
for tx in prev_txn {
11001101
if node_txn[0].input[0].previous_output.txid == tx.txid() {
1101-
check_spends!(node_txn[0], tx.clone());
1102+
check_spends!(node_txn[0], tx);
11021103
assert!(node_txn[0].input[0].witness[2].len() > 106); // must spend an htlc output
11031104
assert_eq!(tx.input.len(), 1); // must spend a commitment tx
11041105

0 commit comments

Comments
 (0)