Skip to content

Commit 6a93f2b

Browse files
committed
Fix clippy errors
1 parent 7b0f91d commit 6a93f2b

File tree

2 files changed

+23
-30
lines changed

2 files changed

+23
-30
lines changed

src/reserves.rs

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -227,18 +227,15 @@ impl ReserveProof for Transaction {
227227
let serialized_tx = serialize(&self);
228228

229229
// Check that all inputs besides the challenge input are valid
230-
prevouts
231-
.iter()
232-
.map(|(i, prevout)| {
233-
bitcoinconsensus::verify(
234-
prevout.script_pubkey.to_bytes().as_slice(),
235-
prevout.value,
236-
&serialized_tx,
237-
*i,
238-
)
239-
.map_err(|e| ProofError::SignatureValidation(*i, format!("{:?}", e)))
240-
})
241-
.collect::<Result<(), _>>()?;
230+
prevouts.iter().try_for_each(|(i, prevout)| {
231+
bitcoinconsensus::verify(
232+
prevout.script_pubkey.to_bytes().as_slice(),
233+
prevout.value,
234+
&serialized_tx,
235+
*i,
236+
)
237+
.map_err(|e| ProofError::SignatureValidation(*i, format!("{:?}", e)))
238+
})?;
242239

243240
// Check that all inputs besides the challenge input actually
244241
// commit to the challenge input by modifying the challenge
@@ -257,23 +254,20 @@ impl ReserveProof for Transaction {
257254
serialize(&malleated_tx)
258255
};
259256

260-
prevouts
261-
.iter()
262-
.map(|(i, prevout)| {
263-
match bitcoinconsensus::verify(
264-
prevout.script_pubkey.to_bytes().as_slice(),
265-
prevout.value,
266-
&serialized_malleated_tx,
257+
prevouts.iter().try_for_each(|(i, prevout)| {
258+
match bitcoinconsensus::verify(
259+
prevout.script_pubkey.to_bytes().as_slice(),
260+
prevout.value,
261+
&serialized_malleated_tx,
262+
*i,
263+
) {
264+
Ok(_) => Err(ProofError::SignatureValidation(
267265
*i,
268-
) {
269-
Ok(_) => Err(ProofError::SignatureValidation(
270-
*i,
271-
"Does not commit to challenge input".to_string(),
272-
)),
273-
Err(_) => Ok(()),
274-
}
275-
})
276-
.collect::<Result<(), _>>()?;
266+
"Does not commit to challenge input".to_string(),
267+
)),
268+
Err(_) => Ok(()),
269+
}
270+
})?;
277271

278272
Ok(sum)
279273
}

src/txout_set.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ where
141141
{
142142
let outpoints: Vec<_> = outpoints.into_iter().collect();
143143

144-
let outpoint_set: BTreeSet<&OutPoint> =
145-
outpoints.iter().map(|outpoint| *outpoint).collect();
144+
let outpoint_set: BTreeSet<&OutPoint> = outpoints.iter().copied().collect();
146145

147146
let tx_heights: BTreeMap<_, _> = if self.max_block_height < u32::MAX {
148147
outpoint_set

0 commit comments

Comments
 (0)