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 290e22b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 32 deletions.
54 changes: 24 additions & 30 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 Expand Up @@ -724,7 +718,7 @@ mod test {
use bdk::bitcoin::hashes::hex::FromHex;
let tx = <Vec<u8> as FromHex>::from_hex(s).unwrap();

deserialize(&mut tx.as_slice()).unwrap()
deserialize(tx.as_slice()).unwrap()
}

#[test]
Expand All @@ -736,6 +730,6 @@ mod test {

let message = "This belongs to me.";

tx.verify_reserve_proof(&message, &wallet).unwrap();
tx.verify_reserve_proof(message, &wallet).unwrap();
}
}
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
1 change: 1 addition & 0 deletions tests/regtestenv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ impl RegTestEnv {
&self.electrsd.electrum_url
}

#[allow(dead_code)]
/// returns the URL where an esplora client can connect to the embedded esplora server
pub fn esplora_url(&self) -> &Option<String> {
&self.electrsd.esplora_url
Expand Down

0 comments on commit 290e22b

Please sign in to comment.