bitcoin: derive `Clone` for `SighashCache`
What changed, and why it matters
This commit simply adds the ability to duplicate (clone) a helper object called SighashCache that is used to speed up Bitcoin signature-hash calculations. It does not change any existing behavior, fix a bug, or alter security logic. There is no indication this is a security patch.
No security action needed; treat as a routine API enhancement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change derives the standard Rust Clone trait for SighashCache
Changed components
bitcoin/src/crypto/sighash.rsInspect captured patch +4 / −4
diff --git a/bitcoin/src/crypto/sighash.rs b/bitcoin/src/crypto/sighash.rs
index 0c3ed66e..306c60fe 100644
--- a/bitcoin/src/crypto/sighash.rs
+++ b/bitcoin/src/crypto/sighash.rs
@@ -95,7 +95,7 @@ hashes::impl_hex_for_newtype!(TapSighash);
hashes::impl_serde_for_newtype!(TapSighash);
/// Efficiently calculates signature hash message for legacy, SegWit and Taproot inputs.
-#[derive(Debug)]
+#[derive(Debug, Clone)]
pub struct SighashCache<T: Borrow<Transaction>> {
/// Access to transaction required for transaction introspection. Moreover, type
/// `T: Borrow<Transaction>` allows us to use borrowed and mutable borrowed types,
@@ -113,7 +113,7 @@ pub struct SighashCache<T: Borrow<Transaction>> {
}
/// Common values cached between SegWit and Taproot inputs.
-#[derive(Debug)]
+#[derive(Debug, Clone)]
struct CommonCache {
prevouts: sha256::Hash,
sequences: sha256::Hash,
@@ -124,7 +124,7 @@ struct CommonCache {
}
/// Values cached for SegWit inputs, equivalent to [`CommonCache`] plus another round of `sha256`.
-#[derive(Debug)]
+#[derive(Debug, Clone)]
struct SegwitCache {
prevouts: sha256d::Hash,
sequences: sha256d::Hash,
@@ -132,7 +132,7 @@ struct SegwitCache {
}
/// Values cached for Taproot inputs.
-#[derive(Debug)]
+#[derive(Debug, Clone)]
struct TaprootCache {
amounts: sha256::Hash,
script_pubkeys: sha256::Hash,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.