diff --git a/coins/bitcoin/src/crypto.rs b/coins/bitcoin/src/crypto.rs index eb30cebe..bcb73936 100644 --- a/coins/bitcoin/src/crypto.rs +++ b/coins/bitcoin/src/crypto.rs @@ -32,9 +32,9 @@ pub fn x(key: &ProjectivePoint) -> [u8; 32] { (*encoded.x().expect("point at infinity")).into() } -/// Convert a non-infinite even point to a XOnlyPublicKey. Panics on invalid input. +/// Convert a non-infinity even point to a XOnlyPublicKey. Panics on invalid input. pub fn x_only(key: &ProjectivePoint) -> XOnlyPublicKey { - XOnlyPublicKey::from_slice(&x(key)).unwrap() + XOnlyPublicKey::from_slice(&x(key)).expect("x_only was passed a point which was infinity or odd") } /// Make a point even by adding the generator until it is even. Returns the even point and the @@ -145,7 +145,8 @@ impl Algorithm for Schnorr { // s = r + cx. Since we added to the r, add to s sig.s += Scalar::from(offset); // Convert to a secp256k1 signature - Signature::from_slice(&sig.serialize()[1 ..]).unwrap() + Signature::from_slice(&sig.serialize()[1 ..]) + .expect("couldn't convert SchnorrSignature to Signature") }) } diff --git a/coins/bitcoin/src/wallet/send.rs b/coins/bitcoin/src/wallet/send.rs index 33c196c6..a176c2fc 100644 --- a/coins/bitcoin/src/wallet/send.rs +++ b/coins/bitcoin/src/wallet/send.rs @@ -339,7 +339,9 @@ impl SignMachine for TransactionSignMachine { commitments[i].clone(), cache .taproot_key_spend_signature_hash(i, &prevouts, TapSighashType::Default) - .unwrap() + // This should never happen since the inputs align with the TX the cache was + // constructed with, and because i is always < prevouts.len() + .expect("taproot_key_spend_signature_hash failed to return a hash") .as_ref(), )?; shares.push(share);