diff --git a/primitives/src/script/borrowed.rs b/primitives/src/script/borrowed.rs index 6e68a6ef6..b16d1c613 100644 --- a/primitives/src/script/borrowed.rs +++ b/primitives/src/script/borrowed.rs @@ -54,7 +54,7 @@ use crate::prelude::{Box, ToOwned, Vec}; /// #[derive(PartialOrd, Ord, PartialEq, Eq, Hash)] #[repr(transparent)] -pub struct Script(pub(in crate::script) [u8]); +pub struct Script([u8]); impl Default for &Script { #[inline] @@ -64,7 +64,7 @@ impl Default for &Script { impl ToOwned for Script { type Owned = ScriptBuf; - fn to_owned(&self) -> Self::Owned { ScriptBuf(self.0.to_owned()) } + fn to_owned(&self) -> Self::Owned { ScriptBuf::from_bytes(self.to_vec()) } } impl Script { @@ -104,7 +104,7 @@ impl Script { /// Returns a copy of the script data. #[inline] - pub fn to_vec(&self) -> Vec { self.0.to_owned() } + pub fn to_vec(&self) -> Vec { self.as_bytes().to_owned() } /// Returns a copy of the script data. #[inline] @@ -113,11 +113,11 @@ impl Script { /// Returns the length in bytes of the script. #[inline] - pub fn len(&self) -> usize { self.0.len() } + pub fn len(&self) -> usize { self.as_bytes().len() } /// Returns whether the script is the empty script. #[inline] - pub fn is_empty(&self) -> bool { self.0.is_empty() } + pub fn is_empty(&self) -> bool { self.as_bytes().is_empty() } /// Converts a [`Box