Merge rust-bitcoin/rust-bitcoin#1499: Add `from_bytes(Vec<u8>)` to `ScriptBuf`
e428486002
Add `from_bytes(Vec<u8>)` to `ScriptBuf` (Martin Habovstiak) Pull request description: This is useful when one already has bytes allocated in a vec that can be reused. The change also documents that the mirror method `into_bytes()` doesn't allocate. ACKs for top commit: tcharding: ACKe428486002
sanket1729: ACKe428486002
Tree-SHA512: 257b9c2cae24fd5006b6ec0e4db4a8baac177e67308758fb6167ef90e79ce75d5553433557d0e887a3e18a8fc63036f5a2acd061528a4467f76f25b6f4852400
This commit is contained in:
commit
46eda5fc33
|
@ -1163,7 +1163,16 @@ impl ScriptBuf {
|
||||||
.into_script()
|
.into_script()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Converts byte vector into script.
|
||||||
|
///
|
||||||
|
/// This method doesn't (re)allocate.
|
||||||
|
pub fn from_bytes(bytes: Vec<u8>) -> Self {
|
||||||
|
ScriptBuf(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
/// Converts the script into a byte vector.
|
/// Converts the script into a byte vector.
|
||||||
|
///
|
||||||
|
/// This method doesn't (re)allocate.
|
||||||
pub fn into_bytes(self) -> Vec<u8> { self.0 }
|
pub fn into_bytes(self) -> Vec<u8> { self.0 }
|
||||||
|
|
||||||
/// Computes the P2SH output corresponding to this redeem script.
|
/// Computes the P2SH output corresponding to this redeem script.
|
||||||
|
|
Loading…
Reference in New Issue