Skip to content

Commit

Permalink
Fix clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ademan committed Jan 14, 2024
1 parent 7b0f91d commit 6a93f2b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 30 deletions.
50 changes: 22 additions & 28 deletions src/reserves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,15 @@ impl ReserveProof for Transaction {
let serialized_tx = serialize(&self);

// Check that all inputs besides the challenge input are valid
prevouts
.iter()
.map(|(i, prevout)| {
bitcoinconsensus::verify(
prevout.script_pubkey.to_bytes().as_slice(),
prevout.value,
&serialized_tx,
*i,
)
.map_err(|e| ProofError::SignatureValidation(*i, format!("{:?}", e)))
})
.collect::<Result<(), _>>()?;
prevouts.iter().try_for_each(|(i, prevout)| {
bitcoinconsensus::verify(
prevout.script_pubkey.to_bytes().as_slice(),
prevout.value,
&serialized_tx,
*i,
)
.map_err(|e| ProofError::SignatureValidation(*i, format!("{:?}", e)))
})?;

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

prevouts
.iter()
.map(|(i, prevout)| {
match bitcoinconsensus::verify(
prevout.script_pubkey.to_bytes().as_slice(),
prevout.value,
&serialized_malleated_tx,
prevouts.iter().try_for_each(|(i, prevout)| {
match bitcoinconsensus::verify(
prevout.script_pubkey.to_bytes().as_slice(),
prevout.value,
&serialized_malleated_tx,
*i,
) {
Ok(_) => Err(ProofError::SignatureValidation(
*i,
) {
Ok(_) => Err(ProofError::SignatureValidation(
*i,
"Does not commit to challenge input".to_string(),
)),
Err(_) => Ok(()),
}
})
.collect::<Result<(), _>>()?;
"Does not commit to challenge input".to_string(),
)),
Err(_) => Ok(()),
}
})?;

Ok(sum)
}
Expand Down
3 changes: 1 addition & 2 deletions src/txout_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ where
{
let outpoints: Vec<_> = outpoints.into_iter().collect();

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

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

0 comments on commit 6a93f2b

Please sign in to comment.