Skip to content

Commit

Permalink
Stop using push_slice
Browse files Browse the repository at this point in the history
The `Witness::push_slice` function is called by `Witness::push` after
calling `as_ref`, hence is equivalent for all types that implement
`AsRef<[u8]>`. Also, `push_slice` is a private method on `Witness`.

In preparation for moving `Witness` over to `primitives` stop using
`push_slice` in favour of `push`.

Internal change only.
  • Loading branch information
tcharding committed Oct 1, 2024
1 parent be163ee commit 6389d1c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bitcoin/src/blockdata/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,15 @@ impl Witness {
/// It is expected that `pubkey` is related to the secret key used to create `signature`.
pub fn p2wpkh(signature: ecdsa::Signature, pubkey: secp256k1::PublicKey) -> Witness {
let mut witness = Witness::new();
witness.push_slice(&signature.serialize());
witness.push_slice(&pubkey.serialize());
witness.push(signature.serialize());
witness.push(pubkey.serialize());
witness
}

/// Creates a witness required to do a key path spend of a P2TR output.
pub fn p2tr_key_spend(signature: &taproot::Signature) -> Witness {
let mut witness = Witness::new();
witness.push_slice(&signature.serialize());
witness.push(signature.serialize());
witness
}

Expand Down Expand Up @@ -363,7 +363,7 @@ impl Witness {
///
/// Pushes the DER encoded signature + sighash_type, requires an allocation.
pub fn push_ecdsa_signature(&mut self, signature: ecdsa::Signature) {
self.push_slice(&signature.serialize())
self.push(signature.serialize())
}

/// Note `index` is the index into the `content` vector and should be the result of calling
Expand Down

0 comments on commit 6389d1c

Please sign in to comment.