Revert the change to to_bytes
During this release cycle we deprecated `to_vec` in favour of `to_bytes`, we have since reversed our position on the name. Remove the deprecation of `to_bytes` from the three types that had it and use `to_vec`.
This commit is contained in:
parent
dc2ca785d2
commit
c5cd0db493
|
@ -1604,7 +1604,7 @@ mod tests {
|
|||
.is_err());
|
||||
|
||||
// test that we get a failure if we corrupt a signature
|
||||
let mut witness = spending.input[1].witness.to_bytes();
|
||||
let mut witness = spending.input[1].witness.to_vec();
|
||||
witness[0][10] = 42;
|
||||
spending.input[1].witness = Witness::from_slice(&witness);
|
||||
|
||||
|
|
|
@ -112,10 +112,6 @@ impl Encodable for Witness {
|
|||
crate::internal_macros::define_extension_trait! {
|
||||
/// Extension functionality for the [`Witness`] type.
|
||||
pub trait WitnessExt impl for Witness {
|
||||
/// Convenience method to create an array of byte-arrays from this witness.
|
||||
#[deprecated(since = "TBD", note = "use `to_bytes` instead")]
|
||||
fn to_vec(&self) -> Vec<Vec<u8>> { self.to_bytes() }
|
||||
|
||||
/// Creates a witness required to spend a P2WPKH output.
|
||||
///
|
||||
/// The witness will be made up of the DER encoded signature + sighash_type followed by the
|
||||
|
@ -269,7 +265,7 @@ mod test {
|
|||
let expected_witness = vec![hex!(
|
||||
"304402207c800d698f4b0298c5aac830b822f011bb02df41eb114ade9a6702f364d5e39c0220366900d2a60cab903e77ef7dd415d46509b1f78ac78906e3296f495aa1b1b54101")
|
||||
];
|
||||
assert_eq!(witness.to_bytes(), expected_witness);
|
||||
assert_eq!(witness.to_vec(), expected_witness);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -61,7 +61,7 @@ impl Signature {
|
|||
///
|
||||
/// Note: this performs an extra heap allocation, you might prefer the
|
||||
/// [`serialize`](Self::serialize) method instead.
|
||||
pub fn to_bytes(self) -> Vec<u8> {
|
||||
pub fn to_vec(self) -> Vec<u8> {
|
||||
self.signature
|
||||
.serialize_der()
|
||||
.iter()
|
||||
|
@ -70,10 +70,6 @@ impl Signature {
|
|||
.collect()
|
||||
}
|
||||
|
||||
/// Serializes an ECDSA signature (inner secp256k1 signature in DER format) into `Vec`.
|
||||
#[deprecated(since = "TBD", note = "use `to_bytes` instead")]
|
||||
pub fn to_vec(self) -> Vec<u8> { self.to_bytes() }
|
||||
|
||||
/// Serializes an ECDSA signature (inner secp256k1 signature in DER format) to a `writer`.
|
||||
#[inline]
|
||||
pub fn serialize_to_writer<W: Write + ?Sized>(&self, writer: &mut W) -> Result<(), io::Error> {
|
||||
|
@ -345,6 +341,6 @@ mod tests {
|
|||
let mut buf = vec![];
|
||||
sig.serialize_to_writer(&mut buf).expect("write failed");
|
||||
|
||||
assert_eq!(sig.to_bytes(), buf)
|
||||
assert_eq!(sig.to_vec(), buf)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ impl Signature {
|
|||
/// Serializes the signature.
|
||||
///
|
||||
/// Note: this allocates on the heap, prefer [`serialize`](Self::serialize) if vec is not needed.
|
||||
pub fn to_bytes(self) -> Vec<u8> {
|
||||
pub fn to_vec(self) -> Vec<u8> {
|
||||
let mut ser_sig = self.signature.as_ref().to_vec();
|
||||
if self.sighash_type == TapSighashType::Default {
|
||||
// default sighash type, don't add extra sighash byte
|
||||
|
@ -57,10 +57,6 @@ impl Signature {
|
|||
ser_sig
|
||||
}
|
||||
|
||||
/// Serializes the signature.
|
||||
#[deprecated(since = "TBD", note = "use `to_bytes` instead")]
|
||||
pub fn to_vec(self) -> Vec<u8> { self.to_bytes() }
|
||||
|
||||
/// Serializes the signature to `writer`.
|
||||
#[inline]
|
||||
pub fn serialize_to_writer<W: Write + ?Sized>(&self, writer: &mut W) -> Result<(), io::Error> {
|
||||
|
|
|
@ -172,7 +172,7 @@ impl Deserialize for secp256k1::PublicKey {
|
|||
}
|
||||
|
||||
impl Serialize for ecdsa::Signature {
|
||||
fn serialize(&self) -> Vec<u8> { self.to_bytes() }
|
||||
fn serialize(&self) -> Vec<u8> { self.to_vec() }
|
||||
}
|
||||
|
||||
impl Deserialize for ecdsa::Signature {
|
||||
|
@ -265,7 +265,7 @@ impl Deserialize for XOnlyPublicKey {
|
|||
}
|
||||
|
||||
impl Serialize for taproot::Signature {
|
||||
fn serialize(&self) -> Vec<u8> { self.to_bytes() }
|
||||
fn serialize(&self) -> Vec<u8> { self.to_vec() }
|
||||
}
|
||||
|
||||
impl Deserialize for taproot::Signature {
|
||||
|
|
|
@ -17,7 +17,7 @@ use crate::prelude::Vec;
|
|||
///
|
||||
/// Can be logically seen as an array of bytestrings, i.e. `Vec<Vec<u8>>`, and it is serialized on the wire
|
||||
/// in that format. You can convert between this type and `Vec<Vec<u8>>` by using [`Witness::from_slice`]
|
||||
/// and [`Witness::to_bytes`].
|
||||
/// and [`Witness::to_vec`].
|
||||
///
|
||||
/// For serialization and deserialization performance it is stored internally as a single `Vec`,
|
||||
/// saving some allocations.
|
||||
|
@ -97,7 +97,7 @@ impl Witness {
|
|||
}
|
||||
|
||||
/// Convenience method to create an array of byte-arrays from this witness.
|
||||
pub fn to_bytes(&self) -> Vec<Vec<u8>> { self.iter().map(|s| s.to_vec()).collect() }
|
||||
pub fn to_vec(&self) -> Vec<Vec<u8>> { self.iter().map(|s| s.to_vec()).collect() }
|
||||
|
||||
/// Returns `true` if the witness contains no element.
|
||||
pub fn is_empty(&self) -> bool { self.witness_elements == 0 }
|
||||
|
|
Loading…
Reference in New Issue